Пример #1
0
        public int UpdateThreadId(string business_id, [FromQuery] string access_token)
        {
            int count = 0;

            if (access_token != "@bazavietnam")
            {
                return(count);
            }
            var list = _threadService.All(business_id).Result.ToList();

            for (int i = 0; i < list.Count(); i++)
            {
                var t    = list[i];
                var id   = t.id;
                var d    = string.IsNullOrWhiteSpace(t.id) ? null : t.id.Split('_');
                var tidn = d != null && d.Length > 0 ? d.Last() : "";
                t.id = ThreadService.FormatId(business_id, tidn);

                if (t.timestamp > 9999999999 || id != t.id || t.timestamp < 99999999)
                {
                    var job = BackgroundJob.Enqueue <ThreadService>(x => x.CreateThread(t, false));
                    count++;
                    if (t.timestamp > 9999999999)
                    {
                        t.timestamp = t.timestamp / 1000;
                    }
                    if (t.timestamp < 99999999)
                    {
                        t.timestamp = t.timestamp * 1000;
                    }
                    BackgroundJob.ContinueWith <ThreadService>(job, x => x.Delete(business_id, id));
                }
            }

            return(count);
        }