public ActionResult IndexExport(int month, int year, string ticketSubject) { try { DateTime startDate = new DateTime(year, month, 1); DateTime endDate = startDate.AddMonths(1).AddSeconds(-1); TicketInfoList list = TicketInfoList.GetReportByDate(startDate, endDate, ticketSubject); var file = CreateFile(list, month, year, ticketSubject); if (file != null) { return(new FileContentResult(file, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "My Excel File.xlsx" }); } } catch (Exception ex) { LogActivity log = LogActivity.NewLogActivity(); log.ControllerName = "ExportController"; log.ActionName = "IndexExport"; log.LogData = Newtonsoft.Json.JsonConvert.SerializeObject(ex.StackTrace); log.CreatedBy = User.Identity.Name; log.CreatedDate = DateTime.Now; log = log.Save(); } return(View()); }
public JsonResult DayToDay(string ticketType) { DateTime baseDate = DateTime.Today; DateTime startDate = baseDate.AddDays(-(int)baseDate.DayOfWeek); DateTime endDate = startDate.AddDays(7).AddSeconds(-1); TicketInfoList list = null; if (!string.IsNullOrEmpty(ticketType)) { list = TicketInfoList.GetReportByDateAndTicketType(startDate, endDate, ticketType); } else { list = TicketInfoList.GetReportByDate(startDate, endDate); } List <TicketInfo> source = new List <TicketInfo>(); List <string> agenIdList = new List <string>(); AgentInfo info = AgentInfo.GetAgentInfo(User.Identity.Name); agenIdList.Add(info.idCustAgent); if (info.IsSupervisor) { var infolist = AgentInfoList.GetAgentByGroup(info.GroupName).Where(x => x.SPVID == info.idCustAgent).ToList(); foreach (var item in infolist) { agenIdList.Add(item.idCustAgent); } } source = list.Where(x => agenIdList.Contains(x.CreatedBy)).ToList(); List <MorrisBar> data = new List <MorrisBar>(); for (DateTime i = startDate; i < endDate.AddDays(1); i = i.AddDays(1)) { var tmpList = source.Where(x => x.CreatedDate.Date == i && agenIdList.Contains(x.TicketOwner)).ToList(); MorrisBar bar = new MorrisBar(); bar.Count = tmpList.Count; bar.Open = tmpList.Where(x => x.TicketStatus == "Open").ToList().Count; bar.Closed = tmpList.Where(x => x.TicketStatus == "Closed").ToList().Count; bar.Tanggal = i.Day; data.Add(bar); } return(Json(data, JsonRequestBehavior.AllowGet)); }
public JsonResult AllCurrentMonthToMonth(string ticketType) { DateTime baseDate = DateTime.Today; DateTime startDate = baseDate.AddDays(1 - baseDate.Day); DateTime endDate = startDate.AddMonths(1).AddSeconds(-1); List <TicketInfo> list = new List <TicketInfo>(); if (!string.IsNullOrEmpty(ticketType)) { list = TicketInfoList.GetReportByDateAndTicketType(startDate, endDate, ticketType).ToList(); } else { list = TicketInfoList.GetReportByDate(startDate, endDate).ToList(); } List <TicketInfo> source = new List <TicketInfo>(); List <string> agenIdList = new List <string>(); AgentInfo info = AgentInfo.GetAgentInfo(User.Identity.Name); agenIdList.Add(info.idCustAgent); if (info.IsSupervisor) { var infolist = AgentInfoList.GetAgentByGroup(info.GroupName).Where(x => x.SPVID == info.idCustAgent).ToList(); foreach (var item in infolist) { agenIdList.Add(item.idCustAgent); } } source = list.Where(x => agenIdList.Contains(x.TicketOwner)).ToList(); List <MorrisDonut> data = new List <MorrisDonut>(); MorrisDonut m = new MorrisDonut(); m.label = "Open"; m.value = source.Where(x => x.TicketStatus == "Open").Count(); data.Add(m); m = new MorrisDonut(); m.value = source.Where(x => x.TicketStatus == "Closed").Count(); m.label = "Closed"; data.Add(m); return(Json(data, JsonRequestBehavior.AllowGet)); }
public JsonResult MonthToMonth(string ticketType) { DateTime baseDate = DateTime.Today; DateTime startDate = baseDate.AddDays(1 - baseDate.Day); DateTime endDate = startDate.AddMonths(1).AddSeconds(-1); TicketInfoList list = null; if (!string.IsNullOrEmpty(ticketType)) { list = TicketInfoList.GetReportByDateAndTicketType(new DateTime(DateTime.Now.Year, 1, 1), new DateTime(DateTime.Now.Year, 12, 31), ticketType); } else { list = TicketInfoList.GetReportByDate(new DateTime(DateTime.Now.Year, 1, 1), new DateTime(DateTime.Now.Year, 12, 31)); } List <TicketInfo> source = new List <TicketInfo>(); List <string> agenIdList = new List <string>(); AgentInfo info = AgentInfo.GetAgentInfo(User.Identity.Name); agenIdList.Add(User.Identity.Name); if (info.IsSupervisor) { var infolist = AgentInfoList.GetAgentByGroup(info.GroupName).Where(x => x.SPVID == info.idCustAgent).ToList(); foreach (var item in infolist) { agenIdList.Add(item.idCustAgent); } } source = list.Where(x => agenIdList.Contains(x.CreatedBy)).ToList(); List <MorrisBar> data = new List <MorrisBar>(); for (int i = 1; i < 13; i++) { var tmpList = source.Where(x => x.CreatedDate.Month == i && agenIdList.Contains(x.TicketOwner)).ToList(); MorrisBar m = new MorrisBar(); m.Count = tmpList.Count; m.Closed = tmpList.Where(x => x.TicketStatus == "Closed").Count(); m.Open = tmpList.Where(x => x.TicketStatus == "Open").Count(); m.Tanggal = i; data.Add(m); } return(Json(data, JsonRequestBehavior.AllowGet)); }