275 lines
10 KiB
C#
275 lines
10 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Collections;
|
|||
|
using System.IO;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
//using BLL.OpenService;
|
|||
|
|
|||
|
namespace BLL
|
|||
|
{
|
|||
|
public class Common_NoticeService
|
|||
|
{
|
|||
|
public static Model.SGGLDB db = Funs.DB;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 记录数
|
|||
|
/// </summary>
|
|||
|
private static int count
|
|||
|
{
|
|||
|
get;
|
|||
|
set;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 定义变量
|
|||
|
/// </summary>
|
|||
|
private static IQueryable<Model.Common_Notice> qq = from x in db.Common_Notice orderby x.NoticeCode select x;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取分页列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="startRowIndex"></param>
|
|||
|
/// <param name="maximumRows"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static IEnumerable getListData(string systemId, string projectId, string type, string noticeCode, string startTime, string endTime, int startRowIndex, int maximumRows)
|
|||
|
{
|
|||
|
IQueryable<Model.Common_Notice> q = qq;
|
|||
|
if (type == "0")
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(projectId))
|
|||
|
{
|
|||
|
q = q.Where(e => e.SystemId == systemId && e.ProjectId == projectId);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
q = q.Where(e => e.SystemId == systemId);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(projectId))
|
|||
|
{
|
|||
|
q = q.Where(e => e.IsRelease == true && (e.AccessSystemId.Contains(systemId + "#") && e.AccessProjectId.Contains(projectId)) ||(e.SystemId == systemId && e.ProjectId == projectId));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
q = q.Where(e => e.IsRelease == true && (e.AccessSystemId.Contains(systemId + "#") || e.SystemId == systemId));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if(!string.IsNullOrEmpty(noticeCode))
|
|||
|
{
|
|||
|
q = q.Where(e => e.NoticeCode.Contains(noticeCode));
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(startTime))
|
|||
|
{
|
|||
|
q = q.Where(e => e.CompileDate >= Funs.GetNewDateTime(startTime));
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(endTime))
|
|||
|
{
|
|||
|
q = q.Where(e => e.CompileDate <= Funs.GetNewDateTime(endTime));
|
|||
|
}
|
|||
|
|
|||
|
count = q.Count();
|
|||
|
if (count == 0)
|
|||
|
{
|
|||
|
return new object[] { "" };
|
|||
|
}
|
|||
|
|
|||
|
return from x in q.Skip(startRowIndex).Take(maximumRows)
|
|||
|
select new
|
|||
|
{
|
|||
|
x.NoticeId,
|
|||
|
x.NoticeCode,
|
|||
|
x.ProjectId,
|
|||
|
x.NoticeTitle,
|
|||
|
x.MainContent,
|
|||
|
x.ClearUpMan,
|
|||
|
x.IsRelease,
|
|||
|
x.State,
|
|||
|
ProjectName = (from y in db.Base_Project where y.ProjectId == x.ProjectId select y.ProjectName).First(),
|
|||
|
ClearUpManName = (from y in db.Sys_User where y.UserId == x.ClearUpMan select y.UserName).First(),
|
|||
|
SignManName = (from y in db.Sys_User
|
|||
|
where y.UserId == (from z in db.Common_NoticeSign where z.NoticeId == x.NoticeId && z.SinaDate == null select z.SignMan).First()
|
|||
|
select y.UserName).First(),
|
|||
|
x.SystemId,
|
|||
|
x.CompileDate,
|
|||
|
SystemName= (from y in db.Sys_System where y.SystemId == x.SystemId select y.SystemName).FirstOrDefault(),
|
|||
|
x.AccessSystemText,
|
|||
|
x.AccessProjectText,
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取列表数
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static int getListCount(string systemId, string projectId, string type, string noticeCode, string startTime, string endTime)
|
|||
|
{
|
|||
|
return count;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据通知Id获取一个通知信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="noticeId">通知Id</param>
|
|||
|
/// <returns>一个通知实体</returns>
|
|||
|
public static Model.Common_Notice GetNoticeByNoticeId(string noticeId)
|
|||
|
{
|
|||
|
return Funs.DB.Common_Notice.FirstOrDefault(x => x.NoticeId == noticeId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 增加通知信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="notice">通知实体</param>
|
|||
|
public static void AddNotice(Model.Common_Notice notice)
|
|||
|
{
|
|||
|
Model.Common_Notice newNotice = new Model.Common_Notice();
|
|||
|
newNotice.NoticeId = notice.NoticeId;
|
|||
|
newNotice.NoticeCode = notice.NoticeCode;
|
|||
|
newNotice.ProjectId = notice.ProjectId;
|
|||
|
newNotice.NoticeTitle = notice.NoticeTitle;
|
|||
|
newNotice.MainContent = notice.MainContent;
|
|||
|
newNotice.ClearUpMan = notice.ClearUpMan;
|
|||
|
newNotice.AttachUrl = notice.AttachUrl;
|
|||
|
newNotice.IsRelease = notice.IsRelease;
|
|||
|
newNotice.State = notice.State;
|
|||
|
newNotice.SystemId = notice.SystemId;
|
|||
|
newNotice.CompileDate = notice.CompileDate;
|
|||
|
newNotice.Flag = notice.Flag;
|
|||
|
|
|||
|
newNotice.AccessProjectId = notice.AccessProjectId;
|
|||
|
newNotice.AccessSystemId = notice.AccessSystemId;
|
|||
|
newNotice.AccessProjectText = notice.AccessProjectText;
|
|||
|
newNotice.AccessSystemText = notice.AccessSystemText;
|
|||
|
|
|||
|
db.Common_Notice.InsertOnSubmit(newNotice);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改通知信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="notice">通知实体</param>
|
|||
|
public static void UpdateNotice(Model.Common_Notice notice)
|
|||
|
{
|
|||
|
Model.Common_Notice newNotice = db.Common_Notice.FirstOrDefault(e => e.NoticeId == notice.NoticeId);
|
|||
|
if (newNotice != null)
|
|||
|
{
|
|||
|
newNotice.NoticeCode = notice.NoticeCode;
|
|||
|
newNotice.ProjectId = notice.ProjectId;
|
|||
|
newNotice.NoticeTitle = notice.NoticeTitle;
|
|||
|
newNotice.MainContent = notice.MainContent;
|
|||
|
newNotice.ClearUpMan = notice.ClearUpMan;
|
|||
|
newNotice.AttachUrl = notice.AttachUrl;
|
|||
|
newNotice.IsRelease = notice.IsRelease;
|
|||
|
newNotice.State = notice.State;
|
|||
|
newNotice.SystemId = notice.SystemId;
|
|||
|
newNotice.Flag = notice.Flag;
|
|||
|
newNotice.AccessProjectId = notice.AccessProjectId;
|
|||
|
newNotice.AccessSystemId = notice.AccessSystemId;
|
|||
|
newNotice.AccessProjectText = notice.AccessProjectText;
|
|||
|
newNotice.AccessSystemText = notice.AccessSystemText;
|
|||
|
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据通知Id删除一个通知信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="noticeId">通知Id</param>
|
|||
|
public static void DeleteNotice(string noticeId)
|
|||
|
{
|
|||
|
Model.Common_Notice notice = db.Common_Notice.FirstOrDefault(e => e.NoticeId == noticeId);
|
|||
|
if (notice != null)
|
|||
|
{
|
|||
|
db.Common_Notice.DeleteOnSubmit(notice);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据状态选择下一步办理类型
|
|||
|
/// </summary>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<Model.HandleStep> GetNetSignStepByState(string state)
|
|||
|
{
|
|||
|
List<Model.HandleStep> handleSteps=new List<Model.HandleStep>();
|
|||
|
if (state == Const.Common_Notice_Check)
|
|||
|
{
|
|||
|
Model.HandleStep step1 = new Model.HandleStep();
|
|||
|
step1.Id=Const.Common_Notice_ReCompile;
|
|||
|
step1.Name="重新整理";
|
|||
|
handleSteps.Add(step1);
|
|||
|
Model.HandleStep step2 = new Model.HandleStep();
|
|||
|
step2.Id = Const.Common_Notice_Sign;
|
|||
|
step2.Name = "签发";
|
|||
|
handleSteps.Add(step2);
|
|||
|
}
|
|||
|
if (state == Const.Common_Notice_Sign)
|
|||
|
{
|
|||
|
Model.HandleStep step1 = new Model.HandleStep();
|
|||
|
step1.Id = Const.Common_Notice_ReCompile;
|
|||
|
step1.Name = "重新整理";
|
|||
|
handleSteps.Add(step1);
|
|||
|
Model.HandleStep step2 = new Model.HandleStep();
|
|||
|
step2.Id = Const.Common_Notice_ApproveCompleted;
|
|||
|
step2.Name = "审核完结";
|
|||
|
handleSteps.Add(step2);
|
|||
|
}
|
|||
|
|
|||
|
return handleSteps;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据用户主键获得通知的数量
|
|||
|
/// </summary>
|
|||
|
/// <param name="userId">角色</param>
|
|||
|
/// <returns></returns>
|
|||
|
public static int GetNoticeCountByUserId(string userId)
|
|||
|
{
|
|||
|
var q = (from x in Funs.DB.Common_Notice where x.ClearUpMan == userId select x).ToList();
|
|||
|
return q.Count();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取已发布的审核完结的通知信息
|
|||
|
/// </summary>
|
|||
|
/// <returns>通知集合</returns>
|
|||
|
public static List<Model.Common_Notice> GetNotices(string systemId, string projectId)
|
|||
|
{
|
|||
|
var notice = from x in Funs.DB.Common_Notice where x.IsRelease == true select x;
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(projectId))
|
|||
|
{
|
|||
|
notice = notice.Where(e => (e.AccessSystemId.Contains(systemId) && e.AccessProjectId.Contains(projectId)) ||(e.SystemId == systemId && e.ProjectId == projectId));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
notice = notice.Where(e => e.AccessSystemId.Contains(systemId) || e.SystemId == systemId);
|
|||
|
}
|
|||
|
|
|||
|
return notice.ToList();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据项目ID查询通知信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="unitType"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static List<Model.Common_Notice> GetNoticeByProjectId(string projectId)
|
|||
|
{
|
|||
|
return (from x in Funs.DB.Common_Notice where x.ProjectId == projectId select x).ToList();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|