コード例 #1
0
        public override void ExecuteOption(OptionReport report)
        {
            string urlLoginName = _databaseUpdateMailrelayFromContact.urlLoginName;
            int    pageSize     = _databaseUpdateMailrelayFromContact.pageSize;
            Guid?  contactId    = _databaseUpdateMailrelayFromContact.contactId;

            DatabaseUrlLogin      login = DatabaseUrlLogin.GetUrlLogin(Connection, urlLoginName);
            DynamicsCrmConnection dynamicsCrmConnection = DynamicsCrmConnection.GetConnection(login.Url, login.Username, login.Password);

            PagingInformation pagingInformation = new PagingInformation();

            List <MailrelayInformation> mailrelayInformations = new List <MailrelayInformation>();

            UpdateReport <int> intReport = new UpdateReport <int>();

            while (pagingInformation.FirstRun || pagingInformation.MoreRecords)
            {
                mailrelayInformations = MailrelayInformation.GetMailrelayFromContact(dynamicsCrmConnection, Config.GetResourcePath, pagingInformation, pageSize, contactId);
                mailrelayInformations.ForEach(information => UpdateIfNeeded(dynamicsCrmConnection, information, intReport));
            }

            Log.Write(Connection, intReport.AsLogText("UpdateMailrelayFromContact"), typeof(UpdateMailrelayFromContact), DataLayer.MongoData.Config.LogLevelEnum.OptionReport);

            report.Success = true;
            return;
        }
コード例 #2
0
        private void AddToMailrelayGroup(DynamicsCrmConnection dynamicsCrmConnection, UpdateReport <int> report, Subscriber subscriber, List <KeyValueEntity <Guid, int?> > crmIdsAndSubscriberIds, int groupInCrm)
        {
            foreach (KeyValueEntity <Guid, int?> idPair in crmIdsAndSubscriberIds)
            {
                MailrelayInformation mailrelayInformation = MailrelayInformation.GetMailrelayFromContact(dynamicsCrmConnection, Config.GetResourcePath, new PagingInformation(), 1, idPair.key).Single();

                UpdateResultEnum result = subscriber.UpdateIfNeeded(idPair.value.Value, mailrelayInformation.fullname, mailrelayInformation.emailaddress1, mailrelayInformation.GetCustomFields(), groupInCrm);

                report.CollectUpdate(result, idPair.value.Value);
            }
        }
コード例 #3
0
        public void GetMailrelayFromContactCanReturnInformation()
        {
            PagingInformation pagingInformation = new PagingInformation();

            int subscriberId = new Random().Next(1, int.MaxValue);

            Contact contact = CreateTestContact();

            contact.new_mailrelaysubscriberid = subscriberId;
            contact.InsertWithoutRead();

            List <MailrelayInformation> informations = MailrelayInformation.GetMailrelayFromContact(_dynamicsCrmConnection, _config.GetResourcePath, pagingInformation, 1, contact.Id);

            contact.Delete();

            Assert.AreEqual(1, informations.Count);
        }