示例#1
0
        private void PrepareTaskQueue()
        {
            this.m_TaskQueue.Clear();
            Type[] baseInAssemblies = this.FindTypesByBaseInAssemblies(this.FindAssembliesByNameKeyInAppDomain("T_"), typeof(TaskBase));
            Array  tasksInfo        = this.GetTasksInfo();
            bool   flag             = tasksInfo == null;

            if (flag)
            {
                AppEventLog.Debug("task info is null");
            }
            else
            {
                Type[] array = baseInAssemblies;
                for (int i = 0; i < array.Length; i++)
                {
                    Type type = array[i];
                    foreach (TaskBase taskBase in tasksInfo)
                    {
                        bool flag2 = taskBase == null || taskBase.TaskResult == TaskExecResult.Executed;
                        if (flag2)
                        {
                            AppEventLog.Debug("task executed, pre task queue");
                        }
                        else
                        {
                            TaskBase task = (TaskBase)Activator.CreateInstance(type);
                            task.Init();
                            bool flag3 = taskBase.MdId.ToString() == task.MdId.ToString() && taskBase.ComId == task.ComId;
                            if (flag3)
                            {
                                task.JobId               = taskBase.JobId;
                                task.JobName             = taskBase.JobName;
                                task.MdId                = taskBase.MdId;
                                task.MdName              = taskBase.MdName;
                                task.ComId               = taskBase.ComId;
                                task.ExecUserId          = taskBase.ExecUserId;
                                task.FailNoticeUserId    = taskBase.FailNoticeUserId;
                                task.RequiredExecuteTime = taskBase.RequiredExecuteTime;
                                task.ExecuteTime         = taskBase.ExecuteTime;
                                task.NextExecuteTime     = taskBase.NextExecuteTime;
                                task.CycleOption         = taskBase.CycleOption;
                                this.AddTask(task);
                                string str  = taskBase.MdId.ToString();
                                string str2 = "|";
                                string str3 = task.MdId.ToString();
                                AppEventLog.Debug(str + str2 + str3);
                                AppEventLog.Debug(taskBase.ComId + "|" + task.ComId);
                                AppEventLog.Debug("task  mdid or comid compare");
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private void application_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context           = ((HttpApplication)sender).Context;
            HttpRequest request           = context.Request;
            string      filePath          = request.FilePath;
            string      executionFilePath = request.AppRelativeCurrentExecutionFilePath;

            GlobalCulture.SetContextCulture();
            LogicContext current = LogicContext.Current;

            current.SetDatabase(AppConfig.DefaultDbId);
            current.Source = filePath;
            HttpCookie cookie = request.Cookies[CookieMemory.FormsCookieName];
            bool       flag   = cookie != null;

            if (flag)
            {
                CookieMemory cookie2      = new CookieMemory(cookie);
                LogicSession logicSession = AuthUtils.GetLogicSession(cookie2);
                bool         flag2        = logicSession != null && logicSession.UserId == cookie2.UserId;
                if (!flag2)
                {
                    AppEventLog.Debug("无法恢复");
                    return;
                }
                current.CookieUpdateTime     = cookie2.UpdateTime;
                logicSession.LastRequestTime = AppRuntime.ServerDateTime;
                current.SetLogicSession(logicSession);
                current.UserAuthCookies = cookie;
            }
            bool flag3 = filePath == null;

            if (!flag3)
            {
                string s     = StringHelper.RightSubstring(filePath, 5);
                bool   flag4 = (!StringHelper.EqualsIgnoreCase(s, ".aspx") && !StringHelper.EqualsIgnoreCase(s, ".asmx") && !StringHelper.EqualsIgnoreCase(s, ".ashx")) || context.Request.Url.ToString().IndexOf("ActiveModule.aspx") < 0;
                if (!flag4)
                {
                    string routeUrl = ModuleUtils.GetRouteUrl(request.QueryString["AMID"].ToString().Trim().ToInt());
                    current.AmId = request.QueryString["AMID"].ToString().Trim().ToInt();
                    bool flag5 = routeUrl.IndexOf("?") < 0;
                    if (flag5)
                    {
                        context.Response.Redirect(routeUrl + "?" + context.Request.QueryString, false);
                    }
                    else
                    {
                        context.Response.Redirect(routeUrl + "&" + context.Request.QueryString, false);
                    }
                }
            }
        }
示例#3
0
        internal static double GN(int mdId, string param)
        {
            double      num        = 0.0;
            IDataModule dataModule = null;

            DataModuleUtils.m_dicMdId_DataModule.TryGetValue(mdId, out dataModule);
            bool flag = dataModule != null;

            if (flag)
            {
                num = dataModule.GN(param);
            }
            else
            {
                AppEventLog.Debug(string.Format("不存在[{0}]数据模块", mdId));
            }
            return(num);
        }
示例#4
0
        public void Execute()
        {
            DateTime now = DateTime.Now;

            this.Init();
            TaskBase[] taskBaseArray = this.DequeueTasks(DateTime.Now);
            TaskBase[] array         = taskBaseArray;
            for (int i = 0; i < array.Length; i++)
            {
                TaskBase taskBase = array[i];
                bool     flag     = !this.UpdateNextTime(taskBase.JobId, taskBase.ExecuteTime, taskBase.NextExecuteTime);
                if (flag)
                {
                    taskBase.TaskResult = TaskExecResult.Executed;
                }
            }
            AppEventLog.Debug("tasks:" + taskBaseArray.Length.ToString());
            TaskBase[] array2 = taskBaseArray;
            for (int j = 0; j < array2.Length; j++)
            {
                TaskBase task = array2[j];
                try
                {
                    bool flag2 = task.TaskResult == TaskExecResult.Executed;
                    if (flag2)
                    {
                        AppEventLog.Debug("TaskResult:true.");
                    }
                    bool flag3 = task.TaskResult != TaskExecResult.Executed;
                    if (flag3)
                    {
                        DateTime dateTime = this.AddZQ(now, task.RequiredExecuteTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime);
                        bool     flag4    = DateTime.Compare(dateTime, now) < 0;
                        if (flag4)
                        {
                            bool skipExecute = task.SkipExecute;
                            if (skipExecute)
                            {
                                task.TaskResult = TaskExecResult.Skip;
                                List <string> list   = task.LogInfoDetail;
                                string        format = "{0} C|跳过 {1} 作业计划已过期,跳过该次运行。";
                                string        str    = DateTime.Now.ToString();
                                string        str2   = task.RequiredExecuteTime.ToString();
                                string        str3   = string.Format(format, str, str2);
                                list.Add(str3);
                                while (DateTime.Compare(this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime), now) < 0)
                                {
                                    task.RequiredExecuteTime = dateTime;
                                    dateTime        = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime);
                                    task.TaskResult = TaskExecResult.Skip;
                                    List <string> list2   = task.LogInfoDetail;
                                    string        format2 = "{0} C|跳过 {1} 作业计划已过期,跳过该次运行。";
                                    string        str4    = DateTime.Now.ToString();
                                    string        str5    = task.RequiredExecuteTime.ToString();
                                    string        str6    = string.Format(format2, str4, str5);
                                    list2.Add(str6);
                                }
                                JobLogUtils.WriteServiceLog(task);
                            }
                            else
                            {
                                task.NextExecuteTime = dateTime;
                                TimerJob timerJob = new TimerJob();
                                timerJob.TaskModule = task;
                                TimerManager.RunTask(timerJob, task.ExecUserId, AppConfig.DefaultDbId);
                                while (DateTime.Compare(this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime), now) < 0)
                                {
                                    task.RequiredExecuteTime = dateTime;
                                    dateTime             = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime);
                                    task.NextExecuteTime = dateTime;
                                    timerJob.TaskModule  = task;
                                    TimerManager.RunTask(timerJob, task.ExecUserId, AppConfig.DefaultDbId);
                                }
                                bool flag5 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception;
                                if (flag5)
                                {
                                    task.TaskResult = TaskExecResult.Success;
                                }
                                JobLogUtils.WriteServiceLog(task);
                            }
                            bool flag6 = DateTime.Compare(dateTime, now) < 0;
                            if (flag6)
                            {
                                task.RequiredExecuteTime = dateTime;
                                task.NextExecuteTime     = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime);
                                TimerManager.RunTask(new TimerJob
                                {
                                    TaskModule = task
                                }, task.ExecUserId, AppConfig.DefaultDbId);
                                bool flag7 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception;
                                if (flag7)
                                {
                                    task.TaskResult = TaskExecResult.Success;
                                }
                                JobLogUtils.WriteServiceLog(task);
                            }
                        }
                        else
                        {
                            TimerManager.RunTask(new TimerJob
                            {
                                TaskModule = task
                            }, task.ExecUserId, AppConfig.DefaultDbId);
                            bool flag8 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception;
                            if (flag8)
                            {
                                task.TaskResult = TaskExecResult.Success;
                            }
                            JobLogUtils.WriteServiceLog(task);
                        }
                    }
                }
                catch (Exception ex_4E3)
                {
                    task.TaskResult = TaskExecResult.Exception;
                    JobLogUtils.WriteServiceLog(task);
                }
            }
        }