public static ListItem GetListItem(ETranslateContentType type, bool selected) { var item = new ListItem(GetText(type), GetValue(type)); if (selected) { item.Selected = true; } return(item); }
public static bool Equals(ETranslateContentType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower())) { return(true); } return(false); }
public static string GetText(ETranslateContentType type) { if (type == ETranslateContentType.Copy) { return("复制"); } if (type == ETranslateContentType.Cut) { return("剪切"); } if (type == ETranslateContentType.Reference) { return("引用地址"); } if (type == ETranslateContentType.ReferenceContent) { return("引用内容"); } throw new Exception(); }
public static string GetValue(ETranslateContentType type) { if (type == ETranslateContentType.Copy) { return("Copy"); } if (type == ETranslateContentType.Cut) { return("Cut"); } if (type == ETranslateContentType.Reference) { return("Reference"); } if (type == ETranslateContentType.ReferenceContent) { return("ReferenceContent"); } throw new Exception(); }
public static void Translate(SiteInfo siteInfo, int channelId, int contentId, int targetSiteId, int targetChannelId, ETranslateContentType translateType) { if (siteInfo == null || channelId <= 0 || contentId <= 0 || targetSiteId <= 0 || targetChannelId <= 0) { return; } var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId); var targetTableName = ChannelManager.GetTableName(targetSiteInfo, targetChannelId); var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId); var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId); if (contentInfo == null) { return; } if (translateType == ETranslateContentType.Copy) { FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } } CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); } else if (translateType == ETranslateContentType.Cut) { FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); var newContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo); DataProvider.ContentDao.DeleteContents(siteInfo.Id, tableName, TranslateUtils.ToIntList(contentId), channelId); DataProvider.ChannelDao.UpdateContentNum(siteInfo, channelId, true); DataProvider.ChannelDao.UpdateContentNum(targetSiteInfo, targetChannelId, true); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, newContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } try { service.OnContentDeleteCompleted(new ContentEventArgs(siteInfo.Id, channelInfo.Id, contentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentDeleteCompleted)); } } CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, newContentId); } else if (translateType == ETranslateContentType.Reference) { if (contentInfo.ReferenceId != 0) { return; } contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.ReferenceId = contentId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo); } else if (translateType == ETranslateContentType.ReferenceContent) { if (contentInfo.ReferenceId != 0) { return; } FileUtility.MoveFileByContentInfo(siteInfo, targetSiteInfo, contentInfo); contentInfo.SiteId = targetSiteId; contentInfo.SourceId = contentInfo.ChannelId; contentInfo.ChannelId = targetChannelId; contentInfo.ReferenceId = contentId; contentInfo.Set(ContentAttribute.TranslateContentType, ETranslateContentType.ReferenceContent.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetSiteInfo, contentInfo); foreach (var service in PluginManager.Services) { try { service.OnContentTranslateCompleted(new ContentTranslateEventArgs(siteInfo.Id, channelInfo.Id, contentId, targetSiteId, targetChannelId, theContentId)); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(service.OnContentTranslateCompleted)); } } CreateManager.CreateContentAndTrigger(targetSiteInfo.Id, contentInfo.ChannelId, theContentId); } }
public static void Translate(SiteInfo siteInfo, int channelId, int contentId, string translateCollection, ETranslateContentType translateType, string administratorName) { var translateList = TranslateUtils.StringCollectionToStringList(translateCollection); foreach (var translate in translateList) { if (string.IsNullOrEmpty(translate)) { continue; } var translates = translate.Split('_'); if (translates.Length != 2) { continue; } var targetSiteId = TranslateUtils.ToInt(translates[0]); var targetChannelId = TranslateUtils.ToInt(translates[1]); Translate(siteInfo, channelId, contentId, targetSiteId, targetChannelId, translateType); } }
public static bool Equals(string typeStr, ETranslateContentType type) { return(Equals(type, typeStr)); }
public static void Translate(string administratorName, PublishmentSystemInfo publishmentSystemInfo, int nodeId, int contentId, int targetPublishmentSystemId, int targetNodeId, ETranslateContentType translateType) { if (publishmentSystemInfo == null || nodeId <= 0 || contentId <= 0 || targetPublishmentSystemId <= 0 || targetNodeId <= 0) { return; } var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemId); var targetTableName = NodeManager.GetTableName(targetPublishmentSystemInfo, targetNodeId); var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemInfo.PublishmentSystemId, nodeId); var tableStyle = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo); var tableName = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo); var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId); if (contentInfo == null) { return; } if (translateType == ETranslateContentType.Copy) { FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Copy.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Copy.ToString()); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; photoInfo.ContentID = theContentId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Insert(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentId); } } else if (translateType == ETranslateContentType.Cut) { FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Cut.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Cut.ToString()); if (StringUtils.EqualsIgnoreCase(tableName, targetTableName)) { contentInfo.Taxis = DataProvider.ContentDao.GetTaxisToInsert(targetTableName, targetNodeId, contentInfo.IsTop); DataProvider.ContentDao.Update(targetTableName, targetPublishmentSystemInfo, contentInfo); } else { DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); DataProvider.ContentDao.DeleteContents(publishmentSystemInfo.PublishmentSystemId, tableName, TranslateUtils.ToIntList(contentId), nodeId); } DataProvider.NodeDao.UpdateContentNum(publishmentSystemInfo, nodeId, true); DataProvider.NodeDao.UpdateContentNum(targetPublishmentSystemInfo, targetNodeId, true); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Update(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, contentInfo.Id); } } else if (translateType == ETranslateContentType.Reference) { if (contentInfo.ReferenceId != 0) { return; } contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.ReferenceId = contentId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.Reference.ToString(); //contentInfo.Attributes.Add(ContentAttribute.TranslateContentType, ETranslateContentType.Reference.ToString()); DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); } else if (translateType == ETranslateContentType.ReferenceContent) { if (contentInfo.ReferenceId != 0) { return; } FileUtility.MoveFileByContentInfo(publishmentSystemInfo, targetPublishmentSystemInfo, contentInfo); contentInfo.PublishmentSystemId = targetPublishmentSystemId; contentInfo.SourceId = contentInfo.NodeId; contentInfo.NodeId = targetNodeId; contentInfo.ReferenceId = contentId; contentInfo.Attributes[ContentAttribute.TranslateContentType] = ETranslateContentType.ReferenceContent.ToString(); var theContentId = DataProvider.ContentDao.Insert(targetTableName, targetPublishmentSystemInfo, contentInfo); if (EContentModelTypeUtils.IsPhoto(nodeInfo.ContentModelId)) { var photoInfoList = DataProvider.PhotoDao.GetPhotoInfoList(publishmentSystemInfo.PublishmentSystemId, contentId); if (photoInfoList.Count > 0) { foreach (var photoInfo in photoInfoList) { photoInfo.PublishmentSystemID = targetPublishmentSystemId; photoInfo.ContentID = theContentId; FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.SmallUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.MiddleUrl); FileUtility.MoveFileByVirtaulUrl(publishmentSystemInfo, targetPublishmentSystemInfo, photoInfo.LargeUrl); DataProvider.PhotoDao.Insert(photoInfo); } } } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(targetPublishmentSystemInfo.PublishmentSystemId, contentInfo.NodeId, theContentId); } } }
public static void Translate(PublishmentSystemInfo publishmentSystemInfo, int nodeId, int contentId, string translateCollection, ETranslateContentType translateType, string administratorName) { var translateArrayList = TranslateUtils.StringCollectionToStringList(translateCollection); foreach (string translate in translateArrayList) { if (!string.IsNullOrEmpty(translate)) { var translates = translate.Split('_'); if (translates.Length == 2) { var targetPublishmentSystemId = TranslateUtils.ToInt(translates[0]); var targetNodeId = TranslateUtils.ToInt(translates[1]); Translate(administratorName, publishmentSystemInfo, nodeId, contentId, targetPublishmentSystemId, targetNodeId, translateType); } } } }