コード例 #1
0
        // We cannot replace neither the email address nor the mobile phone number with default
        // strings. This is because the drivers will verify that those are unique when editing
        // the contacts. Any update there would then fail.
        // Thus we will hash a combination of the personal information and the UTC DateTime of the
        // anonymization/erasure. This should ensure that the resulting strings are unique. Since
        // the DateTime of the process may be logged somewhere, to prevent bruteforce discovery of
        // the original string (which would be comparatively simple in the case of the phone number)
        // rather than using a contant key, we generate a new one each time.

        private void HandleEmailRecords(GDPRContentContext context, EmailContactPart part)
        {
            foreach (var emailRecord in part.EmailRecord)
            {
                // Clear the email address
                emailRecord.Email = emailRecord.Email.GenerateUniqueString();
                _emailRecordRepository.Update(emailRecord);
            }
        }
コード例 #2
0
        public void PolicyChanged(PolicyEventViewModel policyData)
        {
            try {
                // recupera l'item (user o contact) che ha accettato le policy
                if (policyData.ItemPolicyPartRecordId == 0)
                {
                    var loggedUser = _workContext.GetContext().CurrentUser;
                    if (loggedUser == null)
                    {
                        // queste policy non si riferiscono a nessun item (user o contact, per esempio) e non c'è un utente loggato
                        // quindi non fare nulla
                        return;
                    }
                    else
                    {
                        policyData.ItemPolicyPartRecordId = loggedUser.Id;
                    }
                }
                // recupera il contatto
                CommunicationContactPart contactPart = null;
                var item = _contentManager.Get(policyData.ItemPolicyPartRecordId);
                if (item.ContentType == "User")
                {
                    contactPart = _contentManager.Query <CommunicationContactPart, CommunicationContactPartRecord>().Where(w => w.UserPartRecord_Id == item.Id).List().FirstOrDefault();
                }
                else if (item.ContentType == "CommunicationContact")
                {
                    contactPart = item.As <CommunicationContactPart>();
                }
                else
                {
                    // non fa nulla perché non è né uno user né un contatto
                    return;
                }
                // imposta i flag su email e sms
                if (policyData.policyType == PolicyTypeOptions.CommercialUse)
                {
                    EmailContactPart emailPart = contactPart.As <EmailContactPart>();
                    if (emailPart != null)
                    {
                        foreach (CommunicationEmailRecord emailContact in emailPart.EmailRecord)
                        {
                            emailContact.AccettatoUsoCommerciale = policyData.accepted;
                            _emailRepository.Update(emailContact);
                        }
                    }

                    SmsContactPart smsPart = contactPart.As <SmsContactPart>();
                    if (smsPart != null)
                    {
                        foreach (CommunicationSmsRecord smsContact in smsPart.SmsRecord)
                        {
                            smsContact.AccettatoUsoCommerciale = policyData.accepted;
                            _smsRepository.Update(smsContact);
                        }
                    }
                }

                if (policyData.policyType == PolicyTypeOptions.ThirdParty)
                {
                    EmailContactPart emailPart = contactPart.As <EmailContactPart>();
                    if (emailPart != null)
                    {
                        foreach (CommunicationEmailRecord emailContact in emailPart.EmailRecord)
                        {
                            emailContact.AutorizzatoTerzeParti = policyData.accepted;
                            _emailRepository.Update(emailContact);
                        }
                    }

                    SmsContactPart smsPart = contactPart.As <SmsContactPart>();
                    if (smsPart != null)
                    {
                        foreach (CommunicationSmsRecord smsContact in smsPart.SmsRecord)
                        {
                            smsContact.AutorizzatoTerzeParti = policyData.accepted;
                            _smsRepository.Update(smsContact);
                        }
                    }
                }
            }
            catch { }
        }
