예제 #1
0
        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}");
            }
        }
예제 #2
0
        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}");
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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}");
            }
        }
예제 #5
0
        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}");
            }
        }