示例#1
0
 public bool SetStaffUDF(Int32 personid, string udf)
 {
     try
     {
         using (EditEmployee empprocess = new EditEmployee())
         {
             empprocess.Load(personid, DateTime.Now);
             foreach (UDFValue udfVal in empprocess.Employee.UDFValues)
             {
                 if (simsudf == udfVal.TypedValueAttribute.Description)
                 {
                     if (Core.SetUdf(udfVal, udf))
                     {
                         empprocess.Save(DateTime.Now);
                         return(true);
                     }
                     else
                     {
                         return(false);
                     }
                 }
             }
             logger.Error("UDF {0} not found.", simsudf);
             return(false);
         }
     }
     catch (Exception SetStaffUDF_Exception)
     {
         logger.Log(LogLevel.Error, "SetStaffUDF (string)" + SetStaffUDF_Exception);
         return(false);
     }
 }
示例#2
0
        public string GetStaffUDF(int pid)
        {
            logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.GetStaffUDF(pid=" + pid + ")");
            string result = "";

            try
            {
                var empprocess = new EditEmployee();
                empprocess.Load(pid, DateTime.Now);

                foreach (UDFValue udfVal in empprocess.Employee.UDFValues)
                {
                    if (udfVal.FieldTypeCode == UDFFieldType.STRING1_CODE)
                    {
                        string type = udfVal.TypedValueAttribute.Description;

                        if (type == simsudf)
                        {
                            return(((StringAttribute)udfVal.TypedValueAttribute).Value);
                        }
                    }
                }

                empprocess.Dispose();
            }
            catch (Exception GetStaffUdfException)
            {
                logger.Log(LogLevel.Error, GetStaffUdfException);
            }

            return(result);
        }
示例#3
0
        public string GetStaffSurname(int pid)
        {
            logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.GetStaffSurname(pid=" + pid + ")");
            string result = "";

            try
            {
                var empprocess = new EditEmployee();
                empprocess.Load(pid, DateTime.Now);
                result = empprocess.Employee.Surname;
            }
            catch (Exception GetPersonSurnameException)
            {
                logger.Log(LogLevel.Error, GetPersonSurnameException);
            }
            return(result);
        }
示例#4
0
        public string GetStaffDOB(int pid)
        {
            logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.GetStaffDOB(pid=" + pid + ")");
            string result = "";

            try
            {
                var empprocess = new EditEmployee();
                empprocess.Load(pid, DateTime.Now);
                DateTime dt = empprocess.Employee.DateOfBirth;
                result = dt.ToShortDateString();
            }
            catch (Exception GetPersonDobException)
            {
                logger.Log(LogLevel.Error, GetPersonDobException);
            }
            return(result);
        }
示例#5
0
        public string GetStaffTelephone(int pid)
        {
            logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.GetStaffTelephone(pid=" + pid + ")");
            string result = "";

            try
            {
                var empprocess = new EditEmployee();
                empprocess.Load(pid, DateTime.Now);
                if (empprocess.Employee.Telephones.Value.Count > 0)
                {
                    int    workcount = 1;
                    string telephone = null;
                    foreach (Telephone item in empprocess.Employee.Telephones.Value)
                    {
                        //int location = item.Location.ID;
                        //if (location == telephoneLocationId)
                        if (workcount == 1)
                        {
                            telephone = item.Number.ToLower();
                        }
                        else
                        {
                            telephone = telephone + "," + item.Number.ToLower();
                        }
                        workcount = workcount + 1;
                    }
                    if (string.IsNullOrEmpty(telephone))
                    {
                        return("<NO TYPE TELEPHONE>");
                    }
                    return(telephone);
                }
                return("<BLANK>");
            }
            catch (Exception GetPersonEmailException)
            {
                logger.Log(LogLevel.Error, GetPersonEmailException);
            }
            return(result);
        }
示例#6
0
        public string GetStaffEmail(int pid)
        {
            logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.GetStaffEmail(pid=" + pid + ")");
            string result = "";

            try
            {
                var empprocess = new EditEmployee();
                empprocess.Load(pid, DateTime.Now);
                if (empprocess.Employee.EMails.Value.Count > 0)
                {
                    int    workcount      = 1;
                    string emailaddresses = null;

                    foreach (EMail item in empprocess.Employee.EMails.Value)
                    {
                        //int location = item.Location.ID;
                        //if (location == emailLocationId)

                        if (workcount == 1)
                        {
                            emailaddresses = item.Address.ToLower();
                        }
                        else
                        {
                            emailaddresses = emailaddresses + "," + item.Address.ToLower();
                        }
                    }
                    return(emailaddresses);
                }
                return("<BLANK>");
            }
            catch (Exception GetPersonEmailException)
            {
                logger.Log(LogLevel.Error, GetPersonEmailException);
            }
            return(result);
        }
示例#7
0
 public bool SetStaffUDF(Int32 personid, Int32 udf)
 {
     try
     {
         var empprocess = new EditEmployee();
         empprocess.Load(personid, DateTime.Now);
         foreach (UDFValue udfVal in empprocess.Employee.UDFValues)
         {
             if (simsudf == udfVal.TypedValueAttribute.Description)
             {
                 ((IntegerAttribute)udfVal.TypedValueAttribute).Value = udf;
             }
             logger.Log(LogLevel.Debug, "SetStaffUDF (integer) - " + udfVal.Valid());
         }
         empprocess.Save(DateTime.Now);
         empprocess.Dispose();
     }
     catch (Exception SetStaffUDF_Exception)
     {
         logger.Log(LogLevel.Error, "SetStaffUDF (integer)" + SetStaffUDF_Exception);
         return(false);
     }
     return(true);
 }
