1
This commit is contained in:
@@ -0,0 +1,253 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class WorkflowTodoitemsService
|
||||
{
|
||||
public enum Status:int
|
||||
{
|
||||
待办 = 0,
|
||||
已办 = 1,
|
||||
}
|
||||
|
||||
public static string SysCode = "QHSE";
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
private static IQueryable<Model.Workflow_TodoItems> GetWorkflow_TodoItemsByModle(Model.Workflow_TodoItems table)
|
||||
{
|
||||
var q = from x in Funs.DB.Workflow_TodoItems
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.SysCode) || x.SysCode.Contains(table.SysCode)) &&
|
||||
(string.IsNullOrEmpty(table.FlowId) || x.FlowId.Contains(table.FlowId)) &&
|
||||
(string.IsNullOrEmpty(table.RequestName) || x.RequestName.Contains(table.RequestName)) &&
|
||||
(string.IsNullOrEmpty(table.WorkflowName) || x.WorkflowName.Contains(table.WorkflowName)) &&
|
||||
(string.IsNullOrEmpty(table.NodeName) || x.NodeName.Contains(table.NodeName)) &&
|
||||
(string.IsNullOrEmpty(table.PCUrl) || x.PCUrl.Contains(table.PCUrl)) &&
|
||||
(string.IsNullOrEmpty(table.AppUrl) || x.AppUrl.Contains(table.AppUrl)) &&
|
||||
(string.IsNullOrEmpty(table.Creator) || x.Creator.Contains(table.Creator)) &&
|
||||
(string.IsNullOrEmpty(table.Receiver) || x.Receiver.Contains(table.Receiver))
|
||||
select x
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <param name="grid1"></param>
|
||||
/// <returns></returns>
|
||||
private static IEnumerable GetListData(Model.Workflow_TodoItems table, Grid grid1)
|
||||
{
|
||||
var q = GetWorkflow_TodoItemsByModle(table);
|
||||
Count = q.Count();
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.SysCode,
|
||||
x.FlowId,
|
||||
x.RequestName,
|
||||
x.WorkflowName,
|
||||
x.NodeName,
|
||||
x.PCUrl,
|
||||
x.AppUrl,
|
||||
x.Creator,
|
||||
x.CreateDateTime,
|
||||
x.Receiver,
|
||||
x.ReceiveDateTime,
|
||||
x.Status,
|
||||
|
||||
};
|
||||
}
|
||||
private static void UpdateWorkflow_TodoItems(Model.Workflow_TodoItems newtable)
|
||||
{
|
||||
|
||||
Model.Workflow_TodoItems table = Funs.DB.Workflow_TodoItems.FirstOrDefault(x => x.Id == newtable.Id);
|
||||
if (table != null)
|
||||
{
|
||||
table.Id = newtable.Id;
|
||||
table.SysCode = newtable.SysCode;
|
||||
table.FlowId = newtable.FlowId;
|
||||
table.RequestName = newtable.RequestName;
|
||||
table.WorkflowName = newtable.WorkflowName;
|
||||
table.NodeName = newtable.NodeName;
|
||||
table.PCUrl = newtable.PCUrl;
|
||||
table.AppUrl = newtable.AppUrl;
|
||||
table.Creator = newtable.Creator;
|
||||
table.CreateDateTime = newtable.CreateDateTime;
|
||||
table.Receiver = newtable.Receiver;
|
||||
table.ReceiveDateTime = newtable.ReceiveDateTime;
|
||||
table.Status = newtable.Status;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
private static void DeleteWorkflow_TodoItemsById(string Id)
|
||||
{
|
||||
|
||||
Model.Workflow_TodoItems table = Funs.DB.Workflow_TodoItems.FirstOrDefault(x => x.Id == Id);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.Workflow_TodoItems.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
public static Model.Workflow_TodoItems GetWorkflow_TodoItemsById(string id)
|
||||
{
|
||||
return Funs.DB.Workflow_TodoItems.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据接收者获取待办事项
|
||||
/// </summary>
|
||||
/// <param name="receiver">接收者名称</param>
|
||||
/// <returns>待办事项列表</returns>
|
||||
public static List<Model.Workflow_TodoItems> GetWorkflow_TodoItemsByReceiver (string receiver)
|
||||
{
|
||||
return Funs.DB.Workflow_TodoItems.Where(x => x.Receiver == receiver && x.Status == (int)Status.待办).OrderByDescending(x => x.CreateDateTime).ToList();
|
||||
}
|
||||
public static int GetWorkflow_TodoItemCountByReceiver(string receiver)
|
||||
{
|
||||
return Funs.DB.Workflow_TodoItems.Count(x => x.Receiver == receiver && x.Status == (int)Status.待办);
|
||||
}
|
||||
public static List<Model.Workflow_TodoItems> GetWorkflow_TodoItemsByReceiver(string receiver,int state)
|
||||
{
|
||||
if (state==-1)
|
||||
{
|
||||
return Funs.DB.Workflow_TodoItems.Where(x => x.Receiver == receiver ).OrderByDescending(x=>x.CreateDateTime).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return Funs.DB.Workflow_TodoItems.Where(x => x.Receiver == receiver && x.Status == state).OrderByDescending(x => x.CreateDateTime).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加待办事项
|
||||
/// </summary>
|
||||
/// <param name="newtable"></param>
|
||||
public static void AddWorkflow_TodoItems(Model.Workflow_TodoItems newtable)
|
||||
{
|
||||
|
||||
Model.Workflow_TodoItems table = new Model.Workflow_TodoItems
|
||||
{
|
||||
Id = newtable.Id,
|
||||
SysCode = newtable.SysCode,
|
||||
FlowId = newtable.FlowId,
|
||||
RequestName = newtable.RequestName,
|
||||
WorkflowName = newtable.WorkflowName,
|
||||
NodeName = newtable.NodeName,
|
||||
PCUrl = newtable.PCUrl,
|
||||
AppUrl = newtable.AppUrl,
|
||||
Creator = newtable.Creator,
|
||||
CreateDateTime = newtable.CreateDateTime,
|
||||
Receiver = newtable.Receiver,
|
||||
ReceiveDateTime = newtable.ReceiveDateTime,
|
||||
Status = newtable.Status,
|
||||
};
|
||||
Funs.DB.Workflow_TodoItems.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加待办事项
|
||||
/// </summary>
|
||||
/// <param name="flowId">流程ID</param>
|
||||
/// <param name="requestName">标题</param>
|
||||
/// <param name="workflowName">流程类型名称</param>
|
||||
/// <param name="nodeName">步骤名称(节点名称)</param>
|
||||
/// <param name="pcUrl">PC地址</param>
|
||||
/// <param name="appUrl">APP地址</param>
|
||||
/// <param name="creator">创建人</param>
|
||||
/// <param name="receiver">接收人</param>
|
||||
public static void Add(string flowId, string requestName, string workflowName, string nodeName, string pcUrl, string appUrl, string creator, string receiver)
|
||||
{
|
||||
if (IsWorkflow_TodoItems( flowId, receiver, nodeName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Model.Workflow_TodoItems table = new Model.Workflow_TodoItems
|
||||
{
|
||||
Id = SQLHelper.GetNewID(),
|
||||
SysCode = SysCode,
|
||||
FlowId = flowId,
|
||||
RequestName = requestName,
|
||||
WorkflowName = workflowName,
|
||||
NodeName = nodeName,
|
||||
PCUrl = pcUrl,
|
||||
AppUrl = "",
|
||||
Creator = creator,
|
||||
CreateDateTime = DateTime.Now,
|
||||
Receiver = receiver,
|
||||
ReceiveDateTime = DateTime.Now,
|
||||
Status = (int)Status.待办,
|
||||
};
|
||||
Funs.DB.Workflow_TodoItems.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除待办事项
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
public static void DeleteWorkflow_TodoItemsByflowId(string flowId)
|
||||
{
|
||||
|
||||
var q = from x in Funs.DB.Workflow_TodoItems
|
||||
where x.FlowId == flowId
|
||||
select x;
|
||||
foreach (var item in q)
|
||||
{
|
||||
Funs.DB.Workflow_TodoItems.DeleteOnSubmit(item);
|
||||
}
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
//根据flowid 和 receiver 判断是否有待办事项
|
||||
public static bool IsWorkflow_TodoItems(string flowId, string receiver,string nodename)
|
||||
{
|
||||
return Funs.DB.Workflow_TodoItems.Any(x => x.FlowId == flowId && x.Receiver == receiver && x.NodeName== nodename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 办结待办事项
|
||||
/// </summary>
|
||||
/// <param name="flowId"></param>
|
||||
/// <param name="receiver"></param>
|
||||
public static void DoneWorkflow_TodoItems(string flowId,string receiver)
|
||||
{
|
||||
|
||||
Model.Workflow_TodoItems table =
|
||||
Funs.DB.Workflow_TodoItems.FirstOrDefault(x => x.FlowId == flowId && x.Receiver == receiver);
|
||||
if (table != null)
|
||||
{
|
||||
table.Status = (int)Status.已办;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user