You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
210 lines
5.9 KiB
210 lines
5.9 KiB
using Newtonsoft.Json;
|
|
using NFine.Application.KBSSRM;
|
|
using NFine.Code;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace NFine.Web.Areas.KBSSRM.Controllers
|
|
{
|
|
public class MaterialImportController : ControllerBase
|
|
{
|
|
private MaterialImportApp App = new MaterialImportApp();
|
|
// GET: KBSSRM/MaterialImport
|
|
public ActionResult MaterialImport()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
public ActionResult SelectColumnName(string BeginTime, string EndTime)
|
|
{
|
|
var data = App.SelectColumnName(BeginTime, EndTime);
|
|
return Content(data.ToJson());
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public ActionResult GetListGridJsonTOZ( string queryJson, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetListGridJsonTOZ2(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 文件上传到本地
|
|
/// </summary>
|
|
public ActionResult UploadFile(string JSDateDay)
|
|
{
|
|
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 Paths= System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile");
|
|
if (!Directory.Exists(Paths))
|
|
{
|
|
Directory.CreateDirectory(Paths);
|
|
}
|
|
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);
|
|
if (System.IO.File.Exists(savePath))//删除文件
|
|
{
|
|
|
|
System.IO.File.Delete(savePath);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
mess = ex.Message;
|
|
//return Error(ex.Message);
|
|
}
|
|
var JsonData = new
|
|
{
|
|
mass = mess,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult SaveAndUpdate(string ICSInvImport)
|
|
{
|
|
string msg = App.SaveAndUpdate(ICSInvImport);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("添加成功!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public ActionResult EmailNotice(string ICSInvImport)
|
|
{
|
|
DataTable dt = JsonConvert.DeserializeObject<DataTable>(ICSInvImport);
|
|
string mess = "";
|
|
try
|
|
{
|
|
string msg = App.EmailNotice(dt);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
mess = ex.Message;
|
|
//return Error(ex.Message);
|
|
}
|
|
var JsonData = new
|
|
{
|
|
mass = mess,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Delete(string ICSInvImport)
|
|
{
|
|
string msg = App.Delete(ICSInvImport);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
public void StatementExportAll(string ICSInvImport)
|
|
{
|
|
//ICSInvImport= Uri.EscapeDataString(ICSInvImport);
|
|
ICSInvImport = HttpUtility.UrlDecode(ICSInvImport);
|
|
DataTable dt = JsonConvert.DeserializeObject<DataTable>(ICSInvImport);
|
|
AsposeCell.Export(dt);
|
|
}
|
|
|
|
|
|
|
|
public ActionResult GetStartMonth(string keyValue)
|
|
{
|
|
var rows = App.GetStartMonth(keyValue);
|
|
|
|
return Content(rows.ToJson());
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult KBSTZ(string ICSInvImport)
|
|
{
|
|
string msg = App.KBSTZ(ICSInvImport);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("添加成功!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|