public CreateOrUpdateAmoContact(Client1C client1C, Amo amo, Log log, RecentlyUpdatedEntityFilter filter)
 {
     _amo      = amo;
     _log      = log;
     _client1C = client1C;
     _filter   = filter;
 }
Beispiel #2
0
 public UpdateAmoLead(Lead1C lead1C, Amo amo, Log log, RecentlyUpdatedEntityFilter filter)
 {
     _amo    = amo;
     _log    = log;
     _lead1C = lead1C;
     _filter = filter;
 }
Beispiel #3
0
 public CreateOrUpdateAmoLead(Lead1C lead1C, Amo amo, Log log, Cred1C cred1C, RecentlyUpdatedEntityFilter filter)
 {
     _amo    = amo;
     _log    = log;
     _lead1C = lead1C;
     _cred1C = cred1C;
     _filter = filter;
 }
Beispiel #4
0
 public WebhookController(Amo amo, ProcessQueue processQueue, Log log, RecentlyUpdatedEntityFilter filter, GSheets gSheets)
 {
     _amo          = amo;
     _processQueue = processQueue;
     _log          = log;
     _filter       = filter;
     _gSheets      = gSheets;
 }
 public CreateOrUpdate1CCompany(Amo amo, Log log, int leadId, Cred1C cred1C, RecentlyUpdatedEntityFilter filter)
 {
     _amo     = amo;
     _log     = log;
     _leadId  = leadId;
     _amo_acc = 19453687;
     _repo1C  = new(cred1C);
     _filter  = filter;
 }
Beispiel #6
0
 public CreateOrUpdate1CLead(Amo amo, Log log, int leadId, int amo_acc, Cred1C cred1C, RecentlyUpdatedEntityFilter filter)
 {
     _amo     = amo;
     _log     = log;
     _leadId  = leadId;
     _amo_acc = amo_acc;
     _cred1C  = cred1C;
     _filter  = filter;
 }
 public SmilarcompaniesCheckProcessor(int companyNumber, AmoAccount acc, ProcessQueue processQueue, Log log, CancellationToken token, RecentlyUpdatedEntityFilter filter)
 {
     _companyNumber = companyNumber;
     _compRepo      = acc.GetRepo <Company>();
     _token         = token;
     _log           = log;
     _filter        = filter;
     _processQueue  = processQueue;
 }
Beispiel #8
0
 public Integration1CController(Amo amo, ProcessQueue processQueue, Log log, Cred1C cred1C, RecentlyUpdatedEntityFilter filter)
 {
     _amo          = amo;
     _processQueue = processQueue;
     _log          = log;
     _cred1C       = cred1C;
     _filter       = filter;
     _path         = $@"logs\1c\{DateTime.Today.Year}-{DateTime.Today.Month}-{DateTime.Today.Day}.log";
 }
Beispiel #9
0
 public CreateOrUpdateAmoCompany(Company1C company1C, Amo amo, Log log, RecentlyUpdatedEntityFilter filter)
 {
     _amo       = amo;
     _log       = log;
     _company1C = company1C;
     _compRepo  = _amo.GetAccountById(19453687).GetRepo <Company>();
     _amo_acc   = 19453687;
     _filter    = filter;
 }
Beispiel #10
0
 public Update1CClient(Amo amo, Log log, int contactId, int amo_acc, Cred1C cred1C, RecentlyUpdatedEntityFilter filter)
 {
     _amo       = amo;
     _log       = log;
     _contactId = contactId;
     _amo_acc   = amo_acc;
     _repo1C    = new(cred1C);
     _filter    = filter;
 }
Beispiel #11
0
 public TestingController(Amo amo, ProcessQueue processQueue, GSheets gSheets, Log log, Cred1C cred1C, RecentlyUpdatedEntityFilter filter, Uber uber)
 {
     _amo          = amo;
     _processQueue = processQueue;
     _gSheets      = gSheets;
     _log          = log;
     _cred1C       = cred1C;
     _filter       = filter;
     locker        = new();
     _uber         = uber;
 }
