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.
321 lines
11 KiB
321 lines
11 KiB
2 months ago
|
using MESClassLibrary.BLL;
|
||
|
using MESClassLibrary.BLL.Keep;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESWebSite.CommonClass;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
|
||
|
namespace MESWebSite.HttpHandlers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// KeepVersionHandler 的摘要说明
|
||
|
/// </summary>
|
||
|
public class KeepVersionHandler : IHttpHandler
|
||
|
{
|
||
|
|
||
|
HttpRequest Request = null;
|
||
|
HttpResponse Response = null;
|
||
|
|
||
|
public void ProcessRequest(HttpContext context)
|
||
|
{
|
||
|
context.Response.ContentType = "text/plain";
|
||
|
Request = context.Request;
|
||
|
Response = context.Response;
|
||
|
|
||
|
string method = Request.Params["method"];
|
||
|
switch (method)
|
||
|
{
|
||
|
|
||
|
case "QueryList":
|
||
|
QueryList();
|
||
|
break;
|
||
|
case "SaveInfo":
|
||
|
SaveInfo();
|
||
|
break;
|
||
|
case "DelInfo":
|
||
|
DelInfo();
|
||
|
break;
|
||
|
case "QueryCheckList":
|
||
|
QueryCheckList();
|
||
|
break;
|
||
|
case "OpenInfo":
|
||
|
OpenInfo();
|
||
|
break;
|
||
|
case "CloseInfo":
|
||
|
CloseInfo();
|
||
|
break;
|
||
|
case "QueryForCombobox":
|
||
|
QueryForCombobox();
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public bool IsReusable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void QueryList()
|
||
|
{
|
||
|
string page = Request.Params["page"];
|
||
|
string pagesize = Request.Params["rows"];
|
||
|
string DeviceID = Request.Params["DeviceID"];//查询条件
|
||
|
if (string.IsNullOrEmpty(page))
|
||
|
{
|
||
|
page = "0";
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(pagesize))
|
||
|
{
|
||
|
pagesize = "15";
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(DeviceID))
|
||
|
{
|
||
|
DeviceID = "";
|
||
|
}
|
||
|
|
||
|
KeepVersionBLL bll = new KeepVersionBLL();
|
||
|
Response.Write(bll.SearchInfo(page, pagesize, DeviceID));
|
||
|
Response.End();
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
public class parmSave
|
||
|
{
|
||
|
public string ID { get; set; }
|
||
|
public string KeepItemsVersionID { get; set; }
|
||
|
public string DeviceID { get; set; }
|
||
|
public string KeepItemsID { get; set; }
|
||
|
public string Version { get; set; }
|
||
|
public string Description { get; set; }
|
||
|
public string UserID { get; set; }
|
||
|
public string arrid { get; set; }
|
||
|
}
|
||
|
|
||
|
void SaveInfo()
|
||
|
{
|
||
|
string ID = Request.Params["ID"];
|
||
|
string KeepItemsID = Request.Params["KeepItemsID"];
|
||
|
string DeviceID = Request.Params["DeviceID"];
|
||
|
string Version = Request.Params["Version"];
|
||
|
string Description = Request.Params["Description"];
|
||
|
string UserID = Request.Params["UserID"];
|
||
|
|
||
|
KeepVersionBLL bll = new KeepVersionBLL();
|
||
|
tb_KeepVersion md = new tb_KeepVersion();
|
||
|
md.DeviceID = DeviceID;
|
||
|
md.Version = Version;
|
||
|
md.Description = Description;
|
||
|
|
||
|
if (ID == "")
|
||
|
{
|
||
|
md.ID = Guid.NewGuid().ToString();
|
||
|
md.CreateUserID = UserID;
|
||
|
md.CreateTime = DateTime.Now;
|
||
|
md.IsUseing = 0;
|
||
|
Response.Write(bll.AddInfo(md, KeepItemsID) == true ? "true" : "false");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
md.ID = ID;
|
||
|
parmSave model = new parmSave();
|
||
|
string sql_qrecord = @"select a.KeepItemsVersionID from tb_KeepRecord a left join tb_KeepItemsVersion b on a.KeepItemsVersionID= b.ID left
|
||
|
|
||
|
join tb_KeepVersion c on c.ID = b.VersionID where c.ID=@ID ";
|
||
|
|
||
|
|
||
|
string sql_insert1 = @"INSERT INTO [tb_KeepItemsVersion] ([ID],[VersionID],[KeepItemsID],[CreateUserID]) VALUES (@KeepItemsVersionID,@ID,@arrid,@UserID)";
|
||
|
|
||
|
string sql_update = @"
|
||
|
UPDATE tb_KeepVersion
|
||
|
SET [DeviceID] = @DeviceID,
|
||
|
[Version] = @Version,
|
||
|
[Description] = @Description,
|
||
|
[UpdateUserID] = @UserID,
|
||
|
[UpdateTime] = getdate()
|
||
|
WHERE [ID] = @ID";
|
||
|
|
||
|
string sqldel = @"delete from [tb_KeepItemsVersion] where VersionID=@ID";
|
||
|
|
||
|
|
||
|
model.ID = Request.Params["ID"];
|
||
|
model.DeviceID = Request.Params["DeviceID"];
|
||
|
model.Description = Request.Params["Description"];
|
||
|
model.KeepItemsID = Request.Params["KeepItemsID"];
|
||
|
model.Version = Request.Params["Version"];
|
||
|
model.UserID = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
||
|
try
|
||
|
{
|
||
|
DataSet ds = SQLHelper.QueryDataSet(CommandType.Text, sql_qrecord, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
if (ds.Tables[0].Rows.Count > 0)
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
BasicBLL<tb_KeepVersion> db = new BasicBLL<tb_KeepVersion>();
|
||
|
var list = db.SearchInfoByKey("DeviceID", md.DeviceID).Where(p => p.Version == md.Version && p.ID != md.ID).ToList();//判断是否有重复数据
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sql_update, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sqldel, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
if (!string.IsNullOrEmpty(model.KeepItemsID))
|
||
|
{
|
||
|
string[] idArr = model.KeepItemsID.Split(',');
|
||
|
foreach (string id in idArr)
|
||
|
{
|
||
|
if (id == "")
|
||
|
{
|
||
|
break;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
model.KeepItemsVersionID = Guid.NewGuid().ToString();
|
||
|
model.arrid = id;
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sql_insert1, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
Response.Write("true");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
}
|
||
|
Response.End();
|
||
|
}
|
||
|
Response.End();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
public class parmDel
|
||
|
{
|
||
|
public string ID { get; set; }
|
||
|
public string Version { get; set; }
|
||
|
|
||
|
}
|
||
|
void DelInfo()
|
||
|
{
|
||
|
parmDel model = new parmDel();
|
||
|
string sqldel1 = @"delete from [tb_KeepVersion] where ID=@ID";
|
||
|
string sqldel2 = @"delete from [tb_KeepItemsVersion] where VersionID=@ID";
|
||
|
model.ID = Request.Params["ID"].ToString();
|
||
|
try
|
||
|
{
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sqldel1, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sqldel2, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
|
||
|
Response.Write("true");
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
}
|
||
|
Response.End();
|
||
|
}
|
||
|
|
||
|
public class parmQuery
|
||
|
{
|
||
|
public string ID { get; set; }
|
||
|
|
||
|
}
|
||
|
void QueryCheckList()
|
||
|
{
|
||
|
parmQuery queryparms = new parmQuery();
|
||
|
queryparms.ID = Request.Params["Cid"].ToString();
|
||
|
string sql = @"select KeepItemsID as id from tb_KeepItemsVersion t1 left join tb_KeepVersion t2 on t1.versionID= t2.ID
|
||
|
where t2.ID= @ID";
|
||
|
|
||
|
DataSet ds = SQLHelper.QueryDataSet(CommandType.Text, sql, SQLHelper.ModelToParameterList(queryparms).ToArray());
|
||
|
string jsonStr = JSONHelper.DataTableToJSON(ds.Tables[0]);
|
||
|
Response.Write(jsonStr);
|
||
|
Response.End();
|
||
|
}
|
||
|
|
||
|
public class parmOpen
|
||
|
{
|
||
|
public string ID { get; set; }
|
||
|
public string UserID { get; set; }
|
||
|
}
|
||
|
void OpenInfo()
|
||
|
{
|
||
|
parmOpen model = new parmOpen();
|
||
|
string sqlopen = @"update tb_KeepVersion
|
||
|
SET IsUseing=1,
|
||
|
[UpdateUserID] = @UserID,
|
||
|
[UpdateTime] = getdate()
|
||
|
where ID=@ID";
|
||
|
model.ID = Request.Params["ID"] == null ? "0" : Request.Params["ID"].ToString();
|
||
|
model.UserID = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
||
|
try
|
||
|
{
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sqlopen, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
Response.Write("true");
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
}
|
||
|
Response.End();
|
||
|
|
||
|
}
|
||
|
public class parmClose
|
||
|
{
|
||
|
public string ID { get; set; }
|
||
|
public string UserID { get; set; }
|
||
|
}
|
||
|
void CloseInfo()
|
||
|
{
|
||
|
parmClose model = new parmClose();
|
||
|
string sqlclose = @"update tb_KeepVersion
|
||
|
SET IsUseing=0,
|
||
|
[UpdateUserID] = @UserID,
|
||
|
[UpdateTime] = getdate()
|
||
|
where ID=@ID";
|
||
|
model.ID = Request.Params["ID"].ToString();
|
||
|
model.UserID = HttpContext.Current.Request.Cookies["LoginUserInfo"]["UserID"].ToString();
|
||
|
try
|
||
|
{
|
||
|
SQLHelper.ExecuteNonQuery(CommandType.Text, sqlclose, SQLHelper.ModelToParameterList(model).ToArray());
|
||
|
Response.Write("true");
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
Response.Write("false");
|
||
|
}
|
||
|
Response.End();
|
||
|
|
||
|
}
|
||
|
|
||
|
void QueryForCombobox()
|
||
|
{
|
||
|
string d_id = Request.Params["d_id"];
|
||
|
KeepVersionBLL bll = new KeepVersionBLL();
|
||
|
Response.Write(bll.GetComboboxData(d_id));
|
||
|
Response.End();
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|