Пример #1
0
        public ActionResult<IEnumerable<string>> Get()
        {
            IEmailService emailService = new EmailService();
            emailService.SendEmail("subject","test");

            return new string[] { "value1", "value2: + " + (storage.GetHandListStatusLastest() == null ? 1 : 0) };
        }
Пример #2
0
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var     html    = @"http://www.czcfang.com/house/index?sug=cm:4062";
                    HtmlWeb web     = new HtmlWeb();
                    var     htmlDoc = web.Load(html);
                    var     node    = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[5]/div[1]/div/ul/li[3]/span");

                    if (node != null)
                    {
                        int totalCount = 0;
                        if (int.TryParse(node.InnerText, out totalCount))
                        {
                            //check db if exist same value record
                            SendHandListStatus status = dbStorage.GetHandListStatusLastest();
                            if (status == null)
                            {
                                sMSService.SendByPhone("13961570305", "总套数: " + totalCount);
                                dbStorage.SaveHandListStatus(new SendHandListStatus
                                {
                                    Total = totalCount
                                });
                            }
                            else
                            {
                                if (status.Total != totalCount)
                                {
                                    sMSService.SendByPhone("13961570305", "总套数: " + totalCount);
                                    dbStorage.SaveHandListStatus(new SendHandListStatus
                                    {
                                        Total = totalCount
                                    });
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                await Task.Delay(1000 * 60 * 30);
            }
        }