Exemple #1
0
 public JsonResult GetScheduleInvoker(string schemaCode, string id)
 {
     return(ExecuteFunctionRun(() =>
     {
         ActionResult result = new ActionResult();
         result = ParseParam(schemaCode, id);
         if (!result.Success)
         {
             return Json(result, JsonRequestBehavior.AllowGet);
         }
         ScheduleInvokerViewModel model;
         List <Item> states = GetStates();
         List <Item> recurrencyTypes = GetRecurrencyTypes();
         List <Item> filterMethods = GetFilterMethods();
         List <Item> matchers = GetMatchers();
         List <Item> columns = GetColumns();
         List <Item> operators = GetOperators();
         List <Item> orders = GetOrders();
         List <Item> methodExecs = GetMethodExecs();
         if (this.Edit)
         {
             model = GetScheduleInvoker();
         }
         else
         {
             model = new ScheduleInvokerViewModel();
             model.SchemaCode = schemaCode;
             model.DisplayName = "";
             model.Description = "";
             model.State = ScheduleInvokerState.Active.ToString();
             model.StartTime = DateTime.Now.ToShortDateString();
             model.EndTime = DateTime.Now.ToShortDateString();
             model.RecurrencyType = RecurrencyType.AllTheTime.ToString();
             model.IntervalSecond = "1000";
             model.FilterMethod = filterMethods.FirstOrDefault() == null ? "" : filterMethods.FirstOrDefault().Value;
             model.ExeCondition = "";
             model.MethodExec = methodExecs.FirstOrDefault() == null ? "" : methodExecs.FirstOrDefault().Value;
             model.FilterDefinition = OThinker.Data.Convertor.ObjectToXml(H3.DataModel.BizObjectUtility.CreateDefaultFilter(this.Schema));
         }
         result.Extend = new
         {
             ScheduleInvoker = model,
             States = states,
             RecurrencyTypes = recurrencyTypes,
             FilterMethods = filterMethods,
             Matchers = matchers,
             Columns = columns,
             Operators = operators,
             Orders = orders,
             MethodExecs = methodExecs,
             OrdersList = new { },
             ConditionsList = new { },
             ParentId = "",
             IsLocked = BizWorkflowPackageLockByID(this.SchemaCode)
         };
         return Json(result, JsonRequestBehavior.AllowGet);
     }));
 }
Exemple #2
0
        /// <summary>
        /// 获取定时任务信息
        /// </summary>
        /// <returns>定时任务信息</returns>
        private ScheduleInvokerViewModel GetScheduleInvoker()
        {
            ScheduleInvokerViewModel model = new ScheduleInvokerViewModel();

            model.ObjectID         = this.InvokerId;
            model.SchemaCode       = this.SchemaCode;
            model.DisplayName      = this.Invoker.DisplayName;
            model.Description      = this.Invoker.Description;
            model.State            = ((ScheduleInvokerState)this.Invoker.State).ToString();
            model.StartTime        = this.Invoker.StartTime.ToShortDateString();
            model.EndTime          = this.Invoker.EndTime.ToShortDateString();
            model.RecurrencyType   = ((RecurrencyType)this.Invoker.Recurrency).ToString();
            model.IntervalSecond   = this.Invoker.IntervalSecond.ToString();
            model.FilterMethod     = this.Invoker.FilterMethod;
            model.ExeCondition     = this.Invoker.Condition;
            model.MethodExec       = this.Invoker.MethodName;
            model.FilterDefinition = this.Invoker.FilterDefinition;
            return(model);
        }
