예제 #1
0
        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);
        }
예제 #2
0
 public static void RemovePendingTask(CreateTaskInfo taskInfo)
 {
     lock (LockObject)
     {
         PendingTasks.Remove(taskInfo);
     }
 }
예제 #3
0
 public void AddPendingTask(CreateTaskInfo task)
 {
     if (!DataProvider.CreateTaskDao.IsExists(task))
     {
         DataProvider.CreateTaskDao.Insert(task);
     }
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
 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);
     }
 }
예제 #8
0
 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);
     }
 }
예제 #9
0
 public void RemoveCurrent(int siteId, CreateTaskInfo taskInfo)
 {
     lock (LockObject)
     {
         var executingTasks = GetExecutingTasks(siteId);
         executingTasks.Remove(taskInfo);
     }
 }
예제 #10
0
 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);
     }
 }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        public void AddPendingTask(CreateTaskInfo task)
        {
            var pendingTasks = GetPendingTasks(task.PublishmentSystemID);

            foreach (var taskInfo in pendingTasks)
            {
                if (task.Equals(taskInfo))
                {
                    return;
                }
            }
            pendingTasks.Add(task);
        }
예제 #15
0
        /// <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);
        }
예제 #16
0
        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);
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
 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;
 }
예제 #20
0
 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);
         }
     }
 }
예제 #21
0
        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);
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
        }
예제 #24
0
 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);
     }
 }
예제 #25
0
        public static void CreateIndex(int publishmentSystemId)
        {
            var taskInfo = new CreateTaskInfo(0, ECreateType.Index, publishmentSystemId, 0, 0, 0);

            CreateTaskManager.Instance.AddPendingTask(taskInfo);
        }
예제 #26
0
 public bool Equals(CreateTaskInfo taskInfo)
 {
     return(CreateType == taskInfo?.CreateType && SiteId == taskInfo.SiteId && ChannelId == taskInfo.ChannelId && ContentId == taskInfo.ContentId && FileTemplateId == taskInfo.FileTemplateId && SpecialId == taskInfo.SpecialId);
 }