Exemplo n.º 1
0
        public string GetPageInfo()
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            var    msg = "";
            string downByDate, mowDate;

            WFMHelper.GetReportDates(out downByDate, out mowDate);
            var allAgents = WFMHelper.GetAllAgents();
            var agentList = WFMHelper.GetStaffList(allAgents, out msg);
            //var eventList = WFMHelper.GetEventList(DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(2).ToString("yyyy-MM-dd"));
            var managerList   = WFMHelper.GetManagerList(agentList); //TODO: Remove this?
            var mowList       = WFMHelper.GetMowList(agentList);
            var lateShift     = WFMHelper.GetLateShift();
            var icmSchedule   = WFMHelper.GetIcmSchedule();
            var mowSchedule   = WFMHelper.GetMowSchedule(DateTimeExtensions.StartOfWeek(DateTime.Now, DayOfWeek.Monday));
            var latestIcmInfo = WFMHelper.GetLatestIcmInfo(icmSchedule.Last().Value.Last());
            var invitees      = WFMHelper.GetInvitees(allAgents);

            //var latestMowInfo = WFMHelper.GetLatestMowInfo();
            return(JsonConvert.SerializeObject(new { success = msg.ToLower().Contains("success"), msg = msg, downByDate = downByDate, mowDate = mowDate, agentList = agentList, mowList = mowList, managerList = managerList, lateShift = lateShift, icmSchedule = icmSchedule, mowSchedule = mowSchedule, latestIcmInfo = latestIcmInfo, invitees = invitees }));
            //return JsonConvert.SerializeObject(new { success = msg.ToLower().Contains("success"), msg = msg, downByDate = downByDate, mowDate = mowDate, eventList = eventList, agentList = agentList, mowList = mowList, managerList = managerList, lateShift = lateShift, icmSchedule = icmSchedule, mowSchedule = mowSchedule, latestIcmInfo = latestIcmInfo });
        }
Exemplo n.º 2
0
        public async Task <string> SubmitEventForm(CancellationToken cancellationToken, EventForm inputForm)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} called SubmitEventForm \r\n Params: InputForm: {inputForm.ToString()}");
            string msg        = "";
            var    googleAuth = await new AuthorizationCodeMvcAppOverride(this, new AppFlowMetadata(user.LdapUserId)).AuthorizeAsync(cancellationToken);

            if (googleAuth.Credential == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "Error - please refresh page and log back into Google Calendar" }));
            }
            else
            {
                //List<ViewEvent> eventObject = WFMHelper.SubmitEventForm(googleAuth, inputForm, user.LdapUserId, out msg);
                var success = WFMHelper.SubmitEventForm(googleAuth, inputForm, user.LdapUserId, out msg);

                return(JsonConvert.SerializeObject(new { success = success, msg = msg }));
            }
        }
Exemplo n.º 3
0
        public string GetMowScheduleWeek(string mondayString)
        {
            var monday      = DateTime.Parse(mondayString);
            var mowSchedule = WFMHelper.GetMowSchedule(monday);

            return(JsonConvert.SerializeObject(new { mowSchedule = mowSchedule, success = mowSchedule != null }));
        }
Exemplo n.º 4
0
        public ActionResult CreateMOWReport()
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(RedirectToAction("Error", new { msg = "You are not authorized to use WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} created MOW Report");
            string msg = "";

            ViewBag.Title      = "WFM Dashboard";
            ViewBag.ReportType = "MOW";
            var report = WFMHelper.CreateMOWReport(out msg);

            if (report != null)
            {
                ViewBag.report = report;
                var reportString = RenderRazorViewToString("~/Views/Mailer/MowReport.cshtml", ViewBag);
                ViewBag.ReportText = reportString;
                return(View("~/Views/Home/Report.cshtml"));
            }
            else
            {
                log.Warn("Something went wrong creating MOW report");
                return(RedirectToAction("Error", new { msg = msg }));
            }
            //success = WFMHelper.CreateMOWReport();
            //return JsonConvert.SerializeObject(new { success = success, msg = msg });
        }
Exemplo n.º 5
0
        public string GetTeamInfo(int agentNo)
        {
            string msg      = "";
            var    teamInfo = WFMHelper.GetTeamInfo(agentNo);

            return(JsonConvert.SerializeObject(new { success = teamInfo != null, msg = msg, teamInfo = teamInfo }));
        }
Exemplo n.º 6
0
        public string GetEvents(string start, string end)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            var eventList = WFMHelper.GetEventList(start, end);

            return(JsonConvert.SerializeObject(eventList));
        }
Exemplo n.º 7
0
        public string DeleteMowRow(int rowId)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} called DeleteMowRow - Params: /r/n id: {rowId}");
            string msg;
            var    success = WFMHelper.DeleteMowRow(rowId, out msg);

            return(JsonConvert.SerializeObject(new { success = success, msg = msg }));
        }
Exemplo n.º 8
0
        public string SendReport(string reportContent, string reportType)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "Error - you are not authorized to use WFM DAshboard" }));
            }
            log.Info($"User {user.LdapUserId} sent the {reportType} Report");

            var success = WFMHelper.SendReport(reportContent, reportType);

            return(JsonConvert.SerializeObject(new { success = success, msg = "Successfully sent report" }));
        }
