コード例 #1
0
        public virtual DataSet GetScheduleTaskData(string execTaskDataId)
        {
            string sql  = string.Format("select RESULTDATA from AXAEXECTASKDATA where EXECTASKDATAID={0}", LibStringBuilder.GetQuotString(execTaskDataId));
            string data = LibSysUtils.ToString(this.DataAccess.ExecuteScalar(sql));

            if (!string.IsNullOrEmpty(data))
            {
                LibBillDataSerializeHelper.Deserialize(data, this.DataSet);
            }
            return(this.DataSet);
        }
コード例 #2
0
ファイル: LibScheduleTaskHost.cs プロジェクト: liusj666/AxNew
        private void ExecBusinessTask(object obj)
        {
            LibTaskParam    param      = (LibTaskParam)obj;
            LibBusinessTask taskDefine = param.TaskDefine;

            //系统当天是否可以执行
            if (IsExecOfDay(taskDefine))
            {
                try
                {
                    param.Task.TaskState = TaskRunState.Running;
                    LibBcfBase bcf = LibBcfSystem.Default.GetBcfInstance(taskDefine.ProgId);
                    bcf.Handle = LibHandleCache.Default.GetSystemHandle();
                    Type     type      = bcf.GetType();
                    object[] destParam = RestoreParamFormat(type, taskDefine.BusinessTaskId, new string[] { taskDefine.ExecCondition });
                    object   result    = bcf.GetType().InvokeMember(taskDefine.BusinessTaskId, BindingFlags.InvokeMethod, null, bcf, destParam);
                    switch (bcf.Template.BillType)
                    {
                    case AxCRL.Template.BillType.Master:
                    case AxCRL.Template.BillType.Bill:
                        break;

                    case AxCRL.Template.BillType.Grid:
                        break;

                    case AxCRL.Template.BillType.DataFunc:
                        break;

                    case AxCRL.Template.BillType.Rpt:
                    case AxCRL.Template.BillType.DailyRpt:
                        DataSet dataSet = result as DataSet;
                        if (dataSet != null)
                        {
                            LibSysNews news = new LibSysNews();
                            news.Content  = taskDefine.MainContent;
                            news.Data     = LibBillDataSerializeHelper.Serialize(dataSet);
                            news.PersonId = "SYSTEM";
                            news.ProgId   = taskDefine.ProgId;
                            news.Title    = taskDefine.Title;
                            foreach (LibBusinessTaskLiaison item in taskDefine.Liaison)
                            {
                                news.UserList.Add(item.UserId);
                            }
                            LibSysNewsHelper.SendNews(news, false);
                        }
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    //将错误输出
                    string path = System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.MainPath, "Output", "Error", "ScheduleTask", string.Format("{0}.txt", DateTime.Now.Ticks));
                    OutputInfo(path, ex.ToString());
                }
                finally
                {
                    param.Task.TaskState = TaskRunState.Wait;
                }
            }
            bool canNextExec = true;

            if (taskDefine.ExecDate != 0)
            {
                int curDate = LibDateUtils.GetCurrentDate();
                if (taskDefine.ExecDate > curDate)
                {
                    param.Task.Timer.Dispose();
                    canNextExec          = false;
                    param.Task.TaskState = TaskRunState.Stop;
                }
                else if (taskDefine.ExecDate == curDate && taskDefine.ExecTime.Count > 0)
                {
                    int curTime = LibDateUtils.GetLibTimePart(LibDateUtils.GetCurrentDateTime(), LibDateTimePartEnum.Time);
                    if (taskDefine.ExecTime[taskDefine.ExecTime.Count - 1] < curTime)
                    {
                        param.Task.Timer.Dispose();
                        canNextExec          = false;
                        param.Task.TaskState = TaskRunState.Stop;
                    }
                }
            }
            if (canNextExec)
            {
                param.Task.Timer.Change(param.GetTaskDueTime(), Timeout.InfiniteTimeSpan);
            }
            else if (taskDefine.TaskType == LibTaskType.TempTask)
            {
                //删除临时任务
                LibDataAccess dataAccess = new LibDataAccess();
                dataAccess.ExecuteNonQuery(string.Format("delete AXPBUSINESSTEMPTASK where TASKID={0}", LibStringBuilder.GetQuotString(taskDefine.TaskId)), false);
            }
        }