Beispiel #1
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);
        }
Beispiel #2
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;
            }
        }
Beispiel #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",
		}
Beispiel #4
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);
        }
Beispiel #5
0
 private void Attach_of_contact_if_missing(crm.Abonnement crm_abonnement)
 {
     if (crm_abonnement.Nrq_subscriber != null)
     {
         crm.Contact crm_contact = new crm.Contact(_service, _tracingService);
         crm_contact.Get_by_reference(crm_abonnement.Nrq_subscriber);
         Create_or_update_one_contact_in_of(crm_contact);
     }
 }
Beispiel #6
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);
        }
Beispiel #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);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        private void Create_of_aftale(crm.Aftale crm_aftale)
        {
            of.data.Agreement of_aftale = new of.data.Agreement();

            Mapping.Aftale.To_of(crm_aftale, of_aftale);

            crm.Contact crm_contact = Get_crm_contact_from_crm_aftale(crm_aftale);
            if (crm_contact != null)
            {
                Get_or_create_of_contact(crm_contact);
            }

            _of_connection.Agreement.Post(of_aftale);
        }
Beispiel #10
0
        protected crm.Contact Get_crm_contact_from_crm_aftale(crm.Aftale crm_aftale)
        {
            if (crm_aftale.nrq_bidragyder != null)
            {
                crm.Contact crm_contact = new crm.Contact(_service, _tracingService);
                crm_contact.Get_by_reference(crm_aftale.nrq_bidragyder);

                if (crm_contact.CrmEntity != null)
                {
                    return(crm_contact);
                }
            }

            return(null);
        }
Beispiel #11
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;
		}
Beispiel #12
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);
        }
Beispiel #13
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);
        }
        protected override void Execute(CodeActivityContext codeActivityContext)
        {
            try
            {
                Initialize(codeActivityContext);

                EntityReference aftaleEntityReference = ContactEntityReference.Get <EntityReference>(codeActivityContext);

                crm.Contact crm_contact = new crm.Contact(_service, _tracingService);
                crm_contact.Get_by_reference(aftaleEntityReference);

                Maintain maintain = new Maintain(_service, _tracingService, _config, _of_connection);
                maintain.Create_or_update_one_contact_in_of(crm_contact);
            }
            catch (Exception exception)
            {
                Write_exception(exception);
            }
        }
Beispiel #15
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;
		}
Beispiel #16
0
        private bool Add_contact_to_aftale(crm.Aftale crm_aftale, of.data.Agreement of_aftale)
        {
            if (of_aftale.Contact_id.HasValue == false)
            {
                return(false);
            }

            crm.Contact crm_contact = Get_or_create_crm_contact(of_aftale.Contact_id.Value);

            bool update_nrq_bidragyder = false;

            if (crm_aftale.nrq_bidragyder == null || crm_aftale.nrq_bidragyder.Id != crm_contact.Id)
            {
                update_nrq_bidragyder = true;
            }

            crm_aftale.nrq_bidragyder = crm_contact.Get_entity_reference();

            return(update_nrq_bidragyder);
        }
Beispiel #17
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;
		}
Beispiel #18
0
        private void Add_crm_contact_to_abonnement(crm.Abonnement crm_abonnement, of.data.Subscription of_abonnement)
        {
            crm.Contact crm_contact = Get_or_create_crm_contact(of_abonnement.Contact_id.Value);

            crm_abonnement.Nrq_subscriber = crm_contact.Get_entity_reference();
        }
Beispiel #19
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);
        }
Beispiel #20
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();
        }