protected void RemindForParticipant(int?remindType, SysProcessParticipant part, SysProcessRemindTemplate template)
        {
            if (template == null)
            {
                throw new ApplicationException("RemindTemplate为空");
            }
            foreach (IUser user in ParticipantHelper.GetUsers(this._context, part, this.PI, this.AI, this.creator.WiOwnerId).Distinct <IUser>())
            {
                string str3;
                this.AddRemindToken(user);
                string remindTitleByTemplate   = this.creator.GetRemindTitleByTemplate(template, user);
                string remindContentByTemplate = this.creator.GetRemindContentByTemplate(template, user);
                int    valueOrDefault          = remindType.GetValueOrDefault();
                if (remindType.HasValue)
                {
                    switch (valueOrDefault)
                    {
                    case 0:
                        if (this.EmailHandler == null)
                        {
                            throw new ApplicationException("未找到邮件服务,无法发送邮件提醒");
                        }
                        this.EmailHandler.SendEmail(user, remindTitleByTemplate, remindContentByTemplate, this.Model.AprovePageOuterURL, this.Model.ProcessDetailOuterURL);
                        break;

                    case 1:
                        if (this.ShortMessageHandler == null)
                        {
                            throw new ApplicationException("未找到短信服务,无法发送短信提醒");
                        }
                        goto Label_00EA;

                    case 2:
                        if (this.CustomRemindHandler == null)
                        {
                            throw new ApplicationException("未找到自定义提醒服务,无法处理自定义提醒");
                        }
                        goto Label_013F;
                    }
                }
                continue;
                Label_00EA:
                str3 = null;
                if (string.IsNullOrEmpty(remindTitleByTemplate))
                {
                    str3 = remindContentByTemplate;
                }
                else
                {
                    StringBuilder builder = new StringBuilder(remindTitleByTemplate);
                    builder.AppendLine();
                    builder.AppendLine(remindContentByTemplate);
                    str3 = builder.ToString();
                }
                this.ShortMessageHandler.SendMessage(user, str3);
                continue;
Label_013F:
                this.CustomRemindHandler.Execute(user, remindTitleByTemplate, remindContentByTemplate, this.PI, this.AI, this.WorkItem, this.Model);
            }
        }
        public override IList <IUser> GetUsers(SysProcessParticipant part, SysProcessInstance pi, SysActivityInstance ai)
        {
            List <IUser> source = new List <IUser>();

            using (IEnumerator <SysActivityParticipant> enumerator = ai.Activity.ActivityParticipants.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Func <SysProcessParticipant, bool> predicate = null;
                    SysActivityParticipant             p         = enumerator.Current;
                    if (predicate == null)
                    {
                        predicate = i => i.ParticipantId == p.ParticipantId;
                    }
                    SysProcessParticipant participant = pi.Process.ProcessParticipants.FirstOrDefault <SysProcessParticipant>(predicate);
                    if (participant != null)
                    {
                        int?         wiOwnerId  = null;
                        List <IUser> collection = ParticipantHelper.GetUsers(base._context, participant, pi, ai, wiOwnerId);
                        source.AddRange(collection);
                    }
                }
            }
            return(source.Distinct <IUser>().ToList <IUser>());
        }
        private void ExecuteForManual(SysActivity activity, SysProcess process, Queue <WorkflowMessage> queue)
        {
            if ((activity.ActivityParticipants == null) || (activity.ActivityParticipants.Count == 0))
            {
                throw new ApplicationException("未指定参与人");
            }
            Dictionary <SysWorkItemApproveGroup, List <IUser> > dictionary = new Dictionary <SysWorkItemApproveGroup, List <IUser> >(20);
            List <IUser> list = new List <IUser>();

            if (this.AI.UserDefinedApproveUsers.Count > 0)
            {
                SysWorkItemApproveGroup key = this.CreateWorkItemGroup();
                IOrgProxy    orgProxy       = OrgProxyFactory.GetProxy(base.Context);
                List <IUser> users          = (from p in this.AI.UserDefinedApproveUsers select orgProxy.GetUserById(p.UserId.Value)).ToList <IUser>();
                this.RemoveRepeatedUsers(users);
                list.AddRange(users);
                dictionary.Add(key, users);
            }
            else
            {
                using (IEnumerator <SysActivityParticipant> enumerator = activity.ActivityParticipants.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Func <SysProcessParticipant, bool> predicate     = null;
                        SysActivityParticipant             activity_part = enumerator.Current;
                        SysWorkItemApproveGroup            group         = this.CreateWorkItemGroup(activity_part);
                        if (predicate == null)
                        {
                            predicate = p => p.ParticipantId == activity_part.ParticipantId.Value;
                        }
                        SysProcessParticipant part = process.ProcessParticipants.FirstOrDefault <SysProcessParticipant>(predicate);
                        if (part == null)
                        {
                            throw new ApplicationException("参与人为空");
                        }
                        int?         wiOwnerId   = null;
                        var          users       = ParticipantHelper.GetUsers(base.Context, part, base.PI, this.AI, wiOwnerId);
                        List <IUser> targetUsers = users;
                        this.AssertGroupHasUsers(activity_part, group, targetUsers);
                        this.RemoveRepeatedUsers(targetUsers);
                        list.AddRange(targetUsers);
                        dictionary.Add(group, targetUsers);
                    }
                }
            }
            if (list.Count == 0)
            {
                bool?isPassedWithNoParticipants = this.AI.Activity.IsPassedWithNoParticipants;
                if (!(isPassedWithNoParticipants.HasValue ? isPassedWithNoParticipants.GetValueOrDefault() : false))
                {
                    throw new ApplicationException("未计算出任何参与人");
                }
                SysActivityInstance aI = this.AI;
                aI.InstanceStatus  = 10;
                aI.EndTime         = new DateTime?(DateTime.Now);
                aI.ApproveResult   = 1;
                aI.ExpressionValue = 1;
                aI.Remark          = "无人审核,自动通过";
                base.PICacheFactory.UpdateActiviyInstance(this.AI);
                WorkflowMessage item = base.Engine.NewCompleteActivityMessage(this.AI);
                queue.Enqueue(item);
            }
            else
            {
                SysActivity activity3 = this.AI.Activity;
                if (!activity3.PassType.HasValue)
                {
                    activity3.PassType = 1;
                    if (!activity3.MinPassNum.HasValue)
                    {
                        activity3.MinPassNum = 1;
                    }
                }
                foreach (KeyValuePair <SysWorkItemApproveGroup, List <IUser> > pair in dictionary)
                {
                    SysWorkItemApproveGroup group3 = pair.Key;
                    foreach (IUser user in pair.Value)
                    {
                        this.CreateWorkItem(user, group3);
                    }
                }
            }
            if (this.AI.UserDefinedApproveUsers.Count > 0)
            {
                base.PICacheFactory.ClearApproveUsers(this.AI);
            }
        }