示例#1
0
        public SmtpClient Get()
        {
            string host = _applicationSettingService.Get(SettingKeys.SMTP_Host, "smtp.zkea.net");

            int port;

            int.TryParse(_applicationSettingService.Get(SettingKeys.SMTP_Port, "25"), out port);

            string email    = _applicationSettingService.Get(SettingKeys.SMTP_Email, "");
            string password = _applicationSettingService.Get(SettingKeys.SMTP_PassWord, "");

            if (email.IsNullOrWhiteSpace())
            {
                throw new Exception("未设置邮件发送邮箱,请在系统设置中设置 SMTP_Email");
            }
            if (password.IsNullOrWhiteSpace())
            {
                throw new Exception("未设置邮件发送密码,请在系统设置中设置 SMTP_PassWord");
            }
            bool ssl;

            bool.TryParse(_applicationSettingService.Get(SettingKeys.SMTP_UseSSL, "false"), out ssl);

            SmtpClient client = new SmtpClient(host, port);

            client.UseDefaultCredentials = true;
            client.EnableSsl             = ssl;
            client.Credentials           = new NetworkCredential(email, password);
            return(client);
        }
示例#2
0
 public SiteInformation Get()
 {
     return(new SiteInformation
     {
         SiteName = _applicationSettingService.Get("SiteInformation_SiteName", "ZKEASOFT"),
         Logo_Mini = _applicationSettingService.Get("SiteInformation_Logo_Mini", "/images/logo_min.png")
     });
 }
示例#3
0
 public JsonResult GetPageTree()
 {
     var expandAll = _applicationSettingService.Get(SettingKeys.ExpandAllPage, "true");
     var pages = Service.Get(m => !m.IsPublishedPage).OrderBy(m => m.DisplayOrder);
     var node = new Tree<PageEntity>().Source(pages).ToNode(m => m.ID, m => m.PageName, m => m.ParentId, "#", expandAll.Equals("true", StringComparison.OrdinalIgnoreCase));
     return Json(node);
 }
示例#4
0
        public Func <IApplicationContext, T> Get <T>()
        {
            var           currencyOption = _applicationSettingService.Get <CurrencyOption>();
            CurrencyEntry currency       = null;

            if (currencyOption.CurrencyID > 0)
            {
                currency = _currencyService.Get(currencyOption.CurrencyID);
            }
            else
            {
                currency = _currencyService.Get(m => m.Code == "CNY").FirstOrDefault();
            }
            if (currency == null)
            {
                currency = new CurrencyEntry
                {
                    Title  = "Chinese Renmenbi",
                    Code   = "CNY",
                    Symbol = "¥"
                };
            }
            currencyOption.CurrencyID = currency.ID;
            currencyOption.Name       = currency.Title;
            currencyOption.Code       = currency.Code;
            currencyOption.Symbol     = currency.Symbol;
            return((context) =>
            {
                return (T)(object)currencyOption;
            });
        }
示例#5
0
        public Func <IApplicationContext, T> Get <T>()
        {
            bool result = _applicationSettingService.Get(Name, "false") == "true";

            return((context) =>
            {
                return (T)(object)result;
            });
        }
示例#6
0
 public AlipayService(IOptions <AlipayOptions> alipayOptions, IApplicationSettingService applicationSettingService)
 {
     Options = applicationSettingService.Get <AlipayOptions>();
     if (Options.AppId.IsNullOrWhiteSpace())
     {
         Options = alipayOptions.Value;
     }
     _aopClient = new DefaultAopClient(Options.Gatewayurl, Options.AppId, Options.PrivateKey, "json", "1.0",
                                       Options.SignType, Options.AlipayPublicKey, Options.CharSet, Options.IsKeyFromFile);
 }
