Exemplo n.º 1
0
        protected of.data.Contact Get_or_create_of_contact(crm.Contact crm_contact)
        {
            of.data.Contact of_contact = null;

            if (crm_contact.nrq_of_id.HasValue)
            {
                of_contact = _of_connection.Contact.Get(crm_contact.nrq_of_id.Value);
            }
            else
            {
                of_contact = new of.data.Contact();
                Mapping.Contact.To_of(crm_contact, of_contact);

                of.data.IdResponse response = _of_connection.Contact.Post(of_contact);

                crm.Contact update_crm_contact = new crm.Contact(_service, _tracingService)
                {
                    nrq_of_id = response.Id,
                    Id        = crm_contact.Id
                };
                update_crm_contact.Update();
            }

            return(of_contact);
        }
Exemplo n.º 2
0
        private void Create_or_update_associated_entities(crm.Indbetaling crm_indbetaling, of.data.Payment of_indbetaling)
        {
            if (of_indbetaling.Agreement_id.HasValue)
            {
                of.data.Agreement of_aftale = _of_connection.Agreement.Get(of_indbetaling.Agreement_id.Value);

                crm.Aftale crm_aftale = Create_or_update_one_aftale_in_crm(of_aftale);

                crm_indbetaling.Nrq_betalingsaftale = new EntityReference("new_indbetaling", crm_aftale.Id);

                //_tracingService.Trace($"connecting aftale {crm_aftale.Id} to indbetaling {crm_indbetaling.Id}");
            }
            else
            {
                //_tracingService.Trace($"no aftale on indbetaling {crm_indbetaling.Id}");
            }

            if (of_indbetaling.Contact_id.HasValue)
            {
                of.data.Contact of_contact = _of_connection.Contact.Get(of_indbetaling.Contact_id.Value);

                crm.Contact crm_contact = Create_or_update_one_contact_in_crm(of_indbetaling.Contact_id, of_contact);

                crm_indbetaling.Nrq_indbetaler = new EntityReference("contact", crm_contact.Id);

                //_tracingService.Trace($"connecting contact {crm_contact.Id} to indbetaling {crm_indbetaling.Id}");
            }
            else
            {
                //_tracingService.Trace($"no contact on indbetaling {crm_indbetaling.Id}");
            }

            crm_indbetaling.Set_indbetaling_type_from_of_project_id(of_indbetaling.Project_id);
        }
Exemplo n.º 3
0
		public static void To_of(crm.Contact crm_contact, of.data.Contact of_contact)
		{
			of_contact.City = crm_contact.address1_city;
			of_contact.Country = crm_contact.address1_country ?? "DK";
			//of_contact.Gender = crm_contact.Gendercode_enum_to_string(crm_contact.Gendercode_value);
			of_contact.Gender = null;
			//of_contact.Lat = crm_contact.address1_latitude;
			of_contact.Lat = null;
			of_contact.Address = crm_contact.address1_line1;
			//of_contact.Long = crm_contact.address1_longitude;
			of_contact.Long = null;
			of_contact.Postcode = crm_contact.address1_postalcode;
			//of_contact.Birthday_stamp_value = crm_contact.birthdate;
			of_contact.Birthday_stamp_value = null;
			of_contact.Email = crm_contact.emailaddress1;
			of_contact.First_name = crm_contact.firstname;
			of_contact.Last_name = crm_contact.lastname;
			of_contact.Cpr = crm_contact.new_cprnr;
			//of_contact.Id = crm_contact.new_ofcontactid;
			of_contact.Id = null;
			of_contact.Of_id = crm_contact.nrq_of_id;
			of_contact.Valid_adr_ts_value = null;
			of_contact.External_id = crm_contact.new_kkadminmedlemsnr?.ToString();
			of_contact.Crm_id = crm_contact.Id.ToString().ToLower();

			//    "birthday": "11. nov. 2011",
			//"birthday": "2011-11-13",
		}
