///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private static bool ClockIn(PhoneTile tile) { long employeeNum = Security.CurUser.EmployeeNum; //tile.PhoneCur.EmployeeNum; if (employeeNum == 0) //Can happen if logged in as 'admin' user (employeeNum==0). Otherwise should not happen, means the employee trying to clock doesn't exist in the employee table. { MsgBox.Show(langThis, "Inavlid OD User: "******"Working"; Employees.Update(EmpCur); return(true); }
public static void Break(Phone phone) { //verify that employee is logged in as user int extension = phone.Extension; long employeeNum = phone.EmployeeNum; if (!CheckUserCanChangeStatus(phone)) { return; } try { ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break); } catch (Exception ex) { MessageBox.Show(ex.Message); //This message will tell user that they are already clocked out. return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString()); Employees.Update(EmpCur); Phones.SetPhoneStatus(ClockStatusEnum.Break, extension); PhoneAsterisks.SetQueueForExtension(phone.Extension, AsteriskQueues.None); }
public static void Break(PhoneTile tile) { //verify that employee is logged in as user int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll, true)) { if (!CheckSelectedUserPassword(employeeNum)) { return; } } } try { ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break); } catch (Exception ex) { MessageBox.Show(ex.Message); //This message will tell user that they are already clocked out. return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString()); Employees.Update(EmpCur); Phones.SetPhoneStatus(ClockStatusEnum.Break, extension); }
private int CompareSchedule(Schedule x, Schedule y) { if (x == y) { return(0); } if (x == null && y == null) { return(0); } if (y == null) { return(1); } if (x == null) { return(-1); } if (x.SchedType != y.SchedType) { return(x.SchedType.CompareTo(y.SchedType)); } if (x.ProvNum != y.ProvNum) { return(Providers.GetProv(x.ProvNum).ItemOrder.CompareTo(Providers.GetProv(y.ProvNum).ItemOrder)); } if (x.EmployeeNum != y.EmployeeNum) { return(Employees.GetEmp(x.EmployeeNum).FName.CompareTo(Employees.GetEmp(y.EmployeeNum).FName)); } return(x.StartTime.CompareTo(y.StartTime)); }
private void FillRules() { TimeCardRules.RefreshCache(); gridRules.BeginUpdate(); gridRules.Columns.Clear(); ODGridColumn col = new ODGridColumn("Employee", 150); gridRules.Columns.Add(col); col = new ODGridColumn("OT after x Hours", 110); gridRules.Columns.Add(col); col = new ODGridColumn("OT after x Time", 70); gridRules.Columns.Add(col); gridRules.Rows.Clear(); UI.ODGridRow row; for (int i = 0; i < TimeCardRules.Listt.Count; i++) { row = new OpenDental.UI.ODGridRow(); if (TimeCardRules.Listt[i].EmployeeNum == 0) { row.Cells.Add(Lan.g(this, "All Employees")); } else { Employee emp = Employees.GetEmp(TimeCardRules.Listt[i].EmployeeNum); row.Cells.Add(emp.FName + " " + emp.LName); } row.Cells.Add(TimeCardRules.Listt[i].OverHoursPerDay.ToStringHmm()); row.Cells.Add(TimeCardRules.Listt[i].AfterTimeOfDay.ToStringHmm()); gridRules.Rows.Add(row); } gridRules.EndUpdate(); }
private void menuItemBreak_Click(object sender, EventArgs e) { //verify that employee is logged in as user int extension = PhoneList[rowI].Extension; long employeeNum = PhoneList[rowI].EmployeeNum; if (PrefC.GetBool(PrefName.TimecardSecurityEnabled)) { if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { MsgBox.Show(this, "Not authorized."); return; } } } try{ ClockEvents.ClockOut(employeeNum, TimeClockStatus.Break); } catch (Exception ex) { MessageBox.Show(ex.Message); //This message will tell user that they are already clocked out. return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Break.ToString()); Employees.Update(EmpCur); Phones.SetPhoneStatus(ClockStatusEnum.Break, extension); FillEmps(); }
///<summary>Attempts to get Employee photos from the server with a hardcoded filepath. Returns null if the desired picture could not be found or accessed.</summary> private Image GetEmployeePicture(Phone phoneEmployee) { Employee emp = Employees.GetEmp(phoneEmployee.EmployeeNum); if (emp == null) { return(null); } try { //Only grab the first part of the FName if there are multiple uppercased parts (ie. StevenS should be Steven). string fname = Regex.Split(emp.FName, @"(?<!^)(?=[A-Z])")[0]; string employeeName = fname + " " + emp.LName; List <string> files = Directory.GetFiles(@"\\serverfiles\Storage\OPEN DENTAL\Staff\Staff Photos").ToList().FindAll(x => x.ToLower().EndsWith(employeeName.ToLower() + ".jpg")); foreach (string fileSource in files) { using (Bitmap original = (Bitmap)System.Drawing.Image.FromFile(fileSource)) { Bitmap resized = new Bitmap(original, new System.Drawing.Size(original.Width / 8, original.Height / 8)); return(resized); } } } catch (Exception ex) { //Don't really care if it fails so swallow everything. ex.DoNothing(); } return(null); }
///<summary>Name sort order differs according to ScheduleType. This sorts accordingly.<returns></returns> private int CompareNames(Schedule x, Schedule y) { if (x.ProvNum != y.ProvNum) //we are dealing with a provider { return(Providers.GetProv(x.ProvNum).ItemOrder.CompareTo(Providers.GetProv(y.ProvNum).ItemOrder)); } if (x.EmployeeNum != y.EmployeeNum) //we are dealing with an employee { return(Employees.GetEmp(x.EmployeeNum).FName.CompareTo(Employees.GetEmp(y.EmployeeNum).FName)); } return(0); }
///<summary>Fills both grids for currently selected tab.</summary> private void FillGrids() { PhoneEmpSubGroupType typeCur = (PhoneEmpSubGroupType)tabMain.TabPages[tabMain.SelectedIndex].Tag; List <PhoneEmpSubGroup> listEsc = _dictSubGroupsNew[typeCur]; listEsc = listEsc.OrderBy(x => x.EscalationOrder).ToList(); //Fill escalation grid. gridEscalation.BeginUpdate(); gridEscalation.Columns.Clear(); gridEscalation.Columns.Add(new ODGridColumn("Employee", gridEscalation.Width)); gridEscalation.Rows.Clear(); ODGridRow row; for (int i = 0; i < listEsc.Count; i++) { Employee empCur = Employees.GetEmp(listEsc[i].EmployeeNum); if (empCur == null) { continue; } row = new ODGridRow(empCur.FName + (empCur.IsHidden?"(hidden)":"")); row.Tag = _listPED.FirstOrDefault(x => x.EmployeeNum == listEsc[i].EmployeeNum); //can be null if (row.Tag == null) { row.Tag = _dictSubGroupsNew[typeCur].IndexOf(listEsc[i]); //Since we .OrderBy(...) only in FillGrid, pass the index to the tag. } gridEscalation.Rows.Add(row); //Set escalation order for this employee. //Must happen after the add in order to keep the Escalation order 1-based. listEsc[i].EscalationOrder = gridEscalation.Rows.Count; } gridEscalation.EndUpdate(); //Fill employee grid. gridEmployees.BeginUpdate(); gridEmployees.Columns.Clear(); gridEmployees.Columns.Add(new ODGridColumn("Employee", gridEmployees.Width)); gridEmployees.Rows.Clear(); for (int i = 0; i < _listPED.Count; i++) { row = new ODGridRow(); //Omit employee who are already included in escalation grid. if (listEsc.Any(x => x.EmployeeNum == _listPED[i].EmployeeNum)) { continue; } row.Cells.Add(_listPED[i].EmpName.ToString()); row.Tag = _listPED[i]; gridEmployees.Rows.Add(row); } gridEmployees.EndUpdate(); }
private void FillRules() { TimeCardRules.RefreshCache(); //Start with a convenient sorting of all employees on top, followed by a last name sort. List <TimeCardRule> listSorted = TimeCardRules.GetDeepCopy().OrderBy(x => x.IsOvertimeExempt) .ThenBy(x => x.EmployeeNum != 0) .ThenBy(x => (Employees.GetEmp(x.EmployeeNum) ?? new Employee()).LName) .ToList(); gridRules.BeginUpdate(); gridRules.ListGridColumns.Clear(); GridColumn col = new GridColumn("Employee", 150, GridSortingStrategy.StringCompare); gridRules.ListGridColumns.Add(col); col = new GridColumn("OT before x Time", 105, GridSortingStrategy.TimeParse); gridRules.ListGridColumns.Add(col); col = new GridColumn("OT after x Time", 100, GridSortingStrategy.TimeParse); gridRules.ListGridColumns.Add(col); col = new GridColumn("OT after x Hours", 110, GridSortingStrategy.TimeParse); gridRules.ListGridColumns.Add(col); col = new GridColumn("Min Clock In Time", 105, GridSortingStrategy.TimeParse); gridRules.ListGridColumns.Add(col); col = new GridColumn("Is OT Exempt", 100, HorizontalAlignment.Center, GridSortingStrategy.StringCompare); gridRules.ListGridColumns.Add(col); gridRules.ListGridRows.Clear(); UI.GridRow row; for (int i = 0; i < listSorted.Count; i++) { row = new GridRow(); if (listSorted[i].EmployeeNum == 0) { row.Cells.Add(Lan.g(this, "All Employees")); } else { Employee emp = Employees.GetEmp(listSorted[i].EmployeeNum); row.Cells.Add(emp.FName + " " + emp.LName); } row.Cells.Add(listSorted[i].BeforeTimeOfDay.ToStringHmm()); row.Cells.Add(listSorted[i].AfterTimeOfDay.ToStringHmm()); row.Cells.Add(listSorted[i].OverHoursPerDay.ToStringHmm()); row.Cells.Add(listSorted[i].MinClockInTime.ToStringHmm()); row.Cells.Add(listSorted[i].IsOvertimeExempt ? "X" : ""); row.Tag = listSorted[i]; gridRules.ListGridRows.Add(row); } gridRules.EndUpdate(); }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private bool ClockIn() { long employeeNum = PhoneList[rowI].EmployeeNum; if (employeeNum == 0) { MsgBox.Show(this, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (PrefC.GetBool(PrefName.TimecardSecurityEnabled)) { if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { MsgBox.Show(this, "Not authorized."); return(false); } } } try{ ClockEvents.ClockIn(employeeNum); } catch (Exception ex) { if (ex.Message.Contains("Already clocked in")) { return(true); } return(false); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g(this, "Working");; Employees.Update(EmpCur); return(true); }
private void FormReleaseCalculator_Load(object sender, EventArgs e) { textAvgJobHours.Text = _avgJobHours.ToString(); textEngJobPercent.Text = _jobTimePercent.ToString(); textBreakHours.Text = _avgBreakHours.ToString(); foreach (Def def in Defs.GetDefsForCategory(DefCat.JobPriorities, true).OrderBy(x => x.ItemOrder).ToList()) { listPriorities.Items.Add(new ODBoxItem <Def>(def.ItemName, def)); if (def.DefNum.In(597, 601)) { listPriorities.SelectedIndices.Add(listPriorities.Items.Count - 1); } } foreach (JobPhase phase in Enum.GetValues(typeof(JobPhase))) { listPhases.Items.Add(new ODBoxItem <JobPhase>(phase.ToString(), phase)); if (phase.In(JobPhase.Concept, JobPhase.Definition, JobPhase.Development, JobPhase.Quote)) { listPhases.SelectedIndices.Add(listPhases.Items.Count - 1); } } foreach (JobCategory category in Enum.GetValues(typeof(JobCategory))) { listCategories.Items.Add(new ODBoxItem <JobCategory>(category.ToString(), category)); if (category.In(JobCategory.Enhancement, JobCategory.Feature, JobCategory.HqRequest, JobCategory.InternalRequest, JobCategory.ProgramBridge)) { listCategories.SelectedIndices.Add(listCategories.Items.Count - 1); } } foreach (long engNum in _listEngEmpNums) { Employee emp = Employees.GetEmp(engNum); listEngineers.Items.Add(new ODBoxItem <Employee>(emp.FName, emp)); if (_listDefaultEngEmpNums.Contains(engNum)) { listEngineers.SelectedIndices.Add(listEngineers.Items.Count - 1); } } }
public static void Home(PhoneTile tile) { //verify that employee is logged in as user int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckUserCanChangeStatus(tile)) { return; } try { //Update the clock event, phone (HQ only), and phone emp default (HQ only). ClockEvents.ClockOut(employeeNum, TimeClockStatus.Home); } catch (Exception ex) { MessageBox.Show(ex.Message); //This message will tell user that they are already clocked out. return; } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Home.ToString()); Employees.Update(EmpCur); }
///<summary>Replaces all user fields in the given message with the supplied userod's information. Returns the resulting string. ///Only works if the current user has a linked provider or employee, otherwise the replacements will be blank. ///Replaces: [UserNameF], [UserNameL], [UserNameFL]. </summary> public static string ReplaceUser(string message, Userod userod) { string retVal = message; string userNameF = ""; string userNameL = ""; if (userod.ProvNum != 0) { Provider prov = Providers.GetProv(userod.ProvNum); userNameF = prov.FName; userNameL = prov.LName; } else if (userod.EmployeeNum != 0) { Employee emp = Employees.GetEmp(userod.EmployeeNum); userNameF = emp.FName; userNameL = emp.LName; } retVal = retVal.Replace("[UserNameF]", userNameF); retVal = retVal.Replace("[UserNameL]", userNameL); retVal = retVal.Replace("[UserNameFL]", Patients.GetNameFL(userNameL, userNameF, "", "")); return(retVal); }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private bool ClockIn() { long employeeNum = PhoneList[rowI].EmployeeNum; if (employeeNum == 0) { MsgBox.Show(this, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (PrefC.GetBool(PrefName.TimecardSecurityEnabled)) { if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll)) { MsgBox.Show(this, "Not authorized."); return(false); } } } try{ ClockEvents.ClockIn(employeeNum); } catch { //This should never happen. Fail silently. return(true); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g(this, "Working");; Employees.Update(EmpCur); return(true); }
//Timecard--------------------------------------------------- public static void Lunch(PhoneTile tile) { //verify that employee is logged in as user int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckUserCanChangeStatus(tile)) { return; } try { ClockEvents.ClockOut(employeeNum, TimeClockStatus.Lunch); } catch (Exception ex) { MessageBox.Show(ex.Message); //This message will tell user that they are already clocked out. return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = Lan.g("enumTimeClockStatus", TimeClockStatus.Lunch.ToString()); Employees.Update(EmpCur); Phones.SetPhoneStatus(ClockStatusEnum.Lunch, extension); }
///<summary>If already clocked in, this does nothing. Returns false if not able to clock in due to security, or true if successful.</summary> private static bool ClockIn(PhoneTile tile) { long employeeNum = tile.PhoneCur.EmployeeNum; if (employeeNum == 0) { MsgBox.Show(langThis, "No employee at that extension."); return(false); } if (ClockEvents.IsClockedIn(employeeNum)) { return(true); } if (Security.CurUser.EmployeeNum != employeeNum) { if (!Security.IsAuthorized(Permissions.TimecardsEditAll, true)) { if (!CheckSelectedUserPassword(employeeNum)) { return(false); } } } try { ClockEvents.ClockIn(employeeNum); } catch { //This should never happen. Fail silently. return(true); } Employee EmpCur = Employees.GetEmp(employeeNum); EmpCur.ClockStatus = "Working"; Employees.Update(EmpCur); return(true); }
private void FillGrid() { //do not refresh from db SchedList.Sort(CompareSchedule); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableSchedDay", "Provider"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Employee"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Start Time"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Stop Time"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Note"), 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; string note; for (int i = 0; i < SchedList.Count; i++) { row = new ODGridRow(); //Prov if (SchedList[i].ProvNum != 0) { row.Cells.Add(Providers.GetAbbr(SchedList[i].ProvNum)); } else { row.Cells.Add(""); } //Employee if (SchedList[i].EmployeeNum == 0) { row.Cells.Add(""); } else { row.Cells.Add(Employees.GetEmp(SchedList[i].EmployeeNum).FName); } //times if (SchedList[i].StartTime.TimeOfDay == PIn.PDateT("12 AM").TimeOfDay && SchedList[i].StopTime.TimeOfDay == PIn.PDateT("12 AM").TimeOfDay) //SchedList[i].SchedType==ScheduleType.Practice){ { row.Cells.Add(""); row.Cells.Add(""); } else { row.Cells.Add(SchedList[i].StartTime.ToShortTimeString()); row.Cells.Add(SchedList[i].StopTime.ToShortTimeString()); } //note note = ""; if (SchedList[i].Status == SchedStatus.Holiday) { note += Lan.g(this, "Holiday: "); } note += SchedList[i].Note; row.Cells.Add(note); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
///<summary>Draw the graph region</summary> private void splitContainer_Panel1_Paint(object sender, PaintEventArgs e) { Pen penLine = new Pen(Color.Black, LineWidthPixels); Font font = new Font(this.Font.FontFamily, GetFontHeight(), this.Font.Style); try { //offset the drawing region to current scroll location e.Graphics.TranslateTransform(this.splitContainerBottom.Panel1.AutoScrollPosition.X, this.splitContainerBottom.Panel1.AutoScrollPosition.Y); //size the drawable region RectangleF rcBounds = new RectangleF(penLine.Width / 2, penLine.Width / 2, this.splitContainerBottom.Panel1.ClientRectangle.Width - penLine.Width, GetPanel1GraphHeight() + penLine.Width); //fill the background using (Brush brushBack = new SolidBrush(GraphBackColor)) { e.Graphics.FillRectangle(brushBack, rcBounds.Left, rcBounds.Top, rcBounds.Width, rcBounds.Height); } //draw the outline e.Graphics.DrawRectangle(penLine, rcBounds.Left, rcBounds.Top, rcBounds.Width, rcBounds.Height); //shrink the remaining drawable region to fit inside the rest of the pen width rcBounds.Inflate(-penLine.Width / 2, -penLine.Width / 2); //squish the drawable region horizontally so we have some outer edge buffer rcBounds.Inflate(-ExteriorPaddingPixels, 0); //each minute gets this many pixels float pixelsPerMinute = rcBounds.Width / (float)TotalTime.TotalMinutes; //get the pixel width of each hour float hourWidth = rcBounds.Width / (float)TotalTime.TotalHours; for (int hour = 0; hour <= (int)TotalTime.TotalHours; hour++) { float xPos = rcBounds.Left + (hour * hourWidth); //draw 15 minute dashed lines for (int quarter = 0; quarter <= 3; quarter++) { using (Pen penDash = new Pen(quarter == 0?Color.Black:Color.LightGray, LineWidthPixels)) { e.Graphics.DrawLine(penDash, xPos, rcBounds.Bottom, xPos, rcBounds.Top); xPos += (hourWidth / 4); } } } if (_schedulesList == null || _schedulesList.Count <= 0) { return; } //draw the bars for each schedule //the combined height of the followin for loop must match EXACTLY the value returned by GetPanel1GraphHeight(). //each schedule get 1 BarSpacingPixels plus 1 BarHeightPixels //any change to that rule must have a corresponding change to the GetPanel1GraphHeight() function float yPosStart = rcBounds.Top; for (int i = 0; i < _schedulesList.Count; i++) { yPosStart += BarSpacingPixels; List <Schedule> schedules = _schedulesList[i]; for (int j = 0; j < schedules.Count; j++) { Schedule schedule = schedules[j]; float xPosStart = Math.Max(rcBounds.Left, (rcBounds.Left + (float)schedule.StartTime.Subtract(this.StartTime).TotalMinutes *pixelsPerMinute)); float xWidth = Math.Min(rcBounds.Right, (float)(schedule.StopTime.Subtract(schedule.StartTime).TotalMinutes *pixelsPerMinute)); string desc = ""; Color barColor = EmployeeBarColor; Color textColor = EmployeeTextColor; if (schedule.SchedType == ScheduleType.Practice) //this is just used to create a date-level note { xPosStart = rcBounds.Left; xWidth = rcBounds.Width; barColor = PracticeBarColor; textColor = PracticeTextColor; } else if (schedule.ProvNum != 0) //Prov { desc = Providers.GetAbbr(schedule.ProvNum); barColor = ProviderBarColor; textColor = ProviderTextColor; } else if (schedule.EmployeeNum != 0) //Employee { desc = Employees.GetEmp(schedule.EmployeeNum).FName; barColor = EmployeeBarColor; textColor = EmployeeTextColor; } if (schedule.Note != "") { desc += " -- " + schedule.Note; } using (Brush brushBar = new SolidBrush(barColor)) { e.Graphics.FillRectangle(brushBar, xPosStart, yPosStart, xWidth, BarHeightPixels); } using (Brush brushNoteText = new SolidBrush(textColor)) { e.Graphics.DrawString(desc, font, brushNoteText, xPosStart + 2, yPosStart); } } yPosStart += BarHeightPixels; } //draw a faint line indicating what time of day it is right now if (DateTime.Now >= DateTime.Today.AddHours(StartHour) && DateTime.Now <= DateTime.Today.AddHours(EndHour)) { using (Pen penNow = new Pen(Color.FromArgb(128, Color.Red), LineWidthPixels * 2)) { int minutes = (int)DateTime.Now.TimeOfDay.Subtract(TimeSpan.FromHours(StartHour)).TotalMinutes; float xPos = rcBounds.Left + (minutes * pixelsPerMinute); e.Graphics.DrawLine(penNow, xPos, rcBounds.Bottom, xPos, rcBounds.Top); } } if (this.splitContainerBottom.Panel1.AutoScrollMinSize.Height != (int)yPosStart) { //create vertical scrollbar only this.splitContainerBottom.Panel1.AutoScrollMinSize = new Size(0, (int)yPosStart); this.splitContainerBottom.Invalidate(true); } } catch { } finally { if (penLine != null) { penLine.Dispose(); } if (font != null) { font.Dispose(); } } }
private void FillGrid() { //do not refresh from db SchedList.Sort(CompareSchedule); graphScheduleDay.SetSchedules(SchedList); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn(Lan.g("TableSchedDay", "Provider"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Employee"), 100); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Start Time"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Stop Time"), 80); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Ops"), 150); gridMain.Columns.Add(col); col = new ODGridColumn(Lan.g("TableSchedDay", "Note"), 100); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; string note; string opdesc; //string opstr; //string[] oparray; for (int i = 0; i < SchedList.Count; i++) { row = new ODGridRow(); //Prov if (SchedList[i].ProvNum != 0) { row.Cells.Add(Providers.GetAbbr(SchedList[i].ProvNum)); } else { row.Cells.Add(""); } //Employee if (SchedList[i].EmployeeNum == 0) { row.Cells.Add(""); } else { row.Cells.Add(Employees.GetEmp(SchedList[i].EmployeeNum).FName); } //times if (SchedList[i].StartTime == TimeSpan.Zero && SchedList[i].StopTime == TimeSpan.Zero) //SchedList[i].SchedType==ScheduleType.Practice){ { row.Cells.Add(""); row.Cells.Add(""); } else { row.Cells.Add(SchedList[i].StartTime.ToShortTimeString()); row.Cells.Add(SchedList[i].StopTime.ToShortTimeString()); } //ops opdesc = ""; for (int o = 0; o < SchedList[i].Ops.Count; o++) { Operatory op = Operatories.GetOperatory(SchedList[i].Ops[o]); if (op.IsHidden) //Skip hidden operatories because it just confuses users. { continue; } if (opdesc != "") { opdesc += ","; } opdesc += op.Abbrev; } row.Cells.Add(opdesc); //note note = ""; if (SchedList[i].Status == SchedStatus.Holiday) { note += Lan.g(this, "Holiday: "); } note += SchedList[i].Note; row.Cells.Add(note); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
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); } }
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 } }