Ejemplo n.º 1
0
        /// <summary>
        /// 获取上下文
        /// </summary>
        /// <returns>用户信息</returns>
        public string GetContextData()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("userid: {0}", JsonRpcDataContext.GetContextItem("userid")).AppendLine();
            sb.AppendFormat("companycode: {0}", JsonRpcDataContext.GetContextItem("companycode")).AppendLine();
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        protected void Application_Start()
        {
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            JsonRpcRegister.LoadFromConfig();
            JsonRpcConfigManager.SetErrorHandler(OnJsonRpcException);
            JsonRpcConfigManager.SetPreProcessHandler(new PreProcessHandler(PreProcess));
            JsonRpcConfigManager.SetCompletedProcessHandler(new CompletedProcessHandler(CompletedProcess));

            Maha.JsonClient.JsonRpcRequest.SetGlobalContextHandler((collection) =>
            {
                var contextDict = JsonRpcDataContext.GetOrInitCurrentContext();
                foreach (KeyValuePair <string, object> keyValuePair in contextDict)
                {
                    collection[keyValuePair.Key] = (string)keyValuePair.Value;
                }
            });
        }
Ejemplo n.º 3
0
 private void CompletedProcess(JsonRpcRequestContext jsonRequest, JsonRpcResponseContext jsonResponse, object context)
 {
     JsonRpcDataContext.RemoveContext();
 }