コード例 #1
0
        public string QueryWait()
        {
            string appid  = Request.Querys("appid");
            string tabid  = Request.Querys("tabid");
            string flowid = Request.Forms("flowid");
            string title  = Request.Forms("title");
            string date1  = Request.Forms("date1");
            string date2  = Request.Forms("date2");
            string sidx   = Request.Forms("sidx");
            string sord   = Request.Forms("sord");
            string order  = (sidx.IsNullOrEmpty() ? "ReceiveTime" : sidx) + " " + (sord.IsNullOrEmpty() ? "ASC" : sord);
            int    size   = Tools.GetPageSize();
            int    number = Tools.GetPageNumber();

            Business.FlowTask flowTask  = new Business.FlowTask();
            DataTable         dataTable = flowTask.GetWaitTask(size, number, Current.UserId, flowid, title, date1, date2, order, out int count);

            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
            foreach (DataRow dr in dataTable.Rows)
            {
                int           openModel = 0, width = 0, height = 0;
                StringBuilder opation = new StringBuilder("<a href=\"javascript:void(0);\" class=\"list\" onclick=\"openTask('" + Url.Content("~/RoadFlowCore/FlowRun/Index") + "?" + string.Format("flowid={0}&stepid={1}&instanceid={2}&taskid={3}&groupid={4}&appid={5}",
                                                                                                                                                                                                    dr["FlowId"], dr["StepId"], dr["InstanceId"], dr["Id"], dr["GroupId"], appid
                                                                                                                                                                                                    ) + "','" + dr["Title"].ToString().RemoveHTML().UrlEncode() + "','" + dr["Id"] + "'," + openModel + "," + width + "," + height + ");return false;\"><i class=\"fa fa-pencil-square-o\"></i>处理</a>"
                                                          + "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"detail('" + dr["FlowId"] + "','" + dr["GroupId"] + "','" + dr["Id"] + "');return false;\"><i class=\"fa fa-navicon\"></i>过程</a>");

                if (flowTask.IsDelete(dr["Id"].ToString().ToGuid()))//第一步发起者可以删除
                {
                    opation.Append("<a class=\"list\" href=\"javascript:void(0);\" onclick=\"delTask('" + dr["FlowId"] + "','" + dr["GroupId"] + "','" + dr["Id"] + "');return false;\"><i class=\"fa fa-remove\"></i>作废</a>");
                }
                string taskTitle = "<a href=\"javascript:void(0);\" class=\"list\" onclick=\"openTask('" + Url.Content("~/RoadFlowCore/FlowRun/Index") + "?" + string.Format("flowid={0}&stepid={1}&instanceid={2}&taskid={3}&groupid={4}&appid={5}",
                                                                                                                                                                             dr["FlowId"], dr["StepId"], dr["InstanceId"], dr["Id"], dr["GroupId"], appid
                                                                                                                                                                             ) + "','" + dr["Title"].ToString().RemoveHTML().UrlEncode() + "','" + dr["Id"] + "'," + openModel + "," + width + "," + height + ");return false;\">" + dr["Title"] + "</a>";
                string status = "<div>正常</div>";
                if (dr["CompletedTime"].ToString().IsDateTime(out DateTime ctime))
                {
                    DateTime nowTime = DateExtensions.Now;
                    if (nowTime > ctime)
                    {
                        status = "<div title='要求完成时间:" + ctime.ToString("yyyy-MM-dd HH:mm") +
                                 "' style='color:red;font-weight:bold;'>已超期</div>";
                    }
                    else if ((ctime - nowTime).Days < 3)
                    {
                        double day       = Math.Ceiling((ctime - nowTime).TotalDays);
                        string dsystring = day == 0 ? (ctime - nowTime).Hours + "小时" : day.ToString() + "天";
                        status = "<div title='要求完成时间:" + ctime.ToString("yyyy-MM-dd HH:mm") +
                                 "' style='color:#ff7302;font-weight:bold;'>" + dsystring + "内到期</div>";
                    }
                    else
                    {
                        status = "<div title='要求完成时间:" + ctime.ToString("yyyy-MM-dd HH:mm") +
                                 "' style=''>正常</div>";
                    }
                }
                Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject
                {
                    { "id", dr["Id"].ToString() },
                    { "Title", taskTitle },
                    { "FlowName", dr["FlowName"].ToString() },
                    { "StepName", dr["StepName"].ToString() },
                    { "SenderName", dr["SenderName"].ToString() },
                    { "ReceiveTime", dr["ReceiveTime"].ToString().ToDateTime().ToDateTimeString() },
                    { "StatusTitle", status },
                    { "Note", dr["Note"].ToString() },
                    { "Opation", opation.ToString() }
                };
                jArray.Add(jObject);
            }
            return("{\"userdata\":{\"total\":" + count + ",\"pagesize\":" + size + ",\"pagenumber\":" + number + "},\"rows\":" + jArray.ToString() + "}");
        }