protected void SaveSites() { // Remove old items string newValues = ValidationHelper.GetString(usSites.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { int siteId = ValidationHelper.GetInteger(item, 0); ClassSiteInfoProvider.RemoveClassFromSite(ClassId, siteId); } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); bool falseValues = false; // Add all new items to site foreach (string item in newItems) { int siteId = ValidationHelper.GetInteger(item, 0); SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if (si != null) { // Check license if (CheckLicense && !CustomTableItemProvider.LicenseVersionCheck(si.DomainName, ObjectActionEnum.Insert)) { if (ClassSiteInfoProvider.GetClassSiteInfo(ClassId, siteId) == null) { // Show error message ShowError(GetString("LicenseVersion.CustomTables")); falseValues = true; continue; } } try { ClassSiteInfoProvider.AddClassToSite(ClassId, siteId); } catch (Exception ex) { // Show error message ShowError(ex.Message); return; } } } // If some of sites could not be assigned reload selector value if (falseValues) { usSites.Value = GetClassSites(); usSites.Reload(true); } } if (CheckLicense) { CustomTableItemProvider.ClearLicensesCount(true); } // Show message ShowChangesSaved(); }
protected void Page_Load(object sender, EventArgs e) { string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx"; // Get form ID from url customTableId = QueryHelper.GetInteger("customtableid", 0); // Running in site manager? bool siteManager = QueryHelper.GetInteger("sm", 0) == 1; DataClassInfo dci = null; // Read data only if user is site manager global admin or table is bound to current site if (CurrentUser.UserSiteManagerAdmin || (ClassSiteInfoProvider.GetClassSiteInfo(customTableId, CMSContext.CurrentSiteID) != null)) { // Get CustomTable class dci = DataClassInfoProvider.GetDataClass(customTableId); } // Set edited object EditedObject = dci; if (dci != null) { customTableDataList.CustomTableClassInfo = dci; customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty); customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty); // Set alternative form and data container customTableDataList.UniGrid.FilterFormName = dci.ClassName + "." + "filter"; customTableDataList.UniGrid.FilterFormData = new CustomTableItem(dci.ClassName, new CustomTableItemProvider(CMSContext.CurrentUser)); // Set custom pages if (dci.ClassEditingPageURL != String.Empty) { customTableDataList.EditItemPage = dci.ClassEditingPageURL; } if (dci.ClassNewPageURL != String.Empty) { newItemPage = dci.ClassNewPageURL; } if (dci.ClassViewPageUrl != String.Empty) { customTableDataList.ViewItemPage = dci.ClassViewPageUrl; } ScriptHelper.RegisterDialogScript(this); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "' ,'CustomTableFields', 500, 500); }")); if (!siteManager) { CurrentMaster.Title.TitleText = GetString("customtable.edit.header"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_CustomTable/object.png"); CurrentMaster.Title.HelpTopicName = "custom_tables_data"; CurrentMaster.Title.HelpName = "helpTopic"; } // Check 'Read' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") && !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read")) { lblError.Visible = true; lblError.Text = String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName); plcContent.Visible = false; return; } string[,] actions = new string[2, 6]; // New item link actions[0, 0] = HeaderActions.TYPE_HYPERLINK; actions[0, 1] = GetString("customtable.data.newitem"); actions[0, 2] = null; actions[0, 3] = ResolveUrl(newItemPage + "?new=1&customtableid=" + customTableId + (siteManager ? "&sm=1" : "")); actions[0, 4] = null; actions[0, 5] = GetImageUrl("CMSModules/CMS_CustomTables/newitem.png"); // Select fields link actions[1, 0] = HeaderActions.TYPE_HYPERLINK; actions[1, 1] = GetString("customtable.data.selectdisplayedfields"); actions[1, 2] = null; actions[1, 3] = "javascript:SelectFields();"; actions[1, 4] = null; actions[1, 5] = GetImageUrl("CMSModules/CMS_CustomTables/selectfields16.png"); CurrentMaster.HeaderActions.Actions = actions; if (!siteManager) { // Initializes page title string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("customtable.list.title"); breadcrumbs[0, 1] = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx"; breadcrumbs[0, 2] = ""; breadcrumbs[1, 0] = dci.ClassDisplayName; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; } } }
protected void Page_Load(object sender, EventArgs e) { string newItemPage = "~/CMSModules/CustomTables/Tools/CustomTable_Data_EditItem.aspx"; // Get form ID from url customTableId = QueryHelper.GetInteger("objectid", 0); // Running in site manager? bool siteManager = QueryHelper.GetInteger("sm", 0) == 1; DataClassInfo dci = null; // Read data only if user is site manager global admin or table is bound to current site if (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) || (ClassSiteInfoProvider.GetClassSiteInfo(customTableId, SiteContext.CurrentSiteID) != null)) { // Get CustomTable class dci = DataClassInfoProvider.GetDataClassInfo(customTableId); } // Set edited object EditedObject = dci; if ((dci != null) && dci.ClassIsCustomTable) { customTableDataList.CustomTableClassInfo = dci; customTableDataList.EditItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty); customTableDataList.ViewItemPageAdditionalParams = (siteManager ? "sm=1" : String.Empty); // Set alternative form and data container customTableDataList.UniGrid.FilterFormName = dci.ClassName + ".filter"; customTableDataList.UniGrid.FilterFormData = CustomTableItem.New(dci.ClassName); // Set custom pages if (dci.ClassEditingPageURL != String.Empty) { customTableDataList.EditItemPage = dci.ClassEditingPageURL; } if (dci.ClassNewPageURL != String.Empty) { newItemPage = dci.ClassNewPageURL; } if (dci.ClassViewPageUrl != String.Empty) { customTableDataList.ViewItemPage = dci.ClassViewPageUrl; } ScriptHelper.RegisterDialogScript(this); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" + ResolveUrl("~/CMSModules/CustomTables/Tools/CustomTable_Data_SelectFields.aspx") + "?customtableid=" + customTableId + "' ,'CustomTableFields', 500, 500); }")); if (!siteManager) { PageTitle.TitleText = GetString("customtable.edit.header"); } // Check 'Read' permission if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName)); plcContent.Visible = false; return; } // New item link bool canCreate = dci.CheckPermissions(PermissionsEnum.Create, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser); HeaderActions.AddAction(new HeaderAction { Text = GetString("customtable.data.newitem"), RedirectUrl = ResolveUrl(newItemPage + "?new=1&objectid=" + customTableId + (siteManager ? "&sm=1" : "")), Enabled = canCreate, Tooltip = canCreate ? String.Empty : String.Format(GetString("customtable.permissiondenied.create"), dci.ClassName) }); // Select fields link HeaderActions.AddAction(new HeaderAction { Text = GetString("customtable.data.selectdisplayedfields"), OnClientClick = "SelectFields();", ButtonStyle = ButtonStyle.Default, }); if (!siteManager) { // Initializes page title PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = GetString("customtable.list.title"), RedirectUrl = "~/CMSModules/Customtables/Tools/CustomTable_List.aspx" }); PageBreadcrumbs.AddBreadcrumb(new BreadcrumbItem { Text = dci.ClassDisplayName }); } } else { customTableDataList.StopProcessing = true; customTableDataList.Visible = false; ShowError(GetString("customtable.notcustomtable")); } }
/// <summary> /// Provides operations necessary to create and store new content file. /// </summary> private void HandleContentUpload() { string message = string.Empty; bool newDocumentCreated = false; try { if (NodeParentNodeID == 0) { throw new Exception(GetString("dialogs.document.parentmissing")); } // Check license limitations if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Documents, ObjectActionEnum.Insert)) { throw new LicenseException(GetString("cmsdesk.documentslicenselimits")); } // Check if class exists DataClassInfo ci = DataClassInfoProvider.GetDataClassInfo(SystemDocumentTypes.File); if (ci == null) { throw new Exception(string.Format(GetString("dialogs.newfile.classnotfound"), SystemDocumentTypes.File)); } #region "Check permissions" // Get the node TreeNode parentNode = TreeProvider.SelectSingleNode(NodeParentNodeID, LocalizationContext.PreferredCultureCode, true); if (parentNode != null) { // Check whether node class is allowed on site and parent node if (!DocumentHelper.IsDocumentTypeAllowed(parentNode, ci.ClassID) || (ClassSiteInfoProvider.GetClassSiteInfo(ci.ClassID, parentNode.NodeSiteID) == null)) { throw new Exception(GetString("Content.ChildClassNotAllowed")); } } // Check user permissions if (!RaiseOnCheckPermissions("Create", this)) { if (!MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(parentNode, SystemDocumentTypes.File)) { throw new Exception(string.Format(GetString("dialogs.newfile.notallowed"), NodeClassName)); } } #endregion // Check the allowed extensions CheckAllowedExtensions(); // Create new document string fileName = Path.GetFileNameWithoutExtension(ucFileUpload.FileName); string ext = Path.GetExtension(ucFileUpload.FileName); if (IncludeExtension) { fileName += ext; } // Make sure the file name with extension respects maximum file name fileName = TreePathUtils.EnsureMaxFileNameLength(fileName, ci.ClassName); node = TreeNode.New(SystemDocumentTypes.File, TreeProvider); node.DocumentCulture = LocalizationContext.PreferredCultureCode; node.DocumentName = fileName; if (NodeGroupID > 0) { node.SetValue("NodeGroupID", NodeGroupID); } // Load default values FormHelper.LoadDefaultValues(node.NodeClassName, node); node.SetValue("FileDescription", ""); node.SetValue("FileName", fileName); node.SetValue("FileAttachment", Guid.Empty); // Set default template ID node.SetDefaultPageTemplateID(ci.ClassDefaultPageTemplateID); // Insert the document DocumentHelper.InsertDocument(node, parentNode, TreeProvider); newDocumentCreated = true; // Add the file DocumentHelper.AddAttachment(node, "FileAttachment", ucFileUpload.PostedFile, ResizeToWidth, ResizeToHeight, ResizeToMaxSideSize); // Update the document DocumentHelper.UpdateDocument(node, TreeProvider); // Get workflow info wi = node.GetWorkflow(); // Check if auto publish changes is allowed if ((wi != null) && wi.WorkflowAutoPublishChanges && !wi.UseCheckInCheckOut(SiteContext.CurrentSiteName)) { // Automatically publish document node.MoveToPublishedStep(null); } } catch (Exception ex) { // Delete the document if something failed if (newDocumentCreated && (node != null) && (node.DocumentID > 0)) { DocumentHelper.DeleteDocument(node, TreeProvider, false, true); } message = ex.Message; } finally { // Create node info string string nodeInfo = ""; if ((node != null) && (node.NodeID > 0) && (IncludeNewItemInfo)) { nodeInfo = node.NodeID.ToString(); } // Ensure message text message = TextHelper.EnsureLineEndings(message, " "); string containerId = QueryHelper.GetString("containerid", ""); // Call function to refresh parent window string afterSaveScript = null; if (!string.IsNullOrEmpty(AfterSaveJavascript)) { afterSaveScript = String.Format( @" if (window.{0} != null){{ window.{0}(files); }} else if ((window.parent != null) && (window.parent.{0} != null)){{ window.parent.{0}(files); }}", AfterSaveJavascript ); } afterSaveScript += String.Format( @" if (typeof(parent.DFU) !== 'undefined') {{ parent.DFU.OnUploadCompleted({0}); }} if ((window.parent != null) && (/parentelemid={1}/i.test(window.location.href)) && (window.parent.InitRefresh_{1} != null)){{ window.parent.InitRefresh_{1}({2}, false, false{3}{4}); }} ", ScriptHelper.GetString(containerId), ParentElemID, ScriptHelper.GetString(message.Trim()), ((nodeInfo != "") ? ", '" + nodeInfo + "'" : ""), (InsertMode ? ", 'insert'" : ", 'update'") ); ScriptHelper.RegisterStartupScript(this, typeof(string), "afterSaveScript_" + ClientID, ScriptHelper.GetScript(afterSaveScript)); } }
/// <summary> /// Moves the node to the specified target. /// </summary> /// <param name="node">Node to move</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="preservePermissions">Indicates if node permissions should be preserved</param> /// <returns>Whether to set new order</returns> protected bool MoveNode(TreeNode node, TreeNode targetNode, TreeProvider tree, bool preservePermissions) { int targetId = targetNode.NodeID; string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; // If node parent ID is already the target ID, do not move it if (targetId == node.NodeParentID) { if (IsDialogAction) { // Impossible to move document to same location AddError(GetString("contentrequest.cannotmovetosameloc") + encodedAliasPath); } return(true); } // Check move permission if (!IsUserAuthorizedToMove(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToMove") + encodedAliasPath); return(false); } // Get the document to copy int nodeId = node.NodeID; if (nodeId == targetId) { AddError(GetString("ContentRequest.CannotMoveToItself") + encodedAliasPath); return(false); } // Check cyclic movement (movement of the node to some of its child nodes) if ((targetNode.NodeSiteID == node.NodeSiteID) && targetNode.NodeAliasPath.StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase)) { AddError(GetString("ContentRequest.CannotMoveToChild")); return(false); } if (targetNode.NodeSiteID != node.NodeSiteID) { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); string domainToCheck = targetSite.DomainName; // Check the licence limitations if ((node.NodeClassName.ToLower() == "cms.blog") && !LicenseHelper.LicenseVersionCheck(domainToCheck, FeatureEnum.Blogs, VersionActionEnum.Insert)) { AddError(GetString("cmsdesk.bloglicenselimits")); return(false); } } // Check allowed child classes int targetClassId = ValidationHelper.GetInteger(targetNode.GetValue("NodeClassID"), 0); int nodeClassId = ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0); if (!DataClassInfoProvider.IsChildClassAllowed(targetClassId, nodeClassId) || (ClassSiteInfoProvider.GetClassSiteInfo(nodeClassId, targetNode.NodeSiteID) == null)) { AddError(String.Format(GetString("ContentRequest.ErrorDocumentTypeNotAllowed"), node.NodeAliasPath, node.NodeClassName)); return(false); } // Get child documents if ((node.NodeChildNodesCount) > 0 && IsDialogAction) { string columns = SqlHelperClass.MergeColumns(TreeProvider.SELECTNODES_REQUIRED_COLUMNS, "NodeAliasPath"); DataSet childNodes = TreeProvider.SelectNodes(currentSite.SiteName, node.NodeAliasPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, TreeProvider.ALL_LEVELS, false, 0, columns); if (!DataHelper.DataSourceIsEmpty(childNodes)) { foreach (DataRow childNode in childNodes.Tables[0].Rows) { AddLog(HTMLHelper.HTMLEncode(childNode["NodeAliasPath"] + " (" + childNode["DocumentCulture"] + ")")); } } } // Move the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")")); DocumentHelper.MoveDocument(node, targetId, tree, preservePermissions); SetExpandedNode(node.NodeParentID); return(true); }
/// <summary> /// Copies the node to the specified target. /// </summary> /// <param name="node">Node to copy</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="childNodes">Copy also child nodes</param> /// <param name="copyPermissions">Indicates if node permissions should be copied</param> /// <param name="newDocumentName">New document name</param> protected TreeNode CopyNode(TreeNode node, TreeNode targetNode, bool childNodes, TreeProvider tree, bool copyPermissions, string newDocumentName) { string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; int targetId = targetNode.NodeID; // Do not copy child nodes in case of no child nodes childNodes = childNodes && (node.NodeChildNodesCount > 0); // Get the document to copy int nodeId = node.NodeID; if ((nodeId == targetId) && childNodes) { AddError(GetString("ContentRequest.CannotCopyToItself") + encodedAliasPath); return(null); } // Check move permission if (!IsUserAuthorizedToCopyOrLink(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToCopy") + encodedAliasPath); return(null); } // Check cyclic copying (copying of the node to some of its child nodes) if (childNodes && (targetNode.NodeSiteID == node.NodeSiteID) && targetNode.NodeAliasPath.StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase)) { AddError(GetString("ContentRequest.CannotCopyToChild")); return(null); } string domainToCheck = null; if (targetNode.NodeSiteID == node.NodeSiteID) { domainToCheck = URLHelper.GetCurrentDomain(); } else { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); domainToCheck = targetSite.DomainName; } // Check the licence limitations if ((node.NodeClassName.ToLower() == "cms.blog") && !LicenseHelper.LicenseVersionCheck(domainToCheck, FeatureEnum.Blogs, VersionActionEnum.Insert)) { AddError(GetString("cmsdesk.bloglicenselimits")); return(null); } // Check allowed child class int targetClassId = ValidationHelper.GetInteger(targetNode.GetValue("NodeClassID"), 0); int nodeClassId = ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0); if (!DataClassInfoProvider.IsChildClassAllowed(targetClassId, nodeClassId) || (ClassSiteInfoProvider.GetClassSiteInfo(nodeClassId, targetNode.NodeSiteID) == null)) { AddError(String.Format(GetString("ContentRequest.ErrorDocumentTypeNotAllowed"), node.NodeAliasPath, node.NodeClassName)); return(null); } // Copy the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath + " (" + node.DocumentCulture + ")")); node = DocumentHelper.CopyDocument(node, targetId, childNodes, tree, 0, 0, copyPermissions, newDocumentName); SetExpandedNode(node.NodeParentID); return(node); }
/// <summary> /// Links the node to the specified target. /// </summary> /// <param name="node">Node to move</param> /// <param name="targetNode">Target node</param> /// <param name="tree">Tree provider</param> /// <param name="copyPermissions">Indicates if node permissions should be copied</param> /// <param name="childNodes">Indicates whether to link also child nodes</param> protected TreeNode LinkNode(TreeNode node, TreeNode targetNode, TreeProvider tree, bool copyPermissions, bool childNodes) { string encodedAliasPath = " (" + HTMLHelper.HTMLEncode(node.NodeAliasPath) + ")"; int targetId = targetNode.NodeID; // Check create permission if (!IsUserAuthorizedToCopyOrLink(node, targetId, node.NodeClassName)) { AddError(GetString("ContentRequest.NotAllowedToLink") + encodedAliasPath); return(null); } // Check allowed child class int targetClassId = ValidationHelper.GetInteger(targetNode.GetValue("NodeClassID"), 0); int nodeClassId = ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0); if (!DataClassInfoProvider.IsChildClassAllowed(targetClassId, nodeClassId) || (ClassSiteInfoProvider.GetClassSiteInfo(nodeClassId, targetNode.NodeSiteID) == null)) { AddError(String.Format(GetString("ContentRequest.ErrorDocumentTypeNotAllowed"), node.NodeAliasPath, node.NodeClassName)); return(null); } // Determine whether any child nodes are present bool includeChildNodes = (node.NodeChildNodesCount > 0) && childNodes; // Document can't be copied under itself if child nodes are present if ((node.NodeID == targetNode.NodeID) && includeChildNodes) { AddError(GetString("ContentRequest.CannotLinkToItself") + encodedAliasPath); return(null); } string domainToCheck = null; if (targetNode.NodeSiteID == node.NodeSiteID) { domainToCheck = URLHelper.GetCurrentDomain(); } else { SiteInfo targetSite = SiteInfoProvider.GetSiteInfo(targetNode.NodeSiteID); domainToCheck = targetSite.DomainName; } // Check the licence limitations if ((node.NodeClassName.ToLower() == "cms.blog") && !LicenseHelper.LicenseVersionCheck(domainToCheck, FeatureEnum.Blogs, VersionActionEnum.Insert)) { AddError(GetString("cmsdesk.bloglicenselimits")); return(null); } // Check cyclic linking (linking of the node to some of its child nodes) if ((targetNode.NodeSiteID == node.NodeSiteID) && (targetNode.NodeAliasPath.TrimEnd('/') + "/").StartsWith(node.NodeAliasPath + "/", StringComparison.CurrentCultureIgnoreCase) && includeChildNodes) { AddError(GetString("ContentRequest.CannotLinkToChild")); return(null); } // Copy the document AddLog(HTMLHelper.HTMLEncode(node.NodeAliasPath)); DocumentHelper.InsertDocumentAsLink(node, targetId, tree, includeChildNodes, copyPermissions); SetExpandedNode(node.NodeParentID); return(node); }
public bool IsAtSynchronizedSite(DataClassInfo contentType) { var siteId = SiteInfoProvider.GetSiteID(Settings.Sitename); return(ClassSiteInfoProvider.GetClassSiteInfo(contentType.ClassID, siteId) != null); }
private void _processClasses(int retryCount, List <AllowedChildClassInfo> allAllowedChildInfos, string coreConfigName, Stream stream, IDeserializer deserializer, Stopwatch watch, string serializationPath, IEnumerable <string> classTypes, IEnumerable <string> ignoreFields) { var retryClasses = new List <string>(); var concretePath = this.GetRootPath(serializationPath); var yamlFiles = Directory.EnumerateFiles(concretePath, "*.yaml", SearchOption.AllDirectories); foreach (string yamlFile in yamlFiles) { watch.Reset(); watch.Start(); var yamlFileContent = File.ReadAllText(yamlFile); var bridgeClassInfo = deserializer.Deserialize <BridgeClassInfo>(yamlFileContent); if (classTypes.Any(x => x.ToLower() == bridgeClassInfo.ClassName.ToLower())) { var newDCI = DataClassInfoProvider.GetDataClassInfo(bridgeClassInfo.ClassName); if (newDCI == null) { newDCI = new DataClassInfo(); } foreach (var field in bridgeClassInfo.FieldValues) { if (!ignoreFields.Contains(field.Key)) { newDCI[field.Key] = field.Value; } } DataClassInfoProvider.SetDataClassInfo(newDCI); foreach (var allowedType in bridgeClassInfo.AllowedChildTypes) { var matchingClass = new ObjectQuery("cms.class", false).Where("ClassName", QueryOperator.Equals, allowedType)?.Column("ClassID")?.FirstOrDefault(); if (matchingClass != null) { matchingClass["ClassID"]?.ToString(); var acci = new AllowedChildClassInfo() { ChildClassID = int.Parse(matchingClass["ClassID"]?.ToString()), ParentClassID = newDCI.ClassID }; allAllowedChildInfos.Add(acci); } else { retryClasses.Add(allowedType); } } foreach (var siteGUID in bridgeClassInfo.AssignedSites) { var site = SiteInfoProvider.GetSiteInfoByGUID(siteGUID); ClassSiteInfoProvider.AddClassToSite(newDCI.ClassID, site.SiteID); } foreach (var bcq in bridgeClassInfo.Queries) { var qi = QueryInfoProvider.GetQueries().Where("QueryGUID", QueryOperator.Equals, bcq.Value.QueryGUID).FirstOrDefault(); if (qi == null) { qi = new QueryInfo(); } qi.ClassID = newDCI.ClassID; qi.QueryName = bcq.Key; qi.QueryTypeID = bcq.Value.QueryTypeID; qi.QueryText = bcq.Value.QueryText; qi.QueryIsLocked = bcq.Value.QueryIsLocked; qi.QueryIsCustom = bcq.Value.QueryIsCustom; qi.QueryRequiresTransaction = bcq.Value.QueryRequiresTransaction; qi.QueryConnectionString = bcq.Value.QueryConnectionString; qi.QueryGUID = bcq.Value.QueryGUID; QueryInfoProvider.SetQueryInfo(qi); } byte[] bytes = Encoding.UTF8.GetBytes($"Synced {coreConfigName}: {yamlFile.Replace(concretePath, "")} - {watch.ElapsedMilliseconds}ms"); stream.Write(bytes, 0, bytes.Length); stream.WriteByte(10); stream.Flush(); } watch.Stop(); } retryCount--; if (retryCount > 0 && retryClasses.Count > 0) { _processClasses(retryCount, allAllowedChildInfos, coreConfigName, stream, deserializer, watch, serializationPath, retryClasses, ignoreFields); } }