public CaseCount GetWtajCount(int type) { CaseCount model = new CaseCount(); DateTime time = DateTime.Now; DateTime starttime = Convert.ToDateTime("0001-01-01"); DateTime endtime = Convert.ToDateTime("0001-01-01"); if (type == 1) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); endtime = starttime.AddDays(1); } else if (type == 2) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); endtime = starttime.AddMonths(1); } else if (type == 3) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-01-01")); endtime = starttime.AddYears(1); } using (Entities db = new Entities()) { IQueryable <CaseLbModel> queryable = from a in db.case_wtajs select new CaseLbModel { casetype = a.processstatus, wfsname = a.car_num, createtime = a.reporttime }; queryable = queryable.Where(a => a.createtime > starttime && a.createtime < endtime); model.id = "3"; model.name = "违停案件"; model.count = queryable.Count(); model.complete = queryable.Where(a => a.casetype != "1").Count(); model.kept = 0;//queryable.Where(a => a.etime < time).Count(); } return(model); }
public CaseCount GetSimpleCount(int type) { CaseCount model = new CaseCount(); DateTime time = DateTime.Now; DateTime starttime = Convert.ToDateTime("0001-01-01"); DateTime endtime = Convert.ToDateTime("0001-01-01"); if (type == 1) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); endtime = starttime.AddDays(1); } else if (type == 2) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); endtime = starttime.AddMonths(1); } else if (type == 3) { starttime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-01-01")); endtime = starttime.AddYears(1); } using (Entities db = new Entities()) { string sql = string.Format(@"select a.wfsid,a.casetype,a.wfsname,b.wfdid,b.etime ,a.createtime from case_workflowspecifics a left join case_workflowspecificactivitys b on a.wfsid=b.wfsid and b.`status`=1 where a.casetype=3"); IEnumerable <CaseLbModel> queryable = db.Database.SqlQuery <CaseLbModel>(sql); queryable = queryable.Where(a => a.createtime > starttime && a.createtime < endtime); model.id = "2"; model.name = "简易案件"; model.count = queryable.Count(); model.complete = queryable.Where(a => a.wfsname == "结束").Count(); model.kept = queryable.Where(a => a.etime < time).Count(); } return(model); }
/* protected string UpdateCC() { int casecount = -1; DateTime d; DateTime? date = null; if(DateTime.TryParse(Request.Form["date"], out d)) date = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 00); int.TryParse(Request.Form["counts"], out casecount); if (casecount > -1 && date.HasValue) { using (DB db = new DB()) { List<ThroughputHistory> thList = DCSDashboardDemoHelper.getThroughPutHistories(); ThroughputHistory th = (from o in thList where (o.Date.DayOfYear == date.Value.DayOfYear && o.Date.Year == date.Value.Year && o.Date.Hour == date.Value.Hour) orderby o.Date descending select o).FirstOrDefault(); DateTime tmpDate = new DateTime(d.Year, d.Month, d.Day, d.Hour, 00, 00); tmpDate = tmpDate.AddHours(1d); if (th != null) { if (th.Date != date) tmpDate = th.Date; } List<CaseCount> cList = DCSDashboardDemoHelper.GetCaseCounts(date, tmpDate, "lebelge"); foreach (CaseCount cc in cList) { int id = cc.Id; if (cc.EventStop.Value >= d && cc.EventStop.Value.Hour == d.Hour) { CaseCount tmpCase = (from o in db.CaseCountSet where o.Id == id select o).FirstOrDefault(); db.DeleteObject(tmpCase); } } int diff = (int)d.Subtract(tmpDate).TotalMinutes; if (diff < 0) diff = diff * -1; decimal val = (decimal)casecount / ((decimal)diff / 5M); decimal total = 0; decimal lastCC = 0; decimal counter = 0; CaseCount lastCaseCount = (from o in db.CaseCountSet where o.EventStop.Value < date orderby o.EventStop.Value descending select o).FirstOrDefault(); if (lastCaseCount != null) lastCC = lastCaseCount.CaseCount1; total = lastCC; DateTime end = date.Value.AddHours(1d); diff = diff / 5; List<CaseCount> tmpList = new List<CaseCount>(); if (val > 0) { for (int x = 0; x < diff; x++) { if (date.Value.Hour == end.Hour) break; total += val; counter += val; CaseCount cc = new CaseCount(); cc.CaseCount1 = Convert.ToInt32(total); cc.Client = "lebelge"; cc.EventStart = date; cc.EventStop = date; cc.Line = "company-demo"; tmpList.Add(cc); date = date.Value.AddMinutes(5d); } } if (tmpList.Count > 0) { tmpList.ElementAt(tmpList.Count - 1).CaseCount1 = tmpList.ElementAt(0).CaseCount1 + casecount; foreach (CaseCount cc in tmpList) { db.AddToCaseCountSet(cc); } } if (db.SaveChanges() >= 0) return "Success" + d.ToString("MM/dd/yyyy hh:mm:ss tt"); else return "ERROR"; } } return "ERROR"; } */ protected string UpdateCC() { int casecount = -1; DateTime d; DateTime? date = null; if (DateTime.TryParse(Request.Form["date"], out d)) date = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 00); int.TryParse(Request.Form["counts"], out casecount); if (casecount > -1 && date.HasValue) { using (DB db = new DB()) { List<ThroughputHistory> thList = DCSDashboardDemoHelper.getThroughPutHistories("company-demo"); ThroughputHistory th = (from o in thList where (o.Date.DayOfYear == date.Value.DayOfYear && o.Date.Year == date.Value.Year && o.Date.Hour == date.Value.Hour) orderby o.Date descending select o).FirstOrDefault(); DateTime tmpDate = new DateTime(d.Year, d.Month, d.Day, d.Hour, 00, 00); tmpDate = tmpDate.AddHours(1d); if (th != null) { if (th.Date != date) tmpDate = th.Date; } List<CaseCount> cList = DCSDashboardDemoHelper.GetCaseCounts(date, tmpDate, "lebelge"); foreach (CaseCount cc in cList) { int id = cc.Id; if (cc.EventStop.Value >= d && cc.EventStop.Value.Hour == d.Hour) { CaseCount tmpCase = (from o in db.CaseCountSet where o.Id == id select o).FirstOrDefault(); db.DeleteObject(tmpCase); } } int diff = (int)d.Subtract(tmpDate).TotalMinutes; if (diff < 0) diff = diff * -1; CaseCount lastCaseCount = (from o in db.CaseCountSet where o.EventStop.Value < date && o.Client == DCSDashboardDemoHelper.Filter_Client orderby o.EventStop.Value descending select o).FirstOrDefault(); DateTime lastHr = date.Value.AddHours(-1); Dictionary<DateTime, ManualCaseCount> tmpCList = GetCalculatedCaseCounts(date.Value, "company-demo"); decimal lastCC = 0; if (tmpCList.Count > 0) { casecount = casecount - tmpCList[lastHr].cases; } decimal val = (casecount) / ((decimal)diff / 5M); if (lastCaseCount != null) lastCC = lastCaseCount.CaseCount1; decimal total = 0; decimal counter = 0; total = lastCC; DateTime end = date.Value.AddHours(1d); diff = diff / 5; List<CaseCount> tmpList = new List<CaseCount>(); if (val > 0) { for (int x = 0; x < diff; x++) { if (date.Value.Hour == end.Hour) break; total += val; counter += val; CaseCount cc = new CaseCount(); cc.CaseCount1 = Convert.ToInt32(total); cc.Client = "lebelge"; cc.EventStart = date; cc.EventStop = date; cc.Line = "company-demo"; tmpList.Add(cc); date = date.Value.AddMinutes(5d); } } if (tmpList.Count > 0) { tmpList.ElementAt(tmpList.Count - 1).CaseCount1 = tmpList.ElementAt(0).CaseCount1 + casecount; foreach (CaseCount cc in tmpList) { db.AddToCaseCountSet(cc); } } if (db.SaveChanges() >= 0) return "Success" + d.ToString("MM/dd/yyyy hh:mm:ss tt"); else return "ERROR"; } } return "ERROR"; }
public void DecrCase() { count--; CaseCount = CaseCount.Split('-')[0] + "-" + count.ToString(); }
public void IncrCase() { count++; CaseCount = CaseCount.Split('-')[0] + "-" + count.ToString(); }