internal static bool CheckAddPermission(cdeConcurrentDictionary <eWebPlatform, ThePropertyBag> pPlatBag, TheClientInfo pInfo) { cdeConcurrentDictionary <string, string> platPlat = null; if (pPlatBag.ContainsKey(pInfo.WebPlatform)) { platPlat = ThePropertyBag.GetDictionary(pPlatBag[pInfo.WebPlatform], "="); } if (pPlatBag.ContainsKey(eWebPlatform.Any)) { cdeConcurrentDictionary <string, string> tPlat = ThePropertyBag.GetDictionary(pPlatBag[eWebPlatform.Any], "="); if (tPlat.ContainsKey("HideAddButton") && TheCommonUtils.CBool(tPlat["HideAddButton"])) { if (platPlat == null || (platPlat.ContainsKey("ShowAddButton") && !TheCommonUtils.CBool(platPlat["ShowAddButton"]))) { return(false); } } if (tPlat.ContainsKey("RequireFirstNodeForAdd") && TheCommonUtils.CBool(tPlat["RequireFirstNodeForAdd"]) && !pInfo.IsFirstNode) { if (platPlat == null || (platPlat.ContainsKey("AllowAddOnAllNodes") && !TheCommonUtils.CBool(platPlat["AllowAddOnAllNodes"]))) { return(false); } } } else { if (platPlat != null) { if (platPlat.ContainsKey("HideAddButton") && TheCommonUtils.CBool(platPlat["HideAddButton"])) { return(false); } if (platPlat.ContainsKey("RequireFirstNodeForAdd") && TheCommonUtils.CBool(platPlat["RequireFirstNodeForAdd"]) && !pInfo.IsFirstNode) { return(false); } } } return(true); }
internal static List <TheFieldInfo> GetPermittedFields(Guid FormId, TheClientInfo pClientInfo, TheFOR tso, bool UpdateSubs) { List <TheFieldInfo> tReturnLst = new List <TheFieldInfo>(); try { Func <TheFieldInfo, bool> pSelector = (s => TheUserManager.HasUserAccess(pClientInfo.UserID, s.cdeA) && ((s.Flags & 4) == 0 || !pClientInfo.IsMobile) && ((s.Flags & 128) == 0 || pClientInfo.IsFirstNode || pClientInfo.IsUserTrusted)); //NEW3.105: Only Show from First node is set IEnumerable <TheFieldInfo> FormFields = TheNMIEngine.GetFieldsByFunc(s => s.FormID == FormId).Where(pSelector).OrderBy(s => s.FldOrder); //NMI-REDO: this is the main bottleneck Function if (FormFields != null) { foreach (var tField in FormFields) { if (CheckHidePersmission(tField.PlatBag, pClientInfo)) { TheFieldInfo tFld = tField.Clone(); if (tFld.PlatBag.ContainsKey(eWebPlatform.Any)) { tFld.PropertyBag.MergeBag(tFld.PlatBag[eWebPlatform.Any], true, false); } if (tFld.PlatBag.ContainsKey(pClientInfo.WebPlatform)) { tFld.PropertyBag.MergeBag(tFld.PlatBag[pClientInfo.WebPlatform], true, false); } bool DeleteFld = false; if (tso != null) { var tfo = tso.Flds.Where(s => s.FldOrder == tFld.FldOrder); if (tfo != null && tfo.Count() > 0) { foreach (TheFLDOR tF in tfo) { if (tF.PO != null) { tFld.PropertyBag = tF.PO; } if (tF.NewFldOrder > 0) { tFld.FldOrder = tF.NewFldOrder; } else if (tF.NewFldOrder < 0) { DeleteFld = true; } } } } if (!DeleteFld) { tReturnLst.Add(tFld); //NEW in 4.1: All subscriptiosn here if (UpdateSubs) { var tThing = RegisterNMISubscription(pClientInfo, tFld.DataItem, tFld); if (tThing != null && (tFld.Type == eFieldType.FacePlate || tFld.Type == eFieldType.TileButton)) { var tsuc = TheNMIEngine.ParseFacePlateUrlInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTMLUrl", "="), false, pClientInfo.NodeID); if (!tsuc) { TheNMIEngine.ParseFacePlateInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTML", "="), pClientInfo.NodeID); } } } } } } } } catch (Exception e) { TheBaseAssets.MySYSLOG.WriteToLog(777, new TSM(eEngineName.NMIService, "Get Permitted fields failed", eMsgLevel.l1_Error, e.ToString())); } return(tReturnLst); }