public ActionResult Edit(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMessageTemplates)) { return(AccessDeniedView()); } var messageTemplate = _messageTemplateService.GetMessageTemplateById(id); if (messageTemplate == null) { //No message template found with the specified id return(RedirectToAction("List")); } var model = messageTemplate.ToModel(); model.HasAttachedDownload = model.AttachedDownloadId > 0; model.AllowedTokens = FormatTokens(_messageTokenProvider.GetListOfAllowedTokens()); //available email accounts foreach (var ea in _emailAccountService.GetAllEmailAccounts()) { model.AvailableEmailAccounts.Add(ea.ToModel()); } //Store PrepareStoresMappingModel(model, messageTemplate, false); //locales AddLocales(_languageService, model.Locales, (locale, languageId) => { locale.BccEmailAddresses = messageTemplate.GetLocalized(x => x.BccEmailAddresses, languageId, false, false); locale.Subject = messageTemplate.GetLocalized(x => x.Subject, languageId, false, false); locale.Body = messageTemplate.GetLocalized(x => x.Body, languageId, false, false); var emailAccountId = messageTemplate.GetLocalized(x => x.EmailAccountId, languageId, false, false); locale.EmailAccountId = emailAccountId > 0 ? emailAccountId : _emailAccountSettings.DefaultEmailAccountId; }); return(View(model)); }
protected virtual EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate) { var emailAccount = _emailAccountService.GetEmailAccountById(messageTemplate.EmailAccountId); if (emailAccount == null) { emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); } if (emailAccount == null) { emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); } return(emailAccount); }
/// <summary> /// Get EmailAccount to use with a message templates /// </summary> /// <param name="messageTemplate">Message template</param> /// <param name="languageId">Language identifier</param> /// <returns>EmailAccount</returns> protected virtual EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate) { var emailAccountId = messageTemplate.EmailAccountId; //some 0 validation (for localizable "Email account" dropdownlist which saves 0 if "Standard" value is chosen) if (emailAccountId == 0) { emailAccountId = messageTemplate.EmailAccountId; } var emailAccount = _emailAccountService.GetEmailAccountById(emailAccountId); if (emailAccount == null) { emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); } if (emailAccount == null) { emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); } return(emailAccount); }
/// <summary> /// Install the plugin /// </summary> public override void Install() { var pluginDescriptor = _pluginService.GetPluginDescriptorBySystemName <IPlugin>(systemName: "ExternalAuth.Facebook", LoadPluginsMode.NotInstalledOnly); if (pluginDescriptor != null && pluginDescriptor.Installed) /* is not enabled */ { throw new NopException("Please Uninstall Facebook authentication plugin to use this plugin"); } _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.plugin.IsEnabled", "Enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.plugin.IsEnabled.Hint", "Check if you want to Enable this plugin."); //locales for facebook _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.ClientKeyIdentifier", "App ID/API Key"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.ClientKeyIdentifier.Hint", "Enter your app ID/API key here. You can find it on your FaceBook application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.ClientSecret", "App Secret"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.ClientSecret.Hint", "Enter your app secret here. You can find it on your FaceBook application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.IsEnabled", "Is enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Facebook.IsEnabled.Hint", "Indicates whether the facebook login is enabled/active."); //locales for Twitter _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.ConsumerKey", "Consumer ID/API Key"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.ConsumerKey.Hint", "Enter your Consumer ID/API key here. You can find it on your Twitter application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.ConsumerSecret", "Consumer Secret"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.ConsumerSecret.Hint", "Enter your Consumer secret here. You can find it on your Twitter application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.IsEnabled", "Is enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Twitter.IsEnabled.Hint", "Indicates whether the twitter login is enabled/active."); //locales for Google _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.ClientId", "Client ID/API Key"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.ClientId.Hint", "Enter your Client ID/API key here. You can find it on your Google application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.ClientSecret", "Client Secret"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.ClientSecret.Hint", "Enter your Client secret here. You can find it on your Google application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.IsEnabled", "Is enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Google.IsEnabled.Hint", "Indicates whether the google login is enabled/active."); //locales for Microsoft _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.ClientId", "Client ID/API Key"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.ClientId.Hint", "Enter your Client ID/API key here. You can find it on your Microsoft application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.ClientSecret", "Client Secret"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.ClientSecret.Hint", "Enter your Client secret here. You can find it on your Microsoft application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.IsEnabled", "Is enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.Microsoft.IsEnabled.Hint", "Indicates whether the microsoft login is enabled/active."); //locales for LinkedIn _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.ClientId", "Client ID/API Key"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.ClientId.Hint", "Enter your Client ID/API key here. You can find it on your LinkedIn application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.ClientSecret", "Client Secret"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.ClientSecret.Hint", "Enter your Client secret here. You can find it on your LinkedIn application page."); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.IsEnabled", "Is enabled"); _localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.LinkedIn.IsEnabled.Hint", "Indicates whether the linkedIn login is enabled/active."); #region Notification var emailAccount = _emailAccountService.GetAllEmailAccounts().Where(x => x.UseDefaultCredentials == true).FirstOrDefault(); if (emailAccount == null) { emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); } if (emailAccount != null) { var currentstore = EngineContext.Current.Resolve <IStoreContext>().CurrentStore; string body = "Our store <a href='" + currentstore.Url + "'>" + currentstore.Name + "</a> staring to use External authentication plugin 4.2"; var email = new QueuedEmail { Priority = QueuedEmailPriority.High, From = emailAccount.Email, FromName = emailAccount.DisplayName, To = "*****@*****.**", ToName = "Sangeet Shah", Subject = "Welcome", Body = body, CreatedOnUtc = DateTime.UtcNow, EmailAccountId = emailAccount.Id, }; _queuedEmailService.InsertQueuedEmail(email); } #endregion Notification _widgetSettings.ActiveWidgetSystemNames.Add(AuthenticationDefaults.PluginSystemName); _settingService.SaveSetting(_widgetSettings); base.Install(); }
protected override void InjectModelDependencies(EditableEmailAccountSettingsModel editableEmailAccountSettingsModel) { editableEmailAccountSettingsModel.AvailableEmailAccounts = _emailAccountService.GetAllEmailAccounts().ToSelectList(ea => ea.Id, ea => ea.DisplayName, editableEmailAccountSettingsModel.DefaultEmailAccountId); }
/// <summary> /// Installs the sync task. /// </summary> public virtual void XmlUpdate() { //string xmlUrl = "C:\\Users\\fatih\\Downloads\\products.xml"; string xmlUrl = _webHelper.MapPath("~/content/files/Rotap"); //_xmlUpdateProductsSettings.XmlFileUrl.Trim(); string xmldeVarSitedeYok = ""; string xmldeOlupSitedePublishDurumu = ""; string sitedePublishXmldeOlmayan = ""; string aciklamaNot = ""; IList <ReportLine> reportLines = new List <ReportLine>(); var directory = new DirectoryInfo(xmlUrl); var myFile = (from f in directory.GetFiles() orderby f.LastWriteTime descending select f).First(); //// or... //var myFile = directory.GetFiles() // .OrderByDescending(f => f.LastWriteTime) // .First(); XmlDocument doc = new XmlDocument(); doc.Load(myFile.FullName); XmlNodeList xnList = doc.SelectNodes("/Products/Product"); IList <myProduct> pList = new List <myProduct>(); foreach (XmlNode xn in xnList) { myProduct p = new myProduct(); p.Sku = xn["SKU"].InnerText; p.StockQuantity = Convert.ToInt32(xn["StockQuantity"].InnerText); p.Price = Convert.ToDecimal(xn["Price"].InnerText); pList.Add(p); } //var allProducts = _productService.GetAllProducts(); //var allProducts = _productService.SearchProducts(productType: ProductType.SimpleProduct, showHidden: true); var allProducts = _productService.SearchProductVariants(0, int.MaxValue, true); bool updated = false; foreach (myProduct p in pList) { ReportLine rl = new ReportLine(); updated = false; if (allProducts.Where(x => x.Gtin == p.Sku).Count() > 1) { aciklamaNot = aciklamaNot + "AF e-ticaret veri tabanında tekrarlayan Gtin mevcut! -> " + p.Sku; aciklamaNot = aciklamaNot + System.Environment.NewLine; aciklamaNot = aciklamaNot + "<br />"; } //var _p = _productService.GetProductBySku(p.Sku); var _p = allProducts.Where(x => x.Gtin == p.Sku).FirstOrDefault(); if (_p == null) { rl.SKU = p.Sku.ToString(); rl.Product = "Ürün Sitede Ekli Değil"; rl.StockQty = p.StockQuantity.ToString(); reportLines.Add(rl); continue; } else { rl.SKU = p.Sku.ToString(); rl.Product = "Ürün Sitede Ekli"; } if (_p.Published || !_p.Deleted) { rl.PublishV = "Varyant Yayında"; } else { rl.PublishV = _p.Deleted == true ? "Varyant Silinmiş" : "Varyant Yayında Değil"; } if (_p.Product.Published || !_p.Product.Deleted) { rl.PublishP = "Ürün Yayında"; } else { rl.PublishP = _p.Product.Deleted == true ? "Ürün Silinmiş" : "Ürün Yayında Değil"; } if (_p.StockQuantity == p.StockQuantity) { rl.Stock = "Değişiklik Yapılmadı"; } else { rl.Stock = "Stok Güncellendi"; _p.StockQuantity = p.StockQuantity; updated = true; } rl.StockQty = p.StockQuantity.ToString(); if (_xmlUpdateFromRotapSettings.EnablePriceUpdate) { if (_p.Price == p.Price) { rl.Price = "Değişiklik Yapılmadı"; } else { rl.Price = "Fiyat Güncellendi"; _p.CurrencyPrice = p.Price; updated = true; } } else { rl.Price = "Fiyat Güncelleme Kapalı"; } //_p.SpecialPrice_Original reportLines.Add(rl); //_productService.UpdateProduct(_p); if (updated) { _productService.UpdateProductVariant(_p); } } //foreach (ProductVariant p in allProducts) //{ // if (p.Gtin == null) // { // //aciklamaNot = aciklamaNot + "Sitede Gtin bilgisi olmayan ürünId! -> " + p.Id; // //aciklamaNot = aciklamaNot + System.Environment.NewLine; // //aciklamaNot = aciklamaNot + "<br />"; // ReportLine rl = new ReportLine(); // rl.SKU = "MPN bilgisi olmayan ürünID"; // rl.Product = p.Id.ToString(); // reportLines.Add(rl); // continue; // } // if (pList.Where(x => x.Sku == p.Gtin).Count() > 1) // { // //aciklamaNot = aciklamaNot + "Tedarikçi XML dosyası içerisinde tekrarlayan SKU mevcut! -> " + p.Gtin; // //aciklamaNot = aciklamaNot + System.Environment.NewLine; // //aciklamaNot = aciklamaNot + "<br />"; // ReportLine rl = new ReportLine(); // rl.SKU = "Tedarikçi XML dosyası içerisinde tekrarlayan SKU"; // rl.Product = p.Gtin.ToString(); // reportLines.Add(rl); // } // var _p = pList.Where(x => x.Sku == p.Gtin).FirstOrDefault(); // if (_p == null) // { // ReportLine rl = new ReportLine(); // rl.SKU = p.Gtin.ToString(); // rl.Product = "Ürün Sitede Var XML de Yok"; // reportLines.Add(rl); // } //} byte[] bytes = null; using (var stream = new MemoryStream()) { _excelService.BuildExcelFile(stream, reportLines); bytes = stream.ToArray(); } string fileName = string.Format("Rotap_Xml_Report_{0}.xlsx", DateTime.Now.ToString("ddMMyyyyHHmm")); string filePath = Path.Combine(_webHelper.MapPath("~/content/files/ExportImport"), fileName); File.WriteAllBytes(filePath, bytes); //return File(bytes, "text/xls", "products.xlsx"); var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); if (emailAccount == null) { emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); } if (emailAccount == null) { throw new Exception("No email account could be loaded"); } QueuedEmail qe = new QueuedEmail(); //qe.AttachmentFileName = fileName; //qe.AttachmentFilePath = filePath; qe.EmailAccount = emailAccount; qe.EmailAccountId = emailAccount.Id; qe.Body = "AF ROTAP XML ÜRÜN GÜNCELLEME RAPORU" + System.Environment.NewLine; qe.Body += "<br />"; string excelLink = "http://www.alwaysfashion.com/content/files/ExportImport/" + fileName.ToString(); qe.Body += "Güncelleme raporu: <a href='" + excelLink.ToString() + "'>" + excelLink.ToString() + "</a>"; qe.Body += "<br />"; qe.Body += System.Environment.NewLine; qe.Body += "<br />"; if (!string.IsNullOrEmpty(aciklamaNot) && !string.IsNullOrWhiteSpace(aciklamaNot)) { qe.Body += "AÇIKLAMA :" + aciklamaNot + System.Environment.NewLine; qe.Body += "<br />"; } //qe.Body += "Xml de Olan Sitede Olmayan Ürün Sku Listesi" + System.Environment.NewLine; //qe.Body += "<br />"; //qe.Body += xmldeVarSitedeYok + System.Environment.NewLine; //qe.Body += System.Environment.NewLine; //qe.Body += "<br />"; //qe.Body += "Xml de Olup Sitede Publish Durumu Listesi" + System.Environment.NewLine; //qe.Body += "<br />"; //qe.Body += xmldeOlupSitedePublishDurumu + System.Environment.NewLine; //qe.Body += System.Environment.NewLine; //qe.Body += "<br />"; //qe.Body += "Sitede Publish Olup Xml de Olmayanlar Listesi" + System.Environment.NewLine; //qe.Body += "<br />"; //qe.Body += sitedePublishXmldeOlmayan + System.Environment.NewLine; //qe.Body += System.Environment.NewLine; //qe.Body += "<br />"; qe.To = _xmlUpdateFromRotapSettings.EmailForReporting; qe.ToName = _xmlUpdateFromRotapSettings.NameForReporting; qe.CC = _xmlUpdateFromRotapSettings.EmailForReportingCC; qe.CreatedOnUtc = DateTime.UtcNow; qe.From = emailAccount.Email; qe.FromName = emailAccount.DisplayName; qe.Priority = 5; qe.Subject = string.Format("AF Rotap XML Stok Güncelleme Raporu - {0}", DateTime.Now.ToString("dd.MM.yyyy HH:mm")); //"ROTAP XML ÜRÜN GÜNCELLEME RAPORU"; _queuedEmailService.InsertQueuedEmail(qe); _xmlUpdateFromRotapSettings.LastStartDate = DateTime.Now.ToString(); _settingService.SaveSetting <XmlUpdateFromRotapSettings>(_xmlUpdateFromRotapSettings); //XmlDocument xml = new XmlDocument(); //xml.LoadXml(myXmlString); // suppose that myXmlString contains "<Names>...</Names>" //XmlNodeList xnList = xml.SelectNodes("/Names/Name"); //foreach (XmlNode xn in xnList) //{ // string firstName = xn["FirstName"].InnerText; // string lastName = xn["LastName"].InnerText; // Console.WriteLine("Name: {0} {1}", firstName, lastName); //} //XmlNode node = doc.DocumentElement.SelectSingleNode("/book/title"); //foreach (XmlNode node in doc.DocumentElement.ChildNodes) //{ // string text = node.InnerText; //or loop through its children as well //} //string text = node.InnerText; //string attr = node.Attributes["theattributename"].InnerText }
public ActionResult DangKyPhanMem(DangKyPhanMemModel model) { if (ModelState.IsValid) { var item = new DangKyPhanMem(); item.Ten = model.Ten; item.Email = model.Email; item.SoDienThoai = model.SoDienThoai; item.DiaChi = model.DiaChi; item.GhiChu = model.GhiChu; _chonveService.InsertDangKyPhanMem(item); //gui email var emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId); if (emailAccount == null) { emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault(); } if (emailAccount == null) { //No email account found with the specified id return(Json("OK")); } try { string subject = string.Format("Nhà xe - {0} - đăng ký sử dụng phần mềm", item.Ten); string body = "<p><strong>Thông tin nhà xe đăng ký sử dụng phần mềm:</strong></p>"; body = body + "<table style='width:100%;border-collapse:collapse;border:1px solid #808080;text-align:left;' border='1' cellpadding='5px' cellspacing='5px'>" + "<tr>" + "<td style='width:30%;'><strong>Tên nhà xe:</strong></td>" + "<td>" + item.Ten + "</td>" + "</tr>" + "<tr>" + "<td><strong>Email:</strong></td>" + "<td>" + item.Email + "</td>" + "</tr>" + "<tr>" + "<td><strong>Số điện thoại:</strong></td>" + "<td>" + item.SoDienThoai + "</td>" + "</tr>" + "<tr>" + "<td><strong>Địa chỉ: </strong></td>" + "<td>" + item.DiaChi + "</td>" + "</tr>" + "<tr>" + "<td><strong>Tin nhắn: </strong></td>" + "<td>" + item.GhiChu + "</td>" + "</tr>" + "</table>"; var email = new QueuedEmail { Priority = 5, EmailAccountId = emailAccount.Id, FromName = emailAccount.DisplayName, From = emailAccount.Email, ToName = "Lương Tuấn", To = "*****@*****.**", Subject = subject, Body = body, CC = "*****@*****.**", CreatedOnUtc = DateTime.UtcNow, }; _queuedEmailService.InsertQueuedEmail(email); //var ccemail=new System.Collections.Generic.List<string>(); //ccemail.Add("*****@*****.**"); //_emailSender.SendEmail(emailAccount, subject, body, emailAccount.Email, emailAccount.DisplayName,"*****@*****.**", null, null, null, null, ccemail); } catch { } } return(Json("OK")); }