public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var token = (ToggleFunctionRouteActionToken)actionToken;

            using (var data = new DataConnection())
            {
                var route = data.Get <IFunctionRoute>().SingleOrDefault(r => r.Function == token.Function);
                if (route == null)
                {
                    route = data.CreateNew <IFunctionRoute>();

                    route.Id       = Guid.NewGuid();
                    route.Function = token.Function;

                    data.Add(route);
                }
                else
                {
                    data.Delete(route);
                }
            }

            var treeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(entityToken);

            return(null);
        }
Exemple #2
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;

            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return(null);
            }
            if (actionToken is PackageCreatorActionToken)
            {
                var token = actionToken as PackageCreatorActionToken;

                foreach (var item in PackageCreatorActionFacade.GetPackageCreatorItems(entityToken))
                {
                    if (item.CategoryName == token.CategoryName)
                    {
                        //if diffent item for one category and entitytoken
                        var itemActionToken = item as IPackItemActionToken;
                        if (itemActionToken != null)
                        {
                            if (token.Name != itemActionToken.ActionTokenName)
                            {
                                continue;
                            }
                        }
                        if (item is IPackToggle)
                        {
                            if ((item as IPackToggle).CheckedStatus == ActionCheckedStatus.Checked)
                            {
                                PackageCreatorFacade.RemoveItem(item, packageName);
                            }
                            else
                            {
                                PackageCreatorFacade.AddItem(item, packageName);
                            }
                            var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                            parentTreeRefresher.PostRefreshMesseges(entityToken);
                        }
                        else
                        {
                            PackageCreatorFacade.AddItem(item, packageName);
                        }
                        break;
                    }
                }
            }

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return(null);
        }
        private void finalizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            GeneratedDataTypesElementProviderTypeEntityToken castedEntityToken = (GeneratedDataTypesElementProviderTypeEntityToken)this.EntityToken;

            DataFacade.Delete <IGeneratedTypeWhiteList>(f => f.TypeManagerTypeName == castedEntityToken.SerializedTypeName);

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(this.EntityToken, 3);
        }
        private void deleteCodeActivity_Delete_ExecuteCode(object sender, EventArgs e)
        {
            IPage page = GetCurrentPage();

            Pair <string, Type> metaDataPair = this.GetBinding <Pair <string, Type> >("SelectedFieldGroupName");

            page.RemoveMetaDataDefinition(metaDataPair.First);

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
Exemple #5
0
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var token  = entityToken as DataEntityToken;
            var apiKey = token.Data as ApiKey;

            IssuuApi.SetDefault(apiKey);

            var treeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(token.Data.GetDataEntityToken());

            return(null);
        }
        private void finalizeCodeActivity_Finalize_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;

            ISystemActiveLocale systemActiveLocale = (ISystemActiveLocale)dataEntityToken.Data;

            CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(systemActiveLocale.CultureName);

            if (LocalizationFacade.SetDefaultLocale(cultureInfo))
            {
                ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();
                parentTreeRefresher.PostRefreshMesseges(this.EntityToken);
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            PackageCreatorFacade.ActivePackageName = entityToken.Source;
            Tree.Page.ClearCache();
            Tree.Media.ClearCache();
            var specificTreeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
            var parentTreeRefresher   = new ParentTreeRefresher(flowControllerServicesContainer);

            specificTreeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());
            specificTreeRefresher.PostRefreshMesseges(new PageElementProviderEntityToken("PageElementProvider"));
            parentTreeRefresher.PostRefreshMesseges(PCMediaFolder.GetRootEntityToken());


            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var functionName = FavoriteFunctionWrapper.GetFunctionNameFromEntityToken(entityToken);

            using (var data = new DataConnection())
            {
                var favorite = data.Get <IFavoriteFunction>().Single(f => f.FunctionName == functionName);

                data.Delete(favorite);
            }

            var treeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(entityToken);

            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var  token = (GeneratedDataTypesElementProviderTypeEntityToken)entityToken;
            var  type  = TypeManager.GetType(token.SerializedTypeName);
            Guid guid  = type.GetImmutableTypeId();

            var oldDataTypeDescriptor = DataMetaDataFacade.GetDataTypeDescriptor(guid);
            var superInfterface       = ((ToggleSuperInterfaceActionToken)actionToken).InterfaceType;

            var newDataTypeDescriptor = oldDataTypeDescriptor.Clone();

            if (newDataTypeDescriptor.SuperInterfaces.Contains(superInfterface))
            {
                newDataTypeDescriptor.RemoveSuperInterface(superInfterface);
            }
            else
            {
                newDataTypeDescriptor.AddSuperInterface(superInfterface);
            }

            if (newDataTypeDescriptor.DataScopes.Count == 0)
            {
                newDataTypeDescriptor.DataScopes.Add(DataScopeIdentifier.Public);
            }

            if (oldDataTypeDescriptor.DataScopes.Count == 0)
            {
                oldDataTypeDescriptor.DataScopes.Add(DataScopeIdentifier.Public);
            }

            var updateDescriptor = new UpdateDataTypeDescriptor(oldDataTypeDescriptor, newDataTypeDescriptor, true);

            GeneratedTypesFacade.UpdateType(updateDescriptor);

            EntityTokenCacheFacade.ClearCache();

            var treeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(entityToken);

            return(null);
        }
        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 codeActivity_finalize_ExecuteCode(object sender, EventArgs e)
        {
            DataTypeDescriptor dataTypeDescriptor = GetDataTypeDescriptor();

            string errorMessage;

            if (!GeneratedTypesFacade.CanDeleteType(dataTypeDescriptor, out errorMessage))
            {
                this.ShowMessage(DialogType.Warning,
                                 "${Composite.Plugins.GeneratedDataTypesElementProvider, DeleteCompositionTypeWorkflow.ErrorTitle}",
                                 errorMessage);
                return;
            }

            GeneratedTypesFacade.DeleteType(dataTypeDescriptor);

            GeneratedDataTypesElementProviderRootEntityToken entityToken = new GeneratedDataTypesElementProviderRootEntityToken(this.EntityToken.Source, GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId);

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(entityToken, 2);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var item = PackageCreatorActionFacade.GetPackageCreatorItem(entityToken.Type, entityToken.Id);

            PackageCreatorFacade.RemoveItem(item, entityToken.Source);

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);

            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            var itemToggle = item as IPackToggle;

            if (itemToggle != null)
            {
                var itemEntityToken = itemToggle.GetEntityToken();
                if (itemEntityToken != null)
                {
                    var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                    parentTreeRefresher.PostRefreshMesseges(itemEntityToken);
                }
            }

            return(null);
        }
        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);
            }
        }
