private void FillData()
        {
            DictEmployeesPerBucket = new Dictionary <int, List <Employee> >();
            labelDate.Text         = DateShowing.ToString("dddd, MMMM d");
            butEdit.Enabled        = DateShowing.Date >= DateTime.Today;  //do not allow editing of past dates
            listCalls = new List <PointF>();
            if (DateShowing.DayOfWeek == DayOfWeek.Friday)
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 50));               //5-6am
                listCalls.Add(new PointF(6.5f, 133));
                listCalls.Add(new PointF(7.5f, 210));
                listCalls.Add(new PointF(8.5f, 332));
                listCalls.Add(new PointF(9f, 360));               //-
                listCalls.Add(new PointF(9.5f, 370));             //was 380
                listCalls.Add(new PointF(10f, 360));              //-
                listCalls.Add(new PointF(10.5f, 352));            //was 348
                listCalls.Add(new PointF(11.5f, 352));
                listCalls.Add(new PointF(12.5f, 340));            //was 313
                listCalls.Add(new PointF(13.5f, 325));            //was 363
                listCalls.Add(new PointF(14.5f, 277));
                listCalls.Add(new PointF(15.5f, 185));
                listCalls.Add(new PointF(16.5f, 141));
                listCalls.Add(new PointF(17f, 50));
                listCalls.Add(new PointF(17.0f, 0));
            }
            else
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 284));               //5-6am
                listCalls.Add(new PointF(6.5f, 767));
                listCalls.Add(new PointF(7.5f, 1246));
                listCalls.Add(new PointF(8.5f, 1753));
                listCalls.Add(new PointF(9f, 1920));               //-
                listCalls.Add(new PointF(9.5f, 2000));             //was 2029
                listCalls.Add(new PointF(10f, 1950));              //-
                listCalls.Add(new PointF(10.5f, 1875));            //1846
                listCalls.Add(new PointF(11.5f, 1890));            //1899
                listCalls.Add(new PointF(12.5f, 1820));
                listCalls.Add(new PointF(13.5f, 1807));
                listCalls.Add(new PointF(14.5f, 1565));
                listCalls.Add(new PointF(15.5f, 1178));
                listCalls.Add(new PointF(16.5f, 733));
                listCalls.Add(new PointF(17.5f, 226));
                listCalls.Add(new PointF(17.5f, 0));
            }
            buckets    = new float[56];       //Number of total bucket. 4 buckets per hour * 14 hours = 56 buckets.
            ListScheds = Schedules.GetDayList(DateShowing);
            //PhoneGraph exceptions will take precedence over employee default
            List <PhoneGraph> listPhoneGraphs = PhoneGraphs.GetAllForDate(DateShowing);
            TimeSpan          time1;
            TimeSpan          time2;
            TimeSpan          delta;

            for (int i = 0; i < ListScheds.Count; i++)
            {
                if (ListScheds[i].SchedType != ScheduleType.Employee)
                {
                    continue;
                }
                //get this employee
                Employee employee = Employees.GetEmp(ListScheds[i].EmployeeNum);
                if (employee == null)               //employees will NEVER be deleted. even after they cease to work here. but just in case.
                {
                    continue;
                }
                bool hasPhoneGraphEntry = false;
                bool isGraphed          = false;
                //PhoneGraph entries will take priority over the default employee graph state
                for (int iPG = 0; iPG < listPhoneGraphs.Count; iPG++)
                {
                    if (listPhoneGraphs[iPG].EmployeeNum == employee.EmployeeNum)
                    {
                        isGraphed          = listPhoneGraphs[iPG].IsGraphed;
                        hasPhoneGraphEntry = true;
                        break;
                    }
                }
                if (!hasPhoneGraphEntry)                 //no phone graph entry found (likely for a future date which does not have entries created yet OR past date where current employee didn't work here yet)
                {
                    if (DateShowing <= DateTime.Today)   //no phone graph entry and we are on a past OR current date. if it's not already created then don't graph this employee for this date
                    {
                        continue;
                    }
                    //we are on a future date AND we don't have a PhoneGraph entry explicitly set so use the default for this employee
                    PhoneEmpDefault ped = PhoneEmpDefaults.GetEmpDefaultFromList(ListScheds[i].EmployeeNum, ListPED);
                    if (ped == null)                   //we will default to PhoneEmpDefault.IsGraphed so make sure the deafult exists
                    {
                        continue;
                    }
                    //no entry in PhoneGraph for the employee on this date so use the default
                    isGraphed = ped.IsGraphed;
                }
                if (!isGraphed)                 //only care about employees that are being graphed
                {
                    continue;
                }
                for (int b = 0; b < buckets.Length; b++)
                {
                    //minutes field multiplier is a function of buckets per hour. answers the question, "how many minutes long is each bucket?"
                    time1 = new TimeSpan(5, 0, 0) + new TimeSpan(0, b * 15, 0);
                    time2 = new TimeSpan(5, 15, 0) + new TimeSpan(0, b * 15, 0);
                    //situation 1: this bucket is completely within the start and stop times.
                    if (ListScheds[i].StartTime <= time1 && ListScheds[i].StopTime >= time2)
                    {
                        AddEmployeeToBucket(b, employee);
                    }
                    //situation 2: the start time is after this bucket
                    else if (ListScheds[i].StartTime >= time2)
                    {
                        continue;
                    }
                    //situation 3: the stop time is before this bucket
                    else if (ListScheds[i].StopTime <= time1)
                    {
                        continue;
                    }
                    //situation 4: start time falls within this bucket
                    if (ListScheds[i].StartTime > time1)
                    {
                        delta = ListScheds[i].StartTime - time1;
                        //7.5 minutes is half of one bucket.
                        if (delta.TotalMinutes > 7.5)                          //has to work more than 15 minutes to be considered *in* this bucket
                        {
                            AddEmployeeToBucket(b, employee);
                        }
                    }
                    //situation 5: stop time falls within this bucket
                    if (ListScheds[i].StopTime < time2)
                    {
                        delta = time2 - ListScheds[i].StopTime;
                        if (delta.TotalMinutes > 7.5)                          //has to work more than 15 minutes to be considered *in* this bucket
                        {
                            AddEmployeeToBucket(b, employee);
                        }
                    }
                }
                //break;//just show one sched for debugging.
            }
            //missed calls
            //missedCalls=new int[28];
            //List<DateTime> callTimes=PhoneAsterisks.GetMissedCalls(dateShowing);
            //for(int i=0;i<callTimes.Count;i++) {
            //  for(int b=0;b<missedCalls.Length;b++) {
            //    time1=new TimeSpan(5,0,0) + new TimeSpan(0,b*30,0);
            //    time2=new TimeSpan(5,30,0) + new TimeSpan(0,b*30,0);
            //    if(callTimes[i].TimeOfDay >= time1 && callTimes[i].TimeOfDay < time2) {
            //      missedCalls[b]++;
            //    }
            //  }
            //}
            //Minutes Behind
            minutesBehind = PhoneMetrics.AverageMinutesBehind(DateShowing);
            this.Invalidate();
        }
        private void FillGrid()
        {
            //get PhoneGraph entries for this date
            ListPhoneGraphsForDate = PhoneGraphs.GetAllForDate(DateEdit);
            //get current employee defaults
            ListPhoneEmpDefaults = PhoneEmpDefaults.Refresh();
            ListPhoneEmpDefaults.Sort(new PhoneEmpDefaults.PhoneEmpDefaultComparer(PhoneEmpDefaults.PhoneEmpDefaultComparer.SortBy.name));
            //get schedules
            ListSchedulesForDate = Schedules.GetDayList(DateEdit);
            long selectedEmployeeNum = -1;

            if (gridGraph.Rows.Count >= 1 &&
                gridGraph.GetSelectedIndex() >= 0 &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag != null &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag is PhoneEmpDefault)
            {
                selectedEmployeeNum = ((PhoneEmpDefault)gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag).EmployeeNum;
            }
            gridGraph.BeginUpdate();
            gridGraph.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Employee"), 80);

            gridGraph.Columns.Add(col);             //column 0 (name - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Schedule"), 130);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 1 (schedule - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Graph Default"), 90);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 2 (default - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Set Graph Status"), 110);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 3 (set graph status - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Is Overridden?"), 80);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 4 (is value an overridde of default? - not clickable)
            gridGraph.Rows.Clear();
            int selectedRow = -1;

            //loop through all employee defaults and create 1 row per employee
            for (int iPED = 0; iPED < ListPhoneEmpDefaults.Count; iPED++)
            {
                PhoneEmpDefault phoneEmpDefault = ListPhoneEmpDefaults[iPED];
                Employee        employee        = Employees.GetEmp(phoneEmpDefault.EmployeeNum);
                if (employee == null || employee.IsHidden)               //only deal with current employees
                {
                    continue;
                }
                List <Schedule> scheduleForEmployee = Schedules.GetForEmployee(ListSchedulesForDate, phoneEmpDefault.EmployeeNum);
                bool            isGraphed           = phoneEmpDefault.IsGraphed; //set default
                bool            hasOverride         = false;
                for (int iPG = 0; iPG < ListPhoneGraphsForDate.Count; iPG++)     //we have a default, now loop through all known exceptions and find a match
                {
                    PhoneGraph phoneGraph = ListPhoneGraphsForDate[iPG];
                    if (phoneEmpDefault.EmployeeNum == ListPhoneGraphsForDate[iPG].EmployeeNum)                   //found a match so no op necessary for this employee
                    {
                        isGraphed   = phoneGraph.IsGraphed;
                        hasOverride = true;
                        break;
                    }
                }
                ODGridRow row;
                row = new ODGridRow();
                row.Cells.Add(phoneEmpDefault.EmpName);                                                           //column 0 (name - not clickable)
                row.Cells.Add(Schedules.GetCommaDelimStringForScheds(scheduleForEmployee).Replace(", ", "\r\n")); //column 1 (shift times - not clickable)
                row.Cells.Add(phoneEmpDefault.IsGraphed?"X":"");                                                  //column 2 (default - not clickable)
                row.Cells.Add(isGraphed?"X":"");                                                                  //column 3 (set graph status - clickable)
                row.Cells.Add(hasOverride && isGraphed != phoneEmpDefault.IsGraphed?"X":"");                      //column 4 (is overridden to IsGraphed? - not clickable)
                row.Tag = phoneEmpDefault;                                                                        //store the employee for click events
                int rowIndex = gridGraph.Rows.Add(row);
                if (selectedEmployeeNum == phoneEmpDefault.EmployeeNum)
                {
                    selectedRow = rowIndex;
                }
            }
            gridGraph.EndUpdate();
            if (selectedRow >= 0)
            {
                gridGraph.SetSelected(selectedRow, true);
            }
        }
