public ActionResult UploadFiles() { HttpFileCollection postfiles = System.Web.HttpContext.Current.Request.Files; Robots robots = null; if (postfiles[0] != null && postfiles[0].FileName != null && postfiles[0].FileName != "") { NameValueCollection myCol = new NameValueCollection(); System.Text.StringBuilder url = new System.Text.StringBuilder(); url.Append(base._config.UrlHome + "tools/UploadFiles?"); url.Append(Cookies.CreateVerifyString()); robots = new Robots(); string s = robots.HttpUploadFile(url.ToString(), postfiles[0], myCol, "file"); if (robots.IsError) { return(Json(new { error = true, message = robots.ErrorMsg }, JsonRequestBehavior.AllowGet)); } return(Json(new { error = false, message = s }, JsonRequestBehavior.AllowGet)); // ResponseFile file = JsonHelper.JsonToObject<Response<ResponseFile>>(s).Body; // string uploadSaveMapPath = JsonHelper.JsonToObject<Response<ResponseFile>>(s).Body.fileNameList[0].fileKey; // string fullpathXX = JsonHelper.JsonToObject<Response<ResponseFile>>(s).Body.fileNameList[0].fileUrl; //return Json(new { error = false, message = "成功", image = uploadSaveMapPath, fullPath = fullpathXX }, JsonRequestBehavior.AllowGet); } else { return(Json(new { error = true, message = "请选择文件!" }, JsonRequestBehavior.AllowGet)); } /* * string returnUrl = DoRequest.GetFormString("returnurl").Trim(); * * if (!UpLoadFile.IsPostFile()) * { * return Json(new { error = true, message = "请选择上传的文件" }); * } * HttpFileCollection postfiles = System.Web.HttpContext.Current.Request.Files; * if (postfiles[0] != null && postfiles[0].FileName != null && postfiles[0].FileName != "") * { * Robots _rbt = new Robots(); * * System.Text.StringBuilder url = new System.Text.StringBuilder(); * url.Append(base._config.UrlHome + "tools/UploadFiles?"); * url.Append(Cookies.CreateVerifyString()); * * string html = _rbt.PostFile(url.ToString(), postfiles[0], "utf-8"); * if (_rbt.IsError) * { * return Json(new { error = true, message = _rbt.ErrorMsg }); * } * if (string.IsNullOrEmpty(html)) * { * return Json(new { error = true, message = "远程页面无响应..." }); * } * ParseJson pJson = new ParseJson(); * SortedDictionary<string, string> list = pJson.Parse(html); * if (pJson.GetJsonValue(list, "error") == "true") * { * return Json(new { error = true, message = pJson.GetJsonValue(list, "message") }); * } * string uploadFileName = pJson.GetJsonValue(list, "path"); * if (string.IsNullOrEmpty(uploadFileName)) * { * return Json(new { error = true, message = "文件名获取失败..." }); * } * * return Json(new { error = false, message = "上传成功!", path = uploadFileName, fullPath = pJson.GetJsonValue(list, "fullPath"), url = returnUrl.Equals("") ? base._config.UrlHome : returnUrl }); * } * * return Json(new { error = true, message = "上传失败..." }); * */ }
public ActionResult PostPolymericList() { string subject = DoRequest.GetFormString("subject").Trim(); string excelPath = DoRequest.GetFormString("excel").Trim(); string sdate = DoRequest.GetFormString("sdate").Trim(); int shours = DoRequest.GetFormInt("shours"); int sminutes = DoRequest.GetFormInt("sminutes"); DateTime startDate = Utils.IsDateString(sdate) ? DateTime.Parse(sdate + " " + shours + ":" + sminutes + ":00") : DateTime.Now; string edate = DoRequest.GetFormString("edate").Trim(); int ehours = DoRequest.GetFormInt("ehours"); int eminutes = DoRequest.GetFormInt("eminutes"); DateTime endDate = Utils.IsDateString(edate) ? DateTime.Parse(edate + " " + ehours + ":" + eminutes + ":59") : DateTime.Now.AddDays(7); string summary = DoRequest.GetFormString("summary").Trim(); if (subject.Length < 1) { return(Json(new { error = true, message = "请填写主题..." })); } if (subject.Length > 50) { return(Json(new { error = true, message = "主题不能超过50个字符..." })); } if (summary.Length > 500) { return(Json(new { error = true, message = "摘要不能超过500个字符..." })); } Robots _rbt = new Robots(); System.Text.StringBuilder url = new System.Text.StringBuilder(); url.Append(base._config.UrlHome + "Tools/ImportFromExcel?"); url.Append(Cookies.CreateVerifyString()); System.Text.StringBuilder postData = new System.Text.StringBuilder(); postData.Append("subject=" + DoRequest.UrlEncode(AES.Encode(subject))); postData.Append("&excel=" + DoRequest.UrlEncode(AES.Encode(excelPath))); postData.Append("&sdate=" + startDate.ToString("yyyy-MM-dd HH:mm:ss")); postData.Append("&edate=" + endDate.ToString("yyyy-MM-dd HH:mm:ss")); postData.Append("&summary=" + DoRequest.UrlEncode(AES.Encode(summary))); string html = _rbt.Post(url.ToString(), postData.ToString(), "utf-8"); if (_rbt.IsError) { return(Json(new { error = true, message = _rbt.ErrorMsg })); } if (string.IsNullOrEmpty(html)) { return(Json(new { error = true, message = "远程页面无响应..." })); } ParseJson pJson = new ParseJson(); SortedDictionary <string, string> list = pJson.Parse(html); bool isError = false; if (pJson.GetJsonValue(list, "error") == "true") { isError = true; } return(Json(new { error = isError, message = pJson.GetJsonValue(list, "message") })); }