//-----------------------------------------------------------------------------
        //-----------------------------------------------------------------------------
        //-----------------------------------------------------------------------------

        #endregion



        /////---------------------------------------------------------------------------------



        protected override void save()
        {
            EditContact.Save();
            Int32 contactId = EditContact.ContactId;

            if ((contactId == 0) && (!EditContact.IsAnonymous))
            {
                this.showErrorMessage("Contact must be defined!");
                mvOpenSession.ActiveViewIndex = 1;
            }
            else
            {
                IncidentHelper.SetIncidentStateInactive(profileId);
                EditIncident.Save(contactId);
                InfoAboutCall.Save();

                UcControlArgs args = new UcControlArgs();
                dataSaved(args);

                SaveAudioRecord();
            }
        }
Exemple #2
0
        public bool SetContactUDF(Int32 personid, string udfvalue)
        {
            try
            {
                using (EditContact process = new EditContact())
                {
                    // Load Contact record
                    process.Populate(new PersonID(personid));
                    foreach (UDFValue udfVal in process.Contact.UDFValues)
                    {
                        if (simsudf == udfVal.TypedValueAttribute.Description)
                        {
                            if (Core.SetUdf(udfVal, udfvalue))
                            {
                                // Get a NullReferenceException if there isn't a contact relation. So set a 'null' one so it can save, but doesn't update any relationships.
                                StudentContact relation = new StudentContact(0);
                                relation.RelationType           = new RelationType();
                                process.Contact.ContactRelation = relation;
                                return(process.Save());
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }

                    logger.Error("UDF {0} not found.", simsudf);
                    return(false);
                }
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, "SetContactUDF " + e);
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// SetContactTelephone
        /// </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 SetContactTelephone(Int32 personid, string telephone, string main, string primary, string notes, string location, string device)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Contacts.SetContactTelephone(personid=" + personid + ", telephone=" + telephone +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location + ", device=" + device);
                var contactprocess = new EditContact();

                // Load Contact record
                contactprocess.Populate(new PersonID(personid));
                IContactRelation relation = null;
                relation = new StudentContact();
                contactprocess.Contact.ContactRelation = relation;

                // Create a new Email record
                var phone = new Telephone();

                // Set the email address
                phone.NumberAttribute.Value = telephone;


                // Set Main
                switch (main)
                {
                case "Yes":
                    phone.MainAttribute.Value = (contactprocess.Contact.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

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

                case "No":
                    phone.MainAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    phone.MainAttribute.Value = (contactprocess.Contact.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set Primary
                switch (primary)
                {
                case "Yes":
                    phone.PrimaryAttribute.Value = (contactprocess.Contact.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;

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

                case "No":
                    phone.PrimaryAttribute.Value = TelephoneMainCollection.GetValues().Item(0);
                    break;

                default:
                    phone.PrimaryAttribute.Value = (contactprocess.Contact.Phones.Value.Count > 0)
                            ? TelephoneMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : TelephoneMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                // Set the notes
                if (!string.IsNullOrWhiteSpace(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
                contactprocess.Contact.Phones.Add(phone);
                return(contactprocess.Save());
            }
            catch (Exception SetContactsTelephone_Exception)
            {
                logger.Log(LogLevel.Error, "SetContactsTelephone " + SetContactsTelephone_Exception);
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// SetContactEmail
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="emailValue"></param>
        /// <param name="main"></param>
        /// <param name="primary"></param>
        /// <param name="notes"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public bool SetContactEmail(Int32 personid, string emailValue, string main, string primary, string notes, string location)
        {
            try
            {
                logger.Log(LogLevel.Debug, "Trace:: SIMSBulkImport.Classes.Contacts.SetContactEmail(personid=" + personid + ", emailValue=" + emailValue +
                           ", main=" + main + ", primary=" + primary + ", notes=" + notes + ", location=" + location);
                var contactprocess = new EditContact();

                // Load Contact record
                contactprocess.Populate(new PersonID(personid));
                IContactRelation relation = null;
                relation = new StudentContact();
                contactprocess.Contact.ContactRelation = relation;

                // 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 = (contactprocess.Contact.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 = (contactprocess.Contact.Emails.Value.Count > 0)
                            ? EMailMainCollection.GetValues().Item(1) as CodeDescriptionEntity
                            : EMailMainCollection.GetValues().Item(0) as CodeDescriptionEntity;
                    break;
                }

                switch (primary)
                {
                case "Yes":
                    email.PrimaryAttribute.Value = (contactprocess.Contact.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 = (contactprocess.Contact.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
                contactprocess.Contact.Emails.Add(email);
                return(contactprocess.Save());
            }
            catch (Exception SetContactEmail_Exception)
            {
                logger.Log(LogLevel.Error, SetContactEmail_Exception);
                return(false);
            }
        }