コード例 #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //保存文本
            string OriginalTitleText = this.hcTemplate.Value;
            //翻译成模板文本
            string TemplateTitleText = Server.HtmlDecode(OriginalTitleText);

            AllNodes.ToList().ForEach(p => {
                TemplateTitleText = TemplateTitleText.Replace(p.Value, p.Key);
            });

            //保存文本
            string OriginalContentText = this.hcTemplate.Text;
            //翻译成模板文本
            string TemplateContentText = Server.HtmlDecode(OriginalContentText);

            AllNodes.ToList().ForEach(p =>
            {
                TemplateContentText = TemplateContentText.Replace(p.Value, p.Key);
            });

            using (BizDataContext context = new BizDataContext())
            {
                SysProcessRemindTemplate model;
                if (TemplateId == null)
                {
                    model            = new SysProcessRemindTemplate();
                    model.TemplateId = context.GetNextIdentity();
                    model.State      = 1;
                }
                else
                {
                    model = context.FindById <SysProcessRemindTemplate>(TemplateId.Value);
                }
                model.TemplateName        = this.tcTemplateName.Text;
                model.TemplateType        = this.ccTemplateType.SelectedValue.ToInt();
                model.ProcessEntityId     = this.ccProcessEntityId.SelectedValue.ToLong();
                model.ActivityEntityId    = this.ccActivityEntityId.SelectedValue.ToLong();
                model.UseTimeType         = this.ccUseTimeType.SelectedValue.ToInt();
                model.ResultType          = this.ccResultType.SelectedValue.ToInt();
                model.OriginalTitleText   = OriginalTitleText;
                model.OriginalContentText = OriginalContentText;
                model.TemplateContentText = TemplateContentText;
                model.TemplateTitleText   = TemplateTitleText;
                if (TemplateId == null)
                {
                    context.Insert(model);
                }
                else
                {
                    context.Update(model);
                }
            }
            Response.Redirect("~/SystemManagement/ProcessTemplateQuery.aspx");
        }
コード例 #2
0
        public string GetRemindTitleByTemplate(SysProcessRemindTemplate template, IUser user)
        {
            string str3;

            try
            {
                this._model.ReceiveUser = user.User_Name;
                str3 = HttpUtility.HtmlDecode(Razor.Parse <RemindTemplateModel>(template.TemplateTitleText, this._model));
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("提醒模板解析失败,错误:{0}", exception.Message));
            }
            return(str3);
        }
コード例 #3
0
        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);
            }
        }