private void SendPreorder(PreorderModel model, Device device) { try { var mail = new MailMessage(); var client = new SmtpClient("smtpcorp.com", 2525) //Port 8025, 587 and 25 can also be used. { Credentials = new NetworkCredential("*****@*****.**", "JKWEop349f"), EnableSsl = true }; var timeStamp = DateTime.UtcNow.Subtract(new DateTime(2015, 6, 1)).TotalMilliseconds.ToString("R"); var cartId = timeStamp.Contains(',') ? timeStamp.Remove(timeStamp.IndexOf(','), 1) : timeStamp; cartId = cartId.Contains('.') ? cartId.Remove(timeStamp.IndexOf('.'), 1) : cartId; mail.From = new MailAddress("*****@*****.**"); mail.To.Add("*****@*****.**"); mail.ReplyToList.Add(model.Email); mail.Subject = "DEV предварительный заказ № \"" + cartId + "\" на устройство \"" + device.Name.Name + "\""; var cont = String.Format(@" <h2>Название устройства: {0}</h2> <h2>Для: {1} {2}</h2> <h2>Дата заказа: {3}</h2> <h2>Комментарий: {4}</h2> </html>", device.Name.Name, model.Name, model.Email, DateTime.Now.ToShortDateString(), model.Comment); var htmlView = AlternateView.CreateAlternateViewFromString(cont, null, "text/html"); mail.AlternateViews.Add(htmlView); client.Send(mail); mail.To.Clear(); mail.To.Add(model.Email); mail.ReplyToList.Clear(); mail.ReplyToList.Add("*****@*****.**"); cont = String.Format(@"<html><h2>Ваш предварительный заказ размещён!</h2> <h2>Название устройства: {0}</h2> <h2>Для: {1} {2}</h2> <h2>Дата заказа: {3}</h2> <h2>Комментарий: {4}</h2> </html>", device.Name.Name, model.Name, model.Email, DateTime.Now.ToShortDateString(), model.Comment); htmlView = AlternateView.CreateAlternateViewFromString(cont, null, "text/html"); mail.AlternateViews.Clear(); mail.AlternateViews.Add(htmlView); client.Send(mail); } catch (Exception e) //post failure { ViewData["Message"] = "При отправке заказа произошла ошибка"; } }
private string GetImageFileName(Device device) { var dir = SectionContentDir; if (!dir.Exists) { dir.Create(); } string uriString = device.GetCoverPhoto(true).Url; if (string.IsNullOrEmpty(uriString)) { return null; } Uri address = new Uri(uriString); string fileName = dir.FullName + "\\" + address.Segments[address.Segments.Length - 1]; using (WebClient client = new WebClient()) { client.DownloadFile(address, fileName); } return fileName; }
public ActionResult Device_in_development(Device device) { ViewBag.Title = device.Name.Name; ViewBag.Description = device.Name.Name; ViewBag.Keywords = device.Name.Name; ViewBag.Parameter_groups = _repository.TermsDeviceParameters.Where(par => par.Level == 0).ToList(); ViewBag.Files_groups = _repository.TermsFileTypes.Where(type => type.Level == 0).ToList(); ViewBag.Step = device.Label.OwnNameFromPath; return View("Dev", device); }
public DeviceTreeNode(DevicesTree tree, DeviceTreeNode parentNode, Device device) { _tree = tree; _parentNode = parentNode; _device = device; }