private void FillTiles(bool refreshList) { if (refreshList) //Refresh the phone list. This will cause a database refresh for our list and call this function again with the new list. { SetPhoneList(PhoneEmpDefaults.Refresh(), Phones.GetPhoneList(), ChatUsers.GetAll()); return; } if (PhoneList == null) { return; } PhoneTile tile; for (int i = 0; i < TileCount; i++) { //Application.DoEvents(); Control[] controlMatches = Controls.Find("phoneTile" + (i + 1).ToString(), false); if (controlMatches.Length == 0) //no match found for some reason. { continue; } tile = ((PhoneTile)controlMatches[0]); tile.TimeDelta = timeDelta; tile.ShowImageForced = checkBoxAll.Checked; if (PhoneList.Count > i) { tile.SetPhone(PhoneList[i], PhoneEmpDefaults.GetEmpDefaultFromList(PhoneList[i].EmployeeNum, PhoneEmpDefaultList), ChatList.Where(x => x.Extension == PhoneList[i].Extension).FirstOrDefault(), PhoneEmpDefaults.IsTriageOperatorForExtension(PhoneList[i].Extension, PhoneEmpDefaultList)); } else { Controls.Remove(tile); } } }
private void FillTile() { //Get the new phone list from the database and redraw control. SetPhoneList(PhoneEmpDefaults.Refresh(), Phones.GetPhoneList()); //Set the currently selected phone accordingly. if (phoneList == null) //No phone list. Shouldn't get here. { phoneTile.SetPhone(null, null, false); return; } Phone phone = Phones.GetPhoneForExtension(phoneList, Extension); PhoneEmpDefault phoneEmpDefault = null; if (phone != null) { phoneEmpDefault = PhoneEmpDefaults.GetEmpDefaultFromList(phone.EmployeeNum, phoneEmpDefaultList); } phoneTile.SetPhone(phone, phoneEmpDefault, PhoneEmpDefaults.IsTriageOperatorForExtension(Extension, phoneEmpDefaultList)); }
private void FillTile() { //UpdateComboRooms();//We can't do this in the constructor and all the other methods fire too often. FillTile is a good place for this. //Get the new phone list from the database and redraw control. SetPhoneList(PhoneEmpDefaults.Refresh(), Phones.GetPhoneList()); //Set the currently selected phone accordingly. if (_listPhones == null) //No phone list. Shouldn't get here. { phoneTile.SetPhone(null, null, null, false); return; } Phone phone = Phones.GetPhoneForExtension(_listPhones, Extension); PhoneEmpDefault phoneEmpDefault = null; ChatUser chatUser = null; if (phone != null) { phoneEmpDefault = PhoneEmpDefaults.GetEmpDefaultFromList(phone.EmployeeNum, _listPhoneEmpDefaults); chatUser = ChatUsers.GetFromExt(phone.Extension); } phoneTile.SetPhone(phone, phoneEmpDefault, chatUser, PhoneEmpDefaults.IsTriageOperatorForExtension(Extension, _listPhoneEmpDefaults)); }
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(); }
///<summary>Refresh the phone panel every X seconds after it has already been setup. Make sure to call FillMapAreaPanel before calling this the first time.</summary> public void SetPhoneList(List <PhoneEmpDefault> peds, List <Phone> phones, List <PhoneEmpSubGroup> listSubGroups, List <ChatUser> listChatUsers) { try { string title = "Call Center Map - Triage Coord. - "; try { //get the triage coord label but don't fail just because we can't find it SiteLink siteLink = SiteLinks.GetFirstOrDefault(x => x.SiteNum == _mapCur.SiteNum); title += Employees.GetNameFL(Employees.GetEmp(siteLink.EmployeeNum)); } catch { title += "Not Set"; } labelTriageCoordinator.Text = title; labelCurrentTime.Text = DateTime.Now.ToShortTimeString(); #region Triage Counts //The triage count used to only count up the triage operators within the currently selected room. //Now we want to count all operators at the selected site (local) and then all operators across all sites (total). int triageStaffCountLocal = 0; int triageStaffCountTotal = 0; foreach (PhoneEmpDefault phoneEmpDefault in peds.FindAll(x => x.IsTriageOperator && x.HasColor)) { Phone phone = phones.FirstOrDefault(x => x.Extension == phoneEmpDefault.PhoneExt); if (phone == null) { continue; } if (phone.ClockStatus.In(ClockStatusEnum.None, ClockStatusEnum.Home, ClockStatusEnum.Lunch, ClockStatusEnum.Break, ClockStatusEnum.Off , ClockStatusEnum.Unavailable, ClockStatusEnum.NeedsHelp, ClockStatusEnum.HelpOnTheWay)) { continue; } //This is a triage operator who is currently here and on the clock. if (phoneEmpDefault.SiteNum == _mapCur.SiteNum) { triageStaffCountLocal++; } triageStaffCountTotal++; } labelTriageOpsCountLocal.Text = triageStaffCountLocal.ToString(); labelTriageOpsCountTotal.Text = triageStaffCountTotal.ToString(); #endregion for (int i = 0; i < this.mapAreaPanelHQ.Controls.Count; i++) //loop through all of our cubicles and labels and find the matches { try { if (!(this.mapAreaPanelHQ.Controls[i] is MapAreaRoomControl)) { continue; } MapAreaRoomControl room = (MapAreaRoomControl)this.mapAreaPanelHQ.Controls[i]; if (room.MapAreaItem.Extension == 0) //This cubicle has not been given an extension yet. { room.Empty = true; continue; } Phone phone = Phones.GetPhoneForExtension(phones, room.MapAreaItem.Extension); if (phone == null) //We have a cubicle with no corresponding phone entry. { room.Empty = true; continue; } ChatUser chatuser = listChatUsers.Where(x => x.Extension == phone.Extension).FirstOrDefault(); PhoneEmpDefault phoneEmpDefault = PhoneEmpDefaults.GetEmpDefaultFromList(phone.EmployeeNum, peds); if (phoneEmpDefault == null) //We have a cubicle with no corresponding phone emp default entry. { room.Empty = true; continue; } //we got this far so we found a corresponding cubicle for this phone entry room.EmployeeNum = phone.EmployeeNum; room.EmployeeName = phone.EmployeeName; if (phone.DateTimeNeedsHelpStart.Date == DateTime.Today) //if they need help, use that time. { TimeSpan span = DateTime.Now - phone.DateTimeNeedsHelpStart + _timeDelta; DateTime timeOfDay = DateTime.Today + span; room.Elapsed = timeOfDay.ToString("H:mm:ss"); } else if (phone.DateTimeStart.Date == DateTime.Today && phone.Description != "") //else if in a call, use call time. { TimeSpan span = DateTime.Now - phone.DateTimeStart + _timeDelta; DateTime timeOfDay = DateTime.Today + span; room.Elapsed = timeOfDay.ToString("H:mm:ss"); } else if (phone.Description == "" && chatuser != null && chatuser.CurrentSessions > 0) //else if in a chat, use chat time. { TimeSpan span = TimeSpan.FromMilliseconds(chatuser.SessionTime) + _timeDelta; room.Elapsed = span.ToStringHmmss(); } else if (phone.DateTimeStart.Date == DateTime.Today) //else available, use that time. { TimeSpan span = DateTime.Now - phone.DateTimeStart + _timeDelta; DateTime timeOfDay = DateTime.Today + span; room.Elapsed = timeOfDay.ToString("H:mm:ss"); } else //else, whatever. { room.Elapsed = ""; } if (phone.IsProxVisible) { room.ProxImage = Properties.Resources.Figure; } else if (phone.DateTProximal.AddHours(8) > DateTime.Now) { room.ProxImage = Properties.Resources.NoFigure; //TODO: replace image with one from Nathan } else { room.ProxImage = null; } room.IsAtDesk = phone.IsProxVisible; string status = Phones.ConvertClockStatusToString(phone.ClockStatus); //Check if the user is logged in. if (phone.ClockStatus == ClockStatusEnum.None || phone.ClockStatus == ClockStatusEnum.Home) { status = "Home"; } room.Status = status; if (phone.Description == "") { room.PhoneImage = null; if (chatuser != null && chatuser.CurrentSessions != 0) { room.ChatImage = Properties.Resources.gtaicon3; } else { room.ChatImage = null; } } else { room.PhoneImage = Properties.Resources.phoneInUse; } Color outerColor; Color innerColor; Color fontColor; bool isTriageOperatorOnTheClock; //get the cubicle color and triage status Phones.GetPhoneColor(phone, phoneEmpDefault, true, out outerColor, out innerColor, out fontColor, out isTriageOperatorOnTheClock); if (!room.IsFlashing) //if the control is already flashing then don't overwrite the colors. this would cause a "spastic" flash effect. { room.OuterColor = outerColor; room.InnerColor = innerColor; } room.ForeColor = fontColor; if (phone.ClockStatus == ClockStatusEnum.NeedsHelp) //turn on flashing { room.StartFlashing(); } else //turn off flashing { room.StopFlashing(); } room.Invalidate(true); } catch (Exception e) { e.DoNothing(); } } refreshCurrentTabHelper(peds, phones, listSubGroups); } catch { //something failed unexpectedly } }
private void UserControlPhoneSmall_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.FillRectangle(SystemBrushes.Control, this.Bounds); if (phoneList == null) { return; } int rows = 7; int columns = 7; float boxWidth = 21.4f; float boxHeight = 17f; float hTot = boxHeight * rows; float x = 0f; float y = 0f; //Create a white "background" rectangle so that any empty squares (no employees) will show as white boxes instead of no color. g.FillRectangle(new SolidBrush(Color.White), x, y, boxWidth * columns, boxHeight * rows); for (int i = 0; i < phoneList.Count; i++) { //Draw the extension number if a person is available at that extension. if (phoneList[i].ClockStatus != ClockStatusEnum.Home && phoneList[i].ClockStatus != ClockStatusEnum.None) { //Colors the box a color based on the corresponding phone's status. Color outerColor; Color innerColor; Color fontColor; bool isTriageOperatorOnTheClock = false; //get the cubicle color and triage status PhoneEmpDefault ped = PhoneEmpDefaults.GetEmpDefaultFromList(phoneList[i].EmployeeNum, phoneEmpDefaultList); Phones.GetPhoneColor(phoneList[i], ped, false, out outerColor, out innerColor, out fontColor, out isTriageOperatorOnTheClock); using (Brush brush = new SolidBrush(outerColor)) { g.FillRectangle(brush, x * boxWidth, y * boxHeight, boxWidth, boxHeight); } Font baseFont = new Font("Arial", 7); SizeF extSize = g.MeasureString(phoneList[i].Extension.ToString(), baseFont); float padX = (boxWidth - extSize.Width) / 2; float padY = (boxHeight - extSize.Height) / 2; using (Brush brush = new SolidBrush(Color.Black)) { g.DrawString(phoneList[i].Extension.ToString(), baseFont, brush, (x * boxWidth) + (padX), (y * boxHeight) + (padY)); } } x++; if (x >= columns) { x = 0f; y++; } } //horiz lines for (int i = 0; i < rows + 1; i++) { g.DrawLine(Pens.Black, 0, i * boxHeight, Width, i * boxHeight); } //Very bottom g.DrawLine(Pens.Black, 0, Height - 1, Width, Height - 1); //vert for (int i = 0; i < columns; i++) { g.DrawLine(Pens.Black, i * boxWidth, 0, i * boxWidth, hTot); } g.DrawLine(Pens.Black, Width - 1, 0, Width - 1, hTot); }
///<summary>Refresh the phone panel every X seconds after it has already been setup. Make sure to call FillMapAreaPanel before calling this the first time.</summary> public void SetPhoneList(List <PhoneEmpDefault> peds, List <Phone> phones) { try { string title = "Call Center Status Map - Triage Coordinator - "; try { //get the triage coord label but don't fail just because we can't find it title += Employees.GetNameFL(PrefC.GetLong(PrefName.HQTriageCoordinator)); } catch { title += "Not Set"; } labelTriageCoordinator.Text = title; labelCurrentTime.Text = DateTime.Now.ToShortTimeString(); int triageStaffCount = 0; for (int i = 0; i < this.mapAreaPanelHQ.Controls.Count; i++) //loop through all of our cubicles and labels and find the matches { if (!(this.mapAreaPanelHQ.Controls[i] is MapAreaRoomControl)) { continue; } MapAreaRoomControl room = (MapAreaRoomControl)this.mapAreaPanelHQ.Controls[i]; if (room.MapAreaItem.Extension == 0) //This cubicle has not been given an extension yet. { room.Empty = true; continue; } Phone phone = Phones.GetPhoneForExtension(phones, room.MapAreaItem.Extension); if (phone == null) //We have a cubicle with no corresponding phone entry. { room.Empty = true; continue; } PhoneEmpDefault phoneEmpDefault = PhoneEmpDefaults.GetEmpDefaultFromList(phone.EmployeeNum, peds); if (phoneEmpDefault == null) //We have a cubicle with no corresponding phone emp default entry. { room.Empty = true; continue; } //we got this far so we found a corresponding cubicle for this phone entry room.EmployeeNum = phone.EmployeeNum; room.EmployeeName = phone.EmployeeName; if (phone.DateTimeStart.Date == DateTime.Today) { TimeSpan span = DateTime.Now - phone.DateTimeStart + _timeDelta; DateTime timeOfDay = DateTime.Today + span; room.Elapsed = timeOfDay.ToString("H:mm:ss"); } else { room.Elapsed = ""; } string status = phone.ClockStatus.ToString(); //Check if the user is logged in. if (phone.ClockStatus == ClockStatusEnum.None || phone.ClockStatus == ClockStatusEnum.Home) { status = "Home"; } room.Status = status; if (phone.Description == "") { room.PhoneImage = null; } else { room.PhoneImage = Properties.Resources.phoneInUse; } Color outerColor; Color innerColor; Color fontColor; bool isTriageOperatorOnTheClock = false; //get the cubicle color and triage status Phones.GetPhoneColor(phone, phoneEmpDefault, true, out outerColor, out innerColor, out fontColor, out isTriageOperatorOnTheClock); if (!room.IsFlashing) //if the control is already flashing then don't overwrite the colors. this would cause a "spastic" flash effect. { room.OuterColor = outerColor; room.InnerColor = innerColor; } room.ForeColor = fontColor; if (isTriageOperatorOnTheClock) { triageStaffCount++; } if (phone.ClockStatus == ClockStatusEnum.NeedsHelp) //turn on flashing { room.StartFlashing(); } else //turn off flashing { room.StopFlashing(); } room.Invalidate(true); } this.labelTriageOpsStaff.Text = triageStaffCount.ToString(); } catch { //something failed unexpectedly } }