Exemplo n.º 4
0
        public void Update_all_medlemsnr_in_of()
        {
            of.connector.Contacts contacts = _of_connection.Get_contacts();
            foreach (int id in contacts)
            {
                crm.Contact crm_contact = new crm.Contact(_service, _tracingService);

                of.data.Contact of_contact = _of_connection.Contact.Get(id);
                crm_contact.Get_contact_from_basis_information(_service, of_contact.Of_id.ToString());                //todo felter

                if (crm_contact.CrmEntity == null)
                {
                    continue;
                }

                if (Needs_medlemsnr_update_in_of(crm_contact, of_contact))
                {
                    //todo sæt medlemsnr
                    of_contact.External_id = crm_contact.new_kkadminmedlemsnr?.ToString();
                    _of_connection.Contact.Patch(of_contact.Of_id.Value, of_contact);
                }
                //todo remove
                break;
            }
        }
Exemplo n.º 5
0
        private bool Needs_medlemsnr_update_in_of(crm.Contact crm_contact, of.data.Contact of_contact)
        {
            //todo skal se om medlemsnr er udfyldt
            if (crm_contact.new_kkadminmedlemsnr?.ToString() != of_contact.External_id)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        private void Update_of_contact(crm.Contact crm_contact, of.data.Contact of_contact)
        {
            List <string> parameters_to_update = Mapping.Contact.Needs_update_in_of(crm_contact, of_contact);

            if (parameters_to_update.Any() == false)
            {
                return;
            }

            Mapping.Contact.To_of(crm_contact, of_contact);

            _of_connection.Contact.Patch(of_contact.Of_id.Value, of_contact, parameters_to_update);
        }
Exemplo n.º 7
0
        private void Update_contact_in_crm(crm.Contact crm_contact, of.data.Contact of_contact)
        {
            List <string> parameters_to_update = Mapping.Contact.Needs_update_in_crm(crm_contact, of_contact);

            if (parameters_to_update.Any() == false)
            {
                return;
            }

            Mapping.Contact.To_crm(crm_contact, of_contact, _tracingService);

            crm_contact.Update(parameters_to_update);
        }
Exemplo n.º 8
0
		public static void To_crm(crm.Contact crm_contact, of.data.Contact of_contact, ITracingService tracingService)
		{
			crm_contact.address1_city = of_contact.City;
			crm_contact.address1_country = of_contact.Country;
			crm_contact.gendercode.Select(of_contact.Gender, tracingService);
			crm_contact.address1_latitude = of_contact.Lat;
			crm_contact.address1_line1 = of_contact.Address;
			crm_contact.address1_longitude = of_contact.Long;
			crm_contact.address1_postalcode = of_contact.Postcode;
			crm_contact.birthdate = of_contact.Birthday_stamp_value;
			crm_contact.emailaddress1 = of_contact.Email;
			crm_contact.firstname = of_contact.First_name;
			crm_contact.lastname = of_contact.Last_name;
			crm_contact.new_cprnr = of_contact.Cpr;
			crm_contact.nrq_of_id = of_contact.Of_id;
		}
Exemplo n.º 9
0
        protected crm.Contact Get_or_create_crm_contact(int of_contact_id)
        {
            of.data.Contact of_contact = _of_connection.Contact.Get(of_contact_id);

            crm.Contact contact = new crm.Contact(_service, _tracingService);
            contact.Get_contact(_service, of_contact.Of_id, of_contact.Of_id.Value, of_contact.Email);

            if (contact.CrmEntity == null)
            {
                Mapping.Contact.To_crm(contact, of_contact, _tracingService);

                contact.Create();
            }

            return(contact);
        }
Exemplo n.º 10
0
        public crm.Contact Create_or_update_one_contact_in_crm(int?of_contact_id, of.data.Contact of_contact)
        {
            crm.Contact crm_contact = new crm.Contact(_service, _tracingService);
            crm_contact.Get_contact_from_of_contact_id(_service, of_contact_id.Value);

            if (crm_contact.CrmEntity == null)
            {
                Create_contact_in_crm(crm_contact, of_contact);
            }
            else
            {
                Update_contact_in_crm(crm_contact, of_contact);
            }

            return(crm_contact);
        }
Exemplo n.º 11
0
		public static List<string> Needs_update_in_crm(crm.Contact crm_contact, of.data.Contact of_contact)
		{
			List<string> parameters = new List<string>();

			Mapping_update_helper.Add_if_unequal(parameters, "address1_city", crm_contact.address1_city, of_contact.City);
			Mapping_update_helper.Add_if_unequal(parameters, "address1_country", crm_contact.address1_country, of_contact.Country);
			Mapping_update_helper.Add_if_unequal(parameters, "Gendercode", crm_contact.gendercode.SelectedValue, of_contact.Gender);
			Mapping_update_helper.Add_if_unequal(parameters, "address1_latitude", crm_contact.address1_latitude, of_contact.Lat);
			Mapping_update_helper.Add_if_unequal(parameters, "address1_line1", crm_contact.address1_line1, of_contact.Address);
			Mapping_update_helper.Add_if_unequal(parameters, "address1_longitude", crm_contact.address1_longitude, of_contact.Long);
			Mapping_update_helper.Add_if_unequal(parameters, "address1_postalcode", crm_contact.address1_postalcode, of_contact.Postcode);
			Mapping_update_helper.Add_if_unequal(parameters, "birthdate", crm_contact.birthdate, of_contact.Birthday_stamp_value);
			Mapping_update_helper.Add_if_unequal(parameters, "emailaddress1", crm_contact.emailaddress1, of_contact.Email);
			Mapping_update_helper.Add_if_unequal(parameters, "firstname", crm_contact.firstname, of_contact.First_name);
			Mapping_update_helper.Add_if_unequal(parameters, "lastname", crm_contact.lastname, of_contact.Last_name);
			Mapping_update_helper.Add_if_unequal(parameters, "new_cprnr", crm_contact.new_cprnr, of_contact.Cpr);

			return parameters;
		}
Exemplo n.º 12
0
		public static List<string> Needs_update_in_of(crm.Contact crm_contact, of.data.Contact of_contact)
		{
			List<string> parameters = new List<string>();

			Mapping_update_helper.Add_if_unequal(parameters, "City", crm_contact.address1_city, of_contact.City);
			Mapping_update_helper.Add_if_unequal(parameters, "Country", crm_contact.address1_country, of_contact.Country);
			Mapping_update_helper.Add_if_unequal(parameters, "Gender", crm_contact.gendercode.SelectedValue, of_contact.Gender);
			Mapping_update_helper.Add_if_unequal(parameters, "Lat", crm_contact.address1_latitude, of_contact.Lat);
			Mapping_update_helper.Add_if_unequal(parameters, "Address", crm_contact.address1_line1, of_contact.Address);
			Mapping_update_helper.Add_if_unequal(parameters, "Long", crm_contact.address1_longitude, of_contact.Long);
			Mapping_update_helper.Add_if_unequal(parameters, "Postcode", crm_contact.address1_postalcode, of_contact.Postcode);
			Mapping_update_helper.Add_if_unequal(parameters, "Email", crm_contact.emailaddress1, of_contact.Email);
			Mapping_update_helper.Add_if_unequal(parameters, "First_name", crm_contact.firstname, of_contact.First_name);
			Mapping_update_helper.Add_if_unequal(parameters, "Last_name", crm_contact.lastname, of_contact.Last_name);
			Mapping_update_helper.Add_if_unequal(parameters, "External_id", crm_contact.new_kkadminmedlemsnr?.ToString(), of_contact.External_id);
			Mapping_update_helper.Add_if_unequal(parameters, "Cpr", crm_contact.new_cprnr, of_contact.Cpr);

			Mapping_update_helper.Add_if_other_exists(parameters, "Address", "Postcode");

			return parameters;
		}
Exemplo n.º 13
0
        protected override void Execute(CodeActivityContext codeActivityContext)
        {
            try
            {
                Initialize(codeActivityContext);

                int             of_contact_id = Of_contact_id_InArgument.Get <int>(codeActivityContext);
                of.data.Contact of_contact    = _of_connection.Contact.Get(of_contact_id);

                _tracingService.Trace($"of_id: {of_contact_id}");

                if (of_contact == null)
                {
                    return;
                }

                Maintain maintain = new Maintain(_service, _tracingService, _config, _of_connection);
                maintain.Create_or_update_one_contact_in_crm(of_contact_id, of_contact);
            }
            catch (Exception exception)
            {
                Write_exception(exception);
            }
        }
Exemplo n.º 14
0
        private void Create_contact_in_crm(crm.Contact crm_contact, of.data.Contact of_contact)
        {
            Mapping.Contact.To_crm(crm_contact, of_contact, _tracingService);

            crm_contact.Create();
        }
Exemplo n.º 15
0
        public void Create_or_update_one_contact_in_of(crm.Contact crm_contact)
        {
            of.data.Contact of_contact = Get_or_create_of_contact(crm_contact);

            Update_of_contact(crm_contact, of_contact);
        }