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); }
public static void Unavailable(PhoneTile tile) { if (!ClockIn(tile)) { return; } int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckSelectedUserPassword(employeeNum)) { return; } PhoneEmpDefault ped = PhoneEmpDefaults.GetByExtAndEmp(extension, employeeNum); if (ped == null) { MessageBox.Show("PhoneEmpDefault (employee setting row) not found for Extension " + extension.ToString() + " and EmployeeNum " + employeeNum.ToString()); return; } FormPhoneEmpDefaultEdit formPED = new FormPhoneEmpDefaultEdit(); formPED.PedCur = ped; formPED.ShowDialog(); Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, extension); }
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(); }
private void menuItemOfflineAssist_Click(object sender, EventArgs e) { if (!ClockIn()) { return; } int extension = PhoneList[rowI].Extension; long employeeNum = PhoneList[rowI].EmployeeNum; PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(ClockStatusEnum.OfflineAssist, extension); FillEmps(); }
private void menuItemWrapUp_Click(object sender, EventArgs e) { if (!ClockIn()) { return; } int extension = PhoneList[rowI].Extension; long employeeNum = PhoneList[rowI].EmployeeNum; PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(ClockStatusEnum.WrapUp, extension); //this is usually an automatic status FillEmps(); }
///<summary>Sets the current phone's employee and extension as "available" and then sets the phone status to the clock status passed in. ///Returns false if the user currently clocked in does not have permission or the credentials to do the desired action. ///Also, calls FillEmps() if action was successfully taken.</summary> private bool SetPhoneAvailable(ClockStatusEnum clockStatus) { if (!ClockIn()) { return(false); } int extension = PhoneList[rowI].Extension; long employeeNum = PhoneList[rowI].EmployeeNum; PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(clockStatus, extension); FillEmps(); return(true); }
private void menuItemBackup_Click(object sender, EventArgs e) { if (!ClockIn()) { return; } int extension = PhoneList[rowI].Extension; long employeeNum = PhoneList[rowI].EmployeeNum; PhoneEmpDefaults.SetAvailable(extension, employeeNum); PhoneAsterisks.SetRingGroups(extension, AsteriskRingGroups.Backup); Phones.SetPhoneStatus(ClockStatusEnum.Backup, extension); FillEmps(); }
public static void Training(PhoneTile tile) { if (!ClockIn(tile)) { return; } int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckSelectedUserPassword(employeeNum)) { return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(ClockStatusEnum.Training, extension); }
public static void Available(Phone phone) { long employeeNum = Security.CurUser.EmployeeNum; if (Security.CurUser.EmployeeNum != phone.EmployeeNum) //We are on someone else's tile. So Let's do some checks before we assume we can take over this extension. { if (phone.ClockStatus == ClockStatusEnum.NeedsHelp) { //Allow the specific state where we are changing their status back from NeedsHelp to Available. //This does not require any security permissions as any tech in can perform this action on behalf of any other tech. Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, phone.EmployeeNum); //green return; } //We are on a tile that is not our own //If another employee is occupying this extension then assume we are trying to change that employee's status back to available. if (ClockEvents.IsClockedIn(phone.EmployeeNum)) //This tile is taken by an employee who is clocked in. //Transition the employee back to available. { ChangeTileStatus(phone, ClockStatusEnum.Available); PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum); return; } if (phone.ClockStatus != ClockStatusEnum.None && phone.ClockStatus != ClockStatusEnum.Home) { //Another person is still actively using this extension. MsgBox.Show(langThis, "Cannot take over this extension as it is currently occuppied by someone who is likely on Break or Lunch."); return; } //If another employee is NOT occupying this extension then assume we are trying clock in at this extension. if (ClockEvents.IsClockedIn(employeeNum)) //We are already clocked in at a different extension. { MsgBox.Show(langThis, "You are already clocked in at a different extension. You must clock out of the current extension you are logged into before moving to another extension."); return; } //We got this far so fall through and allow user to clock in. } //We go here so all of our checks passed and we may login at this extension if (!ClockIn()) //Clock in on behalf of yourself { return; } //Update the Phone tables accordingly. PhoneEmpDefaults.SetAvailable(phone.Extension, employeeNum); PhoneAsterisks.SetToDefaultQueue(phone.EmployeeNum); Phones.SetPhoneStatus(ClockStatusEnum.Available, phone.Extension, employeeNum); //green }
public static void Backup(PhoneTile tile) { if (!ClockIn(tile)) { return; } int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckSelectedUserPassword(employeeNum)) { return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); PhoneAsterisks.SetRingGroups(extension, AsteriskRingGroups.Backup); Phones.SetPhoneStatus(ClockStatusEnum.Backup, extension); }
public static void WrapUp(PhoneTile tile) { if (!ClockIn(tile)) { return; } int extension = tile.PhoneCur.Extension; long employeeNum = tile.PhoneCur.EmployeeNum; if (!CheckSelectedUserPassword(employeeNum)) { return; } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(ClockStatusEnum.WrapUp, extension); //this is usually an automatic status }
///<summary>Verify... ///1) Security.CurUser is clocked in. ///2) Target status change employee is clocked in. ///3) Secruity.CurUser has TimecardsEditAll permission.</summary> private static bool ChangeTileStatus(Phone phoneCur, ClockStatusEnum newClockStatus) { if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //Employee performing the action must be clocked in. { MsgBox.Show(langThis, "You must clock in before completing this action."); return(false); } if (!ClockEvents.IsClockedIn(phoneCur.EmployeeNum)) //Employee having action performed must be clocked in. { MessageBox.Show(Lan.g(langThis, "Target employee must be clocked in before setting this status:") + " " + phoneCur.EmployeeName); return(false); } if (!CheckUserCanChangeStatus(phoneCur)) { return(false); } PhoneEmpDefaults.SetAvailable(phoneCur.Extension, phoneCur.EmployeeNum); Phones.SetPhoneStatus(newClockStatus, phoneCur.Extension); return(true); }
public static void Available(PhoneTile tile) { if (!ClockIn(tile)) { return; } 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; } } } PhoneEmpDefaults.SetAvailable(extension, employeeNum); Phones.SetPhoneStatus(ClockStatusEnum.Available, extension); //green }
public static void Unavailable(Phone phone) { if (!ClockEvents.IsClockedIn(Security.CurUser.EmployeeNum)) //Employee performing the action must be clocked in. { MsgBox.Show("PhoneUI", "You must clock in before completing this action."); return; } if (!ClockEvents.IsClockedIn(phone.EmployeeNum)) //Employee having action performed must be clocked in. { MessageBox.Show(Lan.g("PhoneUI", "Target employee must be clocked in before setting this status:") + " " + phone.EmployeeName); return; } if (!CheckUserCanChangeStatus(phone)) { return; } int extension = phone.Extension; long employeeNum = phone.EmployeeNum; PhoneEmpDefault ped = PhoneEmpDefaults.GetByExtAndEmp(extension, employeeNum); if (ped == null) { MessageBox.Show("PhoneEmpDefault (employee setting row) not found for Extension " + extension.ToString() + " and EmployeeNum " + employeeNum.ToString()); return; } FormPhoneEmpDefaultEdit formPED = new FormPhoneEmpDefaultEdit(); formPED.PedCur = ped; formPED.PedCur.StatusOverride = PhoneEmpStatusOverride.Unavailable; if (formPED.ShowDialog() == DialogResult.OK && formPED.PedCur.StatusOverride == PhoneEmpStatusOverride.Unavailable) { //This phone status update can get skipped from within the editor if the employee is not clocked in. //This would be the case when you are setting an employee other than yourself to Unavailable. //So we will set it here. This keeps the phone table and phone panel in sync. Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, formPED.PedCur.PhoneExt, formPED.PedCur.EmployeeNum); PhoneAsterisks.SetQueueForExtension(phone.Extension, AsteriskQueues.None); } }
//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); }
private void butOK_Click(object sender, System.EventArgs e) { //Using a switch statement in case we want special functionality for the other statuses later on. switch ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex) { case PhoneEmpStatusOverride.None: if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable) { MsgBox.Show(this, "Change your status from unavailable by using the small phone panel."); return; } break; case PhoneEmpStatusOverride.OfflineAssist: if (_pedOld.StatusOverride == PhoneEmpStatusOverride.Unavailable) { MsgBox.Show(this, "Change your status from unavailable by using the small phone panel."); return; } break; } if (IsNew) { if (textEmployeeNum.Text == "") { MsgBox.Show(this, "Unique EmployeeNum is required."); return; } if (textEmpName.Text == "") { MsgBox.Show(this, "Employee name is required."); return; } PedCur.EmployeeNum = PIn.Long(textEmployeeNum.Text); } //Get the current database state of the phone emp default (before we change it) PhoneEmpDefault pedFromDatabase = PhoneEmpDefaults.GetOne(PedCur.EmployeeNum); if (pedFromDatabase == null) { pedFromDatabase = new PhoneEmpDefault(); } else if (pedFromDatabase != null && IsNew) { MessageBox.Show("Employee Num already in use.\r\nEdit their current phone settings entry instead of creating a duplicate."); return; } int newExtension = PIn.Int(textPhoneExt.Text); bool extensionChange = pedFromDatabase.PhoneExt != newExtension; if (extensionChange) //Only check when extension has changed and clocked in. //We need to prevent changes to phoneempdefault table which involve employees who are currently logged in. //Failing to do so would cause subtle race conditions between the phone table and phoneempdefault. //Net result would be the phone panel looking wrong. { if (ClockEvents.IsClockedIn(PedCur.EmployeeNum)) //Prevent any change if employee being edited is currently clocked in. { MsgBox.Show(this, "You must first clock out before making changes"); return; } //Find out if the target extension is already being occuppied by a different employee. Phone phoneOccuppied = Phones.GetPhoneForExtensionDB(PIn.Int(textPhoneExt.Text)); if (phoneOccuppied != null) { if (ClockEvents.IsClockedIn(phoneOccuppied.EmployeeNum)) //Prevent change if employee's new extension is occupied by a different employee who is currently clocked in. { MessageBox.Show(Lan.g(this, "This extension cannot be inherited because it is currently occuppied by an employee who is currently logged in.\r\n\r\nExisting employee: ") + phoneOccuppied.EmployeeName); return; } if (phoneOccuppied.EmployeeNum != PedCur.EmployeeNum) { //We are setting to a new employee so let's clean up the old employee. //This will prevent duplicates in the phone table and subsequently prevent duplicates in the phone panel. Phones.UpdatePhoneToEmpty(phoneOccuppied.EmployeeNum, -1); PhoneEmpDefault pedOccuppied = PhoneEmpDefaults.GetOne(phoneOccuppied.EmployeeNum); if (pedOccuppied != null) //prevent duplicate in phoneempdefault { pedOccuppied.PhoneExt = 0; PhoneEmpDefaults.Update(pedOccuppied); } } } //Get the employee that is normally assigned to this extension (assigned ext set in the employee table). long permanentLinkageEmployeeNum = Employees.GetEmpNumAtExtension(pedFromDatabase.PhoneExt); if (permanentLinkageEmployeeNum >= 1) //Extension is nomrally assigned to an employee. { if (PedCur.EmployeeNum != permanentLinkageEmployeeNum) //This is not the normally linked employee so let's revert back to the proper employee. { PhoneEmpDefault pedRevertTo = PhoneEmpDefaults.GetOne(permanentLinkageEmployeeNum); //Make sure the employee we are about to revert is not logged in at yet a different workstation. This would be rare but it's worth checking. if (pedRevertTo != null && !ClockEvents.IsClockedIn(pedRevertTo.EmployeeNum)) { //Revert to the permanent extension for this PhoneEmpDefault. pedRevertTo.PhoneExt = pedFromDatabase.PhoneExt; PhoneEmpDefaults.Update(pedRevertTo); //Update phone table to match this change. Phones.SetPhoneStatus(ClockStatusEnum.Home, pedRevertTo.PhoneExt, pedRevertTo.EmployeeNum); } } } } //Ordering of these updates is IMPORTANT!!! //Phone Emp Default must be updated first PedCur.EmpName = textEmpName.Text; PedCur.IsGraphed = checkIsGraphed.Checked; PedCur.HasColor = checkHasColor.Checked; PedCur.RingGroups = (AsteriskQueues)listRingGroup.SelectedIndex; PedCur.PhoneExt = PIn.Int(textPhoneExt.Text); PedCur.StatusOverride = (PhoneEmpStatusOverride)listStatusOverride.SelectedIndex; PedCur.Notes = textNotes.Text; if (comboSite.SelectedIndex > -1) { PedCur.SiteNum = ((ODBoxItem <Site>)comboSite.SelectedItem).Tag.SiteNum; } PedCur.IsPrivateScreen = true; //we no longer capture screen shots. PedCur.IsTriageOperator = checkIsTriageOperator.Checked; if (IsNew) { PhoneEmpDefaults.Insert(PedCur); //insert a new Phone record to keep the 2 tables in sync an entry for the new extension in the phone table doesn't already exist. if (PedCur.PhoneExt != 0 && Phones.GetPhoneForExtensionDB(PedCur.PhoneExt) == null) { Phone phoneNew = new Phone(); phoneNew.EmployeeName = PedCur.EmpName; phoneNew.EmployeeNum = PedCur.EmployeeNum; phoneNew.Extension = PedCur.PhoneExt; phoneNew.ClockStatus = ClockStatusEnum.Home; Phones.Insert(phoneNew); } } else { PhoneEmpDefaults.Update(PedCur); } //It is now safe to update Phone table as it will draw from the newly updated Phone Emp Default row if ((PhoneEmpStatusOverride)listStatusOverride.SelectedIndex == PhoneEmpStatusOverride.Unavailable && ClockEvents.IsClockedIn(PedCur.EmployeeNum)) { //We set ourselves unavailable from this window because we require an explanation. //This is the only status that will synch with the phone table, all others should be handled by the small phone panel. Phones.SetPhoneStatus(ClockStatusEnum.Unavailable, PedCur.PhoneExt, PedCur.EmployeeNum); } if (extensionChange) { //Phone extension has changed so update the phone table as well. //We have already guaranteed that this employee is Clocked Out (above) so set to home and update phone table. Phones.SetPhoneStatus(ClockStatusEnum.Home, PedCur.PhoneExt, PedCur.EmployeeNum); } //The user just flagged themselves as a triage operator //OR //This user used to be a triage operator and they no longer want to be one which will need their ring group set back to their default. if ((!_pedOld.IsTriageOperator && checkIsTriageOperator.Checked) || (_pedOld.IsTriageOperator && !checkIsTriageOperator.Checked)) { //Set the queue for this phone emp default to whatever the current ClockStatus is for the phone row associated to this PED. PhoneAsterisks.SetQueueForClockStatus(PedCur); } DialogResult = DialogResult.OK; }