当前位置: 首页>>代码示例>>C#>>正文


C# JsonObject.Accumulate方法代码示例

本文整理汇总了C#中Jayrock.Json.JsonObject.Accumulate方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.Accumulate方法的具体用法?C# JsonObject.Accumulate怎么用?C# JsonObject.Accumulate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jayrock.Json.JsonObject的用法示例。


在下文中一共展示了JsonObject.Accumulate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        /**
         * Processes a JSON request.
         *
         * @param request Original JSON request
         * @return The JSON response.
         */
        public JsonObject Process(JsonObject request)
        {
            JsonObject response = new JsonObject();

            JsonObject requestContext = request.getJSONObject("context");
            JsonArray requestedGadgets = request["gadgets"] as JsonArray;

            // Process all JSON first so that we don't wind up with hanging threads if
            // a JsonException is thrown.
            List<IAsyncResult> gadgets = new List<IAsyncResult>(requestedGadgets.Length);
            for (int i = 0, j = requestedGadgets.Length; i < j; ++i)
            {
                var context = new JsonRpcGadgetContext(requestContext, (JsonObject)requestedGadgets[i]);
                PreloadProcessor proc = new PreloadProcessor(CallJob);
                IAsyncResult result = proc.BeginInvoke(context, null, null);
                gadgets.Add(result);
            }

            foreach (var entry in gadgets)
            {
                try
                {
                    AsyncResult result = (AsyncResult)entry;
                    PreloadProcessor proc = (PreloadProcessor)result.AsyncDelegate;
                    JsonObject gadget = proc.EndInvoke(result);
                    response.Accumulate("gadgets", gadget);
                }
                catch (JsonException e)
                {
                    throw new RpcException("Unable to write JSON", e);
                }
                catch (Exception ee)
                {
                    if (!(ee is RpcException))
                    {
                        throw new RpcException("Processing interrupted", ee);
                    }
                    RpcException e = (RpcException)ee;
                    // Just one gadget failed; mark it as such.
                    try
                    {
                        GadgetContext context = e.Context;
                        
                        JsonObject errorObj = new JsonObject();
                        errorObj.Put("url", context.getUrl())
                            .Put("moduleId", context.getModuleId());
                        errorObj.Accumulate("errors", e.Message);
                        response.Accumulate("gadgets", errorObj);
                    }
                    catch (JsonException je)
                    {
                        throw new RpcException("Unable to write JSON", je);
                    }
                }
            }
            return response;
        }
开发者ID:s7loves,项目名称:pesta,代码行数:63,代码来源:JsonRpcHandler.cs

示例2: UploadPic

 private void UploadPic(HttpRequest Request, HttpResponse Response, string strFileUrl)
 {
     HttpPostedFile file = Request.Files["Filedata"];
     if (file != null)
     {
         //文件夹是否存在
         string pathStr = HttpContext.Current.Server.MapPath("/" + strFileUrl);
         if (!Directory.Exists(pathStr))
         {
             //不存在则自动创建文件夹
             Directory.CreateDirectory(pathStr);
         }
         string ext = Path.GetExtension(file.FileName).ToLower();
         string fileName = Guid.NewGuid().ToString("N", System.Globalization.CultureInfo.InvariantCulture) + ext;
         string savepath = pathStr + "/" + fileName;
         JsonObject json = new JsonObject();
         try
         {
             file.SaveAs(savepath);
             json.Accumulate("Status", "OK");
             json.Accumulate("SavePath", "/" + strFileUrl + "/" + fileName);
             Response.Write(("1|" + json.ToString()));
         }
         catch (Exception)
         {
             json.Accumulate("Status", "Failed");
             json.Accumulate("ErrorMessage", "系统忙,请稍后再试!");
             Response.Write("0|" + json.ToString());
         }
     }
     else
     {
         JsonObject json = new JsonObject();
         json.Accumulate("Status", "Failed");
         json.Accumulate("ErrorMessage", " 系统忙,请稍后再试!");
         Response.Write("0|" + json.ToString());
     }
 }
开发者ID:bookxiao,项目名称:orisoft,代码行数:38,代码来源:IndexHandke.cs

示例3: GetUser

 public string GetUser(string q)
 {
     DataTable table = new FBProject().GetUser(q).Tables[0];
     JsonArray jsonList = new JsonArray();
     Jayrock.Json.JsonObject json;
     foreach (DataRow row in table.Rows)
     {
         json = new Jayrock.Json.JsonObject();
         json.Accumulate("uname", row["username"]);
         //UserId
         jsonList.Add(json);
     }
     string str = jsonList.ToString();
     return str;
 }
开发者ID:jxb505,项目名称:FbCRM2,代码行数:15,代码来源:WebBll.cs


注:本文中的Jayrock.Json.JsonObject.Accumulate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。