示例#3
0
        private void FillData()
        {
            labelDate.Text = dateShowing.ToString("dddd, MMMM d");
            listCalls      = new List <PointF>();
            if (dateShowing.DayOfWeek == DayOfWeek.Friday)
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 50));               //5-6am
                listCalls.Add(new PointF(6.5f, 133));
                listCalls.Add(new PointF(7.5f, 210));
                listCalls.Add(new PointF(8.5f, 332));
                listCalls.Add(new PointF(9f, 360));               //-
                listCalls.Add(new PointF(9.5f, 370));             //was 380
                listCalls.Add(new PointF(10f, 360));              //-
                listCalls.Add(new PointF(10.5f, 352));            //was 348
                listCalls.Add(new PointF(11.5f, 352));
                listCalls.Add(new PointF(12.5f, 340));            //was 313
                listCalls.Add(new PointF(13.5f, 325));            //was 363
                listCalls.Add(new PointF(14.5f, 277));
                listCalls.Add(new PointF(15.5f, 185));
                listCalls.Add(new PointF(16.5f, 141));
                listCalls.Add(new PointF(17f, 50));
                listCalls.Add(new PointF(17.0f, 0));
            }
            else
            {
                listCalls.Add(new PointF(5f, 0));
                listCalls.Add(new PointF(5.5f, 284));               //5-6am
                listCalls.Add(new PointF(6.5f, 767));
                listCalls.Add(new PointF(7.5f, 1246));
                listCalls.Add(new PointF(8.5f, 1753));
                listCalls.Add(new PointF(9f, 1920));               //-
                listCalls.Add(new PointF(9.5f, 2000));             //was 2029
                listCalls.Add(new PointF(10f, 1950));              //-
                listCalls.Add(new PointF(10.5f, 1875));            //1846
                listCalls.Add(new PointF(11.5f, 1890));            //1899
                listCalls.Add(new PointF(12.5f, 1820));
                listCalls.Add(new PointF(13.5f, 1807));
                listCalls.Add(new PointF(14.5f, 1565));
                listCalls.Add(new PointF(15.5f, 1178));
                listCalls.Add(new PointF(16.5f, 733));
                listCalls.Add(new PointF(17.5f, 226));
                listCalls.Add(new PointF(17.5f, 0));
            }
            buckets = new float[28];          //every 30 minutes, starting at 5:15
            //usedLunch=new bool[28];
            List <Schedule> scheds = Schedules.GetDayList(dateShowing);
            TimeSpan        time1;
            TimeSpan        time2;
            TimeSpan        delta;

            for (int i = 0; i < scheds.Count; i++)
            {
                if (scheds[i].SchedType != ScheduleType.Employee)
                {
                    continue;
                }
                if (PhoneEmpDefaults.IsNoGraph(scheds[i].EmployeeNum, ListPED))
                {
                    continue;
                }
                //TimeSpan lunch=scheds[i].StartTime + new TimeSpan((scheds[i].StopTime-scheds[i].StartTime).Ticks/2) - new TimeSpan(0,37,0);//subtract 37 minutes to make it fall within a bucket, and because people seem to like to take lunch early, and because the logic will bump it forward if lunch already used.
                for (int b = 0; b < buckets.Length; b++)
                {
                    time1 = new TimeSpan(5, 0, 0) + new TimeSpan(0, b * 30, 0);
                    time2 = new TimeSpan(5, 30, 0) + new TimeSpan(0, b * 30, 0);
                    //if the lunchtime is within this bucket

                    /*if(lunch >= time1 && lunch < time2) {
                     *      if(usedLunch[b]) {//can't use this bucket for lunch because someone else already did.
                     *              lunch+=new TimeSpan(0,30,0);//move lunch forward half an hour
                     *      }
                     *      else {
                     *              usedLunch[b]=true;
                     *              continue;//used this bucket for lunch (don't add a drop to the bucket)
                     *      }
                     * }*/
                    //situation 1: this bucket is completely within the start and stop times.
                    if (scheds[i].StartTime <= time1 && scheds[i].StopTime >= time2)
                    {
                        buckets[b] += 1;
                    }
                    //situation 2: the start time is after this bucket
                    else if (scheds[i].StartTime >= time2)
                    {
                        continue;
                    }
                    //situation 3: the stop time is before this bucket
                    else if (scheds[i].StopTime <= time1)
                    {
                        continue;
                    }
                    //situation 4: start time falls within this bucket
                    if (scheds[i].StartTime > time1)
                    {
                        delta       = scheds[i].StartTime - time1;
                        buckets[b] += (float)delta.TotalHours * 2f;                       //example, .5 hours would add 1 to the bucket
                    }
                    //situation 5: stop time falls within this bucket
                    if (scheds[i].StopTime < time2)
                    {
                        delta       = time2 - scheds[i].StopTime;
                        buckets[b] += (float)delta.TotalHours * 2f;
                    }
                }
                //break;//just show one sched for debugging.
            }
            //missed calls
            missedCalls = new int[28];
            List <DateTime> callTimes = PhoneAsterisks.GetMissedCalls(dateShowing);

            for (int i = 0; i < callTimes.Count; i++)
            {
                for (int b = 0; b < missedCalls.Length; b++)
                {
                    time1 = new TimeSpan(5, 0, 0) + new TimeSpan(0, b * 30, 0);
                    time2 = new TimeSpan(5, 30, 0) + new TimeSpan(0, b * 30, 0);
                    if (callTimes[i].TimeOfDay >= time1 && callTimes[i].TimeOfDay < time2)
                    {
                        missedCalls[b]++;
                    }
                }
            }
            this.Invalidate();
        }