Esempio n. 1
0
    protected void SaveRWPFUploadInfo()
    {
        string jsonStr3    = "";
        string rcswwdResID = "393296902171";

        if (Request["jsonStr3"] != null)
        {
            jsonStr3 = Request["jsonStr3"];
        }
        Response.ContentType = "text/plain";
        Response.Charset     = "utf-8";
        HttpPostedFile file = Request.Files["Filedata"];

        WebServices.Services Resource = new WebServices.Services();

        string uploadPath = HttpContext.Current.Server.MapPath(Request["folder"]) + "\\";

        DataTable dt = (DataTable)Newtonsoft.Json.JsonConvert.DeserializeObject <DataTable>(jsonStr3);

        WebServices.FieldInfo[] FieldListInfo = new WebServices.FieldInfo[dt.Rows.Count];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                WebServices.FieldInfo fi = new WebServices.FieldInfo();
                fi.FieldDescription = dt.Rows[i]["Description"].ToString();
                fi.FieldValue       = dt.Rows[i]["Value"].ToString();
                FieldListInfo[i]    = fi;
            }
        }
        if (file != null)
        {
            string           fileName = System.IO.Path.GetFileName(file.FileName);
            int              FileLen  = file.ContentLength;
            byte[]           FileData = new byte[FileLen];
            System.IO.Stream sr       = file.InputStream;//创建数据流对象
            sr.Read(FileData, 0, FileLen);
            sr.Close();
            Resource.UploadFile(rcswwdResID, UserID, fileName, FileData, FieldListInfo);
            //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
            Response.Write("1");
        }
        else
        {
            Resource.UploadFile(rcswwdResID, UserID, "", null, FieldListInfo);
            Response.Write("1");
        }
    }