private static void AddNewMetaDataToExistingPages(IEnumerable <IPage> affectedPages, string metaDataDefinitionName, Type metaDataType, IData newDataTemplate) { foreach (IPage affectedPage in affectedPages) { IData data = affectedPage.GetMetaData(metaDataDefinitionName, metaDataType); if (data != null) { continue; } IPublishControlled newData = DataFacade.BuildNew(metaDataType) as IPublishControlled; newDataTemplate.FullCopyChangedTo(newData); newData.PublicationStatus = GenericPublishProcessController.Draft; PageMetaDataFacade.AssignMetaDataSpecificValues(newData, metaDataDefinitionName, affectedPage); ILocalizedControlled localizedData = newData as ILocalizedControlled; if (localizedData != null) { localizedData.SourceCultureName = UserSettings.ActiveLocaleCultureInfo.Name; } newData = DataFacade.AddNew((IData)newData) as IPublishControlled; if (newData.PublicationStatus != affectedPage.PublicationStatus) { newData.PublicationStatus = affectedPage.PublicationStatus; DataFacade.Update(newData); } } }
public bool OnAfterBuildNew(IData data) { ILocalizedControlled localizedData = data as ILocalizedControlled; if (localizedData != null) { if (!LocalizationScopeManager.IsEmpty) { localizedData.SourceCultureName = LocalizationScopeManager.CurrentLocalizationScope.Name; } else { CultureInfo cultureInfo = null; if (UserValidationFacade.IsLoggedIn()) { cultureInfo = UserSettings.ActiveLocaleCultureInfo; } if (cultureInfo == null) { cultureInfo = DataLocalizationFacade.DefaultLocalizationCulture; } if (cultureInfo != null) { localizedData.SourceCultureName = cultureInfo.Name; } } } return(false); }
private static XElement AddData(DataType dataType, CultureInfo cultureInfo) { XElement datasElement = new XElement("Datas"); if (cultureInfo != null) { datasElement.Add(new XAttribute("locale", cultureInfo.Name)); } foreach (XElement addElement in dataType.Dataset) { IData data = DataFacade.BuildNew(dataType.InterfaceType); if (!dataType.InterfaceType.IsInstanceOfType(data)) { dataType.InterfaceType = GetInstalledVersionOfPendingType(dataType.InterfaceType, data); } var properties = GetDataTypeProperties(dataType.InterfaceType); foreach (XAttribute attribute in addElement.Attributes()) { string fieldName = attribute.Name.LocalName; if (IsObsoleteField(dataType, fieldName)) { continue; } PropertyInfo propertyInfo = properties[fieldName]; propertyInfo.SetValue(data, ValueTypeConverter.Convert(attribute.Value, propertyInfo.PropertyType), null); } ILocalizedControlled localizedControlled = data as ILocalizedControlled; if (localizedControlled != null) { localizedControlled.SourceCultureName = LocalizationScopeManager.MapByType(dataType.InterfaceType).Name; } DataFacade.AddNew(data, false, true, false); // Ignore validation, this should have been done in the validation face XElement keysElement = new XElement("Keys"); foreach (PropertyInfo propertyInfo in data.GetKeyProperties()) { string keyName = propertyInfo.Name; object keyValue = propertyInfo.GetValue(data, null); XElement keyElement = new XElement("Key", new XAttribute("name", keyName), new XAttribute("value", keyValue)); keysElement.Add(keyElement); } datasElement.Add(keysElement); } return(datasElement); }
/// <exclude /> public static void AddNewMetaDataToExistingPage(this IPage page, string metaDataDefinitionName, Type metaDataType, IData newDataTemplate) { IData data = page.GetMetaData(metaDataDefinitionName, metaDataType); if (data != null) { return; } IPublishControlled newData = DataFacade.BuildNew(metaDataType) as IPublishControlled; newDataTemplate.FullCopyChangedTo(newData); newData.PublicationStatus = GenericPublishProcessController.Draft; PageMetaDataFacade.AssignMetaDataSpecificValues(newData, metaDataDefinitionName, page); ILocalizedControlled localizedData = newData as ILocalizedControlled; if (localizedData != null) { localizedData.SourceCultureName = page.SourceCultureName; } newData = (IPublishControlled)DataFacade.AddNew((IData)newData); // Cast is needed for the DataFacade to work correctly if (newData.PublicationStatus != page.PublicationStatus) { newData.PublicationStatus = page.PublicationStatus; DataFacade.Update(newData); } }
private void ValidateLocalizeProcess(object sender, ConditionalEventArgs e) { DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken; ILocalizedControlled data = dataEntityToken.Data as ILocalizedControlled; IEnumerable <ReferenceFailingPropertyInfo> referenceFailingPropertyInfos = DataLocalizationFacade.GetReferencingLocalizeFailingProperties(data).Evaluate(); if (referenceFailingPropertyInfos.Any(f => f.OptionalReferenceWithValue == false)) { List <string> row = new List <string>(); row.Add(Texts.LocalizeDataWorkflow_ShowError_Description); foreach (ReferenceFailingPropertyInfo referenceFailingPropertyInfo in referenceFailingPropertyInfos.Where(f => f.OptionalReferenceWithValue == false)) { row.Add(Texts.LocalizeDataWorkflow_ShowError_FieldErrorFormat( referenceFailingPropertyInfo.DataFieldDescriptor.Name, referenceFailingPropertyInfo.ReferencedType.GetTypeTitle(), referenceFailingPropertyInfo.OriginLocaleDataValue.GetLabel())); } List <List <string> > rows = new List <List <string> > { row }; this.UpdateBinding("ErrorHeader", new List <string> { "Fields" }); this.UpdateBinding("Errors", rows); e.Result = false; } else { e.Result = true; } }
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)); }
private XElement AddData(DataType dataType, CultureInfo cultureInfo) { XElement datasElement = new XElement("Datas"); if (cultureInfo != null) { datasElement.Add(new XAttribute("locale", cultureInfo.Name)); } foreach (XElement addElement in dataType.Dataset) { var interfaceType = dataType.InterfaceType; IData data = DataFacade.BuildNew(interfaceType); if (!dataType.InterfaceType.IsInstanceOfType(data)) { dataType.InterfaceType = GetInstalledVersionOfPendingType(interfaceType, data); } var dataKey = CopyFieldValues(dataType, data, addElement); if (dataType.AllowOverwrite || dataType.OnlyUpdate) { IData existingData = DataFacade.TryGetDataByUniqueKey(interfaceType, dataKey); if (existingData != null) { CopyFieldValues(dataType, existingData, addElement); DataFacade.Update(existingData, false, true, false); continue; } if (dataType.OnlyUpdate) { continue; } } ILocalizedControlled localizedControlled = data as ILocalizedControlled; if (localizedControlled != null) { localizedControlled.SourceCultureName = LocalizationScopeManager.MapByType(interfaceType).Name; } if (data is IVersioned) { UpdateVersionId((IVersioned)data); } DataFacade.AddNew(data, false, true, false); // Ignore validation, this should have been done in the validation face XElement keysElement = new XElement("Keys"); foreach (PropertyInfo propertyInfo in data.GetKeyProperties()) { string keyName = propertyInfo.Name; object keyValue = propertyInfo.GetValue(data, null); XElement keyElement = new XElement("Key", new XAttribute("name", keyName), new XAttribute("value", keyValue)); keysElement.Add(keyElement); } datasElement.Add(keysElement); } return(datasElement); }
public IEnumerable<ReferenceFailingPropertyInfo> GetReferencingLocalizeFailingProperties(ILocalizedControlled data) { DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(data.DataSourceId.InterfaceType); IEnumerable<DataFieldDescriptor> requiredDataFieldDescriptors = dataTypeDescriptor.Fields.Where(f => f.ForeignKeyReferenceTypeName != null); foreach (DataFieldDescriptor dataFieldDescriptor in requiredDataFieldDescriptors) { Type referencedType = TypeManager.GetType(dataFieldDescriptor.ForeignKeyReferenceTypeName); if (!DataLocalizationFacade.IsLocalized(referencedType)) continue; // No special handling for not localized data. IData referencedData = data.GetReferenced(dataFieldDescriptor.Name); if (referencedData != null) continue; // Data has already been localized bool optionalReferenceWithValue = false; if (dataFieldDescriptor.IsNullable) { PropertyInfo propertyInfo = data.DataSourceId.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == dataFieldDescriptor.Name); object value = propertyInfo.GetValue(data, null); if (value == null || object.Equals(value, dataFieldDescriptor.DefaultValue)) { continue; // Optional reference is null; } optionalReferenceWithValue = true; } CultureInfo locale = data.DataSourceId.LocaleScope; using (new DataScope(locale)) { referencedData = data.GetReferenced(dataFieldDescriptor.Name); } ReferenceFailingPropertyInfo referenceFailingPropertyInfo = new ReferenceFailingPropertyInfo ( dataFieldDescriptor, referencedType, referencedData, optionalReferenceWithValue ); yield return referenceFailingPropertyInfo; } }
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); }
public void AddData(IData data) { // #3102 Do not export ICompositionContainer with id eb210a75-be25-401f-b0d4-b3787bce36fa - considered always installed if (data is ICompositionContainer) { if ((data as ICompositionContainer).Id == new Guid("eb210a75-be25-401f-b0d4-b3787bce36fa")) { return; } } var keyProperties = data.GetKeyProperties(); if (keyProperties.Count == 1 && keyProperties.First().Name == "Id" && keyProperties.First().PropertyType == typeof(Guid)) { var id = data.GetProperty <Guid>("Id"); if (ExcludedIds.Contains(id)) { return; } } string dataTypeName = TypeManager.SerializeType(data.DataSourceId.InterfaceType); string dataScopeIdentifier = DataScopeManager.CurrentDataScope.Name; string cultureName = string.Empty; ILocalizedControlled localizedData = data as ILocalizedControlled; if (localizedData != null) { cultureName = "?"; } var dataTypeKey = dataTypeName + dataScopeIdentifier + (string.IsNullOrEmpty(cultureName) ? string.Empty : ("_" + cultureName)); var dataTypeFileName = Regex.Replace(dataTypeName, "(.+:|,.+)", "") + "s_" + dataScopeIdentifier + ((string.IsNullOrEmpty(cultureName) || cultureName.Length <= 1) ? string.Empty : ("_" + cultureName)) + ".xml"; //Add only one MetaTypeTab if (Datas.ContainsKey(dataTypeKey)) { if (dataTypeName.Contains("Composite.Data.Types.ICompositionContainer")) { return; } } var shortFilePath = "Datas\\" + dataTypeFileName; var filePath = Path.Combine(_packageDirectoryPath, shortFilePath); if (!Datas.ContainsKey(dataTypeKey)) { Datas.Add( dataTypeKey , new XElement("Type", (installDataTypeNamesList.Contains(dataTypeName)) ? new XAttribute("isDynamicAdded", "true") : null, (AllowOverwriteDataOnInstall) ? new XAttribute("allowOverwrite", "true") : null, new XAttribute("type", dataTypeName), new XElement("Data", new XAttribute("dataScopeIdentifier", dataScopeIdentifier), string.IsNullOrEmpty(cultureName) ? null : new XAttribute("locale", cultureName), new XAttribute("dataFilename", "~\\" + shortFilePath) ) ) ); } DataFiles.Add(filePath, new XElement("Add", from s in TypeManager.GetType(dataTypeName).GetPropertiesRecursively() where s.CanWrite && s.CanRead let val = s.GetValue(data, null) where val != null select new XAttribute(s.Name, SerializeDataField(val)) ) ); }
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")); } }
public IEnumerable <ReferenceFailingPropertyInfo> GetReferencingLocalizeFailingProperties(ILocalizedControlled data) { DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(data.DataSourceId.InterfaceType); IEnumerable <DataFieldDescriptor> requiredDataFieldDescriptors = dataTypeDescriptor.Fields.Where(f => f.ForeignKeyReferenceTypeName != null); foreach (DataFieldDescriptor dataFieldDescriptor in requiredDataFieldDescriptors) { Type referencedType = TypeManager.GetType(dataFieldDescriptor.ForeignKeyReferenceTypeName); if (!DataLocalizationFacade.IsLocalized(referencedType)) { continue; // No special handling for not localized data. } IData referencedData = data.GetReferenced(dataFieldDescriptor.Name); if (referencedData != null) { continue; // Data has already been localized } bool optionalReferenceWithValue = false; if (dataFieldDescriptor.IsNullable) { PropertyInfo propertyInfo = data.DataSourceId.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == dataFieldDescriptor.Name); object value = propertyInfo.GetValue(data, null); if (value == null || object.Equals(value, dataFieldDescriptor.DefaultValue)) { continue; // Optional reference is null; } optionalReferenceWithValue = true; } CultureInfo locale = data.DataSourceId.LocaleScope; using (new DataScope(locale)) { referencedData = data.GetReferenced(dataFieldDescriptor.Name); } ReferenceFailingPropertyInfo referenceFailingPropertyInfo = new ReferenceFailingPropertyInfo ( dataFieldDescriptor, referencedType, referencedData, optionalReferenceWithValue ); yield return(referenceFailingPropertyInfo); } }
/// <exclude /> public static IEnumerable <ReferenceFailingPropertyInfo> GetReferencingLocalizeFailingProperties(ILocalizedControlled data) { return(_dataLocalizationFacade.GetReferencingLocalizeFailingProperties(data)); }
/// <exclude /> public static IEnumerable<ReferenceFailingPropertyInfo> GetReferencingLocalizeFailingProperties(ILocalizedControlled data) { return _dataLocalizationFacade.GetReferencingLocalizeFailingProperties(data); }
public static IPage TranslatePage(IPage sourcePage, CultureInfo sourceCultureInfo, CultureInfo targetCultureInfo) { IPage newPage; using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { List <IPagePlaceholderContent> sourcePagePlaceholders; List <IData> sourceMetaDataSet; using (new DataScope(sourceCultureInfo)) { using (new DataScope(DataScopeIdentifier.Administrated)) { sourcePage = sourcePage.GetTranslationSource(); using (new DataScope(sourcePage.DataSourceId.DataScopeIdentifier)) { sourcePagePlaceholders = DataFacade.GetData <IPagePlaceholderContent>(f => f.PageId == sourcePage.Id).ToList(); sourceMetaDataSet = sourcePage.GetMetaData().ToList(); } } } 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)); } } } } transactionScope.Complete(); } return(newPage); }