天津投入产出系统后端
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.
 
 
 
 
 
 

706 lines
20 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Common.Encrypt;
using QMFrameWork.Data;
using QMAPP.Entity.Sys;
using QMAPP.DAL.Sys;
using QMAPP.BLL.Dict;
using System.IO;
using System.Data;
using QMAPP.Entity;
namespace QMAPP.BLL.Sys
{
/// <summary>
/// 公告管理
/// 创建人:王丹丹
/// 创建时间:2015.03.09
/// </summary>
public class NoticeManageBll:BaseBLL
{
#region 获取公告信息
/// <summary>
/// 获取公告信息
/// </summary>
/// <param name="user">条件</param>
/// <returns>用户信息</returns>
public NoticeInfo Get(NoticeInfo notice)
{
try
{
return new NoticeManageDAL().Get(notice);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 根据通知ID,从通知浏览记录表中,获取发送目标
/// <summary>
/// 根据通知ID,从通知浏览记录表中,获取发送目标
/// </summary>
/// <param name="noticeID">条件</param>
/// <returns></returns>
public IList<NoticeBrowse> GetSendaimIdList(string noticeID)
{
try
{
return new NoticeManageDAL().GetSendaimIdList(noticeID);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取公告列表
/// <summary>
/// 获取公告列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(NoticeInfo condition, DataPage page)
{
try
{
condition.UserName = LoginUser.LoginUserID;
return new NoticeManageDAL().GetList(condition, page);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 公告信息是否重复
/// <summary>
/// 判断公告名称是否存在
/// </summary>
/// <param name="info">信息</param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsNotice(NoticeInfo notice)
{
try
{
return new NoticeManageDAL().ExistsNotice(notice);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存公告
#region 保存
/// <summary>
/// 保存公告
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>插入数</returns>
public DataResult Save(NoticeInfo notice)
{
DataResult result = new DataResult();
NoticeBrowse noticebrowse = new NoticeBrowse();
NoticeManageDAL nmDal = new NoticeManageDAL();
try
{
result.IsSuccess = true;
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
//发送目标ID
string strSendaim = notice.SENDAIM;
if (string.IsNullOrEmpty(notice.NOTICEID))
{
//通知基本信息
notice.NOTICEID = Guid.NewGuid().ToString();
notice.CREATEUSER = (notice.CREATEUSER == null ? LoginUser.UserID : notice.CREATEUSER);
notice.CREATEDATE = DateTime.Now;
notice.SENDTIME = DateTime.Now;
notice.UPDATEUSER = notice.CREATEUSER;
notice.UPDATEDATE = DateTime.Now;
notice.SENDAIM = "";
//插入通知
nmDal.Insert(notice);
//通知浏览基本信息
var list = strSendaim.Split(',');
for (int i = 0; i < list.Count(); i++)
{
noticebrowse.PID = Guid.NewGuid().ToString();
noticebrowse.NOTICEID = notice.NOTICEID;
noticebrowse.USERID = list[i];
noticebrowse.ISREAD = "0";
//插入通知浏览记录
nmDal.Insert(noticebrowse);
}
}
else
{
//修改公告
notice.UPDATEUSER = LoginUser.UserID;
notice.UPDATEDATE = DateTime.Now;
notice.SENDAIM = "";
//更新通知信息
nmDal.Update(notice);
//通知浏览基本信息
var list = strSendaim.Split(',');
for (int i = 0; i < list.Count(); i++)
{
noticebrowse.NOTICEID = notice.NOTICEID;
noticebrowse.USERID = list[i];
NoticeBrowse noticeBrowseModel = new NoticeBrowse();
//获取原通知下的浏览记录
noticeBrowseModel = nmDal.GetBrowseModel(noticebrowse);
if (noticeBrowseModel == null)
{
noticeBrowseModel = new NoticeBrowse();
noticeBrowseModel.NOTICEID = noticebrowse.NOTICEID;
noticeBrowseModel.USERID = noticebrowse.USERID;
noticeBrowseModel.PID = Guid.NewGuid().ToString();
noticeBrowseModel.ISREAD = "0";
nmDal.Insert(noticeBrowseModel);
}
else
{
noticeBrowseModel.ISREAD = "0";
//更新新通知浏览记录
nmDal.Update(noticeBrowseModel);
}
}
}
session.CommitTs();
}
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入公告
/// <summary>
/// 插入公告
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>插入数</returns>
public int Insert(NoticeInfo notice)
{
try
{
int count = 0;
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
count = new NoticeManageDAL().Insert(notice);
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新公告
/// <summary>
/// 更新公告
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>更新个数</returns>
public int Update(NoticeInfo notice)
{
try
{
return new NoticeManageDAL().Update(notice);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 删除公告
/// <summary>
/// 删除公告
/// </summary>
/// <param name="list"></param>
public int DeleteNotice(string selectKey)
{
NoticeInfo notice = new NoticeInfo();
int count = 0;
try
{
string[] list = selectKey.Split(":".ToCharArray());
//删除附件
foreach (var item in list)
{
notice.NOTICEID = item;
notice = Get(notice);
DeleteFile(notice.ATTACHFILE);
}
//删除通知
count = Delete(list);
//删除浏览记录
DeleteBorwse(list);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除公告信息
/// </summary>
/// <param name="users">公告信息</param>
/// <returns>删除个数</returns>
public int Delete(string[] notices)
{
int count = 0;
try
{
foreach (string notice in notices)
{
count += this.Delete(new NoticeInfo { NOTICEID = notice });
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除公告信息
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>删除个数</returns>
public int Delete(NoticeInfo notice)
{
try
{
return new NoticeManageDAL().Delete(notice);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取未读取通知信息
/// <summary>
/// 获取未读取通知信息
/// </summary>
/// <returns></returns>
public List<NoticeInfo> GetNotReadNotice(NoticeInfo model)
{
try
{
return new NoticeManageDAL().GetNotReadNotice(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取未读即时通知信息
/// <summary>
/// 获取未读即时通知信息
/// </summary>
/// <returns></returns>
public List<NoticeInfo> GetNotReadInstantNotice(NoticeInfo model)
{
try
{
return new NoticeManageDAL().GetNotReadInstantNotice(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 公告浏览记录操作
#region 获取公告浏览记录
/// <summary>
/// 获取公告浏览记录
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public NoticeBrowse GetBrowseModel(NoticeBrowse condition)
{
try
{
return new NoticeManageDAL().GetBrowseModel(condition);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取公告浏览记录列表
/// <summary>
/// 获取公告浏览记录列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetBrowseList(NoticeBrowse condition,DataPage page)
{
try
{
condition.UserName = LoginUser.LoginUserID;
condition.USERID = LoginUser.UserID;
return new NoticeManageDAL().GetBrowseList(condition, page);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取公告浏览记录列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>查询数据列表</returns>
public NoticeBrowse GetBrowse(NoticeBrowse condition)
{
try
{
condition.UserName = LoginUser.LoginUserID;
return new NoticeManageDAL().GetBrowse(condition);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新公告浏览记录
/// <summary>
/// 插入公告
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>插入数</returns>
public int UpdateNoticeBrowse(NoticeBrowse model)
{
int count = 0;
NoticeManageDAL nmDal = new NoticeManageDAL();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
count = nmDal.Update(model);
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 定时删除超过六个月的通知浏览记录
/// <summary>
/// 定时删除超过六个月的通知浏览记录
/// </summary>
/// <returns>删除个数</returns>
public int DeleteNoticeBrowse()
{
try
{
return new NoticeManageDAL().DeleteNoticeBrowse();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除浏览记录
/// <summary>
/// 删除浏览记录
/// </summary>
/// <param name="users">浏览记录</param>
/// <returns>删除个数</returns>
public int DeleteBorwse(string[] notices)
{
int count = 0;
try
{
foreach (string notice in notices)
{
count += this.Delete(new NoticeBrowse { NOTICEID = notice });
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除浏览记录
/// </summary>
/// <param name="user">浏览记录</param>
/// <returns>删除个数</returns>
public int Delete(NoticeBrowse noticeBrowse)
{
try
{
return new NoticeManageDAL().Delete(noticeBrowse);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 判断附件路径是否存在
public bool ExistsFile(string newFilePath)
{
bool issuccess = true;
if (!File.Exists(newFilePath))
{
issuccess = false;
}
return issuccess;
}
#endregion
#region 删除附件
public void DeleteFile(string FilePath)
{
if (File.Exists(FilePath))
{
File.Delete(FilePath); ;
}
}
#endregion
#region 根据用户姓名获取用户信息
/// <summary>
/// 获取用户信息
/// </summary>
/// <param name="user">条件</param>
/// <returns>用户信息</returns>
public User GetUser(User user)
{
try
{
return new NoticeManageDAL().Get(user);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取导出的数据
/// <summary>
/// 获取导出的数据
/// </summary>
/// <param name="user">查询条件</param>
/// <returns>数据</returns>
public DataTable GetExportData(NoticeInfo model)
{
DataTable dt=new DataTable();
NoticeManageDAL nmDal=new NoticeManageDAL();
try
{
model.UserName = LoginUser.LoginUserID;
dt= nmDal.GetExportData(model);
//回复数量
foreach (DataRow dr in dt.Rows)
{
if (dr["REPLYCOUNT"].ToString() == "")
{
dr["REPLYCOUNT"] = "0";
}
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构下人员列表
/// <summary>
/// 获取组织机构下人员列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>同级别菜单列表</returns>
public DataPage GetNoticeUserList(string orgaID, DataPage page)
{
try
{
return new NoticeManageDAL().GetNoticeUserList(orgaID, page);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取组织机构数菜单列表
/// <summary>
/// 获取所有组织机构数菜单列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>同级别菜单列表</returns>
public List<Orgaization> GetAllList()
{
try
{
return new NoticeManageDAL().GetAllList();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入未处理问题的公告
/// <summary>
/// 插入未处理问题的公告
/// </summary>
/// <param name="user">公告信息</param>
/// <returns>插入数</returns>
public int SaveOverTimeRemind(NoticeInfo notice)
{
int count = 0;
NoticeBrowse noticebrowse = new NoticeBrowse();
NoticeManageDAL nmDal = new NoticeManageDAL();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
//通知基本信息
notice.NOTICEID = Guid.NewGuid().ToString();
notice.CREATEUSER = LoginUser.UserID;
notice.CREATEDATE = DateTime.Now;
notice.SENDTIME = DateTime.Now;
notice.UPDATEUSER = notice.CREATEUSER;
notice.UPDATEDATE = DateTime.Now;
//判断当天的提醒是否存在
bool existsFlag = nmDal.OverTimeRemindNoticeExists(notice);
if (existsFlag)
{
return 0;
}
//插入通知
count = nmDal.Insert(notice);
//通知浏览基本信息
var list = notice.UserID.Split(',');
for (int i = 0; i < list.Count(); i++)
{
noticebrowse.PID = Guid.NewGuid().ToString();
noticebrowse.NOTICEID = notice.NOTICEID;
noticebrowse.USERID = list[i];
noticebrowse.ISREAD = "0";
//插入通知浏览记录
nmDal.Insert(noticebrowse);
}
session.CommitTs();
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}