Пример #1
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();
        }