public override void Update(DataSourceContext context, IDataItem item, Newtonsoft.Json.Linq.JToken data)
        {
            var           schema = GetAlpaca(context, true, false, false)["schema"] as JObject;
            TabController tc     = new TabController();
            var           tab    = (TabInfo)item.Item;

            if (HasProperty(schema, "", "TabName"))
            {
                tab.TabName = data["TabName"]?.ToString() ?? "";
            }
            if (HasProperty(schema, "", "Title"))
            {
                tab.Title = data["Title"]?.ToString() ?? "";
            }
            if (HasProperty(schema, "", "Description"))
            {
                tab.Description = data["Description"]?.ToString() ?? "";
            }
            if (HasProperty(schema, "", "Settings"))
            {
                var settings       = data["Settings"] as JObject;
                var settingsSchema = schema["properties"]["Settings"]["properties"] as JObject;
                foreach (var prop in settingsSchema.Properties())
                {
                    if (settings[prop.Name] != null)
                    {
                        tc.UpdateTabSetting(tab.TabID, prop.Name, settings[prop.Name].ToString());
                    }
                    else
                    {
                        tc.DeleteTabSetting(tab.TabID, prop.Name);
                    }
                }
            }
            if (HasProperty(schema, "", "Head"))
            {
                string head           = "";
                var    settings       = data["Head"] as JObject;
                var    settingsSchema = schema["properties"]["Head"]["properties"] as JObject;
                foreach (var prop in settingsSchema.Properties())
                {
                    if (settings[prop.Name] != null)
                    {
                        tc.UpdateTabSetting(tab.TabID, prop.Name, settings[prop.Name].ToString());
                    }
                    else
                    {
                        tc.DeleteTabSetting(tab.TabID, prop.Name);
                    }
                    head += $"<meta property=\"{prop.Name}\" content=\"{prop.Value.ToString()}\" />";
                }
                tab.PageHeadText = head;
            }
            tc.UpdateTab(tab);
        }
Exemple #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateWorkFlow updates the currently active Workflow
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="WorkFlowType">The type of workflow (Module | Page | Site)</param>
        /// <param name = "WorkflowID">The ID of the Workflow</param>
        /// <param name="ObjectID">The ID of the object to apply the update to (depends on WorkFlowType)</param>
        /// <param name="ReplaceExistingSettings">Should existing settings be overwritten?</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateWorkflow(int ObjectID, string WorkFlowType, int WorkflowID, bool ReplaceExistingSettings)
        {
            var tabController    = new TabController();
            var moduleController = new ModuleController();

            switch (WorkFlowType)
            {
            case "Module":
                moduleController.UpdateModuleSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                break;

            case "Page":
                tabController.UpdateTabSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                if (ReplaceExistingSettings)
                {
                    //Get All Modules on the current Tab
                    foreach (var kvp in moduleController.GetTabModules(ObjectID))
                    {
                        ClearModuleSettings(kvp.Value);
                    }
                }
                break;

            case "Site":
                PortalController.UpdatePortalSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                if (ReplaceExistingSettings)
                {
                    //Get All Tabs aon the Site
                    foreach (var kvp in tabController.GetTabsByPortal(ObjectID))
                    {
                        tabController.DeleteTabSetting(kvp.Value.TabID, "WorkFlowID");
                    }
                    //Get All Modules in the current Site
                    foreach (ModuleInfo objModule in moduleController.GetModules(ObjectID))
                    {
                        ClearModuleSettings(objModule);
                    }
                }
                break;
            }
        }