Exemplo n.º 1
0
        public ActionResult Create(Reports reports)
        {
            if (ModelState.IsValid)
            {
                ViewData["WorkFor"] = GetWorkFor();

                int finishedLength = int.Parse(Request.Form["hideFinished"]);
                int wIPLength = int.Parse(Request.Form["hideWIP"]);
                int planningLength = int.Parse(Request.Form["hidePlanning"]);
                int blockingLength = int.Parse(Request.Form["hideBlocking"]);

                ReportItems reportItems = new ReportItems();

                reportItems.Finished = GetReportItems(finishedLength, "Finished");
                reportItems.WIP = GetReportItems(wIPLength, "WIP");
                reportItems.Planning = GetReportItems(planningLength, "Planning");
                reportItems.Blocking = GetReportItems(blockingLength, "Blocking");

                if (reportItems.Finished.Count != 0 || reportItems.WIP.Count != 0 || reportItems.Planning.Count != 0 || reportItems.Blocking.Count != 0)
                {
                    reports.DailyReport.Report = reportItems.ToXML();
                    reports.DailyReport.DailyReportID = Guid.NewGuid();
                    reports.DailyReport.AddDate = DateTime.Now;
                    reports.DailyReport.UserID = User.Identity.Name.Split(',')[0];

                    db.DailyReports.Add(reports.DailyReport);
                    db.SaveChanges();

                    return RedirectToAction("Edit", new { id = reports.DailyReport.DailyReportID });
                }

                ReportFiles reportFiles = new ReportFiles();
                reportFiles.Files = GetFiles();

                if (reportFiles.Files.Count != 0)
                {
                    reportFiles.Status = Request.Form["ProjectStatus_TB"];
                    reportFiles.Project = Request.Form["Project_DDL"];

                    reports.DailyProjectReort.Report = reportFiles.ToXML();

                    reports.DailyProjectReort.DailyProjectReportID = Guid.NewGuid();
                    reports.DailyProjectReort.AddDate = DateTime.Now;
                    reports.DailyProjectReort.UserID = User.Identity.Name.Split(',')[0];
                    reports.DailyProjectReort.Project = Request.Form["Project_DDL"];

                    db.DailyProjectReports.Add(reports.DailyProjectReort);
                    db.SaveChanges();
                }
            }
            return View();
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
        public ActionResult Edit(ReportItems reportItems)
        {
            if (ModelState.IsValid)
            {

                Guid dailyReportID = new Guid(Request.Form["hideID"]);
                DailyReport dailyreport = db.DailyReports.Find(dailyReportID);

                int finishedLength = int.Parse(Request.Form["hideFinished"]);
                for (int i = 1; i < finishedLength+1; i++)
                {
                    var reportItem = GetReportItem("Finished", i);
                    if (reportItem != null)
                    {
                        reportItems.Finished.Add(reportItem);
                    }
                }

                int wIPLength = int.Parse(Request.Form["hideWIP"]);
                for (int i = 1; i < wIPLength + 1; i++)
                {
                    var reportItem = GetReportItem("WIP", i);
                    if (reportItem != null)
                    {
                        reportItems.WIP.Add(reportItem);
                    }
                }

                int planningLength = int.Parse(Request.Form["hidePlanning"]);
                for (int i = 1; i < planningLength + 1; i++)
                {
                    var reportItem = GetReportItem("Planning", i);
                    if (reportItem != null)
                    {
                        reportItems.Planning.Add(reportItem);
                    }
                }

                int blockingLength = int.Parse(Request.Form["hideBlocking"]);
                for (int i = 1; i < blockingLength + 1; i++)
                {
                    var reportItem = GetReportItem("Blocking", i);
                    if (reportItem != null)
                    {
                        reportItems.Blocking.Add(reportItem);
                    }
                }

                dailyreport.Report=reportItems.ToXML();

                db.Entry(dailyreport).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Edit", new { id = dailyReportID });
            }
            return View(reportItems);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        /// <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;
        }
Exemplo n.º 8
0
        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;
        }