Exemple #14
0
        public bool OnElementDraggedAndDropped(EntityToken draggedEntityToken, EntityToken newParentEntityToken, int dropIndex, DragAndDropType dragAndDropType, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            IPage draggedPage = (IPage)((DataEntityToken)draggedEntityToken).Data;

            Verify.IsNotNull(draggedPage, "Dragged page does not exist");

            Guid newParentPageId;

            if (newParentEntityToken is PageElementProviderEntityToken)
            {
                newParentPageId = Guid.Empty;
            }
            else if (newParentEntityToken is DataEntityToken)
            {
                IPage newParentPage = (IPage)((DataEntityToken)newParentEntityToken).Data;
                newParentPageId = newParentPage.Id;
            }
            else
            {
                throw new NotImplementedException();
            }

            IPage oldParent   = null;
            Guid  oldParentId = draggedPage.GetParentId();

            if (oldParentId != Guid.Empty)
            {
                oldParent = DataFacade.GetData <IPage>(f => f.Id == oldParentId).Single();
            }

            if (dragAndDropType == DragAndDropType.Move)
            {
                using (var transactionScope = TransactionsFacade.CreateNewScope())
                {
                    string urlTitle = draggedPage.UrlTitle;
                    int    counter  = 1;

                    while (true)
                    {
                        bool urlTitleClash =
                            (from p in PageServices.GetChildren(newParentPageId).AsEnumerable()
                             where p.UrlTitle == urlTitle && p.Id != draggedPage.Id
                             select p).Any();


                        if (!urlTitleClash)
                        {
                            break;
                        }

                        urlTitle = string.Format("{0}{1}", draggedPage.UrlTitle, counter++);
                    }

                    draggedPage.UrlTitle = urlTitle;

                    // Real drop index takes into account pages from other locales
                    int realDropIndex = GetRealDropIndex(draggedPage, newParentPageId, dropIndex);

                    draggedPage.MoveTo(newParentPageId, realDropIndex, false);

                    DataFacade.Update(draggedPage);

                    EntityTokenCacheFacade.ClearCache(draggedPage.GetDataEntityToken());

                    transactionScope.Complete();
                }
            }
            else
            {
                throw new NotImplementedException();
            }


            if (oldParent != null)
            {
                var oldParentParentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                oldParentParentTreeRefresher.PostRefreshMesseges(oldParent.GetDataEntityToken());
            }
            else
            {
                var oldParentspecificTreeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
                oldParentspecificTreeRefresher.PostRefreshMesseges(new PageElementProviderEntityToken(_context.ProviderName));
            }

            var newParentParentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);

            newParentParentTreeRefresher.PostRefreshMesseges(newParentEntityToken);

            return(true);
        }
        private void localizeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken      dataEntityToken = (DataEntityToken)this.EntityToken;
            ILocalizedControlled data            = dataEntityToken.Data as ILocalizedControlled;

            CultureInfo targetCultureInfo = UserSettings.ActiveLocaleCultureInfo;

            if (ExistsInLocale(data, targetCultureInfo))
            {
                string title       = Texts.LocalizeDataWorkflow_ShowError_LayoutLabel;
                string description = Texts.LocalizeDataWorkflow_ShowError_AlreadyTranslated;

                var messageBox = new MessageBoxMessageQueueItem
                {
                    DialogType = DialogType.Message,
                    Message    = description,
                    Title      = title
                };

                ConsoleMessageQueueFacade.Enqueue(messageBox, GetCurrentConsoleId());
                return;
            }

            IEnumerable <ReferenceFailingPropertyInfo> referenceFailingPropertyInfos = DataLocalizationFacade.GetReferencingLocalizeFailingProperties(data).Evaluate();

            IData newData;

            using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
            {
                data = data.GetTranslationSource();

                using (new DataScope(targetCultureInfo))
                {
                    newData = DataFacade.BuildNew(data.DataSourceId.InterfaceType);

                    data.ProjectedCopyTo(newData);

                    ILocalizedControlled localizedControlled = newData as ILocalizedControlled;
                    localizedControlled.SourceCultureName = targetCultureInfo.Name;

                    if (newData is IPublishControlled)
                    {
                        IPublishControlled publishControlled = newData as IPublishControlled;
                        publishControlled.PublicationStatus = GenericPublishProcessController.Draft;
                    }

                    foreach (ReferenceFailingPropertyInfo referenceFailingPropertyInfo in referenceFailingPropertyInfos)
                    {
                        PropertyInfo propertyInfo = data.DataSourceId.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == referenceFailingPropertyInfo.DataFieldDescriptor.Name);
                        if (propertyInfo.PropertyType.IsGenericType &&
                            propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>))
                        {
                            propertyInfo.SetValue(newData, null, null);
                        }
                        else if (propertyInfo.PropertyType == typeof(string))
                        {
                            propertyInfo.SetValue(newData, null, null);
                        }
                        else
                        {
                            propertyInfo.SetValue(newData, referenceFailingPropertyInfo.DataFieldDescriptor.DefaultValue.Value, null);
                        }
                    }

                    newData = DataFacade.AddNew(newData, false, false, true);
                }

                EntityTokenCacheFacade.ClearCache(data.GetDataEntityToken());
                EntityTokenCacheFacade.ClearCache(newData.GetDataEntityToken());

                transactionScope.Complete();
            }

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(newData.GetDataEntityToken());

            if (this.Payload == "Global")
            {
                this.ExecuteWorklow(newData.GetDataEntityToken(), typeof(EditDataWorkflow));
            }
            else if (this.Payload == "Pagefolder")
            {
                this.ExecuteWorklow(newData.GetDataEntityToken(), WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.EditAssociatedDataWorkflow"));
            }
        }
        private void initializeCodeActivity_Copy_ExecuteCode(object sender, EventArgs e)
        {
            var castedEntityToken = (DataEntityToken)this.EntityToken;

            IPage newPage;

            using (var transactionScope = TransactionsFacade.CreateNewScope())
            {
                CultureInfo sourceCultureInfo = UserSettings.ForeignLocaleCultureInfo;

                IPage sourcePage;
                List <IPagePlaceholderContent> sourcePagePlaceholders;
                List <IData> sourceMetaDataSet;

                using (new DataScope(sourceCultureInfo))
                {
                    var  pageFromEntityToken = (IPage)castedEntityToken.Data;
                    Guid sourcePageId        = pageFromEntityToken.Id;
                    Guid sourcePageVersionId = pageFromEntityToken.VersionId;

                    using (new DataScope(DataScopeIdentifier.Administrated))
                    {
                        sourcePage = DataFacade.GetData <IPage>(f => f.Id == sourcePageId).Single();
                        sourcePage = sourcePage.GetTranslationSource();

                        using (new DataScope(sourcePage.DataSourceId.DataScopeIdentifier))
                        {
                            sourcePagePlaceholders = DataFacade
                                                     .GetData <IPagePlaceholderContent>(f => f.PageId == sourcePageId && f.VersionId == sourcePageVersionId)
                                                     .ToList();
                            sourceMetaDataSet = sourcePage.GetMetaData().ToList();
                        }
                    }
                }


                CultureInfo targetCultureInfo = UserSettings.ActiveLocaleCultureInfo;

                using (new DataScope(targetCultureInfo))
                {
                    newPage = DataFacade.BuildNew <IPage>();
                    sourcePage.ProjectedCopyTo(newPage);

                    newPage.SourceCultureName = targetCultureInfo.Name;
                    newPage.PublicationStatus = GenericPublishProcessController.Draft;
                    newPage = DataFacade.AddNew <IPage>(newPage);

                    foreach (IPagePlaceholderContent sourcePagePlaceholderContent in sourcePagePlaceholders)
                    {
                        IPagePlaceholderContent newPagePlaceholderContent = DataFacade.BuildNew <IPagePlaceholderContent>();
                        sourcePagePlaceholderContent.ProjectedCopyTo(newPagePlaceholderContent);

                        newPagePlaceholderContent.SourceCultureName = targetCultureInfo.Name;
                        newPagePlaceholderContent.PublicationStatus = GenericPublishProcessController.Draft;
                        DataFacade.AddNew <IPagePlaceholderContent>(newPagePlaceholderContent);
                    }

                    foreach (IData metaData in sourceMetaDataSet)
                    {
                        ILocalizedControlled localizedData = metaData as ILocalizedControlled;

                        if (localizedData == null)
                        {
                            continue;
                        }

                        IEnumerable <ReferenceFailingPropertyInfo> referenceFailingPropertyInfos = DataLocalizationFacade.GetReferencingLocalizeFailingProperties(localizedData).Evaluate();

                        if (!referenceFailingPropertyInfos.Any())
                        {
                            IData newMetaData = DataFacade.BuildNew(metaData.DataSourceId.InterfaceType);
                            metaData.ProjectedCopyTo(newMetaData);

                            ILocalizedControlled localizedControlled = newMetaData as ILocalizedControlled;
                            localizedControlled.SourceCultureName = targetCultureInfo.Name;

                            IPublishControlled publishControlled = newMetaData as IPublishControlled;
                            publishControlled.PublicationStatus = GenericPublishProcessController.Draft;

                            DataFacade.AddNew(newMetaData);
                        }
                        else
                        {
                            foreach (ReferenceFailingPropertyInfo referenceFailingPropertyInfo in referenceFailingPropertyInfos)
                            {
                                Log.LogVerbose("LocalizePageWorkflow",
                                               "Meta data of type '{0}' is not localized because the field '{1}' is referring some not yet localzed data"
                                               .FormatWith(metaData.DataSourceId.InterfaceType, referenceFailingPropertyInfo.DataFieldDescriptor.Name));
                            }
                        }
                    }
                }

                EntityTokenCacheFacade.ClearCache(sourcePage.GetDataEntityToken());
                EntityTokenCacheFacade.ClearCache(newPage.GetDataEntityToken());

                foreach (var folderType in PageFolderFacade.GetDefinedFolderTypes(newPage))
                {
                    EntityTokenCacheFacade.ClearCache(new AssociatedDataElementProviderHelperEntityToken(
                                                          TypeManager.SerializeType(typeof(IPage)),
                                                          PageElementProvider.DefaultConfigurationName,
                                                          newPage.Id.ToString(),
                                                          TypeManager.SerializeType(folderType)));
                }


                transactionScope.Complete();
            }

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(newPage.GetDataEntityToken(), 2);

            this.ExecuteWorklow(newPage.GetDataEntityToken(), typeof(EditPageWorkflow));
        }
