/// ----------------------------------------------------------------------------- /// <summary> /// SaveModuleDefinition saves the Module Definition to the database /// </summary> /// <param name="moduleDefinition">The Module Definition to save</param> /// <param name="saveChildren">A flag that determines whether the child objects are also saved</param> /// <param name="clearCache">A flag that determines whether to clear the host cache</param> /// <history> /// [cnurse] 01/14/2008 Created /// </history> /// ----------------------------------------------------------------------------- public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache) { int moduleDefinitionID = moduleDefinition.ModuleDefID; if (moduleDefinitionID == Null.NullInteger) { //Add new Module Definition moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID); } else { //Upgrade Module Definition dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID); } if (saveChildren) { foreach (KeyValuePair <string, PermissionInfo> kvp in moduleDefinition.Permissions) { kvp.Value.ModuleDefID = moduleDefinitionID; //check if permission exists var permissionController = new PermissionController(); ArrayList permissions = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey); if (permissions != null && permissions.Count == 1) { var permission = (PermissionInfo)permissions[0]; kvp.Value.PermissionID = permission.PermissionID; permissionController.UpdatePermission(kvp.Value); } else { permissionController.AddPermission(kvp.Value); } } foreach (KeyValuePair <string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls) { kvp.Value.ModuleDefID = moduleDefinitionID; //check if definition exists ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID); if (moduleControl != null) { kvp.Value.ModuleControlID = moduleControl.ModuleControlID; } ModuleControlController.SaveModuleControl(kvp.Value, clearCache); } } if (clearCache) { DataCache.ClearHostCache(true); } return(moduleDefinitionID); }
private void cmdUpdate_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (cboSource.SelectedIndex != 0 || !String.IsNullOrEmpty(txtSource.Text)) { //check whether have a same control key in the module definition var controlKey = !String.IsNullOrEmpty(txtKey.Text) ? txtKey.Text : Null.NullString; var moduleControls = ModuleControlController.GetModuleControlsByModuleDefinitionID(ModuleDefId).Values; var keyExists = moduleControls.Any(c => c.ControlKey.Equals(controlKey, StringComparison.InvariantCultureIgnoreCase) && c.ModuleControlID != ModuleControlId); if (keyExists) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateKey.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } var moduleControl = new ModuleControlInfo { ModuleControlID = ModuleControlId, ModuleDefID = ModuleDefId, ControlKey = controlKey, ControlTitle = !String.IsNullOrEmpty(txtTitle.Text) ? txtTitle.Text : Null.NullString, ControlSrc = !String.IsNullOrEmpty(txtSource.Text) ? txtSource.Text : cboSource.SelectedItem.Text, ControlType = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), cboType.SelectedItem.Value), ViewOrder = !String.IsNullOrEmpty(txtViewOrder.Text) ? int.Parse(txtViewOrder.Text) : Null.NullInteger, IconFile = cboIcon.SelectedIndex > 0 ? cboIcon.SelectedItem.Text : Null.NullString, HelpURL = !String.IsNullOrEmpty(txtHelpURL.Text) ? txtHelpURL.Text : Null.NullString, SupportsPartialRendering = chkSupportsPartialRendering.Checked, SupportsPopUps = supportsModalPopUpsCheckBox.Checked }; try { ModuleControlController.SaveModuleControl(moduleControl, true); } catch { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AddControl.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } Response.Redirect(ReturnURL, true); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("MissingSource.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void cmdUpdate_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (cboSource.SelectedIndex != 0 || !String.IsNullOrEmpty(txtSource.Text)) { var moduleControl = new ModuleControlInfo { ModuleControlID = ModuleControlId, ModuleDefID = ModuleDefId, ControlKey = !String.IsNullOrEmpty(txtKey.Text) ? txtKey.Text : Null.NullString, ControlTitle = !String.IsNullOrEmpty(txtTitle.Text) ? txtTitle.Text : Null.NullString, ControlSrc = !String.IsNullOrEmpty(txtSource.Text) ? txtSource.Text : cboSource.SelectedItem.Text, ControlType = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), cboType.SelectedItem.Value), ViewOrder = !String.IsNullOrEmpty(txtViewOrder.Text) ? int.Parse(txtViewOrder.Text) : Null.NullInteger, IconFile = cboIcon.SelectedIndex > 0 ? cboIcon.SelectedItem.Text : Null.NullString, HelpURL = !String.IsNullOrEmpty(txtHelpURL.Text) ? txtHelpURL.Text : Null.NullString, SupportsPartialRendering = chkSupportsPartialRendering.Checked, SupportsPopUps = supportsModalPopUpsCheckBox.Checked }; try { ModuleControlController.SaveModuleControl(moduleControl, true); } catch { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AddControl.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); return; } Response.Redirect(ReturnURL, true); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("MissingSource.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError); } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private static void SaveModuleControl(ModuleControlDto moduleControlDto) { var moduleControl = moduleControlDto.ToModuleControlInfo(); ModuleControlController.SaveModuleControl(moduleControl, true); }