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.
301 lines
8.2 KiB
301 lines
8.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.Entity.Sys;
|
|
using QMAPP.DAL.Sys;
|
|
using QMFrameWork.Data;
|
|
using System.Data;
|
|
using QMAPP.Entity;
|
|
|
|
namespace QMAPP.BLL.Sys
|
|
{
|
|
/// <summary>
|
|
/// 文件管理逻辑层
|
|
/// 创建者:王丹丹
|
|
/// 创建时间:2015-03-17
|
|
/// </summary>
|
|
public class FileInfoBLL : BaseBLL
|
|
{
|
|
#region 获取信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public FileInfo Get(FileInfo model)
|
|
{
|
|
try
|
|
{
|
|
return new FileInfoDAL().Get(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 根据文件类型获取文件信息
|
|
/// <summary>
|
|
/// 获取信息
|
|
/// </summary>
|
|
/// <param name="">条件</param>
|
|
/// <returns>信息</returns>
|
|
public IList<FileInfo> GetListModel(FileType model)
|
|
{
|
|
try
|
|
{
|
|
return new FileInfoDAL().GetList(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataPage GetList(FileInfo condition, DataPage page)
|
|
{
|
|
try
|
|
{
|
|
return new FileInfoDAL().GetList(condition, page);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 信息是否重复
|
|
/// <summary>
|
|
/// 判断名称是否存在
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
public bool ExistsFileInfo(FileInfo model)
|
|
{
|
|
try
|
|
{
|
|
return new FileInfoDAL().ExistsFileInfo(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 插入文件信息
|
|
/// <summary>
|
|
/// 插入文件信息
|
|
/// </summary>
|
|
/// <param name="model">文件信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public int Insert(FileInfo model)
|
|
{
|
|
try
|
|
{
|
|
//基本信息
|
|
model.PID = Guid.NewGuid().ToString();
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
model.CREATEDATE = DateTime.Now;
|
|
FileInfoDAL cmdDAL = new FileInfoDAL();
|
|
//校验文件名称是否
|
|
if (ExistsFileInfo(model) == true)
|
|
{
|
|
return -1;
|
|
}
|
|
int ret=new FileInfoDAL().Insert(model);
|
|
if (ret > 0)
|
|
{
|
|
SendFileIntoNotice(model);
|
|
}
|
|
return ret;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新信息
|
|
/// <summary>
|
|
/// 更新信息
|
|
/// </summary>
|
|
/// <param name=""></param>
|
|
/// <returns>更新行数</returns>
|
|
public int Update(FileInfo model)
|
|
{
|
|
try
|
|
{
|
|
int ret=new FileInfoDAL().Update(model);
|
|
if (ret > 0)
|
|
{
|
|
SendFileIntoNotice(model);
|
|
}
|
|
return ret;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除文件
|
|
/// </summary>
|
|
/// <param strs="">文件类型主键串</param>
|
|
/// <returns>删除个数</returns>
|
|
public int Delete(string strs)
|
|
{
|
|
int count = 0;
|
|
string[] list = strs.Split(":".ToCharArray());
|
|
try
|
|
{
|
|
foreach (string str in list)
|
|
{
|
|
count += this.DeleteFileInfo(new FileInfo { PID = str });
|
|
}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除文件
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>删除个数</returns>
|
|
public int DeleteFileInfo(FileInfo model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
count = new FileInfoDAL().Delete(model);
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 判断附件路径是否存在
|
|
|
|
public bool ExistsFile(string newFilePath)
|
|
{
|
|
bool issuccess = true;
|
|
if (!System.IO.File.Exists(newFilePath))
|
|
{
|
|
issuccess = false;
|
|
}
|
|
return issuccess;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除附件
|
|
|
|
public void DeleteFile(string FilePath)
|
|
{
|
|
if (System.IO.File.Exists(FilePath))
|
|
{
|
|
System.IO.File.Delete(FilePath); ;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取导出的数据
|
|
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(FileInfo model)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
FileInfoDAL nmDal = new FileInfoDAL();
|
|
try
|
|
{
|
|
dt = nmDal.GetExportData(model);
|
|
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 将文件对象生成对应的通知并创建
|
|
|
|
private DataResult SendFileIntoNotice(FileInfo model)
|
|
{
|
|
try
|
|
{
|
|
NoticeInfo notice = new NoticeInfo();
|
|
FileType fileType = new FileType();
|
|
fileType.TYPENO = model.TYPENO;
|
|
fileType = new FileTypeBLL().Get(fileType);
|
|
notice.NOTICETITLE = "文件管理中的文件分类 '" + fileType.TYPENAME + " '下的文件 '" + model.FILENAME + " ' 被创建或修改!";
|
|
notice.NOTICECONTEXT = "文件管理中的文件分类 '" +fileType.TYPENAME + " '下的文件 '" + model.FILENAME + " ' 被创建或修改!";
|
|
List<User> users = new UserManageDAL().GetAllUser(null);
|
|
StringBuilder strUsers = new StringBuilder();
|
|
foreach (User itemUser in users)
|
|
{
|
|
strUsers.Append(itemUser.UserID + ",");
|
|
}
|
|
if (strUsers.Length > 0)
|
|
{
|
|
notice.SENDAIM = strUsers.ToString();
|
|
notice.SENDAIM = notice.SENDAIM.Substring(0, notice.SENDAIM.Length - 1);
|
|
}
|
|
else
|
|
{
|
|
notice.SENDAIM = string.Empty;
|
|
}
|
|
notice.SENDFLG = "0";
|
|
notice.SENDTIME = System.DateTime.Now;
|
|
notice.USETIME = System.DateTime.Now;
|
|
notice.OUTTIME = DateTime.Now.AddDays(2);
|
|
notice.CREATEUSER = this.LoginUser.UserID;
|
|
notice.CREATEDATE = DateTime.Now;
|
|
notice.UPDATEUSER = this.LoginUser.UserID;
|
|
notice.UPDATEDATE = DateTime.Now;
|
|
notice.CANREPLY = "0";
|
|
notice.NOTICETYPE = "1";
|
|
return new NoticeManageBll().Save(notice);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|