Exemplo n.º 9
0
        public string SubmitLateShiftForm(string date, int agentNo)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} called SubmitLateShiftForm /r/n/ date: {date} \r\n agentNo: {agentNo}");
            string msg;
            var    success   = WFMHelper.SubmitLateShiftForm(date, agentNo, out msg);
            var    lateShift = WFMHelper.GetLateShift();

            return(JsonConvert.SerializeObject(new { lateShift = lateShift, success = success, msg = msg }));
        }
Exemplo n.º 10
0
        //public string DownloadMowScheduleSpreadsheet(string mondayString)
        //{
        //    var monday = DateTime.Parse(mondayString);
        //    var mowSchedule = WFMHelper.GetMowSchedule(monday);
        //    return JsonConvert.SerializeObject(new { mowSchedule = mowSchedule, success = mowSchedule != null });
        //}


        public string SubmitIcmForm(int month, int year, int agentNo)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} called SubmitIcmForm - Params: /r/n month: {month} \r\n year: {year} \r\n agentNo: {agentNo}");
            string msg;
            bool   success;
            var    icmSchedule = WFMHelper.SubmitIcmForm(month, year, agentNo, out msg, out success);

            //var latestIcmInfo = WFMHelper.GetLatestIcmInfo(icmSchedule.Last().Value.Last());
            //return JsonConvert.SerializeObject(new { success = success, msg = msg, icmSchedule = icmSchedule, latestIcmInfo = latestIcmInfo });
            return(JsonConvert.SerializeObject(new { success = success, msg = msg, icmSchedule = icmSchedule }));
        }
Exemplo n.º 11
0
        //public void DownloadMowSpreadsheet(DateTime week)
        public void DownloadMowSpreadsheet(string monday)
        {
            var week      = DateTime.Parse(monday);
            var byteArray = WFMHelper.CreateMowSpreadsheet(week);

            //Write it back to the client
            if (byteArray == null)
            {
                log.Warn("Something went wrong creating MOW spreadsheet");
                RedirectToAction("Error", new { msg = "Error creating spreadsheet" });
            }
            else
            {
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=_______________ WFO and MOW Schedule.xlsx");
                Response.BinaryWrite(byteArray);
            }
        }
Exemplo n.º 12
0
        public string SubmitMowForm(MowFormInput Item, string MondayString)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} called SubmitMowForm /r/n/ MondayString: {MondayString} \r\n InputItem: {Item.ToString()}");
            string msg;
            bool   success;
            var    mowSchedule = WFMHelper.SubmitMowForm(Item, MondayString, out msg, out success);

            //var icmSchedule = WFMHelper.SubmitIcmForm(month, year, agentNo, out msg, out success);
            //var latestIcmInfo = WFMHelper.GetLatestIcmInfo(icmSchedule.Last().Value.Last());
            //return JsonConvert.SerializeObject(new { success = success, msg = msg, icmSchedule = icmSchedule, latestIcmInfo = latestIcmInfo });
            return(JsonConvert.SerializeObject(new { mowSchedule = mowSchedule, success = success, msg = msg }));
        }
Exemplo n.º 13
0
        public async Task <ActionResult> CreateDownByReport(CancellationToken cancellationToken)
        {
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(RedirectToAction("Error", new { msg = "You are not authorized to use WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} created Down By Report");
            string msg = "";

            //bool success = false;
            ViewBag.Title      = "WFM Dashboard - Confirm Report";
            ViewBag.Username   = user.FirstName + " " + user.LastName;
            ViewBag.ReportType = "Down";
            var googleAuth = await new AuthorizationCodeMvcAppOverride(this, new AppFlowMetadata(user.LdapUserId)).AuthorizeAsync(cancellationToken);

            if (googleAuth.Credential != null)
            {
                var report = WFMHelper.CreateDownByReport(googleAuth, out msg);

                if (report != null)
                {
                    ViewBag.report = report;
                    //return View("~/Views/Mailer/DownByReport.cshtml");
                    var reportString = RenderRazorViewToString("~/Views/Mailer/DownByReport.cshtml", ViewBag);
                    ViewBag.ReportText = reportString;
                    return(View("~/Views/Home/Report.cshtml"));
                }
                else
                {
                    log.Warn("Something went wrong creating Down By report");
                    return(RedirectToAction("Error", new { msg = msg }));
                }
            }
            else
            {
                log.Info($"User {user.LdapUserId} is logging into google calendar");
                ViewBag.Title = "WFM Dashboard";
                return(new RedirectResult(googleAuth.RedirectUri));
            }
        }
Exemplo n.º 14
0
        public async Task <string> CancelEvent(CancellationToken cancellationToken, int eventId)
        {
            var success = false;
            var user    = HttpContext.KmIdentity();
            var WFMUser = getWFMUser(user.LdapUserId);

            if (WFMUser == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "You are not authorized to access WFM Dashboard" }));
            }
            log.Info($"User {user.LdapUserId} cancelled event {eventId}");
            var googleAuth = await new AuthorizationCodeMvcAppOverride(this, new AppFlowMetadata(user.LdapUserId)).AuthorizeAsync(cancellationToken);

            if (googleAuth.Credential == null)
            {
                return(JsonConvert.SerializeObject(new { success = false, msg = "Error - please refresh page and log back into Google Calendar" }));
            }
            else
            {
                success = WFMHelper.CancelEvent(googleAuth, eventId);
            }
            return(JsonConvert.SerializeObject(new { success = success }));
        }
Exemplo n.º 15
0
        public string GetRepeatingEventInfo(int eventId)
        {
            var results = WFMHelper.GetRepeatingEventInfo(eventId);

            return(JsonConvert.SerializeObject(new { success = results != null, results = results }));
        }