Exemple #3
0
        public JsonResult GetScheduleInvokerList(PagerInfo pageInfo, string schemaCode)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                ScheduleInvoker[] invokers = this.Engine.BizObjectManager.GetScheduleInvokerList(schemaCode);
                List <ScheduleInvokerViewModel> invokerList = new List <ScheduleInvokerViewModel>();
                ScheduleInvokerViewModel model = new ScheduleInvokerViewModel();

                if (invokers != null && invokers.Length != 0)
                {
                    invokerList = invokers.Skip(pageInfo.PageSize * (pageInfo.PageIndex - 1)).Take(pageInfo.PageSize).Select(s => new ScheduleInvokerViewModel()
                    {
                        ObjectID = s.ObjectID,
                        DisplayName = s.DisplayName,
                        CreatedTime = s.CreatedTime.ToShortDateString(),
                        ModifiedTime = s.ModifiedTime.ToShortDateString(),
                        State = s.State.ToString()
                    }).ToList();
                }
                result.Extend = new { Rows = invokerList, Total = invokerList.Count };
                return Json(result.Extend, JsonRequestBehavior.AllowGet);
            }));
        }
Exemple #4
0
        public JsonResult SaveScheduleInvoker(ScheduleInvokerViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                result = ParseParam(model.SchemaCode, model.ObjectID);
                if (!result.Success)
                {
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                // 验证输入是否正确
                int interval = 0;
                if (!int.TryParse(model.IntervalSecond, out interval))
                {
                    //时间间隔必须是正整数
                    result.Message = "ScheduleInvoker.Msg7";
                    result.Success = false;
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                if (interval < H3.DataModel.Declaration.Filter_MinIntervalSecond)
                {
                    //时间间隔设置过于密集,会造成服务器资源消耗太大
                    result.Message = "ScheduleInvoker.Msg8";
                    result.Success = false;
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                // 验证过滤器的设置
                try
                {
                    H3.BizBus.Filter.Filter filter = (H3.BizBus.Filter.Filter)OThinker.Data.Convertor.XmlToObject(typeof(H3.BizBus.Filter.Filter), model.FilterDefinition);
                }
                catch
                {
                    //过滤器设置不正确,无法解析
                    result.Message = "ScheduleInvoker.Msg9";
                    result.Success = false;
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                // 验证条件表达式
                if (!string.IsNullOrEmpty(model.ExeCondition))
                {
                    H3.DataModel.BizObject bo = new H3.DataModel.BizObject(this.Engine.Organization, this.Engine.MetadataRepository, this.Engine.BizObjectManager, this.Engine.BizBus, this.Schema, this.UserValidator.UserID, this.UserValidator.User.ParentID);
                    try
                    {
                        object v = bo.CalcExpression <bool>(model.ExeCondition);
                    }
                    catch (Exception ex)
                    {
                        //条件表达式不正确
                        result.Message = "ScheduleInvoker.Msg10";
                        result.Success = false;
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                }

                H3.DataModel.ScheduleInvoker si = null;
                if (this.Edit)
                {
                    si = this.Invoker;
                }
                else
                {
                    si = new ScheduleInvoker();
                    si.SchemaCode = this.SchemaCode;
                }

                si.DisplayName = model.DisplayName;
                si.Description = model.Description;
                si.State = (ScheduleInvokerState)Enum.Parse(typeof(ScheduleInvokerState), model.State, false);
                si.StartTime = DateTime.Parse(model.StartTime);
                si.EndTime = DateTime.Parse(model.EndTime);
                si.Recurrency = (RecurrencyType)Enum.Parse(typeof(RecurrencyType), model.RecurrencyType, false);
                si.IntervalSecond = interval;
                si.FilterMethod = model.FilterMethod;
                si.FilterDefinition = model.FilterDefinition;
                si.Condition = string.IsNullOrEmpty(model.ExeCondition) ? null : model.ExeCondition;
                si.MethodName = model.MethodExec;
                si.ModifiedTime = DateTime.Now;
                if (this.Edit)
                {
                    result.Success = this.Engine.BizObjectManager.UpdateScheduleInvoker(si);
                }
                else
                {
                    result.Success = this.Engine.BizObjectManager.AddScheduleInvoker(si);
                }
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }