public ActionResult DailyReportSearch(string searchFrom) { string userid = User.Identity.Name.Split(',')[0]; DateTime dateFrom = Convert.ToDateTime(searchFrom); DateTime dateTo = dateFrom.AddDays(1); DailyReport dailyreport = db.DailyReports.Where(c => c.UserID == userid && c.AddDate >= dateFrom && c.AddDate <= dateTo).FirstOrDefault(); if (dailyreport != null) { string name = dailyreport.UserID; ReportItems reportItems = new ReportItems(); reportItems.FromXML(dailyreport.Report); ViewBag.Report = RF.GetReport(reportItems); return PartialView("DailyReportPartial"); } else return Content("<script >alert('You have not report today!');</script >", "text/html"); }
public ActionResult Edit(Guid id) { ViewBag.ReportProject = GetWorkFor(); string userid = User.Identity.Name.Split(',')[0]; //var project = db.UserRoles.Where(c => c.UserID == userid).ToList(); //ViewBag.ReportProject = project; DailyReport dailyreport = db.DailyReports.Find(id); ViewData["DailyReportID"] = id; ReportItems reportItems = new ReportItems(); reportItems.FromXML(dailyreport.Report); return View(reportItems); }
public ActionResult Details() { string userid = User.Identity.Name.Split(',')[0]; DateTime dateFrom = DateTime.Now.Date; DateTime dateTo = DateTime.Now.Date.AddDays(1); ViewBag.searchFrom = dateFrom.ToString("MM/dd/yyyy"); DailyReport dailyreport = db.DailyReports.Where(c => c.UserID == userid && c.AddDate >=dateFrom && c.AddDate<=dateTo).FirstOrDefault(); if (dailyreport!=null) { ReportItems reportItems = new ReportItems(); reportItems.FromXML(dailyreport.Report); ViewBag.Report = RF.GetReport(reportItems); } return View(); }
private List<Tuple<string, string, string>> GetDisplayData(DateTime startTime, DateTime endTime) { DateTime endDate = endTime.AddDays(1); var reports = (from a in db.DailyReports where a.AddDate >= startTime && a.AddDate <= endDate orderby a.AddDate group a by a.UserID into c orderby c.Key select c).ToList(); List<Tuple<string, string, string>> tuples = new List<Tuple<string, string, string>>(); foreach (var c in reports) { string userID = c.Key; string name = (from d in db.Users where d.UserID == userID select d.UserName).FirstOrDefault(); //build the latest WIP report var uncompletedReport = (from a in db.DailyReports where a.AddDate >= endTime && a.AddDate <= endDate && a.UserID == userID select a).FirstOrDefault(); string uncompleted = string.Empty; if (uncompletedReport != null) { ReportItems uncompletedReportItems = new ReportItems(); uncompletedReportItems.FromXML(uncompletedReport.Report); string str = RF.GetWIPReport(uncompletedReportItems); if (str != "") { uncompleted = str; } } //build Finished report StringBuilder builderF = new StringBuilder(); foreach (var item in c) { ReportItems reportItems = new ReportItems(); reportItems.FromXML(item.Report); string str = RF.GetFinishedReport(reportItems); if (str != "") { builderF.Append(item.AddDate + "</br>"); builderF.Append(str); } } string completed = builderF.ToString(); var tuple = new Tuple<string, string, string>(name, completed, uncompleted); tuples.Add(tuple); } return tuples; }
/// <summary> /// get the data will be displayed in the table /// </summary> /// <param name="flag">a mark(0 means the result will be displayed in html;1 means the result will be displayed in excel)</param> /// <returns>a list will be passed to the view</returns> private List<Tuple<string, List<Tuple<string, string>>>> TableData(int flag) { DateTime dateFrom = DateTime.Now.Date; DateTime dateTo = DateTime.Now.Date.AddDays(1); var projects = db.UserRoles.Select(a => a.GroupName).Distinct().ToList(); projects.Add("Other"); var dailyReports = (from a in db.DailyReports from u in db.Users where a.UserID == u.UserID && a.AddDate >= dateFrom && a.AddDate <= dateTo orderby u.UserName select new { Name = u.UserName, Report = a.Report }).ToList(); List<Tuple<string, List<Tuple<string, string>>>> projectTuples = new List<Tuple<string, List<Tuple<string, string>>>>(); foreach (var project in projects) { string projectName = project; List<Tuple<string, string>> tuples = new List<Tuple<string, string>>(); foreach (var item in dailyReports) { string name = item.Name; ReportItems reportItems = new ReportItems(); reportItems.FromXML(item.Report); StringBuilder tempStr = new StringBuilder(); RF.ReportToGroup(projectName, reportItems, tempStr, flag); if (tempStr.ToString() != "") { var tuple = new Tuple<string, string>(name, tempStr.ToString()); tuples.Add(tuple); } } projectTuples.Add(new Tuple<string, List<Tuple<string, string>>>(projectName, tuples)); } return projectTuples; }
private List<Tuple<string, string, string>> Datas(string projectName) { DateTime dateFrom = DateTime.Now.Date; DateTime dateTo = DateTime.Now.Date.AddDays(1); //var projects = db.UserRoles.Select(a => a.GroupName).Distinct().ToList(); //projects.Add("Other"); var dailyReports = (from a in db.DailyReports from u in db.Users from r in db.UserRoles where a.UserID == u.UserID && r.UserID == u.UserID && r.GroupName == projectName && a.AddDate >= dateFrom && a.AddDate <= dateTo orderby u.UserName select new { Name = u.UserName, Report = a.Report }).ToList(); List<Tuple<string, string, string>> workTuples = new List<Tuple<string, string, string>>(); foreach (var item in dailyReports) { string name = item.Name; ReportItems reportItems = new ReportItems(); reportItems.FromXML(item.Report); string worked = RF.GetWorkedReport(reportItems); string working = RF.GetWorkingReport(reportItems); if (worked != "" || working != "") { var tuple = new Tuple<string, string, string>(name, worked, working); workTuples.Add(tuple); } } return workTuples; }