private static void Init() { if (_yunClient == null || _appInfo == null) { lock (initLock) { if (_yunClient != null && _appInfo != null) return; if (_appInfo == null) { var init = new Yun.ClientCache.CacheFunc(); _appInfo = init.Fetch<AppModel>(_appTableName, "id = 0"); if (_appInfo == null) { throw new Exception("授权信息未设置,无法进行网站初始化"); } } if (_yunClient == null) { var apiUrl = WebConfigurationManager.AppSettings["ServerUrl"]; if (new[] { _appInfo.AppKey, _appInfo.AppSecret, apiUrl }.Any(string.IsNullOrWhiteSpace)) { throw new Exception("服务端必要数据未初始化"); } _yunClient = new DefaultYunClient(apiUrl, _appInfo.AppKey, _appInfo.AppSecret); } } } }
/// <summary> /// 保存城购云配置信息 /// </summary> /// <param name="key">客户KEY</param> /// <param name="secret">客户密钥</param> /// <returns></returns> public static void SaveConfig(string key, string secret) { //先更新内存中数据 _appInfo = new AppModel { AppKey = key, AppSecret = secret}; _yunClient = null; //将数据写入缓存中 var init = new Yun.ClientCache.CacheFunc(); init.DropTable(_appTableName); init.Insert(_appTableName, "id", _appInfo, null); }
public static APPSettModel ConvertGoodsInSql(AppModel model) { if (model != null) { var r = new APPSettModel(); //映射处理 var map = new TypeMapping<AppModel, APPSettModel>(); map.AutoMap(); map.CopyLeftToRight(model, r); //r.TaxonomyId = r.Categorys.Union(r.Tags).Distinct().Select(e => e.Key).ToList(); return r; } return null; }