示例#7
0
        public void ChangeTheme(string id)
        {
            ThemeEntity currentTheme = GetCurrentTheme();

            if (id.IsNullOrEmpty() || currentTheme.ID == id)
            {
                return;
            }

            //update by roc
            var          theme = Get(id);
            const string executeScriptWhenChange = "false";//Disable as default

            if (_applicationSettingService.Get(SettingKeys.ExecuteScriptWhenChangeTheme, executeScriptWhenChange) != executeScriptWhenChange)
            {
                var connection = DbContext.Database.GetDbConnection();
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                using (var transaction = connection.BeginTransaction())
                {
                    try
                    {
                        ExecuteSql(currentTheme.ID, 1, connection, transaction); //uninstall current theme
                        ExecuteSql(theme.ID, 2, connection, transaction);        //install target theme
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        _logger.LogError(ex, ex.Message);
                        throw;
                    }
                    finally
                    {
                        if (connection.State == ConnectionState.Open)
                        {
                            connection.Close();
                        }
                    }
                }
            }

            var activeTheme = Get(m => m.ID != id && m.IsActived);

            activeTheme.Each(m => m.IsActived = false);
            UpdateRange(activeTheme.ToArray());

            theme.IsActived = true;
            Update(theme);
        }
示例#8
0
        public SmtpClient Get()
        {
            string host = _applicationSettingService.Get(SettingKeys.SMTP_Host, "smtp.zkea.net");

            int port;

            int.TryParse(_applicationSettingService.Get(SettingKeys.SMTP_Port, "25"), out port);

            string email    = _applicationSettingService.Get(SettingKeys.SMTP_Email, "");
            string password = _applicationSettingService.Get(SettingKeys.SMTP_PassWord, "");

            bool ssl;

            bool.TryParse(_applicationSettingService.Get(SettingKeys.SMTP_UseSSL, "false"), out ssl);

            SmtpClient client = new SmtpClient(host, port);

            client.UseDefaultCredentials = true;
            client.EnableSsl             = ssl;
            client.Credentials           = new NetworkCredential(email, password);
            return(client);
        }
示例#9
0
 public override ServiceResult<MessageEntity> Add(MessageEntity item)
 {
     ServiceResult<MessageEntity> result = base.Add(item);
     MessageNotificationConfig notifyConfig = _applicationSettingService.Get<MessageNotificationConfig>();
     if (notifyConfig.MessageNotifyEmails.IsNotNullAndWhiteSpace())
     {
         _notificationManager.Send(new RazorEmailNotice
         {
             Subject = "新的留言提醒",
             To = notifyConfig.MessageNotifyEmails.Split(new char[] { '\r', '\n', ',', ';' }, StringSplitOptions.RemoveEmptyEntries),
             Model = item,
             TemplatePath = "~/wwwroot/Plugins/ZKEACMS.Message/EmailTemplates/MessageNotification.cshtml"
         });
     }
     return result;
 }
        public void Handle(object entity, EventArg e)
        {
            if (_applicationSettingService.Get("Animation_Widget_FadeInUp", "false") == "true")
            {
                CMSApplicationContext applicationContext = _applicationContextAccessor.Current;
                HtmlContentBuilder    styleBuilder       = new HtmlContentBuilder();
                HtmlContentBuilder    scriptBuilder      = new HtmlContentBuilder();
#if DEBUG
                styleBuilder.AppendHtml("<link type=\"text/css\" async rel=\"stylesheet\" href=\"/Plugins/ZKEACMS.Animation/Content/animate.css\" />");
                scriptBuilder.AppendHtml("<script type=\"text/javascript\" src=\"/Plugins/ZKEACMS.Animation/Scripts/animate.js\"></script>");
#else
                styleBuilder.AppendHtml("<link type=\"text/css\" async rel=\"stylesheet\" href=\"/Plugins/ZKEACMS.Animation/Content/animate.min.css\" />");
                scriptBuilder.AppendHtml("<script type=\"text/javascript\" src=\"/Plugins/ZKEACMS.Animation/Scripts/animate.min.js\" ></script>");
#endif
                applicationContext.HeaderPart.Add(styleBuilder);
                applicationContext.FooterPart.Add(scriptBuilder);
            }
        }
