Esempio 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
            });
        }
Esempio n. 2
0
    public static DateTime ToDateTime(object value)
    {
        string strValue = YZConvert.ToString(value);

        if (String.IsNullOrEmpty(strValue))
        {
            return(DateTime.MinValue);
        }

        DateTime rv;

        if (!DateTime.TryParse(strValue, out rv))
        {
            rv = DateTime.MinValue;
        }

        return(rv);
    }
Esempio n. 3
0
    public static T ToEnum <T>(object value, bool allowDefault, T defaultValue) where T : struct
    {
        string strValue = YZConvert.ToString(value);
        T      rv;

        if (!Enum.TryParse <T>(strValue, true, out rv))
        {
            if (allowDefault)
            {
                return(defaultValue);
            }

            throw new Exception(String.Format(Resources.YZStrings.Aspx_YZConvert_Invalid_Type, value, typeof(T).Name));
        }
        else
        {
            return(rv);
        }
    }
Esempio n. 4
0
 public static int ToInt32(object value)
 {
     return(YZConvert.ToInt32(value, false, -1));
 }