Ejemplo n.º 1
0
 ///<summary>phoneList is the list of all phone rows just pulled from the database.  phone is the one that we should display here, and it can be null.</summary>
 public void PhoneWebCamTickDisplay(List<Phone> phoneList,Phone phone)
 {
     //send the phoneList to the 2 places where it's needed:
     phoneSmall.PhoneList=phoneList;
     if(formPhoneTiles!=null && !formPhoneTiles.IsDisposed) {
         formPhoneTiles.PhoneList=phoneList;
     }
     if(phone==null) {
         phoneSmall.Extension=0;
     }
     else {
         phoneSmall.Extension=phone.Extension;
     }
     phoneSmall.PhoneCur=phone;
 }
		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(StatusOld==PhoneEmpStatusOverride.Unavailable) {
						MsgBox.Show(this,"Change your status from unavailable by using the small phone panel.");
						return;
					}
					break;
				case PhoneEmpStatusOverride.OfflineAssist:
					if(StatusOld==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();
			}
			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.GetPhoneForExtension(Phones.GetPhoneList(),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=(AsteriskRingGroups)listRingGroup.SelectedIndex;
			PedCur.PhoneExt=PIn.Int(textPhoneExt.Text);
			PedCur.StatusOverride=(PhoneEmpStatusOverride)listStatusOverride.SelectedIndex;
			PedCur.Notes=textNotes.Text;
			PedCur.ComputerName=textComputerName.Text;
			PedCur.IsPrivateScreen=checkIsPrivateScreen.Checked;
			PedCur.IsTriageOperator=checkIsTriageOperator.Checked;
			if(IsNew){
				PhoneEmpDefaults.Insert(PedCur);
				//insert the new Phone record to keep the 2 tables in sync
				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);			
			}
			DialogResult=DialogResult.OK;
		}
Ejemplo n.º 3
0
		///<summary>phoneList is the list of all phone rows just pulled from the database.  phone is the one that we should display here, and it can be null.</summary>
		public void PhoneWebCamTickDisplay(List<PhoneEmpDefault> phoneEmpDefaultList,List<Phone> phoneList,List<Task> listOfficesDown,Phone phone,bool isTriageOperator) {
			try {
				//Send the phoneList to the 2 places where it's needed.
				//1) Send to the small display in the main OD form (quick-glance).
				phoneSmall.SetPhoneList(phoneEmpDefaultList,phoneList);
				if(formPhoneTiles!=null && !formPhoneTiles.IsDisposed) { //2) Send to the big phones panel if it is open.
					formPhoneTiles.SetPhoneList(phoneEmpDefaultList,phoneList);
				}
				if(formMapHQ!=null && !formMapHQ.IsDisposed) { //3) Send to the map hq if it is open.
					formMapHQ.SetPhoneList(phoneEmpDefaultList,phoneList);
					formMapHQ.SetOfficesDownList(listOfficesDown);
				}
				//Now set the small display's current phone extension info.
				if(phone==null) {
					phoneSmall.Extension=0;
				}
				else {
					phoneSmall.Extension=phone.Extension;
				}
				phoneSmall.SetPhone(phone,PhoneEmpDefaults.GetEmpDefaultFromList(phone.EmployeeNum,phoneEmpDefaultList),isTriageOperator);
			}
			catch {
				//HQ users are complaining of unhandled exception when they close OD.
				//Suspect it could be caused here if the thread tries to access a control that has been disposed.
			}
		}
