public static string GetTaskStateDisplayString(BPMConnection cn, TaskState state, int taskid) { if (state != TaskState.Running) { return(YZStringHelper.GetTaskStateDisplayName(state)); } Dictionary <string, BPMObjectNameCollection> results = new Dictionary <string, BPMObjectNameCollection>(); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { string stepName = step.StepDisplayName; if (step.Share && String.IsNullOrEmpty(step.RecipientAccount)) { stepName = stepName + "(等待获取)"; } BPMObjectNameCollection users = null; if (results.ContainsKey(stepName)) { users = results[stepName]; } else { users = new BPMObjectNameCollection(); results.Add(stepName, users); } string userName = YZStringHelper.GetUserShortName(step.RecipientAccount, step.RecipientFullName); if (!String.IsNullOrEmpty(userName) && !users.Contains(userName)) { users.Add(userName); } } List <string> rvs = new List <string>(); foreach (KeyValuePair <string, BPMObjectNameCollection> kv in results) { string users = String.Join(",", kv.Value.ToArray()); if (String.IsNullOrEmpty(users)) { rvs.Add(kv.Key); } else { rvs.Add(String.Format("{0}:{1}", kv.Key, users)); } } return(String.Join(";", rvs.ToArray())); }
public void ProcessRequest(HttpContext context) { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); GridPageInfo gridPageInfo = new GridPageInfo(context); IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; int year; if (context.Request.Params["byYear"] == "0") { year = -1; } else { string strYear = context.Request.Params["Year"]; year = String.IsNullOrEmpty(strYear) ? DateTime.Today.Year : Convert.ToInt32(strYear); } //获得数据 BPMTaskCollection tasks = new BPMTaskCollection(); int rowcount; JsonItem rootItem = new JsonItem(); using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); tasks = cn.GetHistoryTasks(year, HistoryTaskType.AllAccessable, dbProvider.FilterStringHistoryTaskTaskTableFilter, dbProvider.FilterStringHistoryTaskStepTableFilter, null, gridPageInfo.Start, gridPageInfo.Limit, out rowcount); //将数据转化为Json集合 rootItem.Attributes.Add(JsonItem.TotalRows, rowcount); JsonItemCollection children = new JsonItemCollection(); rootItem.Attributes.Add("children", children); rootItem.Attributes.Add("total", rowcount); foreach (BPMTask task in tasks) { JsonItem item = new JsonItem(); children.Add(item); item.Attributes.Add("tid", task.TaskID); item.Attributes.Add("pid", task.ParentStepID); item.Attributes.Add("sn", task.SerialNum); item.Attributes.Add("pn", task.ProcessName); item.Attributes.Add("user", YZStringHelper.GetUserShortName(task.OwnerAccount, task.OwnerDisplayName)); item.Attributes.Add("state", task.TaskState.ToString()); item.Attributes.Add("stateText", YZStringHelper.GetTaskStateDisplayName(task.TaskState)); item.Attributes.Add("stateProcessing", YZStringHelper.GetTaskProcessingStatus(cn, task.TaskState, task.TaskID)); item.Attributes.Add("date", YZStringHelper.DateToStringL(task.CreateAt)); task.Description = task.ShowDescByProcessName(true); item.Attributes.Add("desc", String.IsNullOrEmpty(task.Description) ? "无内容摘要" : task.Description); } } //System.Threading.Thread.Sleep(500); context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); // 响应类型 context.Response.AppendHeader("Access-Control-Allow-Methods", "POST"); // 响应头设置 context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); context.Response.Charset = "gb2312"; //设置字符集类型 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.ContentType = "application/json;charset=gb2312"; //输出数据 context.Response.Write(rootItem.ToString()); }