Example #1
0
        /// <summary>
        /// 保存类库中的视图
        /// </summary>
        /// <param name="type"></param>
        private void SaveViewSetting(Type type)
        {
            PlatformSource?platform = ViewUtils.GetPlatform(type);

            if (platform == null)
            {
                return;
            }
            ViewSetting setting = new ViewSetting()
            {
                Name     = type.Name,
                Platform = platform.Value,
                Code     = type.FullName,
                Status   = ViewSetting.ViewStatus.Normal
            };

            using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted))
            {
                if (setting.Exists(db, t => t.Code))
                {
                    setting = setting.Info(db, t => t.Code);
                }
                else
                {
                    setting.AddIdentity(db);
                }
                db.AddCallback(() =>
                {
                    ViewCaching.Instance().SaveViewID(setting.Code, setting.ID);
                });
                db.Commit();
            }
        }
Example #2
0
        /// <summary>
        /// 获取商户的视图配置
        /// 如果商户模板中没有针对该视图的配置,则返回默认配置
        /// </summary>
        /// <typeparam name="TView">视图配置类(支持抽象类)</typeparam>
        /// <param name="siteId"></param>
        /// <returns></returns>
        protected TView GetViewConfig <TView>(int templateId) where TView : IViewBase
        {
            TView view = ViewCaching.Instance().GetSiteView <TView>(templateId);

            if (view != null)
            {
                return(view);
            }

            ViewSiteTemplate template = this.GetSiteTemplate(templateId);

            if (template == null)
            {
                return(default);
Example #3
0
        /// <summary>
        /// 保存商户对于视图的配置
        /// </summary>
        /// <param name="configId"></param>
        /// <param name="setting"></param>
        /// <returns></returns>
        public bool SaveSiteViewConfig(int configId, string setting)
        {
            ViewSiteConfig config = this.GetSiteViewConfig(configId);

            if (config == null)
            {
                return(this.FaildMessage("配置项目错误"));
            }
            // 验证setting内容是否正确
            ViewSetting view = this.GetViewSetting(config.ViewID);

            try
            {
                ViewUtils.CreateInstance(view.Code, setting);
            }
            catch (Exception ex)
            {
                return(this.FaildMessage(ex.Message));
            }
            config.Setting = setting;
            this.WriteDB.Update <ViewSiteConfig, string>(t => t.Setting, setting, t => t.ID == configId);
            ViewCaching.Instance().SaveSiteConfig(config);
            return(this.AccountInfo.Log(LogType.Site, $"修改商户{config.SiteID}视图配置参数,ID={configId},View={view.Code}"));
        }