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.
733 lines
28 KiB
733 lines
28 KiB
using NFine.Application;
|
|
using NFine.Application.ProductManage;
|
|
using NFine.Application.SRM;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain.Entity.ProductManage;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace NFine.Web.Areas.SRM.Controllers
|
|
{
|
|
public class ASNMangeWeiWaiController : ControllerBase
|
|
{
|
|
ASNMangeWeiWaiApp App = new ASNMangeWeiWaiApp();
|
|
// GET: SRM/ASNMangeWeiWai
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult ASNAddWeiWai()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult ASNCartonSelectWeiWai()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult ASNSelectWeiWai()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult ASNUpdateWeiWai()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[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());
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJson(string STNO, Pagination pagination,string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetSubGridJson(STNO, ref pagination, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
public ActionResult HDeleteSTNO(string keyValue,string WorkPoint,string EATTRIBUTE1)
|
|
{
|
|
string msg = App.DeleteSTNO(keyValue, WorkPoint, EATTRIBUTE1);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult CheckIsAll(string STNO)
|
|
{
|
|
string _result = App.CheckIsAll(STNO);
|
|
var JsonData = new
|
|
{
|
|
result = _result
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSTNO(string WorkPoint)
|
|
{
|
|
string cSTNO = App.GetSTNO(WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
STNO = cSTNO,
|
|
VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSTNOByPerson(string VenCode, string ExpArrivalDate, string WorkPoint)
|
|
{
|
|
string cSTNO = App.GetSTNOByPerson(VenCode, ExpArrivalDate, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
STNO = cSTNO
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetVendor()
|
|
{
|
|
DataTable dt = App.GetVendor();
|
|
return Content(dt.ToJson());
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetVendors()
|
|
{
|
|
DataTable dt = App.GetVendors();
|
|
return Content(dt.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJson_Add(string queryJson, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetSubGridJson_Add(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 GetInfoBySelectItemCode(Pagination pagination, string queryJson,string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetInfoBySelectItemCode(queryJson, ref pagination, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult SaveItemCode(string queryJson, string STNO, string WorkPoint)
|
|
{
|
|
queryJson = queryJson.Substring(1, queryJson.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string msg = App.CheckSTNO_ItemCode(queryJson, STNO, WorkPoint);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("添加成功!");
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult ASNCartonGetCartonGridJson(Pagination pagination, string queryJson, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.ASNCartonGetCartonGridJson(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 GetCartonSubGridJson(string CartonNo, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetCartonSubGridJson(CartonNo, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult SaveCartonNo(string queryJson, string STNO, string WorkPoint)
|
|
{
|
|
queryJson = queryJson.Substring(1, queryJson.Length - 2);
|
|
string msg = App.CheckSTNO_CartonNo(queryJson, STNO, WorkPoint);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("添加成功!");
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteInfo(string keyValue,string WorkPoint)
|
|
{
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string msg = App.DeleteInfo(keyValue, WorkPoint);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ActionResult DeleteSTNO(string keyValue, string DeleteFlag, string WorkPoint, string EATTRIBUTE1)
|
|
{
|
|
if (DeleteFlag == "1")
|
|
{
|
|
string msg = App.DeleteSTNO(keyValue, WorkPoint, EATTRIBUTE1);
|
|
}
|
|
if (DeleteFlag == "2")
|
|
{
|
|
string msg = App.UpdateSTNO(keyValue, EATTRIBUTE1);
|
|
}
|
|
return Success("操作成功!");
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult UpDateBySTNO(string keyValue, string Status, string WorkPoint)
|
|
{
|
|
int result = App.UpDateBySTNO(keyValue, Status, WorkPoint);
|
|
if (result > 0)
|
|
{
|
|
return Success("操作成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("操作失败!");
|
|
}
|
|
}
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
|
|
/// </summary>
|
|
protected string strPrintData;
|
|
/// <summary>
|
|
/// 标识是否安装了控件
|
|
/// </summary>
|
|
protected bool bIsInstallPrintControl = true;
|
|
/// <summary>
|
|
/// 打印控件的Cookie值
|
|
/// </summary>
|
|
protected string strPrintControlCookie = "";
|
|
|
|
|
|
/// <summary>
|
|
/// 获取Url中去掉文件名的路径
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetUrlPath()
|
|
{
|
|
string strUrl = Request.Url.ToString();
|
|
int iEnd = strUrl.LastIndexOf("/");
|
|
strUrl = strUrl.Substring(0, iEnd + 1);
|
|
|
|
return strUrl;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置控件调用的Cookie值,判断是否安装了打印控件
|
|
/// </summary>
|
|
/// <param name="pJson"></param>
|
|
private void SetCookieAndURL(PrintJson pJson)
|
|
{
|
|
bIsInstallPrintControl = false;
|
|
strPrintControlCookie = "";
|
|
HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"];
|
|
if (pCookieInstall != null)
|
|
{ //Cookie存在
|
|
strPrintControlCookie = pCookieInstall.Value.ToString();
|
|
|
|
//以Cookie值查找在数据表中是否存在
|
|
string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
|
|
using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
|
|
{
|
|
if (drCookie.Read())
|
|
{ //标识为已经安装
|
|
bIsInstallPrintControl = true;
|
|
}
|
|
drCookie.Close();
|
|
}
|
|
//更新Cookie的保存时间
|
|
pCookieInstall.Expires = DateTime.Now.AddYears(10);
|
|
Response.SetCookie(pCookieInstall);
|
|
}
|
|
else
|
|
{//Cookie不存在,则新建Cookie
|
|
strPrintControlCookie = System.Guid.NewGuid().ToString();
|
|
pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
|
|
pCookieInstall.Expires = DateTime.Now.AddYears(10);
|
|
Response.Cookies.Add(pCookieInstall);
|
|
}
|
|
|
|
string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
|
|
|
|
pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult PrintItemLot(string keyValue, string WorkPoint)
|
|
{
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string strPrintFileName = Server.MapPath("/ReportFile/") + "ASN.fr3";
|
|
PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
|
|
pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
|
|
pJson.MasterOptions(1, "ASNCode", false); //主从关系
|
|
SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string strSql = @"SELECT z.OASNCode as ASNCode,z.VenCode,x.VenName,CONVERT(varchar(100),z.Mtime, 23) CREATEDATE,GETDATE() AS printdate,z.EATTRIBUTE1
|
|
,VenPerson,VenHand,CONVERT(varchar(20), GETDATE(), 23) as DateNo FROM dbo.ICSOASN z
|
|
left join ICSVendor x on z.VenCode=x.VenCode and z.WorkPoint=x.WorkPoint
|
|
WHERE z.OASNCode IN (" + keyValue.TrimEnd(',') + ") and z.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
|
|
DataTable dtInInfo = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
strSql = @"SELECT Row_Number() OVER (partition by a.OASNCode ORDER BY a.MTIME desc) AS rowno,
|
|
c.OASNCode AS ASNCode,c.InvCode,c.PLANQTY AS Quantity,c.LotnoQTY,c.CartonNOQTY,b.InvName,b.InvStd,b.INVDESC,b.InvUnit,ee.BatchCode,ee.ProjectCode,c.TransCode,ff.CreatePerson,ff.EATTRIBUTE3 as DXEATTRIBUTE3,a.MTIME,ISNULL(ff.Quantity,0)AS POQuantity,ISNULL(ff.Quantity,0)-ISNULL(gg.Quantity,0)AS infoQuantity,ff.EATTRIBUTE2 as BBEATTRIBUTE3
|
|
FROM
|
|
|
|
(select aa.OASNCode,b.InvCode,aa.WorkPoint,sum(aa.Quantity) PLANQTY,count(aa.LotNo) LotnoQTY,count(bb.ContainerID) CartonNOQTY,b.ExtensionID,cc.TransCode,cc.TransSequence
|
|
from ICSOASNDetail aa
|
|
left join ICSInventoryLot b on aa.LotNo=b.LotNo and aa.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventoryLotDetail cc ON b.LotNo=cc.LotNo AND b.WorkPoint=cc.WorkPoint
|
|
left join ICSContainerLot bb on b.LotNo=bb.lotno
|
|
group by aa.OASNCode,b.InvCode,aa.WorkPoint,b.ExtensionID,cc.TransCode,cc.TransSequence,cc.WorkPoint ) c
|
|
|
|
left join ICSOASN a on c.OASNCode=a.OASNCode and c.WorkPoint=a.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory b ON c.InvCode=b.InvCode AND b.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension ee ON c.ExtensionID=ee.ID AND c.WorkPoint=ee.WorkPoint
|
|
LEFT JOIN ICSOutsourcingOrder ff on c.TransCode=ff.OOCode and c.TransSequence=ff.Sequence and c.WorkPoint=ff.WorkPoint
|
|
LEFT JOIN (SELECT TransCode,TransSequence,sum(Quantity) Quantity,WorkPoint FROM dbo.ICSWareHouseLotInfoLog WHERE BusinessCode='1' GROUP BY TransCode,TransSequence,WorkPoint) gg ON ff.OOCode=gg.TransCode AND ff.Sequence=gg.TransSequence AND ff.WorkPoint=gg.WorkPoint
|
|
WHERE c.OASNCode IN (" + keyValue.TrimEnd(',') + ") and c.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
|
|
DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
|
|
string strPrintTempFile = pJson.ShowReport(dtInInfo, dtInMaterial); //产生JSON文件内容
|
|
|
|
//把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
|
|
string strServerURL = GetUrlPath() + "PrintTemp/";
|
|
string strData = strServerURL + strPrintTempFile;
|
|
strPrintData = PrintFunction.EnBase64(strData);
|
|
var JsonData = new
|
|
{
|
|
strPrintData_1 = strPrintData,
|
|
bIsInstallPrintControl_1 = bIsInstallPrintControl,
|
|
strPrintControlCookie_1 = strPrintControlCookie
|
|
};
|
|
// string sql = @"UPDATE dbo.OASNCode
|
|
// SET ADDITION1=ISNULL(ADDITION1,0)+1,
|
|
// ADDITION2=CONVERT(varchar(100), GETDATE(), 21)
|
|
// WHERE STNO in (" + keyValue.TrimEnd(',') + ") and WorkPoint=" + WorkPoint.TrimEnd(',') + "";
|
|
// SqlHelper.ExecuteNonQuery(sql);
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
#region 根据单号打印条码信息
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult PrintItemASNLotByYL(string keyValue)
|
|
{
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string strPrintFileName = Server.MapPath("/ReportFile/") + "lot.fr3";
|
|
PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
|
|
pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
|
|
pJson.MasterOptions(1, "ASNCode", false); //主从关系
|
|
SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string strSql = @"SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
|
|
c.InvStd,
|
|
c.ClassName,c.InvDesc,
|
|
b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
|
|
a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
|
|
,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
|
|
,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.OASNCode as asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
|
|
,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4,c1.LocationCode,c.EATTRIBUTE11,c.EATTRIBUTE12,c.EATTRIBUTE13,c.EATTRIBUTE14,c.EATTRIBUTE15
|
|
,c.EATTRIBUTE16,c.EATTRIBUTE17,c.EATTRIBUTE18,
|
|
CASE WHEN c.EATTRIBUTE19='1'THEN'食品级物料'WHEN c.EATTRIBUTE19='0'THEN'非食品级物料' END EATTRIBUTE19,ISNULL(a.EATTRIBUTE6,'') as isSJBGInvCode,a.EATTRIBUTE8, CASE WHEN c.InvIQC='0' THEN '免'ELSE '' END AS InvIQC
|
|
FROM dbo.ICSInventoryLot a
|
|
left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder b ON b.POCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
|
|
left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint AND d.BatchEnable=1
|
|
left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
|
|
left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
|
|
LEFT JOIN ICSOASNDetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
|
|
LEFT JOIN (
|
|
SELECT
|
|
InvCode,
|
|
WarehouseCode,
|
|
LocationCode,
|
|
MTIME,
|
|
WorkPoint,
|
|
new_index
|
|
FROM
|
|
(
|
|
SELECT
|
|
b.InvCode,
|
|
b.WarehouseCode,
|
|
b.LocationCode,
|
|
b.MTIME,
|
|
b.WorkPoint,
|
|
ROW_NUMBER() OVER (
|
|
PARTITION BY b.InvCode
|
|
ORDER BY b.MTIME ASC
|
|
) AS new_index
|
|
FROM
|
|
ICSWareHouseLotInfo b WITH (NOLOCK)
|
|
WHERE
|
|
b.quantity > 0
|
|
) AS subquery
|
|
WHERE
|
|
new_index = 1
|
|
) c1 ON c1.invcode = a.invcode
|
|
AND c1.WorkPoint = a.WorkPoint
|
|
WHERE i.OASNCode IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dtInInfo = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
|
|
string strPrintTempFile = pJson.ShowReport(dtInInfo); //产生JSON文件内容
|
|
|
|
//把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
|
|
string strServerURL = GetUrlPath() + "PrintTemp/";
|
|
string strData = strServerURL + strPrintTempFile;
|
|
strPrintData = PrintFunction.EnBase64(strData);
|
|
var JsonData = new
|
|
{
|
|
strPrintData_1 = strPrintData,
|
|
bIsInstallPrintControl_1 = bIsInstallPrintControl,
|
|
strPrintControlCookie_1 = strPrintControlCookie
|
|
};
|
|
// string sql = @"UPDATE dbo.ICSASN
|
|
// SET ADDITION1=ISNULL(ADDITION1,0)+1,
|
|
// ADDITION2=CONVERT(varchar(100), GETDATE(), 21)
|
|
// WHERE STNO in (" + keyValue.TrimEnd(',') + ") and WorkPoint=" + WorkPoint.TrimEnd(',') + "";
|
|
// SqlHelper.ExecuteNonQuery(sql);
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 写日志(用于跟踪)
|
|
/// </summary>
|
|
private void WriteLog(string strMessage)
|
|
{
|
|
string strLogFile = Server.MapPath("./Cookie_Log.txt");
|
|
StreamWriter swLogFile = null;
|
|
try
|
|
{
|
|
if (!System.IO.File.Exists(strLogFile))
|
|
{
|
|
swLogFile = System.IO.File.CreateText(strLogFile);
|
|
}
|
|
else
|
|
{
|
|
swLogFile = System.IO.File.AppendText(strLogFile);
|
|
}
|
|
swLogFile.WriteLine(strMessage);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
if (swLogFile != null)
|
|
swLogFile.Close();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
/// </summary>
|
|
/// <param name="strCookie"></param>
|
|
private void UpdateCheckInstall(string strCookie)
|
|
{
|
|
bool bIsExist = false;
|
|
//判断记录是否存在
|
|
GetLastAccessTime(strCookie, ref bIsExist);
|
|
|
|
string strSql = "";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
|
|
if (bIsExist)
|
|
{ //存在则更新最后访问的时间
|
|
strSql = @"Update sys_SRM_CheckInstall
|
|
Set LastAccessTime = getDate()
|
|
Where Cookie = @Cookie";
|
|
}
|
|
else
|
|
{ //不存在则新建一条记录
|
|
strSql = @"Insert into sys_SRM_CheckInstall(Cookie, LastAccessTime)
|
|
Values( @Cookie, getDate() )";
|
|
}
|
|
DbHelper.ExecuteNonQuery(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie);
|
|
}
|
|
|
|
public DateTime ToDateTime(object SrcValue)
|
|
{
|
|
if (Convert.IsDBNull(SrcValue) == true)
|
|
return DateTime.MinValue;
|
|
else
|
|
{
|
|
try
|
|
{
|
|
return Convert.ToDateTime(SrcValue);
|
|
}
|
|
catch
|
|
{
|
|
return DateTime.MinValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取此Cookie的最后访问时间
|
|
/// </summary>
|
|
/// <param name="strCookie"></param>
|
|
/// <returns></returns>
|
|
private DateTime GetLastAccessTime(string strCookie, ref bool bIsExist)
|
|
{
|
|
DateTime dtLastAccessTime = DateTime.MinValue;
|
|
bIsExist = false;
|
|
|
|
string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
|
|
using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
|
|
{
|
|
if (drCookie.Read())
|
|
{
|
|
dtLastAccessTime = ToDateTime(drCookie["LastAccessTime"]);
|
|
bIsExist = true;
|
|
}
|
|
drCookie.Close();
|
|
}
|
|
|
|
return dtLastAccessTime;
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult IsCheckInstall(string checkInstall)
|
|
{
|
|
string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
|
|
if (Request.QueryString["cookie"] != null)
|
|
{ //有控件上传的Cookie值
|
|
string strCookie = Request.QueryString["cookie"].ToString();
|
|
|
|
//判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
UpdateCheckInstall(strCookie);
|
|
|
|
strValue = strValue + "上传的cookie:" + strCookie;
|
|
}
|
|
else if (checkInstall != null)
|
|
{//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
|
|
string strCookie = checkInstall;
|
|
//读取最后访问的时间
|
|
string strResult = "PrintControlInstall";
|
|
bool bIsExist = false;
|
|
DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
|
|
if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
|
|
{
|
|
strResult = "NOT";
|
|
}
|
|
Response.Clear();
|
|
Response.Write(strResult);
|
|
|
|
strValue = strValue + "检测安装的值:" + strCookie;
|
|
}
|
|
|
|
WriteLog(strValue);
|
|
return null;
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult IsCheckInstall()
|
|
{
|
|
string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
|
|
if (Request.QueryString["cookie"] != null)
|
|
{ //有控件上传的Cookie值
|
|
string strCookie = Request.QueryString["cookie"].ToString();
|
|
|
|
//判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
UpdateCheckInstall(strCookie);
|
|
|
|
strValue = strValue + "上传的cookie:" + strCookie;
|
|
}
|
|
else if (Request.QueryString["checkInstall"] != null)
|
|
{//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
|
|
string strCookie = Request.QueryString["checkInstall"];
|
|
//读取最后访问的时间
|
|
string strResult = "PrintControlInstall";
|
|
bool bIsExist = false;
|
|
DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
|
|
if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
|
|
{
|
|
strResult = "NOT";
|
|
}
|
|
Response.Clear();
|
|
Response.Write(strResult);
|
|
|
|
strValue = strValue + "检测安装的值:" + strCookie;
|
|
}
|
|
|
|
WriteLog(strValue);
|
|
return null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetWWICSASNCode(string RoleEnCode, string WorkPoint)
|
|
{
|
|
string ListData = App.GetWWICSASNCode(RoleEnCode, WorkPoint);
|
|
var data = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(data.ToJson());
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult SaveWWICSASNAndDetail(string ICSASN, string WorkPoint)
|
|
{
|
|
|
|
string msg = App.SaveWWICSASNAndDetail(ICSASN, WorkPoint);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("添加成功!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult UpdateWWICSASNAndDetail(string ICSASN)
|
|
{
|
|
|
|
string msg = App.UpdateWWICSASNAndDetail(ICSASN);
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
return Error(msg);
|
|
}
|
|
else
|
|
{
|
|
return Success("修改成功!");
|
|
}
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetLotByContainer(string Value, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetLotByContainer(Value, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
}
|
|
}
|