Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        private Model.PCO.person PCOCreatePerson(string xml)
        {
            F1toPCO.Model.PCO.person person = null;

            var request = new RestRequest
            {
                Path   = "people.xml",
                Method = WebMethod.Post,
                Entity = xml
            };

            using (RestResponse response = PCOClient.Request(request))
            {
                if (response.StatusCode == HttpStatusCode.Created)
                {
                    using (StreamReader streamReader = new StreamReader(response.ContentStream))
                    {
                        XmlSerializer xmlSerializer = new XmlSerializer(typeof(F1toPCO.Model.PCO.person));

                        // Deserialize the response into a Person object.
                        person = xmlSerializer.Deserialize(streamReader) as F1toPCO.Model.PCO.person;
                    }
                }
                else
                {
                    throw new Exception("An error occured: Status code: " + response.StatusCode, response.InnerException);
                }
            }
            return(person);
        }
Exemple #2
0
        public ActionResult ProcessNoMatches()
        {
            foreach (string s in Request.Form)
            {
                if (s.StartsWith("SyncIt"))
                {
                    string f1IndividualID = s.Split('-')[1];

                    Model.F1.person p = this.NoMatches.FindF1PersonByID(f1IndividualID);

                    if (!this.AttributeID.HasValue)
                    {
                        this.AttributeID = this.F1GetAttributeID("SyncMe");
                    }
                    Model.F1.peopleAttribute peopleAttribute = p.attributes.FindByID(this.AttributeID.Value);

                    if (Request.Form[s].ToString() == "1")
                    {
                        F1toPCO.Model.PCO.person pcop = new F1toPCO.Model.PCO.person();
                        this.UpdatePerson(p, ref pcop);

                        try
                        {
                            Model.PCO.person createdPerson = this.PCOCreatePerson(this.SerializeEntity(pcop));
                            if (createdPerson != null)
                            {
                                peopleAttribute.comment = createdPerson.id.Value;
                                this.F1UpdatePeopleAttribute(peopleAttribute);
                            }
                        }
                        catch
                        {
                            this.PersonErrors.Add(p);
                        }
                    }
                    else
                    {
                        this.F1DeletePeopleAttribute(peopleAttribute);
                    }
                }
            }
            this.NoMatches.Clear();

            if (this.Matches.Count > 0)
            {
                return(RedirectToAction("MultipleMatches"));
            }

            return(RedirectToAction("Success"));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="f1Person"></param>
        /// <param name="pcoPerson"></param>
        private void UpdatePerson(F1toPCO.Model.F1.person f1Person, ref F1toPCO.Model.PCO.person pcoPerson)
        {
            pcoPerson.firstname = string.IsNullOrEmpty(f1Person.goesByName) ? f1Person.firstName : f1Person.goesByName;
            pcoPerson.lastname  = f1Person.lastName;

            //Emails
            F1toPCO.Model.F1.communications emailComms = new F1toPCO.Model.F1.communications();
            emailComms.items = f1Person.communications.FindByGeneralCommunicationType(F1toPCO.Model.F1.communicationGeneralType.Email);
            UpdateEmailCommunications(emailComms, pcoPerson.contactData.emailAddresses);

            //Phone numbers
            F1toPCO.Model.F1.communications phoneComs = new F1toPCO.Model.F1.communications();
            phoneComs.items = f1Person.communications.FindByGeneralCommunicationType(F1toPCO.Model.F1.communicationGeneralType.Telephone);
            UpdatePhoneCommunications(phoneComs, pcoPerson.contactData.phoneNumbers);

            //Address
            F1toPCO.Model.F1.address  primaryAddress = f1Person.addresses.FindByType("Primary");
            F1toPCO.Model.PCO.address pcoAddress     = pcoPerson.contactData.addresses.FindByLocation("Home");
            if (primaryAddress != null)
            {
                if (pcoAddress == null)
                {
                    pcoAddress = new F1toPCO.Model.PCO.address();
                    pcoPerson.contactData.addresses.address.Add(pcoAddress);
                }
                pcoAddress.street = FormatStreet(primaryAddress);
                pcoAddress.city   = primaryAddress.city;
                pcoAddress.state  = primaryAddress.stProvince;
                pcoAddress.zip    = primaryAddress.postalCode;
            }
            else
            {
                if (pcoAddress != null)
                {
                    pcoPerson.contactData.addresses.address.Remove(pcoAddress);
                }
            }
        }
Exemple #4
0
        public ActionResult ProcessNoMatches()
        {
            foreach (string s in Request.Form)
            {
                if (s.StartsWith("SyncIt"))
                {
                    string f1IndividualID = s.Split('-')[1];

                    Model.F1.person p = this.NoMatches.FindF1PersonByID(f1IndividualID);

                    if (!this.AttributeID.HasValue)
                    {
                        this.AttributeID = this.F1GetAttributeID("SyncMe");
                    }
                    Model.F1.peopleAttribute peopleAttribute = p.attributes.FindByID(this.AttributeID.Value);

                    if (Request.Form[s].ToString() == "1")
                    {
                        F1toPCO.Model.PCO.person pcop = new F1toPCO.Model.PCO.person();
                        this.UpdatePerson(p, ref pcop);

                        try
                        {
                            Model.PCO.person createdPerson = this.PCOCreatePerson(this.SerializeEntity(pcop));
                            if (createdPerson != null)
                            {
                                peopleAttribute.comment = createdPerson.id.Value;
                                this.F1UpdatePeopleAttribute(peopleAttribute);
                            }
                        }
                        catch
                        {
                            this.PersonErrors.Add(p);

                        }
                    }
                    else
                    {
                        this.F1DeletePeopleAttribute(peopleAttribute);
                    }
                }
            }
            this.NoMatches.Clear();

            if (this.Matches.Count > 0)
            {
                return RedirectToAction("MultipleMatches");
            }

            return RedirectToAction("Success");
        }