示例#11
0
        public SmtpClient Get()
        {
            var        setting = _applicationSettingService.Get <SmtpSetting>();
            SmtpClient client  = null;

            if (setting.Port > 0)
            {
                client = new SmtpClient(setting.Host, setting.Port);
            }
            else
            {
                client = new SmtpClient(setting.Host);
            }
            client.UseDefaultCredentials = true;
            client.EnableSsl             = setting.EnableSsl;
            client.Credentials           = new NetworkCredential(setting.Email, setting.PassWord);
            return(client);
        }
        public void Handle(object entity, EventArg e)
        {
            Comments item = entity as Comments;

            if (item != null)
            {
                MessageNotificationConfig notifyConfig = _applicationSettingService.Get <MessageNotificationConfig>();
                if (notifyConfig.CommentNotifyEmails.IsNotNullAndWhiteSpace())
                {
                    _notificationManager.Send(new RazorEmailNotice
                    {
                        Subject      = _localize.Get("New comment"),
                        To           = notifyConfig.CommentNotifyEmails.Split(new char[] { '\r', '\n', ',', ';' }, StringSplitOptions.RemoveEmptyEntries),
                        Model        = item,
                        TemplatePath = "~/wwwroot/Plugins/ZKEACMS.Message/EmailTemplates/CommentNotification.cshtml"
                    });
                }
            }
        }
示例#13
0
        public SmtpClient Get()
        {
            var setting = _applicationSettingService.Get <SmtpSetting>();

            if (setting.Host.IsNullOrWhiteSpace() || setting.Email.IsNullOrWhiteSpace())
            {
                throw new Exception("SMTP Server is not ready, for more information: https://www.zkea.net/codesnippet/detail/post-97.html");
            }
            SmtpClient client = null;

            if (setting.Port > 0)
            {
                client = new SmtpClient(setting.Host, setting.Port);
            }
            else
            {
                client = new SmtpClient(setting.Host);
            }
            client.UseDefaultCredentials = true;
            client.EnableSsl             = setting.EnableSsl;
            client.Credentials           = new NetworkCredential(setting.Email, setting.PassWord);
            return(client);
        }
        public virtual void OnExecuted(PageEntity currentPage, HttpContext context)
        {
            CMSApplicationContext applicationContext = _applicationContextAccessor.Current;
            var script = _applicationSettingService.Get <T>();

            if (script != null && script.Script.IsNotNullAndWhiteSpace())
            {
                if (script.Script.IndexOf("</script>", StringComparison.OrdinalIgnoreCase) > 0)
                {
                    HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
                    htmlContentBuilder.AppendHtml(script.Script);
                    applicationContext.FooterPart.Add(htmlContentBuilder);
                }
                else
                {
                    HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
                    htmlContentBuilder.AppendHtml("<script type=\"text/javascript\">");
                    htmlContentBuilder.AppendHtml(script.Script);
                    htmlContentBuilder.AppendHtml("</script>");
                    applicationContext.FooterPart.Add(htmlContentBuilder);
                }
            }
        }
示例#15
0
        public virtual void Handle(object entity, EventArg e)
        {
            CMSApplicationContext applicationContext = _applicationContextAccessor.Current;
            var script = _applicationSettingService.Get <T>();

            if (script != null && script.Script.IsNotNullAndWhiteSpace())
            {
                if (script.Script.IndexOf("</script>", StringComparison.OrdinalIgnoreCase) > 0)
                {
                    HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
                    htmlContentBuilder.AppendHtml(script.Script);
                    if (script.Location == (int)ScriptLocation.Header)
                    {
                        applicationContext.HeaderPart.Add(htmlContentBuilder);
                    }
                    else
                    {
                        applicationContext.FooterPart.Add(htmlContentBuilder);
                    }
                }
                else
                {
                    HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
                    htmlContentBuilder.AppendHtml("<script type=\"text/javascript\">");
                    htmlContentBuilder.AppendHtml(script.Script);
                    htmlContentBuilder.AppendHtml("</script>");
                    if (script.Location == (int)ScriptLocation.Header)
                    {
                        applicationContext.HeaderPart.Add(htmlContentBuilder);
                    }
                    else
                    {
                        applicationContext.FooterPart.Add(htmlContentBuilder);
                    }
                }
            }
        }
示例#16
0
 public IActionResult Edit()
 {
     return(View(_applicationSettingService.Get <T>()));
 }
示例#17
0
 public IActionResult Index()
 {
     return(Content(_applicationSettingService.Get <Robots>().Content, "text/plain"));
 }
示例#18
0
 public SmtpSetting GetSmtpSetting()
 {
     return(_applicationSettingService.Get <SmtpSetting>());
 }
示例#19
0
 public virtual IActionResult Config()
 {
     return(View("GeneralSetting", _applicationSettingService.Get <T>()));
 }