/// <summary> /// Processes the step 3 of the wizard /// </summary> private void ProcessStep3(WizardNavigationEventArgs e) { // Actions after next button click var dci = DataClassInfoProvider.GetDataClassInfo(ClassName); // Ensure actual form info FormHelper.ClearFormInfos(true); // Get and load form definition var fi = FormHelper.GetFormInfo(dci.ClassName, false); if (fi.GetFields(true, true).Count() < 2) { e.Cancel = true; FieldEditor.ShowError(GetString("DocumentType_New_Step3.TableMustHaveCustomField")); } else { // Different behavior by mode switch (Mode) { case NewClassWizardModeEnum.DocumentType: { TableManager tm = new TableManager(null); // Create new view if doesn't exist string viewName = SqlHelper.GetViewName(dci.ClassTableName, null); // Create view for document types if (!tm.ViewExists(viewName)) { tm.CreateView(viewName, SqlGenerator.GetSqlQuery(ClassName, SqlOperationTypeEnum.SelectView, null)); } // If new document type is created prepare next step otherwise skip steps 4, 5 and 6 // Disable previous steps' viewstates DisablePreviousStepsViewStates(e.CurrentStepIndex); // Enable next step's viewstate EnableNextStepViewState(e.CurrentStepIndex); // Add implicit value to the list lstFields.Items.Add(new ListItem(GetString("DocumentType_New_Step4.ImplicitDocumentName"), "")); // Get all fields List<FormFieldInfo> ffiFields = fi.GetFields(true, true); if (ffiFields != null) { bool selected = false; // Add all text fields' names to the list except primary-key field foreach (FormFieldInfo ffi in ffiFields) { if (!ffi.PrimaryKey && !ffi.AllowEmpty && ((ffi.DataType == FieldDataType.Text) || (ffi.DataType == FieldDataType.LongText))) { lstFields.Items.Add(new ListItem(ffi.Name, ffi.Name)); // Select the first text field if (!selected) { string controlName = ValidationHelper.GetString(ffi.Settings["controlname"], null); // Preselect only textbox if (CMSString.Compare(controlName, Enum.GetName(typeof (FormFieldControlTypeEnum), FormFieldControlTypeEnum.TextBoxControl), StringComparison.InvariantCultureIgnoreCase) == 0) { lstFields.SelectedValue = ffi.Name; selected = true; } } } } } lblSelectField.Text = GetString("DocumentType_New_Step4.DocumentName"); wzdStep4.Title = GetString("DocumentType_New_Step4.Title"); ucHeader.Description = GetString("DocumentType_New_Step4.Description"); } break; case NewClassWizardModeEnum.Class: { // Update class in DB using (CMSActionContext context = new CMSActionContext()) { // Disable logging into event log context.LogEvents = false; DataClassInfoProvider.SetDataClassInfo(dci); } // Remember that some steps were omitted SomeStepsOmitted = true; // Prepare next step (7) - skip steps 4, 5 and 6 // Disable previous steps' viewstates DisablePreviousStepsViewStates(5); // Enable next step's viewstate EnableNextStepViewState(5); PrepareStep7(); // Go to the step 7 (indexed from 0) wzdNewDocType.ActiveStepIndex = 6; } break; case NewClassWizardModeEnum.CustomTable: { // Update class in DB using (CMSActionContext context = new CMSActionContext()) { // Disable logging into event log context.LogEvents = false; DataClassInfoProvider.SetDataClassInfo(dci); } // Remember that some steps were omitted, SomeStepsOmitted = true; // Prepare next step (6) - skip steps 4, 5 // Disable previous steps' viewstates DisablePreviousStepsViewStates(4); // Enable next step's viewstate EnableNextStepViewState(4); PrepareStep6(); // Go to the step 6 (indexed from 0) wzdNewDocType.ActiveStepIndex = 5; } break; } } }
/// <summary> /// Processes the step 3 of the wizard /// </summary> private void ProcessStep3(WizardNavigationEventArgs e) { // Actions after next button click DataClassInfo dci = DataClassInfoProvider.GetDataClass(ClassName); var genDci = dci.Generalized; List<FormFieldInfo> ffiVisibleFields = null; // Ensure actual form info FormHelper.ClearFormInfos(true); // Get and load form definition FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false); // Get all visible fields ffiVisibleFields = fi.GetFields(true, false); if (fi.GetFields(true, true).Count() < 2) { e.Cancel = true; FieldEditor.ShowError(GetString("DocumentType_New_Step3.TableMustHaveCustomField")); } else { // Generate basic queries if (SqlGenerator.GenerateDefaultQueriesToDB) { SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_SELECT, SqlOperationTypeEnum.SelectQuery, false, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_DELETE, SqlOperationTypeEnum.DeleteQuery, false, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_INSERT, SqlOperationTypeEnum.InsertQuery, true, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_UPDATE, SqlOperationTypeEnum.UpdateQuery, false, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_SELECTALL, SqlOperationTypeEnum.SelectAll, false, false); } // Different behavior by mode switch (Mode) { case NewClassWizardModeEnum.DocumentType: { TableManager tm = new TableManager(null); // Create new view if doesn't exist string viewName = DataHelper.GetViewName(dci.ClassTableName, null); // Create view for document types if (!tm.ViewExists(viewName)) { tm.CreateView(viewName, SqlGenerator.GetSqlQuery(ClassName, SqlOperationTypeEnum.SelectView, null)); } // Generate additional queries when creating new document type if (SqlGenerator.GenerateDefaultQueriesToDB) { SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_SEARCHTREE, SqlOperationTypeEnum.SearchTree, false, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_SELECTDOCUMENTS, SqlOperationTypeEnum.SelectDocuments, false, false); SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_SELECTVERSIONS, SqlOperationTypeEnum.SelectVersions, false, false); } // If new document type is created prepare next step otherwise skip steps 4, 5 and 6 // Disable previous steps' viewstates DisablePreviousStepsViewStates(e.CurrentStepIndex); // Enable next step's viewstate EnableNextStepViewState(e.CurrentStepIndex); // Add implicit value to the list lstFields.Items.Add(new ListItem(GetString("DocumentType_New_Step4.ImplicitDocumentName"), "")); if (ffiVisibleFields != null) { // Add visible fields' names to the list except primary-key field foreach (FormFieldInfo ffi in ffiVisibleFields) { if (!ffi.PrimaryKey) { lstFields.Attributes.Add(ffi.Name, ffi.Name); lstFields.Items.Add(new ListItem(ffi.Name, ffi.Name)); } } } lblSelectField.Text = GetString("DocumentType_New_Step4.DocumentName"); wzdStep4.Title = GetString("DocumentType_New_Step4.Title"); ucHeader.Description = GetString("DocumentType_New_Step4.Description"); } break; case NewClassWizardModeEnum.Class: { // Update class in DB using (CMSActionContext context = new CMSActionContext()) { // Disable logging into event log context.LogEvents = false; DataClassInfoProvider.SetDataClass(dci); } // Remember that some steps were omitted SomeStepsOmitted = true; // Prepare next step (7) - skip steps 4, 5 and 6 // Disable previous steps' viewstates DisablePreviousStepsViewStates(5); // Enable next step's viewstate EnableNextStepViewState(5); PrepareStep8(); // Go to the step 8 (indexed from 0) wzdNewDocType.ActiveStepIndex = 7; } break; case NewClassWizardModeEnum.CustomTable: { // Generate additional delete all query if (SqlGenerator.GenerateDefaultQueriesToDB) { SqlGenerator.GenerateQuery(ClassName, QueryProvider.QUERYNAME_DELETEALL, SqlOperationTypeEnum.DeleteAll, false, false); } // Update class in DB using (CMSActionContext context = new CMSActionContext()) { // Disable logging into event log context.LogEvents = false; DataClassInfoProvider.SetDataClass(dci); } // Remember that some steps were omitted, SomeStepsOmitted = true; // Prepare next step (6) - skip steps 4, 5 // Disable previous steps' viewstates DisablePreviousStepsViewStates(4); // Enable next step's viewstate EnableNextStepViewState(4); PrepareStep6(); // Go to the step 6 (indexed from 0) wzdNewDocType.ActiveStepIndex = 5; } break; } } }