Beispiel #1
0
    public static string getSystemParaBuildinCode()
    {
        Jayrock.Json.JsonObject ja = new Jayrock.Json.JsonObject();
        Jayrock.Json.JsonObject jo;

        DatabaseAccess dbAccess = new DatabaseAccess();
        string         sql      = "select * from SystemParaBuildin";

        System.Data.DataTable dt;
        dbAccess.open();
        try
        {
            dt = dbAccess.select(sql);

            foreach (System.Data.DataRow row in dt.Rows)
            {
                jo = new Jayrock.Json.JsonObject();
                foreach (System.Data.DataColumn col in dt.Columns)
                {
                    jo.Accumulate(col.ColumnName, row[col.ColumnName]);
                }
                ja.Accumulate(row["ID"].ToString(), jo);
            }
        }
        catch
        {
            throw;
        }
        finally
        {
            dbAccess.close();
        }

        return(ja.ToString());
    }
Beispiel #2
0
    public Jayrock.Json.JsonArray getFileJsonArray()
    {
        DatabaseAccess dbAccess = new DatabaseAccess();

        Jayrock.Json.JsonArray  images = new Jayrock.Json.JsonArray();
        Jayrock.Json.JsonObject image;
        System.Data.DataTable   dt;
        string sql = string.Format(" select ID, Name FileName, Description from [File] where parentid = {0}  order by ID ", ID.ToString());

        dbAccess.open();
        try
        {
            dt = dbAccess.select(sql);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            dbAccess.close();
        }

        foreach (System.Data.DataRow row in dt.Rows)
        {
            image = new Jayrock.Json.JsonObject();
            foreach (System.Data.DataColumn col in dt.Columns)
            {
                image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]);
            }
            images.Add(image);
        }

        return(images);
    }
Beispiel #3
0
        /**
         * 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;
        }
Beispiel #4
0
    public Jayrock.Json.JsonArray getImageJsonArray()
    {
        DatabaseAccess dbAccess = new DatabaseAccess();

        Jayrock.Json.JsonArray  images = new Jayrock.Json.JsonArray();
        Jayrock.Json.JsonObject image;

        System.Data.DataTable dt;
        string sql = "select ID, FileName, MIME from [Image] where Category = '"
                     + GlobalSetting.ArticleCategory.Event
                     + "' and ParentID = " + ID.ToString();

        dbAccess.open();
        try
        {
            dt = dbAccess.select(sql);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            dbAccess.close();
        }

        foreach (System.Data.DataRow row in dt.Rows)
        {
            image = new Jayrock.Json.JsonObject();
            foreach (System.Data.DataColumn col in dt.Columns)
            {
                image.Accumulate(col.ColumnName.ToLower(), row[col.ColumnName]);
            }
            images.Add(image);
        }

        return(images);
    }
Beispiel #5
0
 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());
     }
 }
Beispiel #6
0
 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;
 }