Esempio n. 1
0
 public Dictionary <Guid, String> List()
 {
     using (var dc = new WeHeMoDataContext())
     {
         return(dc.TESTs.Select(c => new { c.Id, c.Url }).ToDictionary(c => c.Id, c => c.Url));
     }
 }
Esempio n. 2
0
 public void Delete(Guid testid)
 {
     using (var dc = new WeHeMoDataContext())
     {
         var item = dc.TESTs.Where(c => c.Id == testid).First();
         dc.TESTs.DeleteOnSubmit(item);
         dc.SubmitChanges();
     }
 }
Esempio n. 3
0
 public void Update(Guid customerId, string name, string email, string password)
 {
     using (var dc = new WeHeMoDataContext())
     {
         var item = dc.CUSTOMERs.Where(c => c.Id == customerId).First();
         item.Name       = name;
         item.Email      = email;
         item.Password   = password;
         item.UpdateDate = DateTime.Now;
         dc.SubmitChanges();
     }
 }
Esempio n. 4
0
        public Guid?Login(string email, string password)
        {
            using (var dc = new WeHeMoDataContext())
            {
                var id = dc.CUSTOMERs.Where(c => c.Email == email && c.Password == password).Select(c => c.Id).FirstOrDefault();

                if (id == default(Guid))
                {
                    return(null);
                }
                return(id);
            }
        }
Esempio n. 5
0
 public DTO_Customer Get_Customer(Guid customerid)
 {
     using (var dc = new WeHeMoDataContext())
     {
         return((from t in dc.CUSTOMERs
                 where t.Id == customerid
                 select new DTO_Customer
         {
             name = t.Name,
             email = t.Email,
             password = t.Password
         }).First());
     }
 }
Esempio n. 6
0
 public DTO_Test_Report[] GetTestReport(Guid testid)
 {
     using (var dc = new WeHeMoDataContext())
     {
         return((from t in dc.TEST_RESULTs
                 join s in dc.STATUS_CODEs on t.StatusCode equals s.Code
                 where t.TestId == testid
                 orderby t.CreateDate descending
                 select new DTO_Test_Report
         {
             Description = s.Description,
             Succeed = t.StatusCode == 200,
             TestDate = t.CreateDate
         }).ToArray());
     }
 }
Esempio n. 7
0
        public Guid Add(Guid customerid, string url)
        {
            var item = new TEST();

            item.Id         = Guid.NewGuid();
            item.CustomerId = customerid;
            item.Url        = url;
            item.CreateDate = DateTime.Now;

            using (WeHeMoDataContext dc = new WeHeMoDataContext())
            {
                dc.TESTs.InsertOnSubmit(item);
                dc.SubmitChanges();
            }
            return(item.Id);
        }
Esempio n. 8
0
        public Guid Add(string name, string eMail, string password)
        {
            var item = new CUSTOMER();

            item.Id         = Guid.NewGuid();
            item.Name       = name;
            item.Email      = eMail;
            item.Password   = password;
            item.CreateDate = DateTime.Now;

            using (WeHeMoDataContext dc = new WeHeMoDataContext())
            {
                dc.CUSTOMERs.InsertOnSubmit(item);
                dc.SubmitChanges();
            }
            return(item.Id);
        }
Esempio n. 9
0
 public DTO_Test[] ListDto(Guid customerid)
 {
     using (var dc = new WeHeMoDataContext())
     {
         return((from t in dc.TESTs
                 join s in dc.STATUS_CODEs on t.StatusCode equals s.Code into sTmp
                 from sResult in sTmp.DefaultIfEmpty() //left join
                 where t.CustomerId == customerid
                 orderby t.CreateDate descending
                 select new DTO_Test
         {
             Id = t.Id,
             Url = t.Url,
             Code = t.StatusCode,
             Status = sResult.Description,
             Succeed = (t.StatusCode == null ? null : (bool?)(t.StatusCode == 200)),            // null ? null default(bool?) or new Nullable<bool?>
             Date = t.TestDate
         }).ToArray());
     }
 }
Esempio n. 10
0
        public void SaveResult(Guid testid, int statuscode)
        {
            using (var dc = new WeHeMoDataContext())
            {
                var test = dc.TESTs.Where(c => c.Id == testid).First();
                // var firstError = test.StatusCode != null && test.StatusCode == 200;
                var sendMail    = statuscode != 200 && test.StatusCode != statuscode;                     //Hata olma durumu test.statuscode!=statuscode
                var successMail = statuscode == 200 && test.StatusCode != 200 && test.StatusCode != null; //Hata sonunda erişim durumu
                var time1       = dc.TEST_RESULTs.Where(c => c.TestId == testid && c.StatusCode == 200).OrderByDescending(c => c.CreateDate).Select(c => c.CreateDate).FirstOrDefault();


                test.StatusCode = statuscode;
                test.TestDate   = DateTime.Now;

                var test_result = new TEST_RESULT();
                test_result.Id         = Guid.NewGuid();
                test_result.TestId     = testid;
                test_result.StatusCode = statuscode;
                test_result.CreateDate = DateTime.Now;
                dc.TEST_RESULTs.InsertOnSubmit(test_result);

                dc.SubmitChanges();

                if (sendMail)
                {
                    var email = dc.TESTs.Where(c => c.Id == testid).Select(c => new { c.Url, c.CUSTOMER.Email }).First();
                    var error = dc.STATUS_CODEs.Where(c => c.Code == statuscode).Select(c => c.Description).First();

                    var client = new SmtpClient();
                    client.Host        = "xxxxxxxx";
                    client.Port        = 587;
                    client.EnableSsl   = false;
                    client.Credentials = new NetworkCredential("xxxxxxxxxxxxx", "xxxxxxxxxxx"); //sunucuda username:password

                    var message = new MailMessage();
                    message.Body       = "Sayın Yetkili,<br>" + email.Url + " adresine sahip sayfada sorun tespit edilmiştir.<br>" + "Alınan Hata: <span style:color:red>" + error + "</span><br>WEHEME Team";
                    message.IsBodyHtml = true;
                    message.Subject    = "WEHEMO Notification";
                    message.From       = new MailAddress("xxxxxxxxxx");
                    message.To.Add("xxxxxxxxxxxxxx");
                    client.Send(message);
                }
                if (successMail)
                {
                    var fark   = DateTime.Now.Subtract(time1).TotalHours;
                    var email  = dc.TESTs.Where(c => c.Id == testid).Select(c => new { c.Url, c.CUSTOMER.Email }).First();
                    var client = new SmtpClient();
                    client.Host        = "xxxxxxxxxxxx.com";
                    client.Port        = "xxxxxxx";
                    client.EnableSsl   = false;
                    client.Credentials = new NetworkCredential("xxxxxxx", "xxxxxxxxxx");

                    var message = new MailMessage();
                    message.Body       = "Sayın Yetkili,<br>" + fark + "saattir erişilemeyen " + email.Url + " adresinize erişim sağlanmıştır.<br>WEHEME Team";
                    message.IsBodyHtml = true;
                    message.Subject    = "WEHEMO Notification";
                    message.From       = new MailAddress("xxxxxxxxxxx"); //Kimden
                    message.To.Add("xxxxxxxxxxxxxx");                    //Kime "email.email"
                    client.Send(message);
                }
            }
        }