private void TrySaveEntity() { if (this.editorError != StorageConfigEditorError.None) return; if (this.entity == null) { this.editorError = StorageConfigEditorError.IsNotFound; this.errorMessageText = GetMessageRaw("Message.EntityIsNotFound"); return; } try { this.entity.IsActive = ActiveChkBx.Checked; int i; this.entity.Sort = int.TryParse(SortTbx.Text, out i) ? i : 10; this.entity.StorageTypeName = ProviderDdl.SelectedValue; this.entity.StorageSettings.Assign(PrepareSettingsEditorJsonSerializer().Deserialize<BXStorageSettingsEditor>(SettingsEditorDataFld.Value).Settings); BXStorageBinding[] bindings = null; if (BindingDataFld.Value.Length > 0) { List<BXStorageBinding> lst = PrepareBindingJsonSerializer().Deserialize<List<BXStorageBinding>>(BindingDataFld.Value); if (lst != null) bindings = lst.ToArray(); } else bindings = new BXStorageBinding[0]; this.entity.SetBindings(bindings); this.entity.Save(); this.entityId = this.entity.Id; } catch (Exception ex) { this.errorMessageText = ex.Message; this.editorError = this.entity.IsNew ? StorageConfigEditorError.Creation : StorageConfigEditorError.Modification; } }
protected void OnToolBarButtonClick(object sender, CommandEventArgs e) { if (e.CommandName == "delete") { try { if (this.entity != null) this.entity.Delete(); GoBack(); } catch (Exception ex) { this.errorMessageText = ex.Message; this.editorError = StorageConfigEditorError.Deleting; } } }
protected override void OnInit(EventArgs e) { if (!BXPrincipal.Current.IsCanOperate(BXRoleOperation.Operations.ProductSettingsManage)) BXAuthentication.AuthenticationRequired(); string id = Request.QueryString["id"]; if (string.IsNullOrEmpty(id)) this.entityId = 0; else { try { this.entityId = Convert.ToInt32(Request.QueryString["id"]); } catch { this.entityId = 0; } } if (this.entityId == 0) this.entity = new BXStorageConfiguration(); else if ((this.entity = BXStorageConfiguration.GetById(EntityId, BXTextEncoder.EmptyTextEncoder)) == null) { this.editorError = StorageConfigEditorError.IsNotFound; this.errorMessageText = GetMessageRaw("Message.EntityIsNotFound"); return; } this.editorMode = this.entity.IsNew ? BXAdminPageEditorMode.Creation : BXAdminPageEditorMode.Modification; List<BXTypeInfo> storageInfoLst = new List<BXTypeInfo>(); foreach (BXTypeInfo storageInfo in BXStorageManager.GetStorageInfos()) { //do not include BXFileSystemStorage - is not cloud storage if (!string.Equals(storageInfo.Name, typeof(BXFileSystemStorage).FullName, StringComparison.OrdinalIgnoreCase)) { storageInfoLst.Add(storageInfo); } } this.storageInfos = storageInfoLst.ToArray(); List<BXStorageSettingsEditor> storageSettingsEditorLst = new List<BXStorageSettingsEditor>(); foreach(BXTypeInfo storageInfo in this.storageInfos) { BXStorageSettingsEditor editor = BXStorageManager.CreateStorageSettingsEditor(storageInfo.Name); if (editor != null) { storageSettingsEditorLst.Add(editor); if (!this.entity.IsNew && string.Equals(this.entity.StorageTypeName, storageInfo.Name, StringComparison.OrdinalIgnoreCase)) { editor.Settings = this.entity.StorageSettings; } } } this.storageSettingsEditors = storageSettingsEditorLst.ToArray(); MasterTitle = Page.Title = this.editorMode == BXAdminPageEditorMode.Creation ? GetMessage("PageTitle.Creation") : string.Concat(GetMessage("PageTitle.Modification"), " #", EntityId.ToString()); base.OnInit(e); }