using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Log;
using QMAPP.FJC.Entity;
using QMAPP.Entity;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Basic;
using QMFrameWork.Data;
using QMAPP.BLL;
namespace QMAPP.FJC.BLL.Basic
{
public class WorkCenterBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(WorkCenter model)
{
DataResult result = new DataResult();
try
{
result.Result = new WorkCenterDAL().Get(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工作中心逻辑层-获取信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(WorkCenter condition, DataPage page)
{
DataResult result = new DataResult();
try
{
DataPage dataPage = new WorkCenterDAL().GetList(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工作中心逻辑层-获取列表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 信息是否重复
///
/// 判断工作中心编号是否存在
///
///
/// true:已存在;fasel:不存在。
public bool ExistsWorkCenter(WorkCenter model)
{
try
{
return new WorkCenterDAL().ExistsWorkCenter(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(WorkCenter model)
{
DataResult result = new DataResult();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLAGDEL = "0";
model.CREATEUSR = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSR = model.CREATEUSR;
model.UPDATEDATE = model.CREATEDATE;
WorkCenterDAL cmdDAL = new WorkCenterDAL();
try
{
if (ExistsWorkCenter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new WorkCenterDAL().Insert(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工作中心逻辑层-插入信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(WorkCenter model)
{
DataResult result = new DataResult();
model.UPDATEUSR = this.LoginUser.UserID;
try
{
if (ExistsWorkCenter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
//if (model.Details != null)
//{
// foreach (Equipment detail in model.Details)
// {
// detail.PID = Guid.NewGuid().ToString();
// detail.WORKCENTER_PID = model.PID;
// }
//}
result.Result = new WorkCenterDAL().Update(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工作中心逻辑层-更新信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 删除
///
/// 删除信息
///
///
/// 删除个数
public DataResult Delete(string strs)
{
int count = 0;
string[] list = strs.Split(":".ToCharArray());
DataResult result = new DataResult();
try
{
foreach (string str in list)
{
count += this.DeleteWorkCenter(new WorkCenter { PID = str });
}
if (count == 0)
{
result.IsSuccess = false;
return result;
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteWorkCenter(WorkCenter model)
{
int count = 0;
try
{
count = new WorkCenterDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
//#region 获取工作中心与设备关联信息
/////
///// 获取工作中心与设备关联信息
/////
///// 条件
///// 用户信息
//public List GetWcWithEquipmentList(WcWithEquipment equipment)
//{
// try
// {
// return new WorkCenterDAL().GetWcWithEquipmentList(equipment);
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
//#endregion
//#region 保存配置的数据权限
/////
///// 保存配置的数据权限
/////
///// 信息
///// 插入行数
//public int DataPowerSave(WorkCenter workcenter)
//{
// WorkCenterDAL wcDAL = new WorkCenterDAL();
// try
// {
// List wmList = wcDAL.GetWcWithEquipmentList(new WcWithEquipment { WORKCENTERPID = workcenter.PID });
// using (IDataSession session = AppDataFactory.CreateMainSession())
// {
// session.OpenTs();
// session.Delete(wmList);
// if (workcenter.EQUIPMENT != null)
// {
// session.Insert(workcenter.EQUIPMENT);
// }
// session.CommitTs();
// }
// }
// catch (Exception ex)
// {
// ;
// throw ex;
// }
// return 0;
//}
//#endregion
#region 获取工作中心列表(下拉列表使用)
///
///
///
///
///
public DataResult> GetWorkCenterList(WorkCenter condition)
{
DataResult> result = new DataResult>();
try
{
result.Result = new WorkCenterDAL().GetWorkCenterList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工作中心信息逻辑层-获取列表(绑定下拉列表使用)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
}
}