示例#8
0
        /// <summary>
        /// SetStaffTelephone
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="telephone"></param>
        /// <param name="main"></param>
        /// <param name="primary"></param>
        /// <param name="notes"></param>
        /// <param name="location"></param>
        /// <param name="device"></param>
        /// <returns></returns>
        public bool SetStaffTelephone(Int32 personid, string telephone, string main, string primary, string notes, string location, string device)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.SetStaffTelephone(personid=" + personid + ", telephone=" + telephone +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location + ", device=" + device);
                var empprocess = new EditEmployee();

                // Load employee\staff record
                empprocess.Load(personid, DateTime.Now);

                // Create a new telephone number
                var phone = new Telephone();

                // Set the telephone number
                phone.NumberAttribute.Value = telephone;

                // Set Main
                switch (main)
                {
                case "Yes":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone Main: Yes");
                    phone.MainAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone Main: Yes (Overwrite)");
                    phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone Main: No");
                    phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    logger.Log(LogLevel.Debug, "SetStaffTelephone Main: default");
                    phone.MainAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set Primary
                switch (primary)
                {
                case "Yes":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone primary: Yes");
                    phone.PrimaryAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone primary: Yes (Overwrite)");
                    phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    logger.Log(LogLevel.Debug, "SetStaffTelephone primary: No");
                    phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    logger.Log(LogLevel.Debug, "SetStaffTelephone primary: default");
                    phone.PrimaryAttribute.Value = (empprocess.Employee.Telephones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set the notes
                if (!string.IsNullOrWhiteSpace(notes))
                {
                    logger.Log(LogLevel.Debug, "SetStaffTelephone notes: " + notes);
                    phone.NotesAttribute.Value = notes;
                }

                // Set the location
                phone.LocationAttribute.Value = PersonCache.TelephoneLocations.ItemByDescription(location);

                // Set the device (telephone\fax)
                phone.DeviceAttribute.Value = PersonCache.TelephoneDevices.ItemByDescription(device);

                // Run Validation against the new record
                phone.Validate();
                logger.Log(LogLevel.Debug, "Telephone Valid: " + phone.Valid());

                // Writes the new record to the database
                empprocess.Employee.Telephones.Add(phone);
                bool result = empprocess.Save(DateTime.Now);
                logger.Log(LogLevel.Debug, "SetStaffTelephone result: " + result);
                return(true);
            }
            catch (Exception SetStaffTelephone_Exception)
            {
                logger.Log(LogLevel.Error, "SetStaffTelephone " + SetStaffTelephone_Exception);
                return(false);
            }
        }
示例#9
0
        /// <summary>
        /// SetStaffEmail
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="emailValue"></param>
        /// <param name="main">1=Yes, 2=Yes (overwrite), 3=No</param>
        /// <param name="primary"></param>
        /// <returns></returns>
        public bool SetStaffEmail(Int32 personid, string emailValue, string main, string primary, string notes, string location)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Staff.SetStaffEmail(personid=" + personid + ", emailValue=" + emailValue +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location);
                var empprocess = new EditEmployee();

                // Load employee\staff record
                empprocess.Load(personid, DateTime.Now);

                // Create a new Email record
                var email = new EMail();

                // Set the email address
                email.AddressAttribute.Value = emailValue;

                // Set Main
                switch (main)
                {
                case "Yes":
                    email.MainAttribute.Value = (empprocess.Employee.EMails.Value.Count > 0)
                            ? EMailMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    email.MainAttribute.Value = EMailMainCollection.GetValues().Item(1);
                    break;

                case "No":
                    email.MainAttribute.Value = EMailMainCollection.GetValues().Item(0);
                    break;

                default:
                    email.MainAttribute.Value = (empprocess.Employee.EMails.Value.Count > 0)
                            ? EMailMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set Primary
                switch (primary)
                {
                case "Yes":
                    email.PrimaryAttribute.Value = (empprocess.Employee.EMails.Value.Count > 0)
                            ? EMailPrimaryCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailPrimaryCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

                case "Yes (Overwrite)":
                    email.PrimaryAttribute.Value = EMailPrimaryCollection.GetValues().Item(1);
                    break;

                case "No":
                    email.PrimaryAttribute.Value = EMailPrimaryCollection.GetValues().Item(0);
                    break;

                default:
                    email.PrimaryAttribute.Value = (empprocess.Employee.EMails.Value.Count > 0)
                            ? EMailPrimaryCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailPrimaryCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set the notes
                if (!string.IsNullOrWhiteSpace(notes))
                {
                    email.NotesAttribute.Value = notes;
                }

                // Set the location
                email.LocationAttribute.Value = PersonCache.EmailLocations.ItemByDescription(location);

                // Run Validation against the new record
                email.Validate();
                logger.Log(LogLevel.Debug, "Email Valid: " + email.Valid());

                // Save the new record to the database
                empprocess.Employee.EMails.Add(email);
                return(empprocess.Save(DateTime.Now));
            }
            catch (Exception SetStaffEmail_Exception)
            {
                logger.Log(LogLevel.Error, "SetStaffEmail_Exception " + SetStaffEmail_Exception);
                return(false);
            }
        }