public void PopulateBilling(JsonResultTimes oTimes)
        {
            JsonResultTime oTime;
            SLDocument     sl  = new SLDocument();
            int            row = 1;

            try
            {
                for (int i = 0; i < oTimes.timerecords.Count; i++)
                {
                    oTime = oTimes.timerecords.ElementAt(i);

                    sl.SetCellValue("A" + row, oTime.projecttitle);
                    sl.SetCellValue("B" + row, oTime.companyname);
                    sl.SetCellValue("C" + row, oTime.taskname);
                    sl.SetCellValue("D" + row, oTime.starttime.ToString("MM-dd-yyy"));
                    sl.SetCellValue("E" + row, oTime.contactname);
                    sl.SetCellValue("F" + row, oTime.timetracked / 60);
                    sl.SetCellValue("G" + row, oTime.notes);
                    row++;
                }
                FormatBillingReport(sl);

                sl.SaveAs("C:\\Users\\John Fleischli\\Downloads\\Billing Report.xlsx");
            }
            catch (Exception e)
            {
                SlackClient client = new SlackClient("");
                client.PostMessage("PWF API Tool Error: " + e.ToString().Substring(0, 100), "PWF API Admin", "C9X3YGW5B");
                Environment.Exit(1);
            }
        }
        public Form1()
        {
            InitializeComponent();

            oXL  = new ExcelHelper();
            oAPI = new PWFAPIHelper();

            dateToPicker.MaxDate   = DateTime.Today;
            dateFromPicker.MaxDate = DateTime.Today;

            string timeFrom = DateTime.Today.ToString("yyyy-MM");

            timeFrom = timeFrom + "-01";
            string timeTo     = DateTime.Today.ToString("yyyy-MM-dd");
            string reportName = dateFromPicker.Value.Date.ToString("yyyy-MM");
            // Populate DataGridView with Projects
            List <JsonResultTasks> oTasks    = new List <JsonResultTasks>();
            JsonResultProjects     oProjects = oAPI.GetProjects();
            JsonResultTimes        oTimes    = oAPI.GetTime(timeFrom, timeTo);


            foreach (JsonResultProject project in oProjects.projects)
            {
                JsonResultTasks tasks = oAPI.GetTasks(project.id.ToString());
                oTasks.Add(tasks);
            }

            oXL.PopulateProjects(oProjects, oTasks);
            oXL.PopulateTime(oTimes, reportName);
            //oXL.PopulateBilling(oTimes);
        }
        public void PopulateTime(JsonResultTimes oTimes, string reportName)
        {
            JsonResultTime oTime;
            SLDocument     sl  = new SLDocument();
            int            row = 1;

            try
            {
                for (int i = 0; i < oTimes.timerecords.Count; i++)
                {
                    oTime = oTimes.timerecords.ElementAt(i);

                    sl.SetCellValue("A" + row, oTime.companyname);
                    sl.SetCellValue("B" + row, oTime.projecttitle);
                    sl.SetCellValue("C" + row, oTime.categoryname);
                    sl.SetCellValue("D" + row, oTime.contactname);
                    sl.SetCellValue("E" + row, oTime.taskname);
                    sl.SetCellValue("F" + row, oTime.timetracked / 60);
                    sl.SetCellValue("G" + row, oTime.starttime.ToString("MM-dd-yyy"));
                    row++;
                }
                FormatTimeReport(sl);

                sl.SaveAs("\\\\bigdell\\Clients\\Omega\\00 Analytics\\Hours\\Data\\Actual\\" + reportName + ".xlsx");
            }
            catch (Exception e)
            {
                SlackClient client = new SlackClient("");
                client.PostMessage("PWF API Tool Error: " + e.ToString(), "PWF API Admin", "C9X3YGW5B");
                Environment.Exit(1);
            }
        }
        private void updateButton_Click(object sender, EventArgs e)
        {
            string timeFrom   = dateFromPicker.Value.Date.ToString("yyyy-MM-dd");
            string timeTo     = dateToPicker.Value.Date.ToString("yyyy-MM-dd");
            string reportName = dateFromPicker.Value.Date.ToString("yyyy-MM");
            // Populate DataGridView with Projects
            List <JsonResultTasks> oTasks    = new List <JsonResultTasks>();
            JsonResultProjects     oProjects = oAPI.GetProjects();
            JsonResultTimes        oTimes    = oAPI.GetTime(timeFrom, timeTo);


            foreach (JsonResultProject project in oProjects.projects)
            {
                JsonResultTasks tasks = oAPI.GetTasks(project.id.ToString());
                oTasks.Add(tasks);
            }

            oXL.PopulateProjects(oProjects, oTasks);
            oXL.PopulateTime(oTimes, reportName);
            //oXL.PopulateBilling(oTimes);
        }