Exemple #17
0
        private void codeActivity2_ExecuteCode(object sender, EventArgs e)
        {
            bool hasSubPages = this.GetBinding <bool>("HasSubPages");

            DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;
            IPage           selectedPage    = (IPage)dataEntityToken.Data;

            using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
            {
                if (DataFacade.WillDeleteSucceed <IPage>(selectedPage) == false)
                {
                    this.ShowMessage(
                        DialogType.Error,
                        StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "DeletePageWorkflow.CascadeDeleteErrorTitle"),
                        StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "DeletePageWorkflow.CascadeDeleteErrorMessage")
                        );

                    return;
                }

                List <CultureInfo> cultures = DataLocalizationFacade.ActiveLocalizationCultures.ToList();
                cultures.Remove(selectedPage.DataSourceId.LocaleScope);

                if (hasSubPages)
                {
                    List <IPage> pagesToDelete = selectedPage.GetSubChildren().ToList();

                    foreach (IPage page in pagesToDelete)
                    {
                        if (DataFacade.WillDeleteSucceed <IPage>(page) == false)
                        {
                            this.ShowMessage(
                                DialogType.Error,
                                StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "DeletePageWorkflow.CascadeDeleteErrorTitle"),
                                StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "DeletePageWorkflow.CascadeDeleteErrorMessage")
                                );

                            return;
                        }
                    }

                    foreach (IPage page in pagesToDelete)
                    {
                        if (ExistInOtherLocale(cultures, page) == false)
                        {
                            RemoveAllFolderAndMetaDataDefinitions(page);
                        }

                        page.DeletePageStructure();
                        ProcessControllerFacade.FullDelete(page);
                    }
                }

                if (ExistInOtherLocale(cultures, selectedPage) == false)
                {
                    RemoveAllFolderAndMetaDataDefinitions(selectedPage);
                }

                ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();
                parentTreeRefresher.PostRefreshMesseges(selectedPage.GetDataEntityToken(), 2);

                selectedPage.DeletePageStructure();
                ProcessControllerFacade.FullDelete(selectedPage);

                transactionScope.Complete();
            }
        }
        /// <exclude />
        protected void RefreshParentEntityToken()
        {
            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
Exemple #19
0
        private void localizeDataCodeActivity_Localize_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken      dataEntityToken = (DataEntityToken)this.EntityToken;
            ILocalizedControlled data            = dataEntityToken.Data as ILocalizedControlled;

            CultureInfo targetCultureInfo = UserSettings.ActiveLocaleCultureInfo;

            if (ExistsInLocale(data, targetCultureInfo))
            {
                this.ShowMessage(
                    DialogType.Message,
                    StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeData.ShowError.Layout.Label"),
                    StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "LocalizeData.ShowError.AlreadyTranslated")
                    );

                return;
            }


            IEnumerable <ReferenceFailingPropertyInfo> referenceFailingPropertyInfos = DataLocalizationFacade.GetReferencingLocalizeFailingProperties(data).Evaluate();

            IData newData;

            using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
            {
                data = data.GetTranslationSource();

                using (new DataScope(targetCultureInfo))
                {
                    newData = DataFacade.BuildNew(data.DataSourceId.InterfaceType);

                    data.ProjectedCopyTo(newData);

                    ILocalizedControlled localizedControlled = newData as ILocalizedControlled;
                    localizedControlled.SourceCultureName = targetCultureInfo.Name;

                    if (newData is IPublishControlled)
                    {
                        IPublishControlled publishControlled = newData as IPublishControlled;
                        publishControlled.PublicationStatus = GenericPublishProcessController.Draft;
                    }

                    foreach (ReferenceFailingPropertyInfo referenceFailingPropertyInfo in referenceFailingPropertyInfos)
                    {
                        PropertyInfo propertyInfo = data.DataSourceId.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == referenceFailingPropertyInfo.DataFieldDescriptor.Name);
                        if (propertyInfo.PropertyType.IsGenericType &&
                            propertyInfo.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>))
                        {
                            propertyInfo.SetValue(newData, null, null);
                        }
                        else if (propertyInfo.PropertyType == typeof(string))
                        {
                            propertyInfo.SetValue(newData, null, null);
                        }
                        else
                        {
                            propertyInfo.SetValue(newData, referenceFailingPropertyInfo.DataFieldDescriptor.DefaultValue.Value, null);
                        }
                    }

                    newData = DataFacade.AddNew(newData);
                }

                EntityTokenCacheFacade.ClearCache(data.GetDataEntityToken());
                EntityTokenCacheFacade.ClearCache(newData.GetDataEntityToken());

                transactionScope.Complete();
            }

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(newData.GetDataEntityToken(), 2);
        }