コード例 #3
0
        public ContactExport GetInfoContactExport(ContentItem content)
        {
            ContactExport contact = new ContactExport();

            // Id
            contact.Id = content.Id;

            // Title
            contact.Title = content.As <TitlePart>().Title;

            // Fields
            List <Hashtable> listaField = new List <Hashtable>();

            bool    ExistProfilePart = true;
            bool    ExistCommunicationContactPart = true;
            dynamic fields = null;

            try { fields = ((dynamic)content).CommunicationContactPart.Fields; }
            catch { ExistCommunicationContactPart = false; }
            if (ExistCommunicationContactPart)
            {
                foreach (dynamic cf in fields)
                {
                    Hashtable hs = ConvertField(cf, "CommunicationContactPart");
                    if (hs.Count > 0)
                    {
                        listaField.Add(hs);
                    }
                }
            }



            try {
                fields = ((dynamic)content).ProfilePart.Fields;
            } catch {
                ExistProfilePart = false;
            }



            if (ExistProfilePart)
            {
                foreach (dynamic cf in fields)
                {
                    Hashtable hs = ConvertField(cf, "ProfilePart");
                    if (hs.Count > 0)
                    {
                        listaField.Add(hs);
                    }
                    //if (cf.FieldDefinition.Name != typeof(ContentPickerField).Name && cf.FieldDefinition.Name != typeof(MediaLibraryPickerField).Name) {
                    //    string keyField = "ProfilePart." + ((object)cf.DisplayName).ToString();
                    //    string valueField = "";

                    //    if (cf.FieldDefinition.Name == typeof(DateTimeField).Name) {
                    //        if (cf.DateTime != null && !cf.DateTime.Equals(DateTime.MinValue))
                    //            valueField = ((object)cf.DateTime).ToString();
                    //    }
                    //    else if (cf.FieldDefinition.Name == typeof(TaxonomyField).Name) {
                    //        if (((TaxonomyField)cf).Terms != null) {
                    //            foreach (TermPart term in ((TaxonomyField)cf).Terms) {
                    //                // Più termini selezionati
                    //                if (valueField != "")
                    //                    valueField = ";" + valueField;

                    //                if (term.Path == "/") {
                    //                    // Taxonomy ad un livello
                    //                    valueField = term.Name.Replace('/', '\\').Replace(";", ".,") + valueField;
                    //                }
                    //                else {
                    //                    // Taxonomy su più livelli
                    //                    GetValueCompletoTerms(term, ref valueField);
                    //                }
                    //            }
                    //        }
                    //    } else {
                    //        if (cf.Value != null)
                    //            valueField = ((object)cf.Value).ToString();
                    //    }

                    //    Hashtable hs = new Hashtable();
                    //    hs.Add(keyField, valueField);
                    //    listaField.Add(hs);
                    //}
                }
            }
            contact.Fields = listaField;

            // Sms
            List <string>  listaSms  = new List <string>();
            string         smsPrefix = "";
            SmsContactPart smspart   = content.As <SmsContactPart>();

            foreach (CommunicationSmsRecord sms in smspart.Record.SmsRecord)
            {
                // Rimuovo il carattere '+' perchè Excel lo considera come una formula
                smsPrefix = sms.Prefix ?? "";
                if (smsPrefix.StartsWith("+"))
                {
                    smsPrefix = smsPrefix.Substring(1);
                }

                listaSms.Add(smsPrefix + "/" + sms.Sms);
            }
            contact.Sms = listaSms;

            // Mail
            List <string> listaMail = new List <string>();

            EmailContactPart mailpart = content.As <EmailContactPart>();

            foreach (CommunicationEmailRecord mail in mailpart.Record.EmailRecord)
            {
                listaMail.Add(mail.Email);
            }
            contact.Mail = listaMail;

            return(contact);
        }
コード例 #4
0
 protected void LazyLoadEmailHandlers(LoadContentContext context, EmailContactPart part)
 {
     // Add handlers that will load content for id's just-in-time
     part.EmailEntries.Loader(() => OnEmailLoader(context));
 }