public virtual DataTable GetProcessPerformanceKPI(HttpContext context) { YZRequest request = new YZRequest(context); string strInclude = request.GetString("include", null); string strExclude = request.GetString("exclude", null); string type = request.GetString("Type", "year"); int year = request.GetInt32("year", DateTime.Today.Year); int month = request.GetInt32("month", -1); bool byYear = String.Compare(type, "year", true) == 0; if (byYear) { month = -1; } BPMObjectNameCollection include = null; BPMObjectNameCollection exclude = null; if (!String.IsNullOrEmpty(strInclude)) { include = JArray.Parse(strInclude).ToObject <BPMObjectNameCollection>(); } if (!String.IsNullOrEmpty(strExclude)) { exclude = JArray.Parse(strExclude).ToObject <BPMObjectNameCollection>(); } //获得数据 DataTable srcTable; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { using (YZReader reader = new YZReader(provider.GetProcessPerformanceKPI(cn, year, month, include, exclude))) { srcTable = reader.LoadTable(); } } } int runingProcessCount = 0; int TaskCounts = 0; int AvgMinutes = 0; int MaxMinutes = 0; runingProcessCount = Convert.ToInt32(srcTable.Rows[0]["ProcessCounts"]); TaskCounts = Convert.ToInt32(srcTable.Rows[0]["TaskCounts"]); AvgMinutes = Convert.ToInt32(srcTable.Rows[0]["AvgMinutes"]); MaxMinutes = Convert.ToInt32(srcTable.Rows[0]["MaxMinutes"]); float avgDay = (float)TaskCounts / (float)(year == DateTime.Today.Year ? DateTime.Today.DayOfYear : 365); float avgMonth = (avgDay * 365) / 12; float avgWeek = avgDay * 7; int allProcessCounts; using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); allProcessCounts = ProcessNameManager.GetProcessNames(cn).Count; } //输出KPI DataRow row; DataTable table = new DataTable(); table.Columns.Add("title"); table.Columns.Add("value"); //流程数 row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ProcessCount; row["value"] = String.Format("{0:#,##0}/{1:#,##0}", runingProcessCount, allProcessCounts); //总发起数 row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ReportApprovedCount; row["value"] = TaskCounts.ToString("#,##0"); if (byYear) { row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ReportMonthlyApprovedCount; row["value"] = Convert.ToInt32(avgMonth).ToString("#,##0"); } else { row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ReportDaily; row["value"] = Convert.ToInt32(avgDay).ToString("#,##0"); } row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ReportAvgTimeCost; row["value"] = YZStringHelper.MinutesToStringDHM(AvgMinutes); row = table.NewRow(); table.Rows.Add(row); row["title"] = Resources.YZStrings.Aspx_ReportMaxTimeCost; row["value"] = YZStringHelper.MinutesToStringDHM(MaxMinutes); return(table); }
public static string MinutesToStringDHM(int minutes) { return(YZStringHelper.MinutesToStringDHM(minutes, 24)); }
protected static void TimeSpanRender1(HSSFCell cell, string varName, DataSet dataset, object value, string emptyText) { value = YZStringHelper.MinutesToStringDHM(Convert.ToInt32(value)); DefaultRender(cell, varName, dataset, value, emptyText); }