|
|
|
@ -11,6 +11,7 @@ using HcUtility.Comm;
|
|
|
|
|
using HcUtility.Core;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
{
|
|
|
|
@ -310,78 +311,87 @@ namespace DSWeb.MvcShipping.Controllers
|
|
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Files["LoadFile"];
|
|
|
|
|
var CUSTNO = Request.Form["CUSTNO"];
|
|
|
|
|
var BSNO = Request.Form["BSNO"];
|
|
|
|
|
var TYPE = Request.Form["TYPE"];
|
|
|
|
|
var DOCUMENTATTACHEDCODE = Request.Form["DOCUMENTATTACHEDCODE"];
|
|
|
|
|
var DOCUMENTATTACHEDNO = Request.Form["DOCUMENTATTACHEDNO"];
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name =BasicDataRefDAL.DelOtherWord( Path.GetFileName(file.FileName));
|
|
|
|
|
|
|
|
|
|
var usercode = Convert.ToString(Session["USERCODE"]);
|
|
|
|
|
var partname=usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
string filename = path + "\\"+partname ;
|
|
|
|
|
string filenameURL = "../../UploadFiles/MsOpFiles/" + CUSTNO + "/" + partname;
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
}
|
|
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
if (ext == ".asp"||ext == ".aspx")
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "不允许上传ASP货ASPX文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "" };
|
|
|
|
|
|
|
|
|
|
if (Request.Files.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "请选择上传的文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Files["LoadFile"];
|
|
|
|
|
var CUSTNO = Request.Form["CUSTNO"];
|
|
|
|
|
var BSNO = Request.Form["BSNO"];
|
|
|
|
|
var TYPE = Request.Form["TYPE"];
|
|
|
|
|
var DOCUMENTATTACHEDCODE = Request.Form["DOCUMENTATTACHEDCODE"];
|
|
|
|
|
var DOCUMENTATTACHEDNO = Request.Form["DOCUMENTATTACHEDNO"];
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//20230206 增加逻辑 如果bsno来自一个op_seae_billmanage.as_id 则将BSNO改为它的op_seae_billmanag.BSNO
|
|
|
|
|
//该功能用于将在【提单管理】模块中,选择分单之后上传的附件,在主单的【单据管理】模块中可见
|
|
|
|
|
|
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
|
var fenlist = cdc.OP_SEAE_BILLMANAGE.Where(x => x.AS_ID == CUSTNO).ToList();
|
|
|
|
|
if (fenlist != null && fenlist.Count > 0) {
|
|
|
|
|
BSNO = fenlist[0].BSNO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var path = Server.MapPath("../../UploadFiles/MsOpFiles/" + CUSTNO);
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var size = file.ContentLength;
|
|
|
|
|
var name =BasicDataRefDAL.DelOtherWord( Path.GetFileName(file.FileName));
|
|
|
|
|
|
|
|
|
|
var usercode = Convert.ToString(Session["USERCODE"]);
|
|
|
|
|
var partname=usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
|
|
|
|
|
string filename = path + "\\"+partname ;
|
|
|
|
|
string filenameURL = "../../UploadFiles/MsOpFiles/" + CUSTNO + "/" + partname;
|
|
|
|
|
if (System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
System.IO.File.Delete(filename);
|
|
|
|
|
}
|
|
|
|
|
file.SaveAs(filename);
|
|
|
|
|
|
|
|
|
|
if (!System.IO.File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件发生未知错误,请重新上传" });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
}
|
|
|
|
|
string ext = Path.GetExtension(file.FileName).ToLower();
|
|
|
|
|
if (ext == ".asp"||ext == ".aspx")
|
|
|
|
|
{
|
|
|
|
|
jsonRespose.Success = false;
|
|
|
|
|
jsonRespose.Message = "不允许上传ASP货ASPX文件";
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var message = string.Empty;
|
|
|
|
|
|
|
|
|
|
var isSucess = MsOpReceiptDAL.UpdateFileData(filenameURL, name, BSNO, Convert.ToString(Session["USERID"]),TYPE,DOCUMENTATTACHEDCODE,DOCUMENTATTACHEDNO,CUSTNO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
var json2 = JsonConvert.Serialize(new { success = isSucess.Success, Message = isSucess.Message, data = filename });
|
|
|
|
|
return new ContentResult() { Content = json2 };
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = "上传文件出错,请确认文件正确性" });
|
|
|
|
|
var json = JsonConvert.Serialize(new { success = false, Message = $"上传文件出错,请确认文件正确性{e.Message}" });
|
|
|
|
|
return new ContentResult() { Content = json };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|