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.
405 lines
13 KiB
405 lines
13 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using QMAPP.BLL;
|
|
using QMAPP.Entity;
|
|
using QMAPP.MD.BLL.Dict;
|
|
using QMAPP.MD.DAL;
|
|
using QMAPP.MD.Entity;
|
|
using QMFrameWork.Data;
|
|
|
|
namespace QMAPP.MD.BLL
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:
|
|
/// 作 用:班组成员
|
|
/// 作 者:周晓东
|
|
/// 编写日期:2017年11月21日
|
|
///</summary>
|
|
public class TeamMemberBLL : BaseBLL
|
|
{
|
|
|
|
|
|
#region 获取信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public DataResult<TeamMemberEntity> Get(TeamMemberEntity model)
|
|
{
|
|
DataResult<TeamMemberEntity> result = new DataResult<TeamMemberEntity>();
|
|
try
|
|
{
|
|
result.Result = new TeamMemberDAL().Get(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
public List<TeamMemberEntity> GetAllTeamMember(TeamMemberEntity condition)
|
|
{
|
|
return new TeamMemberDAL().GetAllTeamMember(condition);
|
|
}
|
|
#endregion
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
//public DataResult<DataPage> GetList(TeamMemberEntity condition, DataPage page)
|
|
//{
|
|
// DataResult<DataPage> result = new DataResult<DataPage>();
|
|
// try
|
|
// {
|
|
// //获取班组信息列表
|
|
// DataPage dataPage = new TeamMemberDAL().GetList(condition, page);
|
|
// #region 转换
|
|
// List<TeamMemberEntity> InfoList = dataPage.Result as List<TeamMemberEntity>;
|
|
// var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
// foreach (TeamMemberEntity m in InfoList)
|
|
// {
|
|
// //呼叫类型
|
|
// var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == m.TEAMTYPE.Trim());
|
|
// if (configDetail != null)
|
|
// m.TEAMTYPE_TXT = configDetail.DetailTypeName;
|
|
// //m.TEAMTYPE_TXT = dictProcessTypeBll.GetDictValue(m.TEAMTYPE);
|
|
|
|
// }
|
|
|
|
// #endregion
|
|
// result.Result = dataPage;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// result.IsSuccess = false;
|
|
// result.Msg = Resource.SystemException;
|
|
// throw ex;
|
|
// }
|
|
// result.IsSuccess = true;
|
|
// return result;
|
|
//}
|
|
public DataPage GetList(TeamMemberEntity condition, DataPage page)
|
|
{
|
|
//DataResult<DataPage> result = new DataResult<DataPage>();
|
|
try
|
|
{
|
|
//获取班组信息列表
|
|
DataPage dataPage = new TeamMemberDAL().GetList(condition, page);
|
|
#region 转换
|
|
List<TeamMemberEntity> InfoList = dataPage.Result as List<TeamMemberEntity>;
|
|
var configDetailList = new ConfigDetailBLL().GetAllList("CALL_TYPE");
|
|
foreach (TeamMemberEntity m in InfoList)
|
|
{
|
|
//呼叫类型
|
|
var configDetail = configDetailList.FirstOrDefault(x => x.DetailTypeCode == m.TEAMTYPE.Trim());
|
|
if (configDetail != null)
|
|
m.TEAMTYPE_TXT = configDetail.DetailTypeName;
|
|
//m.TEAMTYPE_TXT = dictProcessTypeBll.GetDictValue(m.TEAMTYPE);
|
|
|
|
}
|
|
|
|
#endregion
|
|
return dataPage;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
throw ex;
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 信息是否重复
|
|
/// <summary>
|
|
/// 判断名称是否存在
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
public bool ExistsTeamMember(TeamMemberEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new TeamMemberDAL().ExistsTeamMember(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
//public int Insert(TeamMemberEntity model)
|
|
//{
|
|
// try
|
|
// {
|
|
// //基本信息
|
|
// model.PID = Guid.NewGuid().ToString();
|
|
// model.CREATEUSER = this.LoginUser.UserID;
|
|
// model.CREATEDATE = DateTime.Now;
|
|
// model.UPDATEUSER = model.CREATEUSER;
|
|
// model.UPDATEDATE = model.CREATEDATE;
|
|
// TeamMemberDAL cmdDAL = new TeamMemberDAL();
|
|
// if (ExistsTeamMember(model) == true)
|
|
// return -1;
|
|
// return new TeamMemberDAL().Insert(model);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
//}
|
|
public DataResult<int> Insert(TeamMemberEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
model.PID = Guid.NewGuid().ToString();
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
try
|
|
{
|
|
//if (ExistsTeam(model) == true)
|
|
//{
|
|
// result.IsSuccess = false;
|
|
// result.Msg = Resource.TeamCodeIsHave;
|
|
// return result;
|
|
//}
|
|
result.Result = new TeamMemberDAL().Insert(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 更新信息
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新行数</returns>
|
|
//public int Update(TeamMemberEntity model)
|
|
//{
|
|
// try
|
|
// {
|
|
// //if (ExistsTeamMember(Model) == true)
|
|
// //return -1;
|
|
// //基本信息
|
|
// model.UPDATEUSER = this.LoginUser.UserID;
|
|
// return new TeamMemberDAL().Update(model);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
//}
|
|
public DataResult<int> Update(TeamMemberEntity model)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
//基本信息
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
try
|
|
{
|
|
//if (ExistsTeam(model) == true)
|
|
//{
|
|
// result.IsSuccess = false;
|
|
// result.Msg = Resource.TeamCodeIsHave;
|
|
// return result;
|
|
//}
|
|
result.Result = new TeamMemberDAL().Update(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>删除个数</returns>
|
|
//public int Delete(string strs)
|
|
//{
|
|
// int count = 0;
|
|
// string[] list = strs.Split(":".ToCharArray());
|
|
// try
|
|
// {
|
|
// foreach (string str in list)
|
|
// {
|
|
// count += this.DeleteTeamMember(new TeamMemberEntity { PID = str });
|
|
// }
|
|
// return count;
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw ex;
|
|
// }
|
|
//}
|
|
public DataResult<int> Delete(string strs)
|
|
{
|
|
DataResult<int> result = new DataResult<int>();
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
try
|
|
{
|
|
foreach (string str in list)
|
|
{
|
|
result.Result += this.DeleteTeamMember(new TeamMemberEntity { PID = str });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Msg = Resource.SystemException;
|
|
throw ex;
|
|
}
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>删除个数</returns>
|
|
public int DeleteTeamMember(TeamMemberEntity model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
count = new TeamMemberDAL().Delete(model);
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 导出数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(TeamMemberEntity model)
|
|
{
|
|
try
|
|
{
|
|
return new TeamMemberDAL().GetExportData(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 导入数据
|
|
public DataResult<ImportMessage> GetImportData(List<TeamMemberEntity> list)
|
|
{
|
|
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
|
TeamMemberDAL cmDal = new TeamMemberDAL();
|
|
List<TeamMemberEntity> List = new List<TeamMemberEntity>();
|
|
int index = 0;
|
|
try
|
|
{
|
|
result.Result = new ImportMessage();
|
|
result.Result.Errors = new List<RowError>();
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//状态判断
|
|
foreach (TeamMemberEntity ma in list)
|
|
{
|
|
index++;
|
|
if (string.IsNullOrEmpty(ma.InfoError) == false)
|
|
{
|
|
ma.PID = null;
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
//修改改时根据主键等信息获取详细内容信息
|
|
TeamMemberEntity oldInfo = cmDal.Get(ma);
|
|
if (oldInfo != null)
|
|
{
|
|
//更新
|
|
ma.PID = oldInfo.PID;
|
|
ma.CREATEUSER = oldInfo.CREATEUSER;
|
|
ma.CREATEDATE = oldInfo.CREATEDATE;
|
|
ma.UPDATEUSER = this.LoginUser.UserID;
|
|
ma.UPDATEDATE = oldInfo.UPDATEDATE;
|
|
ma.IsNewInfo = false;
|
|
result.Result.updateNum += 1;
|
|
}
|
|
else
|
|
{
|
|
//新增
|
|
oldInfo = new TeamMemberEntity();
|
|
ma.PID = Guid.NewGuid().ToString();
|
|
ma.CREATEUSER = this.LoginUser.UserID;
|
|
ma.CREATEDATE = DateTime.Now;
|
|
ma.UPDATEUSER = ma.CREATEUSER;
|
|
ma.UPDATEDATE = ma.CREATEDATE;
|
|
ma.IsNewInfo = true;
|
|
result.Result.insertNum += 1;
|
|
}
|
|
List.Add(ma);
|
|
}
|
|
}
|
|
//导入
|
|
cmDal.GetImportData(List);
|
|
result.Msg = "导入成功";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Ex = ex;
|
|
return result;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|