Ejemplo n.º 4
0
		///<summary>Set phone and triage flag to display. Get/Set accessor won't work here because we require 2 seperate fields in order to update the control properly.</summary>
		public void SetPhone(Phone phone,PhoneEmpDefault phoneEmpDefault,bool isTriageOperator) {
			phoneCur=phone;
			if(phoneCur==null) { //empty out everything and return
				this.Visible=false;
				pictureWebCam.Image=null;//or just make it not visible?
				pictureInUse.Visible=false;
				labelExtensionName.Text="";
				labelStatusAndNote.Text="";
				labelTime.Text="";
				labelTime.BackColor=this.BackColor;
				labelCustomer.Text="";
				return;
			}
			this.Visible=true;
			if(ShowImageForced) {
				pictureWebCam.Image=PIn.Bitmap(phoneCur.WebCamImage);
				pictureWebCam.Visible=true;
			}
			else if(phoneCur.ClockStatus==ClockStatusEnum.Home
				|| phoneCur.ClockStatus==ClockStatusEnum.None
				|| phoneCur.ClockStatus==ClockStatusEnum.Off) 
			{
				pictureWebCam.Image=null;
				pictureWebCam.Visible=false;
			}
			else if(phoneCur.ClockStatus==ClockStatusEnum.Break
						|| phoneCur.ClockStatus==ClockStatusEnum.Lunch) {
				pictureWebCam.Visible=true;
				Bitmap bmp=new Bitmap(pictureWebCam.Width,pictureWebCam.Height);
				Graphics g=Graphics.FromImage(bmp);
				try {
					g.FillRectangle(SystemBrushes.Control,0,0,bmp.Width,bmp.Height);
					string strStat=phoneCur.ClockStatus.ToString();
					SizeF sizef=g.MeasureString(strStat,labelStatusAndNote.Font);
					g.DrawString(strStat,labelStatusAndNote.Font,SystemBrushes.GrayText,(bmp.Width-sizef.Width)/2,(bmp.Height-sizef.Height)/2);
					pictureWebCam.Image=(Image)bmp.Clone();
				}
				finally {
					g.Dispose();
					g=null;
					bmp.Dispose();
					bmp=null;
				}
			}
			else {
				pictureWebCam.Visible=true;
				pictureWebCam.Image=PIn.Bitmap(phoneCur.WebCamImage);
			}
			if(phoneCur.Description=="") {
				pictureInUse.Visible=false;
			}
			else {
				pictureInUse.Visible=true;
			}
			labelExtensionName.Text="";
			string str=phoneCur.ClockStatus.ToString();
			//Check if the user is logged in.
			if(phoneCur.ClockStatus==ClockStatusEnum.None
				|| phoneCur.ClockStatus==ClockStatusEnum.Home) 
			{
				str="Clock In";
			}
			//Always show ext and name, no matter if user is clocked in or not. This keeps phone tiles from appearing blank with no extension and name.
			string nameStr="Vacant";
			if(phoneCur.EmployeeName!="") {
				nameStr=phoneCur.EmployeeName;
			}
			labelExtensionName.Text=phoneCur.Extension.ToString()+" - "+nameStr;
			labelStatusAndNote.Text=str;
			DateTime dateTimeStart=phoneCur.DateTimeStart;
			if(dateTimeStart.Date==DateTime.Today) {
				TimeSpan span=DateTime.Now-dateTimeStart+TimeDelta;
				DateTime timeOfDay=DateTime.Today+span;
				labelTime.Text=timeOfDay.ToString("H:mm:ss");
			}
			else {
				labelTime.Text="";
			}						
			if(phoneCur.ClockStatus==ClockStatusEnum.Home
				|| phoneCur.ClockStatus==ClockStatusEnum.None
				|| phoneCur.ClockStatus==ClockStatusEnum.Break) {
				labelTime.BackColor=this.BackColor;//No color if employee is not currently working.
			}
			else {
				Color outerColor;
				Color innerColor;
				Color fontColor;
				bool isTriageOperatorOnTheClock=false;
				//get the cubicle color and triage status
				Phones.GetPhoneColor(phone,phoneEmpDefault,false,out outerColor,out innerColor,out fontColor,out isTriageOperatorOnTheClock);
				if(!timerFlash.Enabled) { //if the control is already flashing then don't overwrite the colors. this would cause a "spastic" flash effect.
					labelTime.BackColor=outerColor;
				}				
				if(phoneCur.ClockStatus==ClockStatusEnum.NeedsHelp) {
					if(!timerFlash.Enabled) { //Only start the flash timer and color the control once. This prevents over-flashing effect.
						labelTime.Tag=new object[2] { false,labelTime.BackColor };
						timerFlash.Start();
					}
				}
			}
			if(phoneCur.ClockStatus==ClockStatusEnum.Home
				|| phoneCur.ClockStatus==ClockStatusEnum.None) 
			{
				labelTime.BorderStyle=System.Windows.Forms.BorderStyle.None;//Remove color box if employee is not currently working.
			}
			else {
				labelTime.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;
			}
			if(phoneCur.ClockStatus!=ClockStatusEnum.NeedsHelp) { //Always assume the flash timer was previously turned on and turn it off here. No harm if it' already off.
				timerFlash.Stop();
			}
			labelCustomer.Text=phoneCur.CustomerNumber;
		}
		///<summary>Set the phone which is linked to the extension at this desk. If phone==null then no phone info shown.</summary>
		public void SetPhone(Phone phone,PhoneEmpDefault phoneEmpDefault,bool isTriageOperator) {
			phoneTile.SetPhone(phone,phoneEmpDefault,isTriageOperator);
		}