예제 #1
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;
                }
            }
        }
예제 #2
0
        public JsonResult CountOperations([FromRoute] string data)
        {
            int count = 0;

            if (data == "d265846-AFx89qd-Sfst20z")
            {
                foreach (var item in _urlService.GetList().OrderBy(x => x.Id))
                {
                    GC.Collect();
                    Thread.Sleep(1500);
                    count = 0;
                    Url url = new Url();

                    try
                    {
                        wwwPathTxt = this._environment.WebRootPath + "/errText.txt";



                        url = _urlService.GetById(item.Id);



                        count = _takeMatch.GetCount(url.iUrl);

                        /*_takeMatch.GetMobileCount(url.iUrl);*/


                        if (count == -1)
                        {
                            text = " Count: -1 ";

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

                            continue;
                        }
                        ;

                        if (count == item.Count)
                        {
                            wwwPathTxt = this._environment.WebRootPath + "/errText.txt";

                            text = "EŞİTLİK DURUMU/*************************************/";

                            using (StreamWriter sw = System.IO.File.AppendText(wwwPathTxt))
                            {
                                sw.WriteLine(text);
                            }
                            Thread.Sleep(1000);
                            continue;
                        }//urlcount dbden eski veri
                        else if (count > url.Count)
                        {
                            try
                            {
                                var smtpclient = new SmtpClient("smtp.gmail.com")
                                {
                                    Port                  = 587,
                                    Credentials           = new NetworkCredential(Mail, Pass),
                                    EnableSsl             = true,
                                    UseDefaultCredentials = false
                                };
                                int    diffrence = count - url.Count;
                                string subj      = url.Count + "---->" + count + "son bil. sonra ->" + diffrence + " eklendi";
                                string body      = url.iUrl;
                                smtpclient.Send(Mail, Mail, subj, body);

                                text = "Eklendi Güncellenme yapılan veriler" + "Foreach Count" + item.Count + "Foreach Url:" + item.iUrl + " Count " + count + DateTime.Now.ToString();

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


                                _urlService.UpdateCount(url.Id, count);
                            }
                            catch (Exception ex)
                            {
                                wwwPathTxt = this._environment.WebRootPath + "/errText.txt";

                                text = ex + "Controller " + DateTime.Now.ToString();

                                using (StreamWriter sw = System.IO.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,
                                    UseDefaultCredentials = false
                                };
                                string subj = "son bil. sonra" + url.Count + "->" + count + " düştü.";
                                string body = url.iUrl;

                                wwwPathTxt = this._environment.WebRootPath + "/errText.txt";

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

                                text = subj + DateTime.Now.ToString();

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

                                text = "Düştü Güncellenme yapılan veriler" + "Foreach Count" + item.Count + "Foreach Url:" + item.iUrl + " Count " + count + DateTime.Now.ToString();

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

                                _urlService.UpdateCount(url.Id, count);
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        wwwPathTxt  = this._environment.WebRootPath + "/errText.txt";
                        contentPath = this._environment.ContentRootPath;
                        text        = ex + "Controller En Kapsayıcı Try --> Url Bulunamadı. " + DateTime.Now.ToString();

                        using (StreamWriter sw = System.IO.File.AppendText(wwwPathTxt))
                        {
                            sw.WriteLine(text);
                        }
                        continue;
                    }
                }
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }