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 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 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 initializeStateCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { DataTypeDescriptor dataTypeDescriptor = GetDataTypeDescriptor(); var helper = new GeneratedTypesHelper(dataTypeDescriptor); var fieldDescriptors = helper.EditableInDesignerOwnDataFields.ToList(); this.Bindings = new Dictionary <string, object> { { "TypeName", dataTypeDescriptor.Name }, { "TypeNamespace", dataTypeDescriptor.Namespace }, { "TypeTitle", dataTypeDescriptor.Title }, { "LabelFieldName", dataTypeDescriptor.LabelFieldName }, { "HasCaching", helper.IsCacheable }, { "HasPublishing", helper.IsPublishControlled }, { "DataFieldDescriptors", fieldDescriptors }, { "OldTypeName", dataTypeDescriptor.Name }, { "OldTypeNamespace", dataTypeDescriptor.Namespace } }; this.BindingsValidationRules = new Dictionary <string, List <ClientValidationRule> > { { this.NewTypeNameBindingName, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { this.NewTypeNamespaceBindingName, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { this.NewTypeTitleBindingName, new List <ClientValidationRule> { new NotNullClientValidationRule() } } }; }
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 void initialCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e) { var type = GetInterfaceType(); if (!PermissionsFacade.GetPermissionsForCurrentUser(EntityToken).Contains(PermissionType.Publish) || !typeof(IPublishControlled).IsAssignableFrom(type)) { var formData = WorkflowFacade.GetFormData(InstanceId, true); if (formData.ExcludedEvents == null) { formData.ExcludedEvents = new List <string>(); } formData.ExcludedEvents.Add("SaveAndPublish"); } var helper = GetDataTypeDescriptorFormsHelper(); helper.UpdateWithNewBindings(Bindings); var newData = DataFacade.BuildNew(type); var publishControlled = newData as IPublishControlled; if (publishControlled != null) { publishControlled.PublicationStatus = GenericPublishProcessController.Draft; } if (!string.IsNullOrEmpty(Payload)) { var values = new Dictionary <string, string>(); var serializedValues = StringConversionServices.ParseKeyValueCollection(Payload); foreach (var kvp in serializedValues) { values.Add(kvp.Key, StringConversionServices.DeserializeValueString(kvp.Value)); } newData.SetValues(values); } helper.ObjectToBindings(newData, Bindings); GeneratedTypesHelper.SetNewIdFieldValue(newData); Bindings.Add("NewData", newData); }
private void initialStateCodeActivity_ExecuteCode(object sender, EventArgs e) { var dataFieldDescriptors = new List <DataFieldDescriptor> { GeneratedTypesHelper.BuildIdField() }; this.Bindings = new Dictionary <string, object> { { BindingNames.ViewLabel, IsPageDataFolder ? Texts.AddNewAggregationTypeWorkflow_DocumentTitle : Texts.AddNewInterfaceTypeStep1_DocumentTitle }, { BindingNames.NewTypeName, "" }, { BindingNames.NewTypeNamespace, UserSettings.LastSpecifiedNamespace }, { BindingNames.NewTypeTitle, "" }, { BindingNames.DataFieldDescriptors, dataFieldDescriptors }, { BindingNames.HasCaching, false }, { BindingNames.HasPublishing, false }, { BindingNames.HasLocalization, false }, { BindingNames.IsSearchable, true }, { BindingNames.KeyFieldName, dataFieldDescriptors.First().Name }, { BindingNames.LabelFieldName, "" }, { BindingNames.KeyFieldReadOnly, false } }; this.BindingsValidationRules = new Dictionary <string, List <ClientValidationRule> > { { BindingNames.NewTypeName, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { BindingNames.NewTypeNamespace, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { BindingNames.NewTypeTitle, new List <ClientValidationRule> { new NotNullClientValidationRule() } } }; if (RuntimeInformation.IsDebugBuild && DynamicTempTypeCreator.UseTempTypeCreator) { var dynamicTempTypeCreator = new DynamicTempTypeCreator(IsPageDataFolder ? "PageFolder" : "GlobalTest"); dataFieldDescriptors.AddRange(dynamicTempTypeCreator.DataFieldDescriptors); this.UpdateBinding(BindingNames.NewTypeName, dynamicTempTypeCreator.TypeName); this.UpdateBinding(BindingNames.NewTypeTitle, dynamicTempTypeCreator.TypeTitle); this.UpdateBinding(BindingNames.LabelFieldName, dynamicTempTypeCreator.DataFieldDescriptors.First().Name); } }
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); }
public static XElement GetXElement(IData data) { var elementName = data.DataSourceId.InterfaceType.Name; XElement xml = new XElement(elementName); var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(data.DataSourceId.InterfaceType.GetImmutableTypeId()); GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor); //generatedTypesHelper.NotEditableDataFieldDescriptorNames foreach (DataFieldDescriptor fieldDescriptor in dataTypeDescriptor.Fields.Where(dfd => dfd.Inherited == false)) { var propertyInfo = data.DataSourceId.InterfaceType.GetProperty(fieldDescriptor.Name); if (!generatedTypesHelper.NotEditableDataFieldDescriptorNames.Contains(fieldDescriptor.Name)) { string label = fieldDescriptor.FormRenderingProfile.Label; object value = propertyInfo.GetValue(data, null); List <ForeignKeyAttribute> foreignKeyAttributes = propertyInfo.GetCustomAttributesRecursively <ForeignKeyAttribute>().ToList(); if (foreignKeyAttributes.Count > 0) { IData foreignData = data.GetReferenced(propertyInfo.Name); value = DataAttributeFacade.GetLabel(foreignData); } if (value == null) { value = string.Empty; } xml.Add( new XElement("Property", new XAttribute("Label", GetLocalized(label)), new XAttribute("Value", value) ) ); } } return(xml); }
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 initialStateCodeActivity_ExecuteCode(object sender, EventArgs e) { DataTypeDescriptor dataTypeDescriptor = GetDataTypeDescriptor(); var helper = new GeneratedTypesHelper(dataTypeDescriptor); List <DataFieldDescriptor> fieldDescriptors = helper.EditableInDesignerOwnDataFields.ToList(); this.Bindings = new Dictionary <string, object> { { BindingNames.TypeName, dataTypeDescriptor.Name }, { BindingNames.TypeNamespace, dataTypeDescriptor.Namespace }, { BindingNames.TypeTitle, dataTypeDescriptor.Title }, { BindingNames.KeyFieldName, dataTypeDescriptor.KeyPropertyNames.Single() }, { BindingNames.LabelFieldName, dataTypeDescriptor.LabelFieldName }, { BindingNames.InternalUrlPrefix, dataTypeDescriptor.InternalUrlPrefix }, { BindingNames.HasCaching, helper.IsCachable }, { BindingNames.HasPublishing, helper.IsPublishControlled }, { BindingNames.IsSearchable, helper.IsSearchable }, { BindingNames.DataFieldDescriptors, fieldDescriptors }, { BindingNames.OldTypeName, dataTypeDescriptor.Name }, { BindingNames.OldTypeNamespace, dataTypeDescriptor.Namespace } }; this.BindingsValidationRules = new Dictionary <string, List <ClientValidationRule> > { { BindingNames.TypeName, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { BindingNames.TypeNamespace, new List <ClientValidationRule> { new NotNullClientValidationRule() } }, { BindingNames.TypeTitle, new List <ClientValidationRule> { new NotNullClientValidationRule() } } }; }
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; }
private void initializeCodeActivity_BuildNewData_ExecuteCode(object sender, EventArgs e) { Initialize(); this.FormsHelper.UpdateWithNewBindings(this.Bindings); IData newData = DataFacade.BuildNew(InterfaceType); if (PageFolderFacade.GetAllFolderTypes().Contains(InterfaceType)) { Dictionary <string, string> piggybag = PiggybagSerializer.Deserialize(this.ExtraPayload); var piggybagDataFinder = new PiggybagDataFinder(piggybag, this.EntityToken); IPage page = (IPage)piggybagDataFinder.TryGetData(typeof(IPage)); if (page != null) { PageFolderFacade.AssignFolderDataSpecificValues(newData, page); } } var publishControlled = newData as IPublishControlled; if (publishControlled != null) { publishControlled.PublicationStatus = GenericPublishProcessController.Draft; } var values = new Dictionary <string, string>(); var castedEntityToken = this.EntityToken as TreeDataFieldGroupingElementEntityToken; if (castedEntityToken != null) { Tree tree = TreeFacade.GetTree(castedEntityToken.Source); var treeNode = (DataFolderElementsTreeNode)tree.GetTreeNode(castedEntityToken.TreeNodeId); if (treeNode.Range == null && !treeNode.FirstLetterOnly) { foreach (var kvp in castedEntityToken.DeserializedGroupingValues) { values.Add(kvp.Key, ValueTypeConverter.Convert <string>(kvp.Value)); } } } var props = InterfaceType.GetPropertiesRecursively().ToDictionary(prop => prop.Name); foreach (var kvp in this.DataPayload) { // Filtering payload data which is not default field values if (props.ContainsKey(kvp.Key)) { values[kvp.Key] = StringConversionServices.DeserializeValueString(kvp.Value); } } newData.SetValues(values); this.FormsHelper.ObjectToBindings(newData, this.Bindings); GeneratedTypesHelper.SetNewIdFieldValue(newData); this.Bindings.Add("NewData", newData); }
private void finalizeStateCodeActivity_ExecuteCode(object sender, EventArgs e) { try { Type oldType = GetOldTypeFromBindings(); string typeName = this.GetBinding <string>(BindingNames.TypeName); string typeNamespace = this.GetBinding <string>(BindingNames.TypeNamespace); string typeTitle = this.GetBinding <string>(BindingNames.TypeTitle); bool hasCaching = this.GetBinding <bool>(BindingNames.HasCaching); bool hasPublishing = this.GetBinding <bool>(BindingNames.HasPublishing); bool isSearchable = this.GetBinding <bool>(BindingNames.IsSearchable); string keyFieldName = this.GetBinding <string>(BindingNames.KeyFieldName); string labelFieldName = this.GetBinding <string>(BindingNames.LabelFieldName); string internalUrlPrefix = this.GetBinding <string>(BindingNames.InternalUrlPrefix); var dataFieldDescriptors = this.GetBinding <List <DataFieldDescriptor> >(BindingNames.DataFieldDescriptors); var helper = new GeneratedTypesHelper(oldType); bool hasLocalization = typeof(ILocalizedControlled).IsAssignableFrom(oldType); string errorMessage; if (!helper.ValidateNewTypeName(typeName, out errorMessage)) { this.ShowFieldMessage(BindingNames.TypeName, errorMessage); return; } if (!helper.ValidateNewTypeNamespace(typeNamespace, out errorMessage)) { this.ShowFieldMessage(BindingNames.TypeNamespace, errorMessage); return; } if (!helper.ValidateNewTypeFullName(typeName, typeNamespace, out errorMessage)) { this.ShowFieldMessage(BindingNames.TypeName, errorMessage); return; } if (!helper.ValidateNewFieldDescriptors(dataFieldDescriptors, keyFieldName, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.EditInterfaceTypeStep1_ErrorTitle, errorMessage ); return; } helper.SetNewTypeFullName(typeName, typeNamespace); helper.SetNewTypeTitle(typeTitle); helper.SetNewInternalUrlPrefix(internalUrlPrefix); helper.SetNewFieldDescriptors(dataFieldDescriptors, keyFieldName, labelFieldName); if (helper.IsEditProcessControlledAllowed) { helper.SetCachable(hasCaching); helper.SetSearchable(isSearchable); helper.SetPublishControlled(hasPublishing); helper.SetLocalizedControlled(hasLocalization); } bool originalTypeHasData = DataFacade.HasDataInAnyScope(oldType); if (!helper.TryValidateUpdate(originalTypeHasData, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.EditInterfaceTypeStep1_ErrorTitle, errorMessage ); return; } if (!IsPageFolder) { string oldSerializedTypeName = GetSerializedTypeName(GetBinding <string>(BindingNames.OldTypeNamespace), GetBinding <string>(BindingNames.OldTypeName)); string newSerializedTypeName = GetSerializedTypeName(typeNamespace, typeName); if (newSerializedTypeName != oldSerializedTypeName) { UpdateWhiteListedGeneratedTypes(oldSerializedTypeName, newSerializedTypeName); } } helper.CreateType(originalTypeHasData); UpdateBinding(BindingNames.OldTypeName, typeName); UpdateBinding(BindingNames.OldTypeNamespace, typeNamespace); SetSaveStatus(true); var rootEntityToken = new GeneratedDataTypesElementProviderRootEntityToken(this.EntityToken.Source, IsPageFolder ? GeneratedDataTypesElementProviderRootEntityToken.PageDataFolderTypeFolderId : GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId); SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher(); specificTreeRefresher.PostRefreshMesseges(rootEntityToken); IFile markupFile = DynamicTypesAlternateFormFacade.GetAlternateFormMarkupFile(typeNamespace, typeName); if (markupFile != null) { ShowMessage(DialogType.Message, Texts.FormMarkupInfo_Dialog_Label, Texts.FormMarkupInfo_Message(Texts.EditFormMarkup, markupFile.GetRelativeFilePath())); } } catch (Exception ex) { Log.LogCritical(this.GetType().Name, ex); this.ShowMessage(DialogType.Error, ex.Message, ex.Message); } }
private void codeActivity1_ExecuteCode(object sender, EventArgs e) { try { string typeName = this.GetBinding <string>(BindingNames.NewTypeName); string typeNamespace = this.GetBinding <string>(BindingNames.NewTypeNamespace); string typeTitle = this.GetBinding <string>(BindingNames.NewTypeTitle); bool hasCaching = this.GetBinding <bool>(BindingNames.HasCaching); bool hasPublishing = this.GetBinding <bool>(BindingNames.HasPublishing); bool hasLocalization = this.GetBinding <bool>(BindingNames.HasLocalization); bool isSearchable = this.GetBinding <bool>(BindingNames.IsSearchable); string keyFieldName = this.GetBinding <string>(BindingNames.KeyFieldName); string labelFieldName = this.GetBinding <string>(BindingNames.LabelFieldName); string internalUrlPrefix = this.GetBinding <string>(BindingNames.InternalUrlPrefix); var dataFieldDescriptors = this.GetBinding <List <DataFieldDescriptor> >(BindingNames.DataFieldDescriptors); GeneratedTypesHelper helper; Type interfaceType = null; if (this.BindingExist(BindingNames.InterfaceType)) { interfaceType = this.GetBinding <Type>(BindingNames.InterfaceType); helper = new GeneratedTypesHelper(interfaceType); } else { helper = new GeneratedTypesHelper(); } string errorMessage; if (!helper.ValidateNewTypeName(typeName, out errorMessage)) { this.ShowFieldMessage(BindingNames.NewTypeName, errorMessage); return; } if (!helper.ValidateNewTypeNamespace(typeNamespace, out errorMessage)) { this.ShowFieldMessage(BindingNames.NewTypeNamespace, errorMessage); return; } if (!helper.ValidateNewTypeFullName(typeName, typeNamespace, out errorMessage)) { this.ShowFieldMessage(BindingNames.NewTypeName, errorMessage); return; } if (!helper.ValidateNewFieldDescriptors(dataFieldDescriptors, keyFieldName, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.AddNewInterfaceTypeStep1_ErrorTitle, errorMessage ); return; } if (interfaceType != null) { if (hasLocalization != DataLocalizationFacade.IsLocalized(interfaceType) && DataFacade.GetData(interfaceType).ToDataEnumerable().Any()) { this.ShowMessage( DialogType.Error, Texts.AddNewInterfaceTypeStep1_ErrorTitle, "It's not possible to change localization through the current tab" ); return; } } if (helper.IsEditProcessControlledAllowed) { helper.SetCacheable(hasCaching); helper.SetPublishControlled(hasPublishing); helper.SetLocalizedControlled(hasLocalization); helper.SetSearchable(isSearchable); } helper.SetNewTypeFullName(typeName, typeNamespace); helper.SetNewTypeTitle(typeTitle); helper.SetNewInternalUrlPrefix(internalUrlPrefix); helper.SetNewFieldDescriptors(dataFieldDescriptors, keyFieldName, labelFieldName); if (IsPageDataFolder && !this.BindingExist(BindingNames.InterfaceType)) { Type targetType = TypeManager.GetType(this.Payload); helper.SetForeignKeyReference(targetType, Composite.Data.DataAssociationType.Aggregation); } bool originalTypeDataExists = false; if (interfaceType != null) { originalTypeDataExists = DataFacade.HasDataInAnyScope(interfaceType); } if (!helper.TryValidateUpdate(originalTypeDataExists, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.AddNewInterfaceTypeStep1_ErrorTitle, errorMessage ); return; } helper.CreateType(originalTypeDataExists); string serializedTypeName = TypeManager.SerializeType(helper.InterfaceType); EntityToken entityToken = new GeneratedDataTypesElementProviderTypeEntityToken( serializedTypeName, this.EntityToken.Source, IsPageDataFolder ? GeneratedDataTypesElementProviderRootEntityToken.PageDataFolderTypeFolderId : GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId ); if (originalTypeDataExists) { SetSaveStatus(true); } else { SetSaveStatus(true, entityToken); } if (!this.BindingExist(BindingNames.InterfaceType)) { this.AcquireLock(entityToken); } this.UpdateBinding(BindingNames.InterfaceType, helper.InterfaceType); this.UpdateBinding(BindingNames.KeyFieldReadOnly, true); this.UpdateBinding(BindingNames.ViewLabel, typeTitle); RerenderView(); //this.WorkflowResult = TypeManager.SerializeType(helper.InterfaceType); UserSettings.LastSpecifiedNamespace = typeNamespace; var parentTreeRefresher = this.CreateParentTreeRefresher(); parentTreeRefresher.PostRefreshMessages(entityToken); } catch (Exception ex) { Log.LogCritical("Add New Interface Failed", ex); this.ShowMessage(DialogType.Error, ex.Message, ex.Message); } }
private void saveTypeCodeActivity_Save_ExecuteCode(object sender, EventArgs e) { try { string typeName = this.GetBinding <string>(this.NewTypeNameBindingName); string typeNamespace = this.GetBinding <string>(this.NewTypeNamespaceBindingName); string typeTitle = this.GetBinding <string>(this.NewTypeTitleBindingName); bool hasCaching = this.GetBinding <bool>(this.HasCachingNameBindingName); bool hasPublishing = this.GetBinding <bool>(this.HasPublishingBindingName); bool hasLocalization = this.GetBinding <bool>("HasLocalization"); string labelFieldName = this.GetBinding <string>(this.LabelFieldNameBindingName); var dataFieldDescriptors = this.GetBinding <List <DataFieldDescriptor> >(this.DataFieldDescriptorsBindingName); GeneratedTypesHelper helper; Type interfaceType = null; if (this.BindingExist("InterfaceType")) { interfaceType = this.GetBinding <Type>("InterfaceType"); helper = new GeneratedTypesHelper(interfaceType); } else { helper = new GeneratedTypesHelper(); } string errorMessage; if (!helper.ValidateNewTypeName(typeName, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); return; } if (!helper.ValidateNewTypeNamespace(typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeNamespace", errorMessage); return; } if (!helper.ValidateNewTypeFullName(typeName, typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); return; } if (!helper.ValidateNewFieldDescriptors(dataFieldDescriptors, null, out errorMessage)) { this.ShowMessage( DialogType.Warning, "${Composite.Plugins.GeneratedDataTypesElementProvider, AddNewCompositionTypeWorkflow.ErrorTitle}", errorMessage ); return; } if (helper.IsEditProcessControlledAllowed) { helper.SetPublishControlled(hasPublishing); helper.SetLocalizedControlled(hasLocalization); } helper.SetCachable(hasCaching); helper.SetNewTypeFullName(typeName, typeNamespace); helper.SetNewTypeTitle(typeTitle); helper.SetNewFieldDescriptors(dataFieldDescriptors, null, labelFieldName); if (!this.BindingExist("InterfaceType")) { Type targetType = TypeManager.GetType(this.Payload); helper.SetForeignKeyReference(targetType, Composite.Data.DataAssociationType.Composition); } bool originalTypeDataExists = false; if (interfaceType != null) { originalTypeDataExists = DataFacade.HasDataInAnyScope(interfaceType); } if (helper.TryValidateUpdate(originalTypeDataExists, out errorMessage) == false) { this.ShowMessage( DialogType.Warning, "${Composite.Plugins.GeneratedDataTypesElementProvider, AddNewCompositionTypeWorkflow.ErrorTitle}", errorMessage ); return; } helper.CreateType(originalTypeDataExists); if (originalTypeDataExists) { SetSaveStatus(true); } else { string serializedTypeName = TypeManager.SerializeType(helper.InterfaceType); EntityToken entityToken = new GeneratedDataTypesElementProviderTypeEntityToken( serializedTypeName, this.EntityToken.Source, GeneratedDataTypesElementProviderRootEntityToken.PageMetaDataTypeFolderId); SetSaveStatus(true, entityToken); } this.UpdateBinding("InterfaceType", helper.InterfaceType); this.WorkflowResult = TypeManager.SerializeType(helper.InterfaceType); UserSettings.LastSpecifiedNamespace = typeNamespace; ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher(); parentTreeRefresher.PostRefreshMesseges(this.EntityToken); } catch (Exception ex) { LoggingService.LogCritical("AddNewCompositionTypeWorkflow", ex); this.ShowMessage(DialogType.Error, ex.Message, ex.Message); } }
private void saceNewTypeCodeActivity_Save_ExecuteCode(object sender, EventArgs e) { bool saveResult = false; try { string typeName = this.GetBinding <string>(this.NewTypeNameBindingName); string typeNamespace = this.GetBinding <string>(this.NewTypeNamespaceBindingName); string typeTitle = this.GetBinding <string>(this.NewTypeTitleBindingName); bool hasRecycleBin = this.GetBinding <bool>(this.HasRecycleBinBindingName); bool hasPublishing = this.GetBinding <bool>(this.HasPublishingBindingName); bool hasLocalization = this.GetBinding <bool>(this.HasLocalizationBindingName); string labelFieldName = this.GetBinding <string>(this.LabelFieldNameBindingName); var dataFieldDescriptors = this.GetBinding <List <DataFieldDescriptor> >(this.DataFieldDescriptorsBindingName); var helper = new GeneratedTypesHelper(); helper = new GeneratedTypesHelper(); string errorMessage; if (!helper.ValidateNewTypeName(typeName, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); SetSaveStatus(false); return; } if (!helper.ValidateNewTypeNamespace(typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeNamespace", errorMessage); SetSaveStatus(false); return; } if (!helper.ValidateNewTypeFullName(typeName, typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); SetSaveStatus(false); return; } if (!helper.ValidateNewFieldDescriptors(dataFieldDescriptors, null, out errorMessage)) { this.ShowMessage( DialogType.Warning, "${Composite.Management, AssociatedDataElementProviderHelper.AddDataFolderExCreateNewType.ErrorTitle}", errorMessage ); SetSaveStatus(false); return; } if (helper.IsEditProcessControlledAllowed) { helper.SetPublishControlled(hasPublishing); helper.SetLocalizedControlled(hasLocalization); } helper.SetNewTypeFullName(typeName, typeNamespace); helper.SetNewTypeTitle(typeTitle); // TODO: fix and check where the workflow is actually used helper.SetNewFieldDescriptors(dataFieldDescriptors, null, labelFieldName); Type targetType = TypeManager.GetType(this.Payload); helper.SetForeignKeyReference(targetType, Composite.Data.DataAssociationType.Aggregation); helper.CreateType(false); this.UpdateBinding(this.SelectedTypeBindingName, helper.InterfaceType); UserSettings.LastSpecifiedNamespace = typeNamespace; saveResult = true; } catch (Exception ex) { Log.LogCritical("AddNewAggregationTypeWorkflow", ex); this.ShowMessage(DialogType.Error, ex.Message, ex.Message); } SetSaveStatus(saveResult); }
private void saveTypeCodeActivity_Save_ExecuteCode(object sender, EventArgs e) { try { Type oldType = GetOldTypeFromBindings(); string typeName = this.GetBinding <string>("TypeName"); string typeNamespace = this.GetBinding <string>("TypeNamespace"); string typeTitle = this.GetBinding <string>("TypeTitle"); bool hasCaching = this.GetBinding <bool>("HasCaching"); bool hasPublishing = this.GetBinding <bool>("HasPublishing"); string labelFieldName = this.GetBinding <string>("LabelFieldName"); var dataFieldDescriptors = this.GetBinding <List <DataFieldDescriptor> >("DataFieldDescriptors"); var helper = new GeneratedTypesHelper(oldType); string errorMessage; if (!helper.ValidateNewTypeName(typeName, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); return; } if (!helper.ValidateNewTypeNamespace(typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeNamespace", errorMessage); return; } if (!helper.ValidateNewTypeFullName(typeName, typeNamespace, out errorMessage)) { this.ShowFieldMessage("NewTypeName", errorMessage); return; } if (!helper.ValidateNewFieldDescriptors(dataFieldDescriptors, null, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.EditCompositionTypeWorkflow_ErrorTitle, errorMessage ); return; } helper.SetNewTypeFullName(typeName, typeNamespace); helper.SetNewTypeTitle(typeTitle); // TODO: fix helper.SetNewFieldDescriptors(dataFieldDescriptors, null, labelFieldName); helper.SetCacheable(hasCaching); if (helper.IsEditProcessControlledAllowed) { helper.SetPublishControlled(hasPublishing); } bool originalTypeDataExists = DataFacade.HasDataInAnyScope(oldType); if (!helper.TryValidateUpdate(originalTypeDataExists, out errorMessage)) { this.ShowMessage( DialogType.Warning, Texts.EditCompositionTypeWorkflow_ErrorTitle, errorMessage ); return; } helper.CreateType(originalTypeDataExists); UpdateBinding("OldTypeName", typeName); UpdateBinding("OldTypeNamespace", typeNamespace); SetSaveStatus(true); var rootEntityToken = new GeneratedDataTypesElementProviderRootEntityToken(this.EntityToken.Source, GeneratedDataTypesElementProviderRootEntityToken.PageMetaDataTypeFolderId); SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher(); specificTreeRefresher.PostRefreshMesseges(rootEntityToken); IFile markupFile = DynamicTypesCustomFormFacade.GetCustomFormMarkupFile(typeNamespace, typeName); if (markupFile != null) { ShowMessage(DialogType.Message, Texts.FormMarkupInfo_Dialog_Label, Texts.FormMarkupInfo_Message(Texts.EditFormMarkup, markupFile.GetRelativeFilePath())); } } catch (Exception ex) { Log.LogCritical("EditCompositionTypeWorkflow", ex); this.ShowMessage(DialogType.Error, ex.Message, ex.Message); } }