private string DoWork(string sessionId, string encryptData) { if (string.IsNullOrWhiteSpace(encryptData)) { return(ErrorResources.SYSTEM_WARNING_0x0001); } //初始化服务器(插件、配置) string decrypString = ConfigurationLoader.Instance.DataParser.DecryptData(encryptData); string methodText = ConfigurationLoader.Instance.RequestSpliter.GetMethodText(decrypString); string attatchmentText = ConfigurationLoader.Instance.RequestSpliter.GetAttachmentText(decrypString); var request = new RequestSchema(sessionId, methodText, attatchmentText); request.ResolveRequest(ConfigurationLoader.Instance.MethodResolver, ConfigurationLoader.Instance.SessionResolver, ConfigurationLoader.Instance.AttachmentResolver); var dataContext = new ServerDataContext { Request = request }; PluginManager.Instance.UpdateDataContext(dataContext); //定义授权方法 ISecurityAuthorize security = ConfigurationLoader.Instance.SecurityAuthorize; //Session bool sessionPass = ConfigurationLoader.Instance.Business.SessionAccess(request.Session); try { //获取授权信息 if (!security.Authorized(dataContext)) { return(security.Error.SimpleErrorDescription); } if (!sessionPass) { return(ErrorResources.SYSTEM_FATAL_ERROR_0x0001); } //获取请求响应 //TODO:此处的异常应统一处理 if (request.RequestMethod == null) { return(ErrorResources.SYSTEM_WARNING_0x0002); } object obj = MethodRoute.Invoke(request.RequestMethod); string json = JSONConvert.ConvertToString(obj); //压缩发送 return(CompressProvider.Compress(json)); } catch (Exception) { return(ErrorResources.SYSTEM_INFO_0x0001); } }
private string DoWork(string encryptData) { if (string.IsNullOrWhiteSpace(encryptData)) { return(ErrorResources.SYSTEM_WARNING_0x0001); } //初始化服务器(插件、配置) string decrypString = ConfigurationLoader.Instance.DataParser.DecryptData(encryptData); string methodText = ConfigurationLoader.Instance.RequestSpliter.GetMethodText(decrypString); string attatchmentText = ConfigurationLoader.Instance.RequestSpliter.GetAttachmentText(decrypString); var request = new RequestSchema(methodText, attatchmentText); request.ResolveRequestWithoutSession(ConfigurationLoader.Instance.MethodResolver, ConfigurationLoader.Instance.AttachmentResolver); var dataContext = new ServerDataContext { Request = request }; PluginManager.Instance.UpdateDataContext(dataContext); //定义授权方法 ISecurityAuthorize security = ConfigurationLoader.Instance.SecurityAuthorize; try { //获取授权信息 if (!security.Authorized(dataContext)) { return(security.Error.SimpleErrorDescription); } //获取允许的方法 MethodsName = MethodsName ?? (MethodsName = AvailableInvokeMethod(typeof(ILoginEntry))); //获取请求响应 //TODO:此处的异常应统一处理 if (request.RequestMethod == null) { return(ErrorResources.SYSTEM_WARNING_0x0002); } object obj = MethodRoute.Invoke(request.RequestMethod, MethodsName); string json = JSONConvert.ConvertToString(obj); //压缩发送 return(CompressProvider.Compress(json)); } catch (Exception ex) { return(ex.InnerException != null?ex.InnerException.ToString() : ex.ToString()); //return ErrorResources.SYSTEM_INFO_0x0001; } }