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> private static void GetWebSettingRequest() { if (_webInfo != null) return; var init = new Yun.ClientCache.CacheFunc(); var setting = init.Fetch<Settoins>("app", "id = 1"); if (setting != null) { _webInfo = setting.Settoin.ConvertAll(x => new StringKeyValuePair { Key = x.Key, Value = x.Value }); return; } var r = YunClient.Instance.Execute(new GetWebSettingRequest(), Extension.Member.Token).Settings; if (r == null || r.Count <= 0) return; init.Insert("app", "id", new Settoins {id = 1, Settoin = r}, null); _webInfo = r.ConvertAll(x => new StringKeyValuePair {Key = x.Key, Value = x.Value}); }