public ActionResult IBookPost()
        {
            var ckdict  = CookieUtility.UnpackCookie(this);
            var updater = ckdict["logonuser"].Split(new char[] { '|' })[0];

            var vm = new PJReportViewModels();

            vm.username = updater;

            for (var i = 0; i < 20; i++)
            {
                if (Request.Form["pckbox" + i] != null && string.Compare(Request.Form["pckbox" + i], "true", true) == 0)
                {
                    vm.ProjectList.Add(Request.Form["PJKEY" + i]);
                }
            }

            for (var i = 0; i < 20; i++)
            {
                if (Request.Form["rckbox" + i] != null && string.Compare(Request.Form["rckbox" + i], "true", true) == 0)
                {
                    vm.ReportTypeList.Add(Request.Form["RPType" + i]);
                }
            }

            vm.reporttime     = Request.Form["ReportTimeList"].ToString();
            vm.lastupdatetime = DateTime.Now;
            vm.StoreBookReportRecord();


            ViewBag.PJList = ProjectViewModels.RetrieveAllProjectKey();

            var temptypelist = new List <string>();

            temptypelist.Add(PJReportType.YieldTrend);
            temptypelist.Add(PJReportType.IssueTrend);
            temptypelist.Add(PJReportType.FailureTrend);
            temptypelist.Add(PJReportType.MonthlyPareto);
            ViewBag.RepTypeList = temptypelist;

            vm = PJReportViewModels.RetrieveBookReportRecord(updater);
            var rsilist = new List <string>();

            string[] rlist = { ReportSelectTime.MON, ReportSelectTime.TUE, ReportSelectTime.WEN, ReportSelectTime.THU, ReportSelectTime.FRI, ReportSelectTime.SAT, ReportSelectTime.SUN, ReportSelectTime.EVE };
            rsilist.AddRange(rlist);
            if (vm != null)
            {
                ViewBag.ReportTimeList = CreateSelectList(rsilist, vm.reporttime);
            }
            else
            {
                ViewBag.ReportTimeList = CreateSelectList(rsilist, "");
            }

            return(RedirectToAction("ViewReport"));
        }
        // GET: PJReport
        public ActionResult ITag()
        {
            var ckdict = CookieUtility.UnpackCookie(this);

            if (ckdict.ContainsKey("logonuser") && !string.IsNullOrEmpty(ckdict["logonuser"]))
            {
            }
            else
            {
                var ck = new Dictionary <string, string>();
                ck.Add("logonredirectctrl", "PJReport");
                ck.Add("logonredirectact", "ITag");
                CookieUtility.SetCookie(this, ck);
                return(RedirectToAction("LoginUser", "User"));
            }

            ViewBag.PJList = ProjectViewModels.RetrieveAllProjectKey();

            var temptypelist = new List <string>();

            temptypelist.Add(PJReportType.YieldTrend);
            temptypelist.Add(PJReportType.IssueTrend);
            temptypelist.Add(PJReportType.FailureTrend);
            temptypelist.Add(PJReportType.MonthlyPareto);
            ViewBag.RepTypeList = temptypelist;

            var username = ckdict["logonuser"].Split(new char[] { '|' })[0];
            var vm       = PJReportViewModels.RetrieveBookReportRecord(username);

            var rsilist = new List <string>();

            string[] rlist = { ReportSelectTime.MON, ReportSelectTime.TUE, ReportSelectTime.WEN, ReportSelectTime.THU, ReportSelectTime.FRI, ReportSelectTime.SAT, ReportSelectTime.SUN, ReportSelectTime.EVE };
            rsilist.AddRange(rlist);
            if (vm != null)
            {
                ViewBag.ReportTimeList = CreateSelectList(rsilist, vm.reporttime);
            }
            else
            {
                ViewBag.ReportTimeList = CreateSelectList(rsilist, "");
            }

            return(View(vm));
        }
        public ActionResult ViewReport()
        {
            var ckdict = CookieUtility.UnpackCookie(this);

            if (ckdict.ContainsKey("logonuser") && !string.IsNullOrEmpty(ckdict["logonuser"]))
            {
            }
            else
            {
                var ck = new Dictionary <string, string>();
                ck.Add("logonredirectctrl", "PJReport");
                ck.Add("logonredirectact", "ViewReport");
                CookieUtility.SetCookie(this, ck);
                return(RedirectToAction("LoginUser", "User"));
            }

            var updater = ckdict["logonuser"].Split(new char[] { '|' })[0];
            var vm      = PJReportViewModels.RetrieveBookReportRecord(updater);

            if (vm == null)
            {
                return(RedirectToAction("ITag"));
            }

            var pjreportdict = new Dictionary <string, PJReportItem>();

            foreach (var pjkey in vm.ProjectList)
            {
                foreach (var reptype in vm.ReportTypeList)
                {
                    if (string.Compare(reptype, PJReportType.YieldTrend) == 0)
                    {
                        ProjectController.ProjectWeeklyTrend(this, pjkey, 14);
                        var reportitem = new PJReportItem();
                        if (!string.IsNullOrEmpty(this.ViewBag.chartscript))
                        {
                            reportitem.YieldTrend    = this.ViewBag.chartscript.Replace("weeklyyield", pjkey + "weeklyyield");
                            this.ViewBag.chartscript = null;
                            if (!pjreportdict.ContainsKey(pjkey))
                            {
                                pjreportdict.Add(pjkey, reportitem);
                            }
                            else
                            {
                                pjreportdict[pjkey].YieldTrend = reportitem.YieldTrend;
                            }
                        }
                    }

                    if (string.Compare(reptype, PJReportType.MonthlyPareto) == 0)
                    {
                        MonthlyPareto(pjkey);
                        if (!string.IsNullOrEmpty(this.ViewBag.rparetoscript))
                        {
                            if (pjreportdict.ContainsKey(pjkey))
                            {
                                pjreportdict[pjkey].MonthlyPareto = ViewBag.rparetoscript.Replace("rparetochart", pjkey + "rparetochart");
                                ViewBag.rparetoscript             = null;
                            }
                            else
                            {
                                var reportitem = new PJReportItem();
                                reportitem.MonthlyPareto = ViewBag.rparetoscript.Replace("rparetochart", pjkey + "rparetochart");
                                ViewBag.rparetoscript    = null;
                                pjreportdict.Add(pjkey, reportitem);
                            }
                        }
                    }

                    if (string.Compare(reptype, PJReportType.IssueTrend) == 0)
                    {
                        IssueCountTrend(pjkey);
                        if (!string.IsNullOrEmpty(this.ViewBag.issuetrendscript))
                        {
                            if (pjreportdict.ContainsKey(pjkey))
                            {
                                pjreportdict[pjkey].IssueTrend = ViewBag.issuetrendscript.Replace("issuetrendchart", pjkey + "issuetrendchart");
                                ViewBag.issuetrendscript       = null;
                            }
                            else
                            {
                                var reportitem = new PJReportItem();
                                reportitem.IssueTrend    = ViewBag.issuetrendscript.Replace("issuetrendchart", pjkey + "issuetrendchart");
                                ViewBag.issuetrendscript = null;
                                pjreportdict.Add(pjkey, reportitem);
                            }
                        }
                    }

                    if (string.Compare(reptype, PJReportType.FailureTrend) == 0)
                    {
                        var chartlist = PJFailureTrend(pjkey);
                        for (var idx = 0; idx < chartlist.Count; idx++)
                        {
                            chartlist[idx] = chartlist[idx].Replace("#ElementID#", pjkey + "failuretrend" + idx);
                        }

                        if (pjreportdict.ContainsKey(pjkey))
                        {
                            pjreportdict[pjkey].FailureTrends = chartlist;
                        }
                        else
                        {
                            var reportitem = new PJReportItem();
                            reportitem.FailureTrends = chartlist;
                            pjreportdict.Add(pjkey, reportitem);
                        }
                    }
                }
            }

            ViewBag.ReportDict = pjreportdict;

            return(View());
        }