|
|
using NFine.Application.SRM; using NFine.Code; using NFine.Domain._03_Entity.SRM; using System; using System.Data; using System.IO; using System.Web; using System.Web.Mvc;
namespace NFine.Web.Areas.SRM.Controllers { public class BicDoc_PublishController : ControllerBase { private BicDoc_PublishApp App = new BicDoc_PublishApp(); [HttpGet] [HandlerAjaxOnly] public ActionResult GetGridJson(Pagination pagination, string queryJson) { DataTable ListData = App.GetGridJson(queryJson, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
public ActionResult ICSBicDoc_PubLish() { return View(); } public ActionResult ICSBicDocAdd_PubLish() { return View(); } public ActionResult ICSBicDocDetail_PubLish() { return View(); } public ActionResult ICSBicDoc_Item() { return View(); } public ActionResult ICSBicDoc_Supplier() { return View(); } public ActionResult ICSBicDocByPU() { return View(); } public ActionResult ICSBicDoc_AddFCS() { return View(); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetBidUser(string WorkPoint) { DataTable dt = App.GetBidUser(WorkPoint); return Content(dt.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetBidDocBDInfoByCode(string queryJson, Pagination pagination) { DataTable ListData = App.GetBidDocBDInfoByCode(queryJson, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetBidDocBDInfoByBidCode(string queryJson, Pagination pagination, string WorkPoint) { DataTable ListData = App.GetBidDocBDInfoByBidCode(queryJson, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetBidDocGYSInfoByCode(string queryJson, Pagination pagination, string WorkPoint) { DataTable ListData = App.GetBidDocGYSInfoByCode(queryJson, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetItemList(Pagination pagination, string queryJson, string WorkPoint) { WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); DataTable ListData = App.GetItemList(queryJson, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetVendorList(Pagination pagination, string queryJson, string WorkPoint) { DataTable ListData = App.GetVendorList(queryJson, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
[HttpPost] public ActionResult SubmitForm(ICSBicDoc details) { try { App.SaveDetail(details); return Success("招标书方案保存成功!"); } catch (Exception ex) { return Error(ex.Message); } }
[HttpGet] public ActionResult GetFormDetail(string ID, string WorkPoint) { try { DataRow dr = App.GetFormDetail(ID, WorkPoint); var JsonData = new { ID = dr["ID"].ToString(), BidCode = dr["BidCode"].ToString(), BidName = dr["BidName"].ToString(), BidUser = dr["BidUser"].ToString(), StarTime = dr["StarTime"].ToString(), EndTime = dr["EndTime"].ToString(), BidStatus = dr["BidStatus"].ToString(), Remark = dr["Remark"].ToString(), WorkPoint = dr["WorkPoint"].ToString(), ZTBCount = dr["ZTBCount"].ToString(), FileName = dr["FileName"].ToString(), }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult UpDateByDocNo(string ID, string BidCode, string WorkPoint) { WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); int result = App.UpDateByDocNo(ID, BidCode, WorkPoint); if (result > 0) { return Success("操作成功!"); } else { return Error("操作失败!"); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteBidDoc(string keyValue, string WorkPoint) { WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); string msg = App.DeleteBidDoc(keyValue, WorkPoint); if (string.IsNullOrWhiteSpace(msg)) { return Success("删除成功!"); } else { return Error("删除失败"); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult CloseBidding(string ID, string BidCode, string WorkPoint) { WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); int result = App.CloseBidding(ID, BidCode, WorkPoint); if (result > 0) { return Success("操作成功!"); } else { return Error("操作失败!"); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteSup(string keyValue, string WorkPoint) { string msg = App.DeleteSup(keyValue, WorkPoint); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } }
[HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteBD(string keyValue, string WorkPoint) { string msg = App.DeleteBD(keyValue, WorkPoint); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } } [HttpPost] public ActionResult UpLoadFileImport(string BidCode, string ID) {
string FileName = ""; string PathName = ""; //获取上传的文件集合
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files; for (int i = 0; i < httpFile.Count; i++) { //获取送货单号
//string STNO = Request.Form["STNO"].ToString();
string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName) + Path.GetExtension(httpFile[i].FileName); string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\ZTBFile\\" + BidCode); if (!Directory.Exists(Paths)) { Directory.CreateDirectory(Paths); } string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\ZTBFile\\" + BidCode + "\\" + fileName);
int iLen = httpFile[0].ContentLength; byte[] bData = new byte[iLen]; httpFile[0].InputStream.Read(bData, 0, iLen); FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate); fs.Write(bData, 0, bData.Length); fs.Flush(); fs.Close(); fs.Dispose(); FileName += "" + fileName + ";"; PathName += "" + filePath + ";"; } int count = App.UpLoadFile(FileName, PathName, BidCode, ID); if (count > 0) { return Success("上传成功!"); } else { return Error("上传失败"); } } /// <summary>
/// Post 请求发送文件
/// </summary>
/// <param name="url"></param>
/// <param name="fileName"></param>
/// <returns></returns>
//public static string PostFile(string url, string fileName)
//{
// //验证文件是否存在
// if (File.Exists(fileName) == false)
// throw new Exception("发送文件不存在!");
// FileInfo file = new FileInfo(fileName);
// string boundary = "qianle";//分隔符
// HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
// //构造请求体
// byte[] itemBoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n");
// byte[] byteEnd = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); //结束标识 --xxxx--
// StringBuilder strContent = new StringBuilder();
// strContent
// .Append("Content-Disposition:form-data;name=\"filename\";filename=\"" + file.Name + "\"")
// .AppendLine()
// .Append("Content-Type:application/octet-stream")
// .AppendLine()
// .AppendLine(); //特别说明,Content-Disposition 前边不能添加换行符号
// byte[] byteContent = Encoding.UTF8.GetBytes(strContent.ToString());
// byte[] byteFile = File.ReadAllBytes(fileName);
// //执行发送
// req.Method = "POST";
// req.ContentType = $"multipart/form-data;charset=utf-8;boundary={boundary}";
// req.UserAgent = UserAgent;
// req.ContinueTimeout = 20000;
// var reqStrem = req.GetRequestStream();
// reqStrem.Write(itemBoundaryBytes, 0, itemBoundaryBytes.Length); //文件开始
// reqStrem.Write(byteContent, 0, byteContent.Length);//文件信息
// reqStrem.Write(byteFile, 0, byteFile.Length);//文件内容
// reqStrem.Write(byteEnd, 0, byteEnd.Length); //文件结束
// reqStrem.Close();
// WebResponse resp = req.GetResponse();
// StreamReader sr = new StreamReader(resp.GetResponseStream());
// string result = sr.ReadToEnd();
// sr.Close();
// resp.Close();
// return result;
//}
[HttpPost] /// <summary>
/// 文件上传到本地
/// </summary>
public ActionResult UploadFile(string ID, string BidCode, string WorkPoint) { string mess = ""; try { HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files; if (hpFiles != null && hpFiles.Count > 0) {
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx") {
mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
} string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength; if (Directory.Exists(savePath)) mess = "文件已存在"; byte[] bData = new byte[iLen]; hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate); newFile.Write(bData, 0, bData.Length); newFile.Flush(); int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close(); newFile.Dispose(); //bool del = false;
mess = App.SetData_PR(savePath, ID, BidCode, WorkPoint); if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath); }
} else { mess = "获取文件失败"; } } catch (Exception ex) {
mess = ex.Message; } var JsonData = new { mass = mess, }; return Content(JsonData.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult InsertID(string ID,string WorkPoints) { string GUID = App.InsertID(ID, WorkPoints); var JsonData = new { GUID = GUID, }; return Content(JsonData.ToJson()); } public ActionResult GetSubGridJsonBid(string STNO, Pagination pagination, string WorkPoint) { DataTable ListData = App.GetSubGridJsonBid(STNO, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } /// <summary>
/// 请购单信息
/// </summary>
/// <param name="STNO"></param>
/// <param name="pagination"></param>
/// <param name="WorkPoint"></param>GetBicDocByPU
/// <returns></returns>
public ActionResult GetBicDocByPU(string queryJson, Pagination pagination, string WorkPoint) { WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); DataTable ListData = App.GetBicDocByPU(queryJson, ref pagination, WorkPoint); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
/// <summary>
/// 采购人员加载站点
/// </summary>
/// <returns></returns>
[HttpGet] public ActionResult GetWorkPointByUser() { try { DataTable ListData = App.GetWorkPointByUser(); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } } [HttpGet] [HandlerAjaxOnly] public ActionResult GetBidCode(string WorkPoint, string Vendor) { try { string BidCode = App.GetBidCode(WorkPoint, Vendor); var JsonData = new { BidCode = BidCode, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } } [HttpGet] [HandlerAjaxOnly] public ActionResult GetBidItemCode(string WorkPoint, string Vendor) { try { string BidItemCode = App.GetBidItemCode(WorkPoint, Vendor); var JsonData = new { BidItemCode = BidItemCode, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } }
//public ActionResult SubmitICSBicDocAddFCS(string keyValue)
//{
// try
// {
// string msg = App.SubmitFormCFType(keyValue);
// var JsonData = new
// {
// msg = msg,
// };
// return Content(JsonData.ToJson());
// }
// catch (Exception ex)
// {
// return Error(ex.Message);
// }
//}
/// <summary>
/// 调用OA接口
/// </summary>
/// <param name="TEMPVENDORCODE">公司名称</param>
/// <returns></returns>
[HttpPost] public ActionResult SubmitOARejict(string BidCode, string WorkPoint) { try { string msg= App.SubmitOARejict(BidCode, WorkPoint); var JsonData = new { msg = msg, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error("推送失败"+ex.Message); }
} } }
|