Esempio n. 1
0
        public IActionResult Index()
        {
            UrlViewModel model = new UrlViewModel()
            {
                UrlList = _urlService.GetList()
            };

            if (String.IsNullOrEmpty(HttpContext.Session.GetObject <String>("username")))
            {
                return(RedirectToAction("Index", "Login"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 2
0
        public void CountOperations()
        {
            foreach (var item in _urlService.GetList())
            {
                var url = _urlService.GetById(item.Id);

                var count = _takeMatch.GetCount(url.iUrl);


                if (count == -1)
                {
                    continue;
                }
                ;

                if (count == url.Count)
                {
                    Thread.Sleep(1000);
                    continue;
                }
                else if (count > url.Count)
                {
                    try
                    {
                        var smtpClient = new SmtpClient("smtp.gmail.com")
                        {
                            Port        = 587,
                            Credentials = new NetworkCredential(Mail, Pass),
                            EnableSsl   = true,
                        };
                        int    diffrence = count - url.Count;
                        string subj      = "Son Bildiriden sonra ->" + diffrence + " Eklendi";
                        string body      = item.iUrl;
                        smtpClient.Send(Mail, Mail, subj, body);

                        _urlService.UpdateCount(item.Id, count);
                    }
                    catch (Exception ex)
                    {
                        string wwwPathTxt  = this.environment.WebRootPath + "/errText.txt";
                        string contentPath = this.environment.ContentRootPath;
                        var    text        = ex + "Mail Gönderimi sıkıntısı" + DateTime.Now.ToString();

                        using (StreamWriter sw = File.AppendText(wwwPathTxt))
                        {
                            sw.WriteLine(text);
                        }

                        continue;
                    }
                }
                else if (url.Count > count)
                {
                    try
                    {
                        var smtpClient = new SmtpClient("smtp.gmail.com")
                        {
                            Port        = 587,
                            Credentials = new NetworkCredential(Mail, Pass),
                            EnableSsl   = true,
                        };
                        string subj = "Son Bildiriden sonra" + url.Count + "->" + count + " düştü.";
                        string body = url.iUrl;



                        smtpClient.Send(Mail, Mail, subj, body);

                        _urlService.UpdateCount(item.Id, count);
                    }
                    catch (Exception ex)
                    {
                        string wwwPathTxt  = this.environment.WebRootPath + "/errText.txt";
                        string contentPath = this.environment.ContentRootPath;
                        var    text        = ex + "Mail Gönderimi sıkıntısı" + DateTime.Now.ToString();

                        using (StreamWriter sw = File.AppendText(wwwPathTxt))
                        {
                            sw.WriteLine(text);
                        }
                        continue;
                    }
                }
                else
                {
                    continue;
                }
            }
        }