Ejemplo n.º 1
0
 private static void ShowInvalidEntityMessage(string consoleId)
 {
     // TODO: Add tree refreshing, localize message
     var msgBoxEntry = new MessageBoxMessageQueueItem { DialogType = DialogType.Error, Title = "Data item not found", Message = "This item seems to have been deleted.\n\nPlease update the tree by using the context menu \"Refresh\" command." };
     ConsoleMessageQueueFacade.Enqueue(msgBoxEntry, consoleId);
 }
Ejemplo n.º 2
0
        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"));
            }
        }