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(); } }
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(); } }
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); }
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); }
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); } } }