public string GetChargPilePair(HttpContext context) { var schedulejobsbll = new ScheduleJobsBll(); var csid = context.Request.Params["csid"]; if (string.IsNullOrEmpty(csid)) { return("{\"total\":0,\"rows\":[]}"); } string str; var count = 0; try { var icsid = int.Parse(csid); var dt = schedulejobsbll.FindBy(icsid); str = ConvertToJson.DataTableToJson("rows", dt); str = str.Substring(1, str.Length - 2); str = "{\"total\":\"" + count + "\"," + str + "}"; } catch (Exception e) { Log.Error(e); throw; } return(str); }
public string InitTable(HttpContext context) { var schedulejobsbll = new ScheduleJobsBll(); string str; var page = context.Request.Params["page"]; var rows = context.Request.Params["rows"]; var cmdtype = context.Request.Params["cmdtype"]; var pageIndex = 0; var size = 0; var count = 0; var result = "0"; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(rows)) { size = int.Parse(rows); } try { var dt = schedulejobsbll.FindBy(pageIndex, size, ref count, cmdtype); //TODO: dt.Columns.Add("rate", Type.GetType("System.String")); foreach (DataRow dr in dt.Rows) { var sumcount = schedulejobsbll.FindBySumCount(dr["ID"].ToString()); var successcount = schedulejobsbll.FindBySuccessCount(dr["ID"].ToString()); if (successcount != 0) { double rate = successcount / (float)sumcount; rate = rate * 100; result = String.Format("{0:N2}", rate); } dr["rate"] = result; result = "0"; } str = ConvertToJson.DataTableToJson("rows", dt); str = str.Substring(1, str.Length - 2); str = "{\"total\":\"" + count + "\"," + str + "}"; } catch (Exception e) { Log.Error(e); throw; } return(str); }