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 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.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 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.IsCachable}, {"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 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 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; }
public static void UpdateKeyType(DataFieldDescriptor idField, GeneratedTypesHelper.KeyFieldType selectedFieldType) { switch (selectedFieldType) { case GeneratedTypesHelper.KeyFieldType.Guid: idField.StoreType = StoreFieldType.Guid; idField.InstanceType = typeof(Guid); idField.DefaultValue = null; break; case GeneratedTypesHelper.KeyFieldType.RandomString4: idField.StoreType = StoreFieldType.String(22); idField.InstanceType = typeof(string); idField.DefaultValue = DefaultValue.RandomString(4, true); break; case GeneratedTypesHelper.KeyFieldType.RandomString8: idField.StoreType = StoreFieldType.String(22); idField.InstanceType = typeof(string); idField.DefaultValue = DefaultValue.RandomString(8, false); break; } }
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 step2CodeActivity_ShowWizzard_ExecuteCode(object sender, EventArgs e) { IPageTypeMetaDataTypeLink pageTypeMetaDataTypeLink = this.GetBinding<IPageTypeMetaDataTypeLink>("NewMetaDataTypeLink"); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(pageTypeMetaDataTypeLink.DataTypeId); 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 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); 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.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); 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.SetCachable(hasCaching); helper.SetPublishControlled(hasPublishing); helper.SetLocalizedControlled(hasLocalization); } 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 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_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 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 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.SetCachable(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); } }
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); } }
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) ); }