public AbstractLeadProcessor(int leadNumber, AmoAccount acc, ProcessQueue processQueue, Log log, CancellationToken token) { _leadRepo = acc.GetRepo <Lead>(); _processQueue = processQueue; _token = token; _acc = acc; _leadNumber = leadNumber; _log = log; custom_fields_values = new(); tags = new(); try { Thread.Sleep((int)TimeSpan.FromSeconds(3).TotalMilliseconds); lead = _leadRepo.GetById(leadNumber); if (lead is not null && lead._embedded is not null && lead._embedded.tags is not null) { tags = lead._embedded.tags; } } catch (Exception e) { _processQueue.Stop(leadNumber.ToString()); _processQueue.Remove(leadNumber.ToString()); _log.Add($"Error: Unable to create leadProcessor {leadNumber}: {e.Message}"); } }
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}"); } }
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}"); } }
public RetailCourseProcessor(Amo amo, ProcessQueue processQueue, CancellationToken token, int leadNumber, Log log) { _repo = amo.GetAccountById(28395871).GetRepo <Lead>(); _processQueue = processQueue; _token = token; _leadNumber = leadNumber; _log = log; }
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; }
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; }
public AbstractLeadProcessor(AmoAccount acc, ProcessQueue processQueue, Log log, CancellationToken token) { _leadRepo = acc.GetRepo <Lead>(); _processQueue = processQueue; _token = token; _acc = acc; _log = log; custom_fields_values = new(); tags = new(); }
public RetailRespProcessor(Amo amo, ProcessQueue processQueue, CancellationToken token, int entityNumber, Log log, Type type, int oldResp, int modResp) { _leadRepo = amo.GetAccountById(28395871).GetRepo <Lead>(); _contRepo = amo.GetAccountById(28395871).GetRepo <Contact>(); _processQueue = processQueue; _token = token; _entityNumber = entityNumber; _log = log; _type = type; _oldResp = oldResp; _modResp = modResp; }
public SendToRetProcessor(Amo amo, Log log, ProcessQueue processQueue, int leadNumber, CancellationToken token) { _log = log; _leadNumber = leadNumber; _processQueue = processQueue; _token = token; _leadRepo = amo.GetAccountById(28395871).GetRepo <Lead>(); _contRepo = amo.GetAccountById(28395871).GetRepo <Contact>(); _sourceLeadRepo = amo.GetAccountById(19453687).GetRepo <Lead>(); _sourceContRepo = amo.GetAccountById(19453687).GetRepo <Contact>(); }
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}"); } }
public RetailPaidProcessor(Amo amo, Log log, ProcessQueue processQueue, CancellationToken token, GSheets gSheets, string taskName, string phone, string email, string price) { _log = log; _processQueue = processQueue; _token = token; _taskName = taskName; _phone = phone.Trim().Replace("+", "").Replace("-", "").Replace(" ", "").Replace("(", "").Replace(")", ""); _email = email.Trim().Replace(" ", ""); int.TryParse(price, out _price); var acc = amo.GetAccountById(28395871); _contRepo = acc.GetRepo <Contact>(); }
private static void UpdateCourseInAmo(Course1C course, IAmoRepo <Lead> leadRepo, int ce_id, int acc_id) { CatalogElement ce = new() { id = ce_id, name = course.name, custom_fields = new() }; AddUIDToEntities(course, acc_id, ce); PopulateCFs(course, acc_id, ce); leadRepo.UpdateCEs(ce); }
public SiteFormRetailProcessor(Amo amo, Log log, FormRequest formRequest, ProcessQueue processQueue, CancellationToken token, GSheets gSheets, string taskName) { _amo = amo; _log = log; _formRequest = formRequest; _processQueue = processQueue; _token = token; _gSheets = gSheets; _taskname = taskName; var acc = amo.GetAccountById(28395871); _leadRepo = acc.GetRepo <Lead>(); _contRepo = acc.GetRepo <Contact>(); }
public ConferencePaidProcessor(Amo amo, Log log, ProcessQueue processQueue, CancellationToken token, GSheets gSheets, string taskName, string phone, string email) { _amo = amo; _log = log; _processQueue = processQueue; _token = token; _gSheets = gSheets; _taskName = taskName; _phone = phone.Trim().Replace("+", "").Replace("-", "").Replace(" ", "").Replace("(", "").Replace(")", ""); _email = email.Trim().Replace(" ", ""); var acc = amo.GetAccountById(19453687); _leadRepo = acc.GetRepo <Lead>(); _contRepo = acc.GetRepo <Contact>(); _compRepo = acc.GetRepo <Company>(); }
public PPIELeadsProcessor(int leadNumber, AmoAccount acc, ProcessQueue processQueue, Log log, CancellationToken token) { _leadRepo = acc.GetRepo <Lead>(); _processQueue = processQueue; _token = token; _leadNumber = leadNumber; _log = log; try { Thread.Sleep((int)TimeSpan.FromSeconds(3).TotalMilliseconds); lead = _leadRepo.GetById(leadNumber); } catch (Exception e) { _processQueue.Stop(leadNumber.ToString()); _processQueue.Remove(leadNumber.ToString()); _log.Add($"Error: Unable to create leadProcessor {leadNumber}: {e.Message}"); } }
private static Amo_id CreateCourseInAmo(Course1C course, IAmoRepo <Lead> leadRepo, int acc_id) { CatalogElement ce = new() { name = course.name, custom_fields = new() }; AddUIDToEntity(course, acc_id, ce); PopulateCFs(course, acc_id, ce); var result = leadRepo.AddCEs(ce); if (!result.Any()) { throw new Exception($"Unable to update course in amo {course.name}"); } return(new() { account_id = acc_id, entity_id = result.First().id }); }
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}"); } }
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}"); } }
private static Request GetProcessedLeadRequest(Lead lead, int sheetId, IAmoRepo <Company> compRepo) { #region Оганизация string A = ""; if (lead._embedded.companies.Any()) { A = compRepo.GetById(lead._embedded.companies.FirstOrDefault().id).name; } #endregion #region Назначение платежа string B = lead.GetCFStringValue(118509); #endregion #region Кол-во человек int C = lead.GetCFIntValue(611005); if (C == 0) { C++; } #endregion #region Сумма int E = (int)lead.price; #endregion #region Стоимость string D = @"=INDIRECT(""R[0]C[1]"", FALSE)/INDIRECT(""R[0]C[-1]"", FALSE)"; #endregion #region Дата прихода long payment_date_unix; if (lead.custom_fields_values.Any(x => x.field_id == 118675)) { payment_date_unix = (long)lead.custom_fields_values.FirstOrDefault(x => x.field_id == 118675).values[0].value; } else { payment_date_unix = 0; } string F = DateTimeOffset.FromUnixTimeSeconds(payment_date_unix).UtcDateTime.AddHours(3).ToShortDateString(); #endregion #region Номер квитанции string G = lead.GetCFStringValue(118609); #endregion #region асчет string H = lead.GetCFStringValue(118545); #endregion #region Исполнитель string I = lead.GetCFStringValue(162301); #endregion #region Номер сделки int J = lead.id; #endregion #region % сделки int K = lead.GetCFIntValue(613663); #endregion #region Вознаграждение string L = @"=INDIRECT(""R[0]C[-7]"", FALSE)*INDIRECT(""R[0]C[-1]"", FALSE)/100"; #endregion return(GetRowRequest(sheetId, GetCellData(A, B, C, D, E, F, G, H, I, J, K, L))); }
public LeadTasksController(Amo amo) { _amo = amo; _leadRepo = amo.GetAccountById(28395871).GetRepo <Lead>(); }