public void OnLeadChanged([FromBody] EventResponse response) { Log.Debug("Изменение лида"); Log.Debug(response.data.fields.ID); try { BitrixClient Bitrix = BitrixClient.Instance; AirTableClient AirTable = AirTableClient.Instance; var Lead = Bitrix.GetLead(response.data.fields.ID); if (Lead.Lead.DATE_CREATE > new DateTime(2019, 7, 2, 13, 11, 0)) { if (Lead.Lead.IsValid) { AirTable.UpdateOrCreate(Lead); } else { AirTable.DeleteIfExist(Lead); } } else { Log.Debug("Старый лид"); } } catch (Exception ex) { Log.Debug($"{ex}\r\nВнутреннее исключение:{ex.InnerException}"); } }
public void OnDealChanged([FromBody] EventResponse response) { try { Log.Debug("Изменение сделки"); Log.Debug(response.data.fields.ID); BitrixClient Bitrix = BitrixClient.Instance; AirTableClient AirTable = AirTableClient.Instance; var Deal = Bitrix.GetDeal(response.data.fields.ID); if (Deal.Deal.DATE_CREATE > new DateTime(2019, 7, 2, 13, 11, 0)) { if (Deal.Deal.IsValid) { AirTable.UpdateOrCreate(Deal); } } else { Log.Debug("Старая сделка"); } } catch (Exception ex) { Log.Debug($"{ex}\r\nВнутреннее исключение:{ex.InnerException}"); } }
public void TestGettingID() { BitrixClient Bitrix = BitrixClient.Instance; AirTableClient AirTable = AirTableClient.Instance; var d = Bitrix.GetDeal("1521"); string s = JsonConvert.SerializeObject(d); s = s.Replace("[75]", "false"); var dd = JsonConvert.DeserializeObject <DealResponse>(s); s = JsonConvert.SerializeObject(dd); AirTable.UpdateOrCreate(d); }
public void OnCommentAdd([FromBody] EventResponse response) { try { BitrixClient Bitrix = BitrixClient.Instance; AirTableClient AirTable = AirTableClient.Instance; var Comment = Bitrix.GetComment(response.data.fields.ID); AirTable.Update(Comment); } catch (Exception ex) { Log.Debug($"{ex}\r\nВнутреннее исключение:{ex.InnerException}"); } }
public void OnCommentUpdate([FromBody] EventResponse response) { try { BitrixClient Bitrix = BitrixClient.Instance; AirTableClient AirTable = AirTableClient.Instance; var Comment = Bitrix.GetComment(response.data.fields.ID); var OtherComments = Bitrix.GetTimeLine(Comment.Comment.ENTITY_ID.ToString(), Comment.Comment.ENTITY_TYPE); if (Comment.Comment == OtherComments.Entries.OrderByDescending(c => c.CREATED).FirstOrDefault()) { AirTable.Update(Comment); } } catch (Exception ex) { Log.Debug($"{ex}\r\nВнутреннее исключение:{ex.InnerException}"); } }