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 PopulateProjects(JsonResultProjects oProjects, List <JsonResultTasks> oTasks)
        {
            JsonResultProject oProject;

            SLDocument sl = new SLDocument();

            int row = 1;

            try
            {
                for (int i = 0; i < oProjects.projects.Count; i++)
                {
                    // Extract a project
                    oProject = oProjects.projects.ElementAt(i);

                    for (int j = 0; j < oTasks[i].tasks.Count; j++)
                    {
                        sl.SetCellValue("A" + row, oTasks[i].tasks[j].companyname);
                        sl.SetCellValue("B" + row, oProject.title);
                        sl.SetCellValue("C" + row, oProject.categoryname);
                        sl.SetCellValue("D" + row, oProject.managername);
                        sl.SetCellValue("E" + row, oProject.startdate.Split('T')[0]);
                        sl.SetCellValue("F" + row, oProject.duedate.Split('T')[0]);
                        sl.SetCellValue("G" + row, oTasks[i].tasks[j].completedate.Split('T')[0]);
                        sl.SetCellValue("H" + row, oTasks[i].tasks[j].name);
                        sl.SetCellValue("I" + row, oTasks[i].tasks[j].status);
                        sl.SetCellValue("J" + row, oTasks[i].tasks[j].ordernumber);
                        row++;
                    }
                }
                FormatProjectReport(sl);

                sl.SaveAs("\\\\bigdell\\Clients\\Omega\\00 Analytics\\Project Status\\Data\\Active-Projects-Tasks.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);
        }