public HttpResponseMessage MetricsByDocType(CustomerSearchRequest requestInfo) { var docTypeList = _IOrgdoctypService.GetOrgdoctyps().Where(p => p.OrgId == requestInfo.orgId).Select(s => s.Id).ToList(); var result = _IWkflowinstanceService.GetWkflowinstances().Where(p => p.WkflowDefId == 4 && p.OrgId == requestInfo.orgId && (requestInfo.StartDate == null || p.CreateDate > requestInfo.StartDate) && (requestInfo.EndDate == null || p.CreateDate > requestInfo.EndDate)).Where(q => docTypeList.Contains((int)q.WkflowInstanceDocs.FirstOrDefault().Doc.OrgDocTypId)).GroupBy(g => g.WkflowInstanceDocs.FirstOrDefault().Doc.OrgDocTyp.Descript).Select(s => new { Name = s.Key, Value = s.Count() }); if (result == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <IEnumerable <object> >(HttpStatusCode.OK, result)); }
public HttpResponseMessage GetWkflowsByFilter(int?orgId, int?docTypeId) { var wkflowInstances = _IWkflowinstanceService.GetWkflowinstances().Where(p => p.OrgId == orgId && p.WkflowInstanceDocs.FirstOrDefault().Doc.OrgDocTypId == docTypeId).ToList(); var result = PlatformMappingHelper.Map <IList <WkflowInstance>, IList <WkflowInstanceDTO> >(wkflowInstances.ToList()).ToList(); if (result == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <IEnumerable <WkflowInstanceDTO> >(HttpStatusCode.OK, result)); }
public HttpResponseMessage CustomerSignupByDay(int resellerId) { var date = DateTime.UtcNow; var CurrStartDate = new DateTime(date.Year, date.Month, 1); var CurrEndDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)); var curDays = DateTime.DaysInMonth(date.Year, date.Month); var custwork = _IWkflowinstanceService.GetWkflowinstances().Where(q => q.WkflowDefId == 1 && q.Org.OrgOrgs1.Count > 0).Where(p => p.Org.OrgOrgs1.FirstOrDefault().Org.Id == resellerId && p.CreateDate >= CurrStartDate && p.CreateDate <= CurrEndDate).GroupBy(g => ((DateTime)g.CreateDate).ToString("dd-MMM")).Select(i => new { Date = i.Key.Substring(0, 6), Count = i.Count() }); List <object> finalwork = new List <object>(); for (int day = 0; day < curDays; day++) { int custcount = 0; var datecal = CurrStartDate.AddDays(day).ToString("dd-MMM"); var key = datecal.Substring(0, 6); var find = custwork.Where(p => p.Date == key); if (find.Count() > 0) { custcount = find.FirstOrDefault().Count; } finalwork.Add(new { Date = key, Count = custcount }); } if (finalwork == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <IEnumerable <object> >(HttpStatusCode.OK, finalwork)); }
public HttpResponseMessage TicketsOpenedSinceLastLogin() { int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault()); var loginHist = _IUserService.GetUser(userID).UserLoginHists.OrderByDescending(o => o.Id); var userLastLogin = loginHist.Count() > 0 ? loginHist.FirstOrDefault().LoginDate : null; var data = _IWkflowinstanceService.GetWkflowinstances().Where(p => p.WkflowDef.Code.Contains("SRW") && p.WkflowStepHists.OrderByDescending(o => o.Id).FirstOrDefault().WkflowStat.Code != "Closed" && (userLastLogin == null || p.CreateDate >= userLastLogin)).Select(u => new { Id = u.Id, CustomerName = u.Org.Name, Reason = u.WkflowStepHists.OrderBy(j => j.Id).FirstOrDefault().WkflowStatRea.Descript }); return(Request.CreateResponse <object>(HttpStatusCode.OK, data)); }