Beispiel #1
0
        public void Execute()
        {
            var lockThis = new object();

            lock (lockThis)
            {
                // 如果服务组件启用了的话,则通过服务组件生成
                if (ServiceManager.IsServiceOnline())
                {
                    return;
                }
                var taskInfo = CreateTaskManager.Instance.GetLastPendingTask();
                if (taskInfo != null)
                {
                    try
                    {
                        var start = DateTime.Now;
                        var fso   = new FileSystemObject(taskInfo.PublishmentSystemID);
                        fso.Execute(taskInfo);
                        var timeSpan = DateUtils.GetRelatedDateTimeString(start);
                        CreateTaskManager.Instance.RemovePendingAndAddSuccessLog(taskInfo, timeSpan);
                    }
                    catch (Exception ex)
                    {
                        CreateTaskManager.Instance.RemovePendingAndAddFailureLog(taskInfo, ex);
                    }

                    Clients.Client(Context.ConnectionId).next(false);
                }
                else
                {
                    Clients.Client(Context.ConnectionId).next(true);
                }
            }
        }
Beispiel #2
0
        public static bool ExecutePendingCreate()
        {
            try
            {
                if (!ServiceManager.IsPendingCreateTask())
                {
                    return(false);
                }

                while (true)
                {
                    var taskInfo = CreateTaskManager.Instance.GetLastPendingTask();
                    if (taskInfo == null)
                    {
                        ServiceManager.ClearIsPendingCreateCache();
                        return(true);
                    }

                    try
                    {
                        var start = DateTime.Now;
                        var fso   = new FileSystemObject(taskInfo.PublishmentSystemID);
                        fso.Execute(taskInfo);
                        var timeSpan = DateUtils.GetRelatedDateTimeString(start);
                        CreateTaskManager.Instance.RemovePendingAndAddSuccessLog(taskInfo, timeSpan);
                    }
                    catch (Exception ex)
                    {
                        CreateTaskManager.Instance.RemovePendingAndAddFailureLog(taskInfo, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.AddAdminLog(string.Empty, "服务组件生成失败", ex.ToString());
            }

            return(false);
        }