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.
234 lines
7.2 KiB
234 lines
7.2 KiB
2 months ago
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.EFModel;
|
||
|
using MESClassLibrary.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace MESClassLibrary.BLL.Keep
|
||
|
{
|
||
|
public class KeepVersionBLL
|
||
|
{
|
||
|
BasicBLL<tb_KeepVersion> db = new BasicBLL<tb_KeepVersion>();
|
||
|
|
||
|
/// <summary>
|
||
|
/// 新增信息
|
||
|
/// </summary>
|
||
|
/// <param name="md"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool AddInfo(tb_KeepVersion md, string s)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var list = db.SearchInfoByKey("DeviceID", md.DeviceID).Where(p => p.Version == md.Version).ToList();//判断是否有重复数据
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
if (db.AddInfo(md))
|
||
|
{
|
||
|
BasicBLL<tb_KeepItemsVersion> KeepItemsVersion_db = new BasicBLL<tb_KeepItemsVersion>();
|
||
|
string[] arry = s.Split(',');
|
||
|
for (int i = 0; i < arry.Length; i++)
|
||
|
{
|
||
|
tb_KeepItemsVersion m = new tb_KeepItemsVersion();
|
||
|
m.ID = Guid.NewGuid().ToString();
|
||
|
m.VersionID = md.ID;
|
||
|
m.KeepItemsID = arry[i];
|
||
|
m.CreateUserID = md.CreateUserID;
|
||
|
m.CreateTime = md.CreateTime;
|
||
|
m.IsUseing = 1;
|
||
|
KeepItemsVersion_db.AddInfo(m);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 修改信息
|
||
|
/// </summary>
|
||
|
/// <param name="md"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool UpdateInfo(tb_KeepVersion md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name="md"></param>
|
||
|
/// <param name="flag"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool DeleteInfo(tb_KeepVersion md)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.DelInfo(md);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查询全部信息分页
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public string SearchInfoAll(string page, string pagesize)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string jsonStr = "[]";
|
||
|
int total = 0;//总行数
|
||
|
|
||
|
List<tb_KeepVersion> list = db.SearchAllInfo();
|
||
|
|
||
|
total = list.Count;
|
||
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
||
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
||
|
|
||
|
JsonDataModel<tb_KeepVersion> md = new JsonDataModel<tb_KeepVersion>();
|
||
|
md.total = total.ToString();
|
||
|
md.rows = list;
|
||
|
return JSONTools.ScriptSerialize(md);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 根据ID查询信息
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
public tb_KeepVersion SearchInfoByID(string id)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return db.SearchInfoByID(id);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public string SearchInfo(string page, string pagesize, string deviceID)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
|
||
|
BasicBLL<tb_Station> station_db = new BasicBLL<tb_Station>();
|
||
|
BasicBLL<tb_Device> device_db = new BasicBLL<tb_Device>();
|
||
|
|
||
|
var station_list = station_db.SearchAllInfo().ToList();
|
||
|
var device_list = device_db.SearchAllInfo().ToList();
|
||
|
|
||
|
|
||
|
string jsonStr = "[]";
|
||
|
int total = 0;//总行数
|
||
|
List<tb_KeepVersion> list = null;
|
||
|
|
||
|
list = db.SearchAllInfo().ToList();
|
||
|
|
||
|
|
||
|
if (deviceID != "")
|
||
|
{
|
||
|
list = list.Where(p => p.DeviceID.Equals(deviceID)).ToList();
|
||
|
}
|
||
|
|
||
|
List<KeepVersionModel> KeepVersionList = new List<KeepVersionModel>();
|
||
|
if (list.Count > 0)
|
||
|
{
|
||
|
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
|
||
|
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
|
||
|
|
||
|
total = list.Count;
|
||
|
|
||
|
#region 联查
|
||
|
|
||
|
|
||
|
foreach (var item in list)
|
||
|
{
|
||
|
KeepVersionModel dm = Tool.Mapper<KeepVersionModel, tb_KeepVersion>(item);
|
||
|
var info = device_list.FirstOrDefault(p => p.DeviceID.Equals(item.DeviceID));
|
||
|
if (info != null)
|
||
|
{
|
||
|
dm.DeviceID = info.DeviceID;
|
||
|
dm.DeviceName = info.DeviceNo + "----" + info.DeviceName;
|
||
|
}
|
||
|
if (item.IsUseing == 1)
|
||
|
{
|
||
|
dm.IsUseingName = "启用";
|
||
|
}
|
||
|
KeepVersionList.Add(dm);
|
||
|
}
|
||
|
#endregion
|
||
|
JsonDataModel<KeepVersionModel> md = new JsonDataModel<KeepVersionModel>();
|
||
|
md.total = total.ToString();
|
||
|
md.rows = KeepVersionList;
|
||
|
jsonStr = JSONTools.ScriptSerialize(md);
|
||
|
}
|
||
|
return jsonStr;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public string GetComboboxData(string deviceID)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string jsonStr = "[]";
|
||
|
var list = db.SearchInfoByKey("IsUseing", 1).ToList();//判断是否有重复数据
|
||
|
if (deviceID != null && deviceID != "")
|
||
|
{
|
||
|
list = list.Where(p => p.DeviceID.Equals(deviceID)).OrderByDescending(p=>p.Version).ToList();
|
||
|
}
|
||
|
jsonStr = JSONTools.ScriptSerialize(list);
|
||
|
return jsonStr;
|
||
|
}
|
||
|
catch (Exception)
|
||
|
{
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|