123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Configuration;
- using System.Data.Entity;
- using Autofac;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.Entities;
- using EMIS.ViewModel.SystemView;
- using Bowin.Common.JSON;
- using EMIS.CommonLogic.PlugworkflowServices;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using System.Linq.Expressions;
- using EMIS.Utility.FormValidate;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.WorkflowManage;
- using EMIS.Utility;
- using EMIS.DataLogic.StudentManage.StudentProfile;
- namespace EMIS.CommonLogic.SystemServices
- {
- public class BaseWorkflowServices<TEntity> : BaseServices, IBaseWorkflowServices<TEntity> where TEntity : class
- {
- protected Func<List<Guid>, Guid, bool> DataRangeUserFunc { get; set; }
- public Lazy<IWorkflowServices> WorkflowServices { get; set; }
- public StudentDAL StudentDAL { get; set; }
- private string tableName { get; set; }
-
-
-
- public BaseWorkflowServices()
- {
- tableName = typeof(TEntity).Name;
- var scope = AutofacHelper.RequestLifetimeScope;
- StudentDAL = scope.Resolve<StudentDAL>();
- }
-
-
-
-
- public int? GetStartStatus()
- {
- return WorkflowServices.Value.GetStartStatus(tableName);
- }
-
-
-
-
- public int? GetSendBackStatus()
- {
- return WorkflowServices.Value.GetSendBackStatus(tableName);
- }
-
-
-
-
- public int? GetPassNoEndStatus()
- {
- return WorkflowServices.Value.GetPassNoEndStatus(tableName);
- }
-
-
-
-
- public List<int?> GetEndStatus()
- {
- return WorkflowServices.Value.GetEndStatus(tableName);
- }
-
-
-
-
- public int? GetCorrectEndStatus()
- {
- return WorkflowServices.Value.GetCorrectEndStatus(tableName);
- }
-
-
-
-
- public List<int?> GetBackpointStatus()
- {
- return WorkflowServices.Value.GetBackpointStatus(tableName);
- }
-
-
-
-
- public List<int?> GetStartApproveStatusList()
- {
- return WorkflowServices.Value.GetStartApproveStatusList(tableName);
- }
-
-
-
-
- public List<int?> GetRebutStatus()
- {
- return WorkflowServices.Value.GetRebutStatus(tableName);
- }
-
-
-
-
- public List<WorkflowStatusView> GetStatusViewList()
- {
- return WorkflowServices.Value.GetStatusViewList(tableName);
- }
-
-
-
-
- public List<WorkflowStatusView> GetApproveStatusViewList()
- {
- return WorkflowServices.Value.GetApproveStatusViewList(tableName);
- }
-
-
-
-
- public List<ActionView> GetActionView()
- {
- return WorkflowServices.Value.GetActionView(tableName);
- }
-
-
-
-
- public List<ActionView> GetStartActionView()
- {
- return WorkflowServices.Value.GetStartActionView(tableName);
- }
-
-
-
-
-
-
- public List<ActionView> GetActionView(Guid formID, Guid userID)
- {
- try
- {
- return WorkflowServices.Value.GetActionView(tableName, formID, userID);
- }
- catch (Exception)
- {
- throw;
- }
- }
-
-
-
-
-
-
- public bool IsCanApprove(Guid formID, Guid userID)
- {
- try
- {
- var action = this.WorkflowServices.Value.GetActionView(tableName, formID, userID).FirstOrDefault();
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, action.ActionID, new List<Guid> { formID }, DataRangeUserFunc);
- }
- else
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, action.ActionID, new List<Guid> { formID });
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
-
- public List<WorkflowPermissionView> IsCanApprove(Guid userID, List<Guid> formIDs)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, formIDs);
- }
-
-
-
-
-
- public bool GetRangeUserList(Guid userID, Guid actionID, List<Guid> formIDs)
- {
- return WorkflowServices.Value.IsCanApprove(tableName, userID, actionID, formIDs, DataRangeUserFunc);
- }
-
-
-
-
-
-
- public void StartUp(List<Guid> formIDList, Guid userID, string comment = "")
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.BatchStartUp(tableName, formIDList, userID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.BatchStartUp(tableName, formIDList, userID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
-
- public void StartUp(Guid formID, Guid userID, Guid actionID, string comment)
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.StartUp(tableName, formID, userID, actionID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.StartUp(tableName, formID, userID, actionID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
-
- public void Approve(List<Guid> formIDList, Guid userID, Guid actionID, string comment = "")
- {
- try
- {
- if (StudentDAL.StudentRepository.GetSingle(x => x.UserID == userID) == null)
- {
- WorkflowServices.Value.BatchApprove(tableName, formIDList, userID, actionID, comment, DataRangeUserFunc);
- }
- else
- {
- WorkflowServices.Value.BatchApprove(tableName, formIDList, userID, actionID, comment, null);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
- public void ModifyProcessState(Guid formID, string status, string description)
- {
- try
- {
- WorkflowServices.Value.ModifyProcessState(tableName, formID, status, description);
- }
- catch (Exception)
- {
- throw;
- }
- }
-
-
-
-
-
- public IList<ViewModel.SystemView.WorkflowApproveHistoryView> GetApproveHistoryViewList(Guid formID)
- {
- try
- {
- return WorkflowServices.Value.GetApproveHistoryViewList(tableName, formID);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
-
-
-
-
- public IGridResultSet<T> QueryByPendingJob<T, TOrder>(IQueryable<T> query, Guid userID, Expression<Func<T, Guid>> pkSelector,
- Expression<Func<T, TOrder>> orderby, bool isDescending = false, int? pageIndex = null, int? pageSize = null)
- {
- try
- {
- return WorkflowServices.Value.QueryByPendingJob(tableName, query, userID, pkSelector, orderby, isDescending, pageIndex, pageSize);
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|