Esempio n. 1
0
        ///<summary>The employee passed in will take over the extension passed in.
        ///Moves any other employee who currently has this extension set (in phoneempdefault) to extension zero.
        ///This prevents duplicate extensions in phoneempdefault.</summary>
        public static void SetAvailable(int extension, long empNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), extension, empNum);
                return;
            }
            Employee emp = Employees.GetEmp(empNum);

            if (emp == null)           //Should never happen. This means the employee that's changing their status doesn't exist in the employee table.
            {
                return;
            }
            string command = "UPDATE phoneempdefault "
                             + "SET StatusOverride=" + POut.Int((int)PhoneEmpStatusOverride.None)
                             + ",PhoneExt=" + POut.Int(extension)
                             + ",EmpName='" + POut.String(emp.FName) + "' "
                             + "WHERE EmployeeNum=" + POut.Long(empNum);

            Db.NonQ(command);
            //Set the extension to 0 for any other employee that is using this extension to prevent duplicate rows using the same extentions.
            //This would cause confusion for the ring groups.  This is possible if a user logged off and another employee logs into their computer.
            command = "UPDATE phoneempdefault SET PhoneExt=0 "
                      + "WHERE PhoneExt=" + POut.Int(extension) + " "
                      + "AND EmployeeNum!=" + POut.Long(empNum);
            Db.NonQ(command);
        }
Esempio n. 2
0
        ///<summary>Special logic needs to be run for the phone system when users clock out.</summary>
        private static void ClockOutForHQ(long employeeNum)
        {
            //The name showing for this extension might change to a different user.
            //It would only need to change if the employee clocking out is not assigned to the current extension. (assigned ext set in the employee table)
            //Get the information corresponding to the employee clocking out.
            PhoneEmpDefault pedClockingOut = PhoneEmpDefaults.GetOne(employeeNum);

            if (pedClockingOut == null)
            {
                return;                //This should never happen.
            }
            //Get the employee that is normally assigned to this extension (assigned ext set in the employee table).
            long permanentLinkageEmployeeNum = Employees.GetEmpNumAtExtension(pedClockingOut.PhoneExt);

            if (permanentLinkageEmployeeNum >= 1)               //Extension is nomrally assigned to an employee.
            {
                if (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 = pedClockingOut.PhoneExt;
                        PhoneEmpDefaults.Update(pedRevertTo);
                        //Update phone table to match this change.
                        Phones.SetPhoneStatus(ClockStatusEnum.Home, pedRevertTo.PhoneExt, pedRevertTo.EmployeeNum);
                    }
                }
            }
            //Now let's switch this employee back to his normal extension.
            Employee employeeClockingOut = Employees.GetEmp(employeeNum);

            if (employeeClockingOut == null)           //should not get here
            {
                return;
            }
            if (employeeClockingOut.PhoneExt != pedClockingOut.PhoneExt)           //Revert PhoneEmpDefault and Phone to the normally assigned extension for this employee.
            //Start by setting this employee back to their normally assigned extension.
            {
                pedClockingOut.PhoneExt = employeeClockingOut.PhoneExt;
                //Now check to see if we are about to steal yet a third employee's extension.
                Phone phoneCurrentlyOccupiedBy = Phones.GetPhoneForExtension(Phones.GetPhoneList(), employeeClockingOut.PhoneExt);
                if (phoneCurrentlyOccupiedBy != null &&           //There is yet a third employee who is currently occupying this extension.
                    ClockEvents.IsClockedIn(phoneCurrentlyOccupiedBy.EmployeeNum))
                {
                    //The third employee is clocked in so set our employee extension to 0.
                    //The currently clocked in employee will retain the extension for now.
                    //Our employee will retain the proper extension next time they clock in.
                    pedClockingOut.PhoneExt = 0;
                    //Update the phone table accordingly.
                    Phones.UpdatePhoneToEmpty(pedClockingOut.EmployeeNum, -1);
                }
                PhoneEmpDefaults.Update(pedClockingOut);
            }
            //Update phone table to match this change.
            Phones.SetPhoneStatus(ClockStatusEnum.Home, pedClockingOut.PhoneExt, employeeClockingOut.EmployeeNum);
        }
Esempio n. 3
0
 ///<summary>Attempts to fill the list of engineers from the wikilist. Fills with empty if something failed</summary>
 private static void FillEngineerList()
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod());
         return;
     }
     _listEngineers = new List <Engineer>();
     try {
         string    command = "SELECT Title,EmployeeNum FROM wikilist_employees WHERE Title LIKE '%Engineer%'";
         DataTable dt      = Db.GetTable(command);
         foreach (DataRow dr in dt.Rows)
         {
             Employee emp         = Employees.GetEmp(PIn.Long(dr["EmployeeNum"].ToString()));
             Userod   user        = Userods.GetUserByEmployeeNum(emp.EmployeeNum);
             Engineer newEngineer = new Engineer(user, emp, PIn.String(dr["Title"].ToString()));
             _listEngineers.Add(newEngineer);
         }
     }
     catch (Exception e) {
         //Do nothing
     }
 }
