/// <summary>
        /// 通过指定 AppKey 獲取前台應用配置訊息
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static QueryAppOption RetrieveByKey(string key)
        {
            var ret = new QueryAppOption()
            {
                AppCode = key
            };
            var dicts = DictHelper.RetrieveDicts();

            ret.AppName    = dicts.FirstOrDefault(d => d.Category == "應用程式" && d.Code == key)?.Name ?? "";
            ret.AppUrl     = dicts.FirstOrDefault(d => d.Category == "應用首頁" && d.Name == key)?.Code ?? "";
            ret.AppTitle   = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "網站標題")?.Code ?? "";
            ret.AppFooter  = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "網站頁腳")?.Code ?? "";
            ret.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "網站圖標")?.Code ?? "";
            ret.AppIcon    = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon")?.Code ?? "";
            return(ret);
        }
        /// <summary>
        /// 通过指定 AppKey 获取前台应用配置信息
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static QueryAppOption RetrieveByKey(string key)
        {
            var ret = new QueryAppOption()
            {
                AppCode = key
            };
            var dicts = DictHelper.RetrieveDicts();

            ret.AppName    = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == key).Name ?? "";
            ret.AppUrl     = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name == key).Code ?? "";
            ret.AppTitle   = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站标题").Code ?? "";
            ret.AppFooter  = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站页脚").Code ?? "";
            ret.AppFavicon = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "网站图标").Code ?? "";
            ret.AppIcon    = dicts.FirstOrDefault(d => d.Category == ret.AppName && d.Name == "favicon").Code ?? "";
            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// 保存前台应用配置信息
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public static bool SaveAppSettings(QueryAppOption option)
        {
            bool update = option.AppId == "edit";

            // dict define == 1 时为新建前台应用
            bool ret;

            // 前台网站配置地址 不允许以 / 结尾
            option.AppUrl = option.AppUrl.TrimEnd('/');
            if (update)
            {
                // Update
                ret = SaveSettings(new BootstrapDict[] {
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站标题",
                        Code     = option.AppTitle,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站页脚",
                        Code     = option.AppFooter,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = "应用首页",
                        Name     = option.AppCode,
                        Code     = option.AppUrl,
                        Define   = 0
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站图标",
                        Code     = option.AppFavicon,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "favicon",
                        Code     = option.AppIcon,
                        Define   = 1
                    }
                });
            }
            else
            {
                ret = Save(new BootstrapDict()
                {
                    Category = "应用程序",
                    Name     = option.AppName,
                    Code     = option.AppCode,
                    Define   = 0
                });
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = "应用首页",
                        Name     = option.AppCode,
                        Code     = option.AppUrl,
                        Define   = 0
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站标题",
                        Code     = option.AppTitle,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站页脚",
                        Code     = option.AppFooter,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "个人中心地址",
                        Code     = "/Admin/Profiles",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "系统设置地址",
                        Code     = "/Admin/Index",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "系统通知地址",
                        Code     = "/Admin/Notifications",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "网站图标",
                        Code     = option.AppFavicon,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "favicon",
                        Code     = option.AppIcon,
                        Define   = 1
                    });
                }
            }
            return(ret);
        }
Beispiel #4
0
        /// <summary>
        /// 保存前台應用配置訊息
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public static bool SaveAppSettings(QueryAppOption option)
        {
            bool update = option.AppId == "edit";

            // dict define == 1 時為新建前台應用
            bool ret;

            // 前台網站配置地址 不允許以 / 结尾
            option.AppUrl = option.AppUrl.TrimEnd('/');
            if (update)
            {
                // Update
                ret = SaveSettings(new BootstrapDict[] {
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站標題",
                        Code     = option.AppTitle,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站頁腳",
                        Code     = option.AppFooter,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = "應用首頁",
                        Name     = option.AppCode,
                        Code     = option.AppUrl,
                        Define   = 0
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站圖標",
                        Code     = option.AppFavicon,
                        Define   = 1
                    },
                    new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "favicon",
                        Code     = option.AppIcon,
                        Define   = 1
                    }
                });
            }
            else
            {
                ret = Save(new BootstrapDict()
                {
                    Category = "應用程式",
                    Name     = option.AppName,
                    Code     = option.AppCode,
                    Define   = 0
                });
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = "應用首頁",
                        Name     = option.AppCode,
                        Code     = option.AppUrl,
                        Define   = 0
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站標題",
                        Code     = option.AppTitle,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站頁腳",
                        Code     = option.AppFooter,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "個人中心地址",
                        Code     = "/Admin/Profiles",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "系統設置地址",
                        Code     = "/Admin/Index",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "系統通知地址",
                        Code     = "/Admin/Notifications",
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "網站圖標",
                        Code     = option.AppFavicon,
                        Define   = 1
                    });
                }
                if (ret)
                {
                    ret = Save(new BootstrapDict()
                    {
                        Category = option.AppName,
                        Name     = "favicon",
                        Code     = option.AppIcon,
                        Define   = 1
                    });
                }
            }
            return(ret);
        }