Beispiel #12
0
        private static void UpdateCompanyInAmo(Company1C company1C, IAmoRepo <Company> compRepo, int company_id, int amo_acc, RecentlyUpdatedEntityFilter filter)
        {
            Company company = new()
            {
                id = company_id,
                //name = company1C.name,
                custom_fields_values = new()
            };

            AddUIDToEntity(company1C, amo_acc, company);

            PopulateCFs(company1C, amo_acc, company);

            try
            {
                filter.AddEntity(company_id);
                compRepo.Save(company);
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to update company {company_id} in amo: {e.Message}");
            }
        }
Beispiel #13
0
        private static int CreateCompanyInAmo(Company1C company1C, IAmoRepo <Company> compRepo, int amo_acc, RecentlyUpdatedEntityFilter filter)
        {
            Company company = new()
            {
                name = company1C.name,
                custom_fields_values = new()
            };

            AddUIDToEntity(company1C, amo_acc, company);

            PopulateCFs(company1C, amo_acc, company);

            try
            {
                var result = compRepo.AddNew(company).ToList();
                result.ForEach(x => filter.AddEntity(x.id));
                if (result.Any())
                {
                    return(result.First().id);
                }
                else
                {
                    throw new Exception("Amo returned no company Ids.");
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to create company in amo: {e.Message}");
            }
        }
Beispiel #14
0
        private static void UpdateLeadInAmo(Lead1C lead1C, IAmoRepo <Lead> leadRepo, int lead_id, int acc_id, RecentlyUpdatedEntityFilter filter)
        {
            Lead lead = new()
            {
                id    = lead_id,
                price = lead1C.price,
                responsible_user_id  = UserList.GetAmoUser(lead1C.responsible_user),
                custom_fields_values = new(),
            };

            if (lead.responsible_user_id is null)
            {
                lead.responsible_user_id = UserList.GetAmoUser(lead1C.author);
            }

            AddUIDToEntity(lead1C, acc_id, lead);

            PopulateCFs(lead1C, acc_id, lead);

            try
            {
                filter.AddEntity(lead_id);
                leadRepo.Save(lead);
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to update lead {lead_id} in amo: {e.Message}");
            }
        }
Beispiel #15
0
        private static void UpdateContactInAmo(Client1C client1C, IAmoRepo <Contact> contRepo, int contact_id, int acc_id, RecentlyUpdatedEntityFilter filter)
        {
            Contact contact = new()
            {
                id   = contact_id,
                name = client1C.name,
                custom_fields_values = new(),
            };

            AddUIDToEntity(client1C, acc_id, contact);

            PopulateCFs(client1C, acc_id, contact);

            try
            {
                filter.AddEntity(contact_id);
                contRepo.Save(contact);
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to update contact {contact_id} in amo: {e.Message}");
            }
        }
Beispiel #16
0
 private static Guid GetOrCreateContragent(Amo amo, Lead1C lead1C, Cred1C cred1C, int amo_acc, RecentlyUpdatedEntityFilter filter)
 {
     if (amo_acc == 19453687)
     {
         return(default);
Beispiel #17
0
        private static int CreateLeadInAmo(Lead1C lead1C, IAmoRepo <Lead> leadRepo, int acc_id, int contact_id, int course_id, int company_id, RecentlyUpdatedEntityFilter filter)
        {
            Lead lead = new()
            {
                name  = "Новая сделка",
                price = lead1C.price,
                responsible_user_id  = UserList.GetAmoUser(lead1C.responsible_user),
                custom_fields_values = new(),
                _embedded            = new() { tags = new() { new() { name = "1C" } } }
            };

            if (lead.responsible_user_id is null)
            {
                lead.responsible_user_id = UserList.GetAmoUser(lead1C.author);
            }

            AddUIDToEntity(lead1C, acc_id, lead);

            PopulateCFs(lead1C, acc_id, lead);

            PopulateConnectedEntities(contact_id, company_id, lead);

            try
            {
                var result = leadRepo.AddNewComplex(lead).ToList();
                result.ForEach(x => filter.AddEntity(x));
                if (result.Any())
                {
                    EntityLink link = new()
                    {
                        to_entity_id   = course_id,
                        to_entity_type = "catalog_elements",
                        metadata       = new() {
                            quantity   = 1,
                            catalog_id = GetCatalogId(acc_id)
                        }
                    };

                    leadRepo.LinkEntity(result.First(), link);
                    return(result.First());
                }
                else
                {
                    throw new Exception("Amo returned no lead Ids.");
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to update lead {lead1C.lead_id_1C} in amo: {e.Message}");
            }
        }