Esempio n. 4
0
        ///<summary>this code is similar to code in the phone tracking server.  But here, we frequently only change clockStatus and ColorBar by setting employeeNum=-1.  If employeeNum is not -1, then EmployeeName also gets set.  If employeeNum==0, then clears employee from that row.</summary>
        public static void SetPhoneStatus(ClockStatusEnum clockStatus, int extens, long employeeNum = -1)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), clockStatus, extens, employeeNum);
                return;
            }
            string command = @"SELECT phoneempdefault.EmployeeNum,phoneempdefault.IsTriageOperator,Description,phoneempdefault.EmpName,HasColor,phone.ClockStatus "
                             + "FROM phone "
                             + "LEFT JOIN phoneempdefault ON phone.Extension=phoneempdefault.PhoneExt "
                             + "WHERE phone.Extension=" + POut.Long(extens);
            DataTable tablePhone = Db.GetTable(command);

            if (tablePhone.Rows.Count == 0)
            {
                //It would be nice if we could create a phone row for this extension.
                return;
            }
            long     empNum           = PIn.Long(tablePhone.Rows[0]["EmployeeNum"].ToString());
            bool     isTriageOperator = PIn.Bool(tablePhone.Rows[0]["IsTriageOperator"].ToString());
            string   empName          = PIn.String(tablePhone.Rows[0]["EmpName"].ToString());
            string   clockStatusDb    = PIn.String(tablePhone.Rows[0]["ClockStatus"].ToString());
            Employee emp = Employees.GetEmp(employeeNum);

            if (emp != null)           //A new employee is going to take over this extension.
            {
                empName = emp.FName;
                empNum  = emp.EmployeeNum;
            }
            else if (employeeNum == 0)           //Clear the employee from that row.
            {
                empName = "";
                empNum  = 0;
            }
            //if these values are null because of missing phoneempdefault row, they will default to false
            //PhoneEmpStatusOverride statusOverride=(PhoneEmpStatusOverride)PIn.Int(tablePhone.Rows[0]["StatusOverride"].ToString());
            bool hasColor = PIn.Bool(tablePhone.Rows[0]["HasColor"].ToString());

            #region DateTimeStart
            //When a user shows up as a color on the phone panel, we want a timer to be constantly going to show how long they've been off the phone.
            string dateTimeStart = "";
            //It's possible that a new user has never clocked in before, therefore their clockStatus will be empty.  Simply set it to the status that they are trying to go to.
            if (clockStatusDb == "")
            {
                clockStatusDb = clockStatus.ToString();
            }
            if (clockStatus == ClockStatusEnum.Break ||
                clockStatus == ClockStatusEnum.Lunch)
            {
                //The user is going on Lunch or Break.  Start the DateTimeStart counter so we know how long they have been gone.
                dateTimeStart = "DateTimeStart=NOW(), ";
            }
            else if (clockStatus == ClockStatusEnum.Home)
            {
                //User is going Home.  Always clear the DateTimeStart column no matter what.
                dateTimeStart = "DateTimeStart='0001-01-01', ";
            }
            else              //User shows as a color on big phones and is not going to a status of Home, Lunch, or Break.  Example: Available, Training etc.
                              //Get the current clock status from the database.
            {
                ClockStatusEnum clockStatusCur = (ClockStatusEnum)Enum.Parse(typeof(ClockStatusEnum), clockStatusDb);
                //Start the clock if the user is going from a break status to any other non-break status.
                if (clockStatusCur == ClockStatusEnum.Home ||
                    clockStatusCur == ClockStatusEnum.Lunch ||
                    clockStatusCur == ClockStatusEnum.Break)
                {
                    //The user is clocking in from home, lunch, or break.  Start the timer up.
                    if (hasColor)                     //Only start up the timer when someone with color clocks in.
                    {
                        dateTimeStart = "DateTimeStart=NOW(), ";
                    }
                    else                       //Someone with no color then reset the timer. They are back from break, that's all we need to know.
                    {
                        dateTimeStart = "DateTimeStart='0001-01-01', ";
                    }
                }
            }
            string dateTimeNeedsHelpStart;
            if (clockStatus == ClockStatusEnum.NeedsHelp)
            {
                dateTimeNeedsHelpStart = "DateTimeNeedsHelpStart=NOW(), ";
            }
            else
            {
                dateTimeNeedsHelpStart = "DateTimeNeedsHelpStart=" + POut.DateT(DateTime.MinValue) + ", ";
            }
            #endregion
            //Update the phone row to reflect the new clock status of the user.
            string clockStatusNew = clockStatus.ToString();
            if (clockStatus == ClockStatusEnum.None)
            {
                clockStatusNew = "";
            }
            if (clockStatus == ClockStatusEnum.HelpOnTheWay && clockStatusDb == ClockStatusEnum.HelpOnTheWay.ToString())           //If HelpOnTheWay already
            {
                clockStatusNew = ClockStatusEnum.Available.ToString();
            }
            command = "UPDATE phone SET ClockStatus='" + POut.String(clockStatusNew) + "', "
                      + dateTimeStart
                      + dateTimeNeedsHelpStart
                      //+"ColorBar=-1, " //ColorBar is now determined at runtime by OD using Phones.GetPhoneColor.
                      + "EmployeeNum=" + POut.Long(empNum) + ", "
                      + "EmployeeName='" + POut.String(empName) + "' "
                      + "WHERE Extension=" + extens;
            Db.NonQ(command);
            //Zero out any duplicate phone table rows for this employee.
            //This is possible if a user logged off and another employee logs into their computer. This would cause duplicate entries in the big phones window.
            UpdatePhoneToEmpty(employeeNum, extens);
        }