private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { DataTypeDescriptor dataTypeDescriptor = GetDataTypeDescriptor(); string formMarkup; XDocument formMarkupDocument = DynamicTypesCustomFormFacade.GetCustomFormMarkup(dataTypeDescriptor); if (formMarkupDocument != null) { formMarkup = formMarkupDocument.ToString(); } else { bool isMetaDataType = dataTypeDescriptor.SuperInterfaces.Contains(typeof(IPageMetaData)); var formsHelper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor, null, !isMetaDataType, null); var generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); formsHelper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); formMarkup = formsHelper.GetForm(); } this.Bindings.Add("Title", string.Format("{0}.{1} XML", dataTypeDescriptor.Namespace, dataTypeDescriptor.Name)); this.Bindings.Add("FileContent", formMarkup); }
private void collectDefaultValuesCodeActivity_ShowWizzard_ExecuteCode(object sender, EventArgs e) { Pair <string, Type> metaDataPair = this.GetBinding <Pair <string, Type> >("SelectedMetaDataDefinition"); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(metaDataPair.Second); Type metaDataType = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName); DataTypeDescriptorFormsHelper helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); helper.LayoutLabel = StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", "PageType.AddPageTypeMetaDataFieldWorkflow.AddingDefaultMetaData.Title"); helper.LayoutIconHandle = "pagetype-add-metedatafield"; GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); IData newDataTemplate = DataFacade.BuildNew(metaDataType); helper.UpdateWithNewBindings(this.Bindings); helper.ObjectToBindings(newDataTemplate, this.Bindings); this.UpdateBinding("NewDataTemplate", newDataTemplate); this.DeliverFormData( metaDataType.GetTypeTitle(), StandardUiContainerTypes.Wizard, helper.GetForm(), this.Bindings, helper.GetBindingsValidationRules(newDataTemplate) ); }
private DataTypeDescriptorFormsHelper GetDataTypeDescriptorFormsHelper() { if (_helper == null) { var type = GetInterfaceType(); var guid = type.GetImmutableTypeId(); var typeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(guid); if (typeDescriptor == null) { throw new InvalidOperationException(string.Format("Can not find the type descriptor for the type '{0}'", type)); } var generatedTypesHelper = new GeneratedTypesHelper(typeDescriptor) { AllowForeignKeyEditing = true }; _helper = new DataTypeDescriptorFormsHelper(typeDescriptor, true, EntityToken) { LayoutIconHandle = "generated-type-data-add" }; _helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); _typeName = typeDescriptor.Name; } return(_helper); }
private DataTypeDescriptorFormsHelper GetDataTypeDescriptorFormsHelper() { if (_helper == null) { var dataEntityToken = (DataEntityToken)EntityToken; var guid = dataEntityToken.Data.DataSourceId.InterfaceType.GetImmutableTypeId(); var typeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(guid); var generatedTypesHelper = new GeneratedTypesHelper(typeDescriptor) { AllowForeignKeyEditing = true }; _helper = new DataTypeDescriptorFormsHelper(typeDescriptor, true, EntityToken) { LayoutIconHandle = "generated-type-data-edit" }; _helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); _typeName = typeDescriptor.Name; } return(_helper); }
private void enterDefaultValuesCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { Type type = this.GetBinding <Type>(SelectedTypeBindingName); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type.GetImmutableTypeId()); DataTypeDescriptorFormsHelper helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); helper.LayoutIconHandle = "associated-data-add"; GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); IData newData = DataFacade.BuildNew(type); helper.UpdateWithNewBindings(this.Bindings); helper.ObjectToBindings(newData, this.Bindings); this.DeliverFormData( type.Name, StandardUiContainerTypes.Wizard, helper.GetForm(), this.Bindings, helper.GetBindingsValidationRules(newData) ); }
private void enterDataCodeActivity_ExecuteCode(object sender, EventArgs e) { var dataTypeDescriptor = GetBinding <DataTypeDescriptor>("DataTypeDescriptor"); var type = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName); Guid pageId = GetBinding <Guid>(BindingNames.PageId); var helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor, true, EntityToken) { LayoutIconHandle = "associated-data-add" }; var generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); IData newData; if (!BindingExist("NewData")) { newData = DataFacade.BuildNew(type); PageFolderFacade.AssignFolderDataSpecificValues(newData, pageId); var publishControlled = newData as IPublishControlled; if (publishControlled != null) { publishControlled.PublicationStatus = GenericPublishProcessController.Draft; } var localizedData = newData as ILocalizedControlled; if (localizedData != null) { var cultureInfo = UserSettings.ActiveLocaleCultureInfo ?? DataLocalizationFacade.DefaultLocalizationCulture; localizedData.SourceCultureName = cultureInfo.Name; } Bindings.Add("NewData", newData); helper.UpdateWithNewBindings(Bindings); helper.ObjectToBindings(newData, Bindings); } else { newData = GetBinding <IData>("NewData"); } DeliverFormData( type.Name, StandardUiContainerTypes.Document, helper.GetForm(), Bindings, helper.GetBindingsValidationRules(newData) ); }
private static DataTypeDescriptorFormsHelper CreateDataTypeDescriptorFormsHelper(IPageMetaDataDefinition pageMetaDataDefinition, DataTypeDescriptor dataTypeDescriptor) { var bindingPrefix = $"{pageMetaDataDefinition.Name}:{dataTypeDescriptor.Namespace}.{dataTypeDescriptor.Name}"; var helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor, bindingPrefix); var generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); helper.FieldGroupLabel = StringResourceSystemFacade.ParseString(pageMetaDataDefinition.Label); return(helper); }
private DataTypeDescriptorFormsHelper GetDataTypeDescriptorFormsHelper() { if (_helper == null) { var dataEntityToken = (DataEntityToken)EntityToken; var interfaceType = dataEntityToken.Data.DataSourceId.InterfaceType; var guid = interfaceType.GetImmutableTypeId(); var typeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(guid); var generatedTypesHelper = new GeneratedTypesHelper(typeDescriptor); _helper = new DataTypeDescriptorFormsHelper(typeDescriptor, true, EntityToken); _helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); _typeName = typeDescriptor.Name; } return(_helper); }
private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e) { Type selectedMetaDataType = this.GetBinding <Type>(SelectedTypeBindingName); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(selectedMetaDataType.GetImmutableTypeId()); PageMetaDataDescription dataAssociationVisabilityRule = this.GetBinding <PageMetaDataDescription>(DataAssociationVisabilityDescriptionBindingName); Guid metaDataContainerId = this.GetBinding <Guid>(SelectedContainerBindingName); string metaDataDefinitionName = this.GetBinding <string>(FieldGroupNameBindingName); string metaDataDefinitionLabel = this.GetBinding <string>(FieldGroupLabelBindingName); IData newDataTemplate = null; if (IsAnyPagesAffected()) { DataTypeDescriptorFormsHelper helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); newDataTemplate = DataFacade.BuildNew(selectedMetaDataType); helper.BindingsToObject(this.Bindings, newDataTemplate); } using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope()) { IPage page = GetCurrentPage(); page.AddMetaDataDefinition(metaDataDefinitionName, metaDataDefinitionLabel, selectedMetaDataType.GetImmutableTypeId(), metaDataContainerId, dataAssociationVisabilityRule.StartLevel, dataAssociationVisabilityRule.Levels); if (newDataTemplate != null) { page.AddNewMetaDataToExistingPages(metaDataDefinitionName, newDataTemplate); } transactionScope.Complete(); } ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher(); parentTreeRefresher.PostRefreshMesseges(this.EntityToken); }
private void MetaDataValid(object sender, ConditionalEventArgs e) { bool valid = ValidateBindings(); Type selectedMetaDataType = this.GetBinding <Type>(SelectedTypeBindingName); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(selectedMetaDataType.GetImmutableTypeId()); DataTypeDescriptorFormsHelper helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); IData newDataTemplate = DataFacade.BuildNew(selectedMetaDataType); if (!BindAndValidate(helper, newDataTemplate)) { valid = false; } if (valid) { var fieldsWithInvalidForeginKey = new List <string>(); DataReferenceFacade.TryValidateForeignKeyIntegrity(newDataTemplate, fieldsWithInvalidForeginKey); if (fieldsWithInvalidForeginKey.Count > 0) { foreach (string fieldName in fieldsWithInvalidForeginKey) { if (!generatedTypesHelper.NotEditableDataFieldDescriptorNames.Contains(fieldName)) { this.ShowFieldMessage(fieldName, "Invalid reference"); valid = false; } } } } e.Result = valid; }
private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e) { var dataTypeDescriptor = GetBinding <DataTypeDescriptor>("DataTypeDescriptor"); var newData = GetBinding <IData>("NewData"); var helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor, true, newData.GetDataEntityToken()); var generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); var isValid = ValidateBindings(); if (!BindAndValidate(helper, newData)) { isValid = false; } var justAdded = false; if (isValid) { var published = false; if (!BindingExist("DataAdded")) { var dataScopeIdentifier = DataScopeIdentifier.Public; if (dataTypeDescriptor.SuperInterfaces.Contains(typeof(IPublishControlled))) { dataScopeIdentifier = DataScopeIdentifier.Administrated; } using (new DataScope(dataScopeIdentifier)) { newData = DataFacade.AddNew(newData); justAdded = true; } PublishControlledHelper.PublishIfNeeded(newData, _doPublish, Bindings, ShowMessage); AcquireLock(newData.GetDataEntityToken()); UpdateBinding("NewData", newData); Bindings.Add("DataAdded", true); } else { var publishedControlled = newData as IPublishControlled; if (publishedControlled != null) { var refreshedData = (IPublishControlled)DataFacade.GetDataFromDataSourceId(newData.DataSourceId); if (refreshedData != null && refreshedData.PublicationStatus == GenericPublishProcessController.Published) { refreshedData.PublicationStatus = GenericPublishProcessController.Draft; DataFacade.Update(refreshedData); } } DataFacade.Update(newData); published = PublishControlledHelper.PublishIfNeeded(newData, _doPublish, Bindings, ShowMessage); EntityTokenCacheFacade.ClearCache(newData.GetDataEntityToken()); } if (!published) { var specificTreeRefresher = CreateParentTreeRefresher(); specificTreeRefresher.PostRefreshMesseges(EntityToken); } if (justAdded) { SetSaveStatus(true, newData); } else { SetSaveStatus(true); } } else { SetSaveStatus(false); } }
public static void InsertForm(Control control, ParameterList parameters) { Page currentPageHandler = HttpContext.Current.Handler as Page; if (currentPageHandler == null) { throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page"); } Type dataType = null; DataTypeDescriptor dataTypeDescriptor = null; string dataTypeName = parameters.GetParameter <string>("DataType"); dataType = TypeManager.GetType(dataTypeName); dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(dataType); IFormChannelIdentifier channelIdentifier = FormsRendererChannel.Identifier; formHelper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor); newData = DataFacade.BuildNew(dataType); GeneratedTypesHelper.SetNewIdFieldValue(newData); //Hide not editable fields, fox example - PageId GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); formHelper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames); //If is Page Datatype if (PageFolderFacade.GetAllFolderTypes().Contains(dataType)) { IPage currentPage = PageRenderer.CurrentPage; if (currentPage.GetDefinedFolderTypes().Contains(dataType) == false) { currentPage.AddFolderDefinition(dataType.GetImmutableTypeId()); } PageFolderFacade.AssignFolderDataSpecificValues(newData, currentPage); } _compiler = new FormTreeCompiler(); //bindings = formHelper.GetBindings(newData); bindings = new Dictionary <string, object>(); formHelper.UpdateWithNewBindings(bindings); formHelper.ObjectToBindings(newData, bindings); using (XmlReader reader = XDocument.Parse(formHelper.GetForm()).CreateReader()) { try { _compiler.Compile(reader, channelIdentifier, bindings, formHelper.GetBindingsValidationRules(newData)); #region ClientValidationRules clientValidationRules = new Dictionary <string, List <ClientValidationRule> >(); foreach (var item in _compiler.GetField <object>("_context").GetProperty <IEnumerable>("Rebindings")) { var SourceProducer = item.GetProperty <object>("SourceProducer"); var uiControl = SourceProducer as IWebUiControl; if (uiControl != null) { clientValidationRules[uiControl.UiControlID] = uiControl.ClientValidationRules; } } #endregion } catch (ConfigurationErrorsException e) { if (e.Message.Contains("Failed to load the configuration for IUiControlFactory")) { throw new ConfigurationErrorsException("Composite.Forms.Renderer does not support widget. " + e.Message); } else { throw new ConfigurationErrorsException(e.Message); } } } webUiControl = (IWebUiControl)_compiler.UiControl; Control form = webUiControl.BuildWebControl(); control.Controls.Add(form); /*if (currentPageHandler.IsPostBack) * try * { * compiler.SaveControlProperties(); * } * catch { }*/ if (!currentPageHandler.IsPostBack) { webUiControl.InitializeViewState(); } return; }