Пример #1
0
        /// <summary>
        /// 撤销操作时进行的相关审批记录操作,如果要用不同的记录,必须重写该方法
        /// </summary>
        /// <param name="instance">The instance.</param>
        protected virtual void TrackUndo(WorkflowInstance instance)
        {
            ApprovalRecord       record          = new ApprovalRecord();
            IIdentityService     service         = WorkflowRuntime.Current.GetService <IIdentityService>();
            IApprovalSaveService approvalService = WorkflowRuntime.Current.GetService <IApprovalSaveService>();

            if (service == null)
            {
                throw new WorkflowExecuteExeception("身份信息提供服务为空");
            }
            IUserIdentity userInfo = service.GetUserIdentity();

            record.OperatorTime       = DateTime.Now;
            record.WorkflowInstanceId = instance.Id;
            record.OperatorId         = userInfo.GetUserId();
            record.OperatorName       = userInfo.GetUserName();
            record.OperatorUnitCode   = userInfo.GetUserUnitCode();
            record.OperatorRole       = this.UserApprovalRole;
            record.EaId = instance.EaId;

            StateMachineWorkflowInstance stateMachine = instance as StateMachineWorkflowInstance;

            record.ApprovalType = GetUndoName(instance);
            record.StateName    = stateMachine.CurrentState.Description;
            if (recordId != 0)
            {
                ApprovalRecord historyRecord = approvalService.GetRecordById(recordId);
                historyRecord.IsCanceled = true;
                approvalService.SaveRecord(historyRecord);
            }
            WorkflowRuntime.Current.GetService <IApprovalSaveService>().InsertRecord(record);
        }
Пример #2
0
        /// <summary>
        /// 在记录操作日志前,需要判断代办情况重新设置操作记录,如果是代办那么操作用户名设置为格式***(代***),
        /// 同时需要设置当前动作的UserId为当前真正执行改该动作的用户,以允许该执行者可以撤销操作,该方法允许被重载
        /// </summary>
        /// <param name="record">The record.</param>
        protected virtual void ResetRecordAndUserId(ApprovalRecord record)
        {
            IIdentityService service       = WorkflowRuntime.Current.GetService <IIdentityService>();
            IUserIdentity    userInfo      = service.GetUserIdentity();
            string           currentUserId = userInfo.GetUserId();

            if (currentUserId != userId)
            {
                IUserIdentity userIdentity = service.GetUserIdentity(userId);
                record.OperatorName     = userInfo.GetUserName() + "(代" + userIdentity.GetUserName() + ")";
                record.OperatorUnitCode = userIdentity.GetUserUnitCode();
                userId = currentUserId;
            }
        }
Пример #3
0
		/// <summary>
		/// 获取某用户的代理办理项目列表
		/// </summary>
		/// <param name="taskName">任务名称</param>
		/// <param name="agentInfoId">待办记录的Id</param>
		/// <returns></returns>
		public virtual TaskList GetAgentProceedList(string taskName, int agentInfoId)
		{
			IApprovalSaveService service = WorkflowRuntime.Current.GetService<IApprovalSaveService>();
			ApprovalAgent agentInfo = service.GetAgentInfoById(agentInfoId);
			string agentUserId = agentInfo.ToUserId;
			string agentUserName = agentInfo.ToUserName;
			IUserIdentity setAgentUserIdentity = WorkflowRuntime.Current.GetService<IIdentityService>().GetUserIdentity(agentInfo.SetUserId);
			string setAgentUserName = setAgentUserIdentity.GetUserName();
			string agentRecordUserInfo = agentUserName + "(代" + setAgentUserName + ")";
			List<ApprovalRecord> recordList = new List<ApprovalRecord>();
			string[] workflowNames = WorkflowRuntime.Current.DefineService.GetAllWorkflowDefineName(applicationName);
			foreach (string workflowName in workflowNames)
			{
				WorkflowRuntime.Current.GetService<IApprovalSaveService>().GetRecord(workflowName, agentInfo.BeginDate, agentInfo.EndDate, agentInfo.SetUserId);
			}
			List<int> eaIds = new List<int>();
			foreach (ApprovalRecord record in recordList)
			{
				if (record.OperatorName == agentRecordUserInfo)
				{
					if (!eaIds.Contains(record.EaId))
						eaIds.Add(record.EaId);
				}
			}
			List<StateMachineWorkflowInstance> instanceList = new List<StateMachineWorkflowInstance>();
			foreach (int eaid in eaIds)
			{
				List<StateMachineWorkflowInstance> instances = WorkflowRuntime.Current.GetInstance(applicationName, eaid, false);
				foreach (StateMachineWorkflowInstance instance in instances)
				{
					if (instance.ParentId == null || instance.ParentId == Guid.Empty)
					{
						instanceList.Add(instance);
						break;
					}
				}
			}
			return new TaskList("a." + taskName, ItemProcessor.GenerateTaskTable(instanceList, true));
		}
Пример #4
0
        /// <summary>
        /// 执行审批操作时进行的相关审批记录操作,如果要用不同的记录,必须重写该方法
        /// </summary>
        /// <param name="instance">The instance.</param>
        protected virtual void TrackExecute(WorkflowInstance instance)
        {
            ApprovalRecord   record  = new ApprovalRecord();
            IIdentityService service = WorkflowRuntime.Current.GetService <IIdentityService>();

            if (service == null)
            {
                throw new WorkflowExecuteExeception("身份信息提供服务为空");
            }
            IUserIdentity userInfo = service.GetUserIdentity();

            record.OperatorTime       = DateTime.Now;
            record.WorkflowInstanceId = instance.Id;
            string currentUserId = userInfo.GetUserId();

            record.OperatorId       = userId;
            record.OperatorName     = userInfo.GetUserName();
            record.OperatorUnitCode = userInfo.GetUserUnitCode();

            ResetRecordAndUserId(record);

            record.OperatorRole = this.UserApprovalRole;
            record.EaId         = instance.EaId;
            StateMachineWorkflowInstance stateMachine = instance as StateMachineWorkflowInstance;

            //如果没有定义活动的名称,那么从时间的描述中取出来
            if (string.IsNullOrEmpty(this.activityName))
            {
                this.activityName = stateMachine.CurrentState.GetEventByName(eventName).Description;
            }
            record.ApprovalType = this.ActivityName;
            record.StateName    = stateMachine.CurrentState.Description;
            record.SolutionInfo = solutionInfo;
            WorkflowRuntime.Current.GetService <IApprovalSaveService>().InsertRecord(record);
            this.recordId = record.Id;
        }