internal static string GetTaskName(CreateTaskInfo taskInfo) { var name = string.Empty; if (taskInfo.CreateType == ECreateType.Index) { name = "首页"; } else if (taskInfo.CreateType == ECreateType.Channel) { name = NodeManager.GetNodeName(taskInfo.PublishmentSystemID, taskInfo.ChannelID); } else if (taskInfo.CreateType == ECreateType.AllContent) { var nodeInfo = NodeManager.GetNodeInfo(taskInfo.PublishmentSystemID, taskInfo.ChannelID); name = $"{nodeInfo.NodeName}下所有内容页,共{nodeInfo.ContentNum}项"; } else if (taskInfo.CreateType == ECreateType.Content) { name = BaiRongDataProvider.ContentDao.GetValue(NodeManager.GetTableName(PublishmentSystemManager.GetPublishmentSystemInfo(taskInfo.PublishmentSystemID), taskInfo.ChannelID), taskInfo.ContentID, ContentAttribute.Title); } else if (taskInfo.CreateType == ECreateType.File) { name = TemplateManager.GetTemplateName(taskInfo.PublishmentSystemID, taskInfo.TemplateID); } return(name); }
public static void RemovePendingTask(CreateTaskInfo taskInfo) { lock (LockObject) { PendingTasks.Remove(taskInfo); } }
public void AddPendingTask(CreateTaskInfo task) { if (!DataProvider.CreateTaskDao.IsExists(task)) { DataProvider.CreateTaskDao.Insert(task); } }
public static void CreateAll(int publishmentSystemId) { CreateTaskManager.Instance.ClearAllTask(publishmentSystemId); var taskInfo = new CreateTaskInfo(0, ECreateType.Index, publishmentSystemId, 0, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); var dic = NodeManager.GetNodeInfoHashtableByPublishmentSystemId(publishmentSystemId); foreach (NodeInfo nodeInfo in dic.Values) { if (nodeInfo.NodeId != publishmentSystemId) { taskInfo = new CreateTaskInfo(0, ECreateType.Channel, publishmentSystemId, nodeInfo.NodeId, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); } taskInfo = new CreateTaskInfo(0, ECreateType.AllContent, publishmentSystemId, nodeInfo.NodeId, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); } foreach (var templateId in TemplateManager.GetAllTemplateIDList(publishmentSystemId)) { taskInfo = new CreateTaskInfo(0, ECreateType.File, publishmentSystemId, 0, 0, templateId); CreateTaskManager.Instance.AddPendingTask(taskInfo); } }
public void RemovePendingAndAddSuccessLog(CreateTaskInfo taskInfo, string timeSpan) { DataProvider.CreateTaskDao.Delete(taskInfo.ID); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.PublishmentSystemID, CreateTaskManager.GetTaskName(taskInfo), timeSpan, true, string.Empty, DateTime.Now); DataProvider.CreateTaskLogDao.Insert(taskLog); }
public void RemovePendingAndAddFailureLog(CreateTaskInfo taskInfo, Exception ex) { DataProvider.CreateTaskDao.Delete(taskInfo.ID); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.PublishmentSystemID, CreateTaskManager.GetTaskName(taskInfo), string.Empty, false, ex.Message, DateTime.Now); DataProvider.CreateTaskLogDao.Insert(taskLog); }
public static void CreateFile(int publishmentSystemId, int templateId) { if (templateId > 0) { var taskInfo = new CreateTaskInfo(0, ECreateType.File, publishmentSystemId, 0, 0, templateId); CreateTaskManager.Instance.AddPendingTask(taskInfo); } }
public static void CreateAllContent(int publishmentSystemId, int channelId) { if (channelId > 0) { var taskInfo = new CreateTaskInfo(0, ECreateType.AllContent, publishmentSystemId, channelId, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); } }
public void RemoveCurrent(int siteId, CreateTaskInfo taskInfo) { lock (LockObject) { var executingTasks = GetExecutingTasks(siteId); executingTasks.Remove(taskInfo); } }
public static void CreateContentAndTrigger(int publishmentSystemId, int channelId, int contentId) { if (channelId > 0 && contentId > 0) { var taskInfo = new CreateTaskInfo(0, ECreateType.Content, publishmentSystemId, channelId, contentId, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); ContentTrigger(publishmentSystemId, channelId); } }
public void AddFailureLog(CreateTaskInfo taskInfo, Exception ex) { var taskLogs = GetTaskLogs(taskInfo.SiteId); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.TemplateId, taskInfo.Name, string.Empty, false, ex.Message, DateTime.Now); if (taskLogs.Count > 20) { taskLogs.RemoveAt(20); } taskLogs.Add(taskLog); }
public void AddSuccessLog(CreateTaskInfo taskInfo, string timeSpan) { var taskLogs = GetTaskLogs(taskInfo.SiteId); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.TemplateId, taskInfo.Name, timeSpan, true, string.Empty, DateTime.Now); if (taskLogs.Count > 20) { taskLogs.RemoveAt(20); } taskLogs.Add(taskLog); }
public static void AddSuccessLog(CreateTaskInfo taskInfo, string timeSpan) { var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.FileTemplateId, taskInfo.SpecialId, taskInfo.Name, timeSpan, true, string.Empty, DateTime.Now); lock (LockObject) { if (TaskLogs.Count > 20) { TaskLogs.RemoveAt(20); } TaskLogs.Insert(0, taskLog); } }
public void AddPendingTask(CreateTaskInfo task) { var pendingTasks = GetPendingTasks(task.PublishmentSystemID); foreach (var taskInfo in pendingTasks) { if (task.Equals(taskInfo)) { return; } } pendingTasks.Add(task); }
/// <summary> /// 添加一个任务 /// </summary> /// <param name="task"></param> public void AddPendingTask(CreateTaskInfo task) { var pendingTasks = GetPendingTasks(task.SiteId); // 查找某站点所有任务 foreach (var taskInfo in pendingTasks) { if (task.Equals(taskInfo)) { return; } } pendingTasks.Enqueue(task); }
public static void AddFailureLog(CreateTaskInfo taskInfo, Exception ex) { var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.SiteId, taskInfo.ChannelId, taskInfo.ContentId, taskInfo.FileTemplateId, taskInfo.SpecialId, taskInfo.Name, string.Empty, false, ex.Message, DateTime.Now); lock (LockObject) { if (TaskLogs.Count > 20) { TaskLogs.RemoveAt(20); } TaskLogs.Insert(0, taskLog); } }
public void RemovePendingAndAddSuccessLog(CreateTaskInfo taskInfo, string timeSpan) { var pendingTasks = GetPendingTasks(taskInfo.PublishmentSystemID); var taskLogs = GetTaskLogs(taskInfo.PublishmentSystemID); pendingTasks.Remove(taskInfo); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.PublishmentSystemID, CreateTaskManager.GetTaskName(taskInfo), timeSpan, true, string.Empty, DateTime.Now); if (taskLogs.Count > 20) { taskLogs.RemoveAt(20); } taskLogs.Add(taskLog); }
public void RemovePendingAndAddFailureLog(CreateTaskInfo taskInfo, Exception ex) { var pendingTasks = GetPendingTasks(taskInfo.PublishmentSystemID); var taskLogs = GetTaskLogs(taskInfo.PublishmentSystemID); pendingTasks.Remove(taskInfo); var taskLog = new CreateTaskLogInfo(0, taskInfo.CreateType, taskInfo.PublishmentSystemID, CreateTaskManager.GetTaskName(taskInfo), string.Empty, false, ex.Message, DateTime.Now); if (taskLogs.Count > 20) { taskLogs.RemoveAt(20); } taskLogs.Add(taskLog); }
public CreateTaskSummaryItem(CreateTaskInfo taskInfo, string timeSpan, bool isPending, bool isSuccess, string errorMessage) { siteId = taskInfo.SiteId; channelId = taskInfo.ChannelId; contentId = taskInfo.ContentId; fileTemplateId = taskInfo.FileTemplateId; specialId = taskInfo.SpecialId; type = ECreateTypeUtils.GetText(taskInfo.CreateType); name = taskInfo.Name; this.timeSpan = timeSpan; this.isPending = isPending; this.isSuccess = isSuccess; this.errorMessage = errorMessage; }
private static void ContentTrigger(int publishmentSystemId, int channelId) { if (channelId > 0) { var nodeInfo = NodeManager.GetNodeInfo(publishmentSystemId, channelId); var nodeIdList = TranslateUtils.StringCollectionToIntList(nodeInfo.Additional.CreateChannelIDsIfContentChanged); if (nodeInfo.Additional.IsCreateChannelIfContentChanged && !nodeIdList.Contains(channelId)) { nodeIdList.Add(channelId); } foreach (var theNodeId in nodeIdList) { var taskInfo = new CreateTaskInfo(0, ECreateType.Channel, publishmentSystemId, theNodeId, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); } } }
public static void CreateFile(int siteId, int fileTemplateId) { if (siteId <= 0 || fileTemplateId <= 0) { return; } var taskName = GetTaskName(ECreateType.File, siteId, 0, 0, fileTemplateId, 0, out int pageCount); if (pageCount == 0) { return; } var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.File, siteId, 0, 0, fileTemplateId, 0, pageCount); CreateTaskManager.AddPendingTask(taskInfo); }
public static void CreateSpecial(int siteId, int specialId) { if (siteId <= 0 || specialId <= 0) { return; } var taskName = GetTaskName(ECreateType.Special, siteId, 0, 0, 0, specialId, out int pageCount); if (pageCount == 0) { return; } var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.Special, siteId, 0, 0, 0, specialId, pageCount); CreateTaskManager.AddPendingTask(taskInfo); }
public static void CreateAllContent(int siteId, int channelId) { if (siteId <= 0 || channelId <= 0) { return; } var taskName = GetTaskName(ECreateType.AllContent, siteId, channelId, 0, 0, 0, out int pageCount); if (pageCount == 0) { return; } var taskInfo = new CreateTaskInfo(0, taskName, ECreateType.AllContent, siteId, channelId, 0, 0, 0, pageCount); CreateTaskManager.AddPendingTask(taskInfo); }
public static void AddPendingTask(CreateTaskInfo task) { lock (LockObject) { if (task.CreateType == ECreateType.Content) { if (PendingTasks.Any(taskInfo => taskInfo.CreateType == ECreateType.AllContent && taskInfo.ChannelId == task.ChannelId)) { return; } } if (PendingTasks.Any(taskInfo => task.CreateType == taskInfo.CreateType && task.SiteId == taskInfo.SiteId && task.ChannelId == taskInfo.ChannelId && task.ContentId == taskInfo.ContentId && task.FileTemplateId == taskInfo.FileTemplateId && task.SpecialId == taskInfo.SpecialId)) { return; } PendingTasks.Insert(0, task); } }
public static void CreateIndex(int publishmentSystemId) { var taskInfo = new CreateTaskInfo(0, ECreateType.Index, publishmentSystemId, 0, 0, 0); CreateTaskManager.Instance.AddPendingTask(taskInfo); }
public bool Equals(CreateTaskInfo taskInfo) { return(CreateType == taskInfo?.CreateType && SiteId == taskInfo.SiteId && ChannelId == taskInfo.ChannelId && ContentId == taskInfo.ContentId && FileTemplateId == taskInfo.FileTemplateId && SpecialId == taskInfo.SpecialId); }