Exemplo n.º 1
0
        public virtual object GetHandoverRequests(HttpContext context)
        {
            YZRequest  request = new YZRequest(context);
            string     uid     = request.GetString("uid");
            PageResult result;

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    result = TaskListManager.GetHandoverMyRequests(provider, cn, uid, this.GetFilterStringHandoverRequests(request, provider), request.GetSortString("TaskID ASC"), request.Start, request.Limit);
                }
            }

            JArray children = new JArray();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                foreach (DataRow task in result.Table.Rows)
                {
                    JObject item = new JObject();
                    children.Add(item);

                    int    taskid       = YZConvert.ToInt32(task["TaskID"]);
                    string desc         = YZConvert.ToString(task["Description"]);
                    string ownerAccount = YZConvert.ToString(task["OwnerAccount"]);
                    string agentAccount = YZConvert.ToString(task["AgentAccount"]);

                    User owner = User.TryGetUser(cn, ownerAccount);
                    User agent = null;

                    if (!String.IsNullOrEmpty(agentAccount))
                    {
                        agent = User.TryGetUser(cn, agentAccount);
                    }

                    item["TaskID"]           = taskid;
                    item["SerialNum"]        = YZConvert.ToString(task["SerialNum"]);
                    item["ProcessName"]      = YZConvert.ToString(task["ProcessName"]);
                    item["ProcessVersion"]   = YZConvert.ToString(task["ProcessVersion"]);
                    item["OwnerAccount"]     = ownerAccount;
                    item["OwnerDisplayName"] = owner == null ? ownerAccount : owner.ShortName;
                    item["AgentAccount"]     = agentAccount;
                    item["AgentDisplayName"] = agent == null ? agentAccount : agent.ShortName;
                    item["CreateAt"]         = YZConvert.ToDateTime(task["CreateAt"]);
                    item["State"]            = YZJsonHelper.GetTaskStateJObject(cn, YZConvert.ToEnum <TaskState>(task["State"]), taskid);
                    item["Description"]      = String.IsNullOrEmpty(desc) ? Resources.YZStrings.All_None : desc;
                }
            }

            return(new
            {
                success = true,
                total = result.TotalRows,
                children = children
            });
        }
Exemplo n.º 2
0
 public static int ToInt32(object value)
 {
     return(YZConvert.ToInt32(value, false, -1));
 }