internal static async Task <IList <BusinessAccountWrapper> > GetBusinessAccountsWithContacts(
     ApiConnectionConfig config,
     CancellationToken ct)
 {
     return(await JsonFileCacheManager.Instance.ReadFromCacheOrSaveAsync(
                BusinessAccountsWithContactsCacheName,
                () => GetBusinessAccountsWithContactsApi(config, ct)));
 }
Ejemplo n.º 2
0
        public static MaintenanceClient LoginLogoutClient(ApiConnectionConfig apiConnectionConfig)
        {
            if (apiConnectionConfig == null)
            {
                throw new ArgumentNullException(nameof(apiConnectionConfig));
            }

            var client = LogoutClient(apiConnectionConfig.EndpointSettings);

            client.Login(apiConnectionConfig.LoginInfo);
            return(client);
        }
 public OpportunityGenerationRunner(ApiConnectionConfig apiConnectionConfig, OpportunityGenerationSettings generationSettings)
     : base(apiConnectionConfig, generationSettings)
 {
 }
Ejemplo n.º 4
0
 public abstract GenerationRunner GetGenerationRunner(ApiConnectionConfig apiConnectionConfig);
 public LinkEmailsGenerationRunner(ApiConnectionConfig apiConnectionConfig, LinkEmailsGenerationSettings generationSettings) : base(apiConnectionConfig, generationSettings)
 {
 }
Ejemplo n.º 6
0
 public override GenerationRunner GetGenerationRunner(ApiConnectionConfig apiConnectionConfig) => new LeadGenerationRunner(apiConnectionConfig, this);
Ejemplo n.º 7
0
 public override GenerationRunner GetGenerationRunner(ApiConnectionConfig apiConnectionConfig) => new OpportunityGenerationRunner(apiConnectionConfig, this);
Ejemplo n.º 8
0
 public LeadConvertGenerationRunner(ApiConnectionConfig apiConnectionConfig, LeadConvertGenerationSettings generationSettings)
     : base(apiConnectionConfig, generationSettings)
 {
 }
        // fetches only contacts with emails
        private static async Task <IList <BusinessAccountWrapper> > GetBusinessAccountsWithContactsApi(
            ApiConnectionConfig config,
            CancellationToken ct)
        {
            #region help
            // cannot get emails for baccounts via cb - so need to fetch data with sql
            // example sql query:

            /*
             *
             * select  b.BAccountID as BusinessAccountOriginID,
             * b.AcctCD as BusinessAccountID,
             * b.Type,
             * c.ContactID,
             * c.EMail as ContactEmail,
             * defC.EMail as BusinessAccountEmail
             *
             * from            Baccount b
             * left join   Contact c       ON c.BAccountID = b.BAccountID
             * left join   Contact defC    ON defC.ContactID = b.DefContactID
             *
             * where   c.ContactType = 'PN'
             * and c.IsActive = 1
             * and b.[Status] = 'A'
             * and (c.EMail is not null or defC.EMail is not null)
             * and b.CompanyID = 2
             * and b.DeletedDatabaseRecord = 0
             * and c.DeletedDatabaseRecord = 0
             * and defC.DeletedDatabaseRecord = 0
             *
             */

            // save as json
            // use ParseJsonBusinessAccountFetchedData after to get prepared cache
            #endregion

            var prefetchedFile = JsonFileCacheManager.Instance.CacheFolder
                                 + BusinessAccountsWithContactsCacheName
                                 + ".prepared"
                                 + JsonFileCacheManager.Instance.FileExtension;
            if (!System.IO.File.Exists(prefetchedFile))
            {
                throw new NotSupportedException("Cannot execute optimized export for Business Accounts to get Contacts and Main Contact," +
                                                "you have to write custom sql script and put cache by yourself.");
            }

            await System.Threading.Tasks.Task.Yield();

            return(ParseJsonBusinessAccountFetchedData(prefetchedFile));

            //IEnumerable<BusinessAccount> accounts;
            //IEnumerable<Contact> contacts;
            //using (var client = await GenerationRunner.ApiLoginLogoutClientFactory(config))
            //{
            //    var accountsTask = client.GetListAsync(
            //        new BusinessAccount
            //        {
            //            BusinessAccountID = new StringReturn(),
            //            Type = new StringReturn(),
            //            Contacts = new BusinessAccountContact[]
            //            {
            //                new BusinessAccountContact
            //                {
            //                    ContactID = new IntReturn(),
            //                    Email = new StringReturn(),
            //                },
            //            },
            //            ReturnBehavior = ReturnBehavior.OnlySpecified,
            //        },
            //        ct
            //    );

            //    var contactsTask = client.GetListAsync(
            //        new Contact
            //        {
            //            ContactID = new IntReturn(),
            //            BusinessAccount = new StringReturn(),
            //            Email = new StringSearch(null, StringCondition.IsNotNull),
            //            Active = new BooleanSearch { Value = true },
            //            ReturnBehavior = ReturnBehavior.OnlySpecified
            //        },
            //        ct
            //    );
            //    // consuming operation. in parallel should be faster.
            //    accounts = await accountsTask;
            //    contacts = await contactsTask;
            //}

            //var groupedContacts = contacts
            //    .GroupBy(c => c.BusinessAccount?.Value)
            //    .Where(c => c.Key != null)
            //    .ToDictionary(g => g.Key, g => g);

            //return accounts
            //    .Select(a => BusinessAccountWrapper.FromBusinessAccount(a))
            //    .ToList();
        }
Ejemplo n.º 10
0
 protected EntitiesSearchGenerationRunner(ApiConnectionConfig apiConnectionConfig, TGenerationSettings generationSettings) : base(apiConnectionConfig, generationSettings)
 {
 }
 public CaseGenerationRunner(ApiConnectionConfig apiConnectionConfig, CaseGenerationSettings generationSettings)
     : base(apiConnectionConfig, generationSettings)
 {
 }
Ejemplo n.º 12
0
 public override GenerationRunner GetGenerationRunner(ApiConnectionConfig apiConnectionConfig) => new LinkActivitiesGenerationRunner(apiConnectionConfig, this);