コード例 #1
0
        public IEnumerable <CrmCompany> GetCompanies()
        {
            var companies = new List <CrmCompany>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig);
                if (companiesList == null)
                {
                    break;
                }
                if (companiesList.Response.Error == "Неверный логин или пароль")
                {
                    Thread.Sleep(5000);
                    companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig);
                    if (companiesList == null)
                    {
                        break;
                    }
                }
                companies.AddRange(companiesList.Response.Companies);
                if (offset > 0 && offset % 500 == 0)
                {
                    Thread.Sleep(1000);
                }

                //if (offset > 300)   break;
            }
            return(companies);
        }
コード例 #2
0
        public CrmContact GetContact(long contactId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = contactId, Type = ParameterType.QueryString
            };
            var contact = AmoMethod.Get <CrmGetContactResponse>(_crmConfig, parameterId);

            return(contact?.Response?.Contacts?.FirstOrDefault());
        }
コード例 #3
0
        public CrmCompany GetCompany(long companyId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = companyId, Type = ParameterType.QueryString
            };
            var company = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig, parameterId);

            return(company.Response.Companies.FirstOrDefault());
        }
コード例 #4
0
        public CrmAccountInfo GetAccountInfo()
        {
            var accountInfo = AmoMethod.Get <CrmGetAccountInfoResponse>(_crmConfig);

            if (accountInfo == null || accountInfo.Response == null)
            {
                throw new AmoCrmException(AmoCrmErrors.Unknown);
            }
            return(accountInfo.Response.Account);
        }
コード例 #5
0
        public CrmLead GetLead(long leadId)
        {
            var parameterId = new Parameter {
                Name = "id", Value = leadId, Type = ParameterType.QueryString
            };
            var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig, parameterId);

            if (leadsList == null)
            {
                return(null);
            }
            return(leadsList.Response.Leads.FirstOrDefault());
        }
コード例 #6
0
        public IEnumerable <CrmPipeline> GetPipelines()
        {
            var pipelines = new List <CrmPipeline>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var pipelinesList = AmoMethod.Get <CrmGetPipeLineResponse>(_crmConfig);

                pipelines.AddRange(pipelinesList.Response.Pipelines.Select(t => t.Value).ToList());
                break;
            }
            return(pipelines);
        }
コード例 #7
0
        public IEnumerable <CrmLead> GetLeads()
        {
            var leads = new List <CrmLead>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig);
                if (leadsList == null)
                {
                    break;
                }
                leads.AddRange(leadsList.Response.Leads);
            }
            return(leads);
        }
コード例 #8
0
        public IEnumerable <CrmContact> GetContacts()
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var contactsList = AmoMethod.Get <CrmGetContactResponse>(_crmConfig);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
コード例 #9
0
        public IEnumerable <CrmLead> GetLeads(int status)
        {
            var leads = new List <CrmLead>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "status", Value = status.ToString(), Type = ParameterType.QueryString
                };
                var leadsList = AmoMethod.Get <CrmGetLeadResponse>(_crmConfig, parameterQuery);
                if (leadsList == null)
                {
                    break;
                }
                leads.AddRange(leadsList.Response.Leads);
            }
            return(leads);
        }
コード例 #10
0
        public IEnumerable <CrmNote> GetNotes(string query)
        {
            var notes = new List <CrmNote>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterResponsibleUserId = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmGetNoteResponse>(_crmConfig, parameterResponsibleUserId);
                if (contactsList == null)
                {
                    break;
                }
                notes.AddRange(contactsList.Response.Notes);
            }
            return(notes);
        }
コード例 #11
0
        public IEnumerable <CrmContact> GetContacts(long responsibleUserId)
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterResponsibleUserId = new Parameter {
                    Name = "responsible_user_id", Value = responsibleUserId, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmGetContactResponse>(_crmConfig, parameterResponsibleUserId);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
コード例 #12
0
        public IEnumerable <CrmContact> GetContacts(string query)
        {
            var contacts = new List <CrmContact>();

            for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var contactsList = AmoMethod.Get <CrmContactResponse>(_crmConfig, parameterQuery);
                if (contactsList == null)
                {
                    break;
                }
                contacts.AddRange(contactsList.Response.Contacts);
            }
            return(contacts);
        }
コード例 #13
0
        public IEnumerable <CrmCompany> GetCompanies(string query)
        {
            var companies = new List <CrmCompany>();

            for (var offset = 0; ; offset += _crmConfig.LimitRows ?? 500)
            {
                _crmConfig.LimitOffset = offset;
                var parameterQuery = new Parameter {
                    Name = "query", Value = query, Type = ParameterType.QueryString
                };
                var companiesList = AmoMethod.Get <CrmGetCompanyResponse>(_crmConfig, parameterQuery);
                if (companiesList == null)
                {
                    break;
                }
                companies.AddRange(companiesList.Response.Companies);
                if (offset > 0 && offset % 1000 == 0)
                {
                    Thread.Sleep(1000);
                }
            }
            return(companies);
        }