Esempio n. 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);
     }
 }
Esempio n. 2
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);
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }