Exemple #1
0
        public async Task Login(string pwd)
        {
            var ret = await HttpService.Post <object>($"UserName=13718607977&Pwd={pwd}&OnlineStatus=400&AccountType=1&Ccp=", Config._Login);

            if (ret.CookieCollection.Count > 0 && ret.CookieCollection["webim_sessionid"] != null)
            {
                var webimsessionid = ret.CookieCollection["webim_sessionid"].Value;
                using (var live = new LiveContext())
                {
                    var im = live.WebImConfig.FirstOrDefault();
                    if (im == null)
                    {
                        live.WebImConfig.Add(new WebImConfig()
                        {
                            UserName = "******", Ssid = webimsessionid
                        });
                    }
                    else
                    {
                        im.UserName = "******";
                        im.Ssid     = webimsessionid;
                    }
                    live.SaveChanges();
                }
                GetConnect(webimsessionid);
            }
        }
Exemple #2
0
        public async Task <IActionResult> Index(string msg, string imno)
        {
            WebImConfig im;

            using (var live = new LiveContext())
            {
                im = live.WebImConfig.FirstOrDefault();
            }

            var body   = $"UserName={im.UserName}&Msg={msg}&Receivers={imno}&ssid={im.Ssid}";
            var result = await HttpService.Post <object>(body, Config._Sendsms);

            using (var live = new LiveContext())
            {
                live.SmsQu.Add(new SmsQu()
                {
                    Msg       = msg,
                    Receivers = imno,
                    Completed = result.StringBody.rc == "200",
                    AddTime   = DateTime.Now
                });
                live.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public IActionResult Contact(string mobile, string imno)
        {
            using (var live = new LiveContext())
            {
                var rece = live.Receivers.Any(i => i.Mobile == mobile && i.ImNo == imno);
                if (!rece)
                {
                    live.Receivers.Add(new Receivers()
                    {
                        Mobile  = mobile,
                        ImNo    = imno,
                        AddTime = DateTime.Now
                    });
                }
                live.SaveChanges();
            }

            return(RedirectToAction("Contact"));
        }
        public async Task BooksUpdateAsync()
        {
            Console.WriteLine("Start updatign books");
            var bestList = new List <Book>();


            await _context.SaveChangesAsync();

            var bonitos = await new Bonito().GetBestsellersAsync();

            bestList.AddRange(bonitos);
            var aros = await new Aros().GetBestsellersAsync();

            bestList.AddRange(aros);
            var czytams = await new Czytam().GetBestsellersAsync();

            bestList.AddRange(czytams);
            var empiks = await new Empik().GetBestsellersAsync();

            bestList.AddRange(empiks);
            var gandalfs = await new Gandalf().GetBestsellersAsync();

            bestList.AddRange(gandalfs);
            var livros = await new Livro().GetBestsellersAsync();

            bestList.AddRange(livros);
            var profit24s = await new Profit24().GetBestsellersAsync();

            bestList.AddRange(profit24s);

            Log.Information($"Finish bestsellers update with {bestList.Count} books");
            Log.Information($"{bonitos.Count} from Bonito");
            Log.Information($"{aros.Count} from Aros");
            Log.Information($"{czytams.Count} from Czytam");
            Log.Information($"{empiks.Count} from Empik");
            Log.Information($"{gandalfs.Count} from Gandalf");
            Log.Information($"{livros.Count} from Livro");
            Log.Information($"{profit24s.Count} from Profit24");

            var actualBestsellers = _context.Bestsellers.ToList();

            _context.Bestsellers.RemoveRange(_context.Bestsellers.Where(x => x.Store != ""));
            _context.SaveChanges();

            int group = 1;

            foreach (var book in bestList)
            {
                var theSameList = bestList.Where(x => x.GroupNo == -1)
                                  .Where(x => x.TheSame(book.Title, book.Author)).ToList();

                if (theSameList.Count > 0)
                {
                    foreach (var theSameBook in theSameList)
                    {
                        theSameBook.GroupNo = group;
                    }
                    group++;
                }
            }

            int no = 1;

            foreach (var book in bestList)
            {
                var exists = actualBestsellers.FirstOrDefault(x => x.ImageSrc == book.ImageSrc);

                if (exists != null)
                {
                    Console.WriteLine("Added exists");
                    exists.Added = DateTime.Now;

                    var theSame = bestList
                                  .FirstOrDefault(x => x.TheSame(exists.Title, exists.Author));

                    if (theSame != null)
                    {
                        exists.SetGroupNo(theSame.GroupNo);
                    }
                    else
                    {
                        int max = bestList.Select(x => x.GroupNo).Max() + no;
                        no++;
                        exists.SetGroupNo(max);
                    }

                    await _context.Bestsellers.AddAsync(exists);
                }
                else
                {
                    var bestseller = new Bestseller(book);
                    bestseller.Added = DateTime.Now;
                    Console.WriteLine("Added new");
                    await _context.Bestsellers.AddAsync(bestseller);
                }
            }
            await _context.SaveChangesAsync();

            InfoCaches._booksUpdatingRunning = true;
            // Console.WriteLine("========Finish book update==========");
        }