mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
完成流程列表
This commit is contained in:
104
OpenAuth.App/CommonApplyApp.cs
Normal file
104
OpenAuth.App/CommonApplyApp.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class CommonApplyApp
|
||||
{
|
||||
private IRepository<CommonApply> _repository;
|
||||
private IUnitWork _unitWork;
|
||||
|
||||
public CommonApplyApp(IRepository<CommonApply> repository, IUnitWork unitWork)
|
||||
{
|
||||
_repository = repository;
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
public void AddOrUpdate(CommonApply model)
|
||||
{
|
||||
if (model.Id == Guid.Empty)
|
||||
{
|
||||
var obj = model.CopyTo<CommonApply>();
|
||||
_repository.Add(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.Update(u => u.Id == model.Id, u => new CommonApply
|
||||
{
|
||||
UserId = model.UserId,
|
||||
Name = model.Name,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改流程状态
|
||||
/// </summary>
|
||||
public void ChangeState(Guid id,string state, string statename)
|
||||
{
|
||||
_repository.Update(u =>u.Id == id, u =>new CommonApply
|
||||
{
|
||||
State = state,
|
||||
StateName = statename
|
||||
});
|
||||
}
|
||||
|
||||
public CommonApply Get(Guid value)
|
||||
{
|
||||
return _repository.FindSingle(u =>u.Id == value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载流程处理
|
||||
/// </summary>
|
||||
/// <param name="userid">用户ID</param>
|
||||
/// <param name="type">inbox:待办事项/outbox:已办事项</param>
|
||||
public GridData Load(Guid userid, string type, int pageCurrent, int pageSize)
|
||||
{
|
||||
var result = new GridData
|
||||
{
|
||||
pageCurrent = pageCurrent
|
||||
};
|
||||
|
||||
if (type == "inbox") //待办事项
|
||||
{
|
||||
var inboxes = GetInboxProcessIds(userid);
|
||||
result.total = _unitWork.Find<CommonApply>(u => inboxes.Contains(u.Id)).Count();
|
||||
result.list = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending",u => inboxes.Contains(u.Id)).ToList();
|
||||
}
|
||||
else if (type == "outbox") //已办事项
|
||||
{
|
||||
IQueryable<Guid> outboxes = GetOutboxProcessIds(userid);
|
||||
result.total = _unitWork.Find<CommonApply>(u => outboxes.Contains(u.Id)).Count();
|
||||
result.list = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending", u => outboxes.Contains(u.Id)).ToList();
|
||||
}
|
||||
else //我的流程
|
||||
{
|
||||
result.total = _unitWork.Find<CommonApply>(u => u.UserId == userid).Count();
|
||||
result.list = _unitWork.Find<CommonApply>(pageCurrent, pageSize, "Sort descending", u => u.UserId == userid).ToList();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IQueryable<Guid> GetOutboxProcessIds(Guid userid)
|
||||
{
|
||||
return _unitWork.Find<ApplyTransitionHistory>(u => u.UserId == userid).Select(u => u.ApplyId);
|
||||
}
|
||||
|
||||
private IQueryable<Guid> GetInboxProcessIds(Guid userid)
|
||||
{
|
||||
return _unitWork.Find<Relevance>(u =>u.Key =="ProcessUser" &&(userid == Guid.Empty || u.SecondId == userid)).Select(u =>u.FirstId);
|
||||
}
|
||||
|
||||
public void Del(Guid id)
|
||||
{
|
||||
_repository.Delete(u =>u.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
using System;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class GoodsApplyApp
|
||||
{
|
||||
private IRepository<GoodsApply> _repository;
|
||||
|
||||
public GoodsApplyApp(IRepository<GoodsApply> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public void AddOrUpdate(GoodsApply model)
|
||||
{
|
||||
if (model.Id == Guid.Empty)
|
||||
{
|
||||
_repository.Add(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.Update(u => u.Id == model.Id, u => new GoodsApply
|
||||
{
|
||||
UserId = model.UserId,
|
||||
Name = model.Name,
|
||||
Number = model.Number
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改流程状态
|
||||
/// </summary>
|
||||
public void ChangeState(Guid id,string state, string statename)
|
||||
{
|
||||
_repository.Update(u =>u.Id == id, u =>new GoodsApply
|
||||
{
|
||||
State = state,
|
||||
StateName = statename
|
||||
});
|
||||
}
|
||||
|
||||
public GoodsApply Get(Guid value)
|
||||
{
|
||||
return _repository.FindSingle(u =>u.Id == value);
|
||||
}
|
||||
|
||||
public GridData Load(Guid userid, Guid parentId, int pageCurrent, int pageSize)
|
||||
{
|
||||
var result = new GridData
|
||||
{
|
||||
pageCurrent = pageCurrent
|
||||
};
|
||||
|
||||
result.list= _repository.Find( pageCurrent, pageSize);
|
||||
result.total = _repository.GetCount(null);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Del(Guid id)
|
||||
{
|
||||
_repository.Delete(u =>u.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
@@ -100,13 +100,13 @@
|
||||
<Compile Include="SSO\SSOAuthAttribute.cs" />
|
||||
<Compile Include="SSO\UserAuthSession.cs" />
|
||||
<Compile Include="SSO\UserAuthSessionService.cs" />
|
||||
<Compile Include="GoodsApplyApp.cs" />
|
||||
<Compile Include="CommonApplyApp.cs" />
|
||||
<Compile Include="StockManagerApp.cs" />
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="OrgManagerApp.cs" />
|
||||
<Compile Include="ViewModel\CommandModel.cs" />
|
||||
<Compile Include="ViewModel\GoodsApplyVM.cs" />
|
||||
<Compile Include="ViewModel\CommonApplyVM.cs" />
|
||||
<Compile Include="ViewModel\GridData.cs" />
|
||||
<Compile Include="ViewModel\UserWithAccessedCtrls.cs" />
|
||||
<Compile Include="ViewModel\ModuleElementVM.cs" />
|
||||
|
@@ -17,7 +17,7 @@ namespace OpenAuth.App.ViewModel
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class GoodsApplyVM :Entity
|
||||
public class CommonApplyVM :Entity
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -59,14 +59,14 @@ namespace OpenAuth.App.ViewModel
|
||||
|
||||
public Dictionary<string, string> AvailiableStates { get; set; }
|
||||
|
||||
public static implicit operator GoodsApplyVM(GoodsApply obj)
|
||||
public static implicit operator CommonApplyVM(CommonApply obj)
|
||||
{
|
||||
return obj.MapTo<GoodsApplyVM>();
|
||||
return obj.MapTo<CommonApplyVM>();
|
||||
}
|
||||
|
||||
public static implicit operator GoodsApply(GoodsApplyVM obj)
|
||||
public static implicit operator CommonApply(CommonApplyVM obj)
|
||||
{
|
||||
return obj.MapTo<GoodsApply>();
|
||||
return obj.MapTo<CommonApply>();
|
||||
}
|
||||
|
||||
}
|
@@ -7,9 +7,9 @@ namespace OpenAuth.App
|
||||
{
|
||||
public class WorkflowInboxApp
|
||||
{
|
||||
private IRepository<WorkflowInbox> _repository;
|
||||
private IRepository<Relevance> _repository;
|
||||
|
||||
public WorkflowInboxApp(IRepository<WorkflowInbox> repository)
|
||||
public WorkflowInboxApp(IRepository<Relevance> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
@@ -17,10 +17,10 @@ namespace OpenAuth.App
|
||||
|
||||
public void DeleteAllByProcess(Guid processId)
|
||||
{
|
||||
_repository.Delete(u =>u.ProcessId == processId);
|
||||
_repository.Delete(u =>u.FirstId == processId && u.Key=="ProcessUser");
|
||||
}
|
||||
|
||||
public void Add(WorkflowInbox newInboxItem)
|
||||
public void Add(Relevance newInboxItem)
|
||||
{
|
||||
_repository.Add(newInboxItem);
|
||||
}
|
||||
|
Reference in New Issue
Block a user