/// <summary> /// 新增一个类型 /// </summary> /// <param name="at"></param> public void AddAdviceType(AdviceType at) { //at.ID = Helper.CreateNewID(); at.CreateDate = DateTime.Now; Assistant.Insert(at); SaveToConfigFile(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { adviceType = new AdviceTypeHelper().GetAdviceType(AdviceTypeID); } }
public override IMessage Invoke(IMessage msg) { #region 获取AdviceType AdviceType type = AdviceType.None; IMethodCallMessage call = (IMethodCallMessage)msg; foreach (Attribute attr in call.MethodBase.GetCustomAttributes(false)) { MethodAopAdviceAttribute mehodAopAttr = attr as MethodAopAdviceAttribute; if (mehodAopAttr != null) { type = mehodAopAttr.AdviceType; break; } } #endregion IMessage message; if (type == AdviceType.Before || type == AdviceType.Around) { this.PreProcess(msg); Console.WriteLine("::Before Or Around"); } message = this.Proessed(msg); if (type == AdviceType.After || type == AdviceType.Around) { this.PostProcess(msg, message); Console.WriteLine("::After Or Around"); } return(message); }
/// <summary> /// 发送处理结果到提交者(用户)邮箱 /// </summary> /// <param name="advice"></param> /// <param name="reply"></param> /// <param name="adviceType"></param> /// <returns></returns> public bool SendResultMailToAdvicer(Advice advice, AdviceReply reply, AdviceType adviceType, AdviceEmailConfigInfo info) { try { if (adviceType == null) { adviceType = AdviceTypeHelper.GetAdviceType(advice.TypeID); } string userEmail = advice.Email; MailHelper mailHelper = GetMailHelper(adviceType); string siteFullName = GeneralConfigs.GetConfig().SiteFullName; //string body = "尊敬的{0}先生/女士:您好!<br><br>"; //body += "我们于{1}接收到您的反馈信息({2}),有关部门已做出处理,现答复如下:<br><br>"; //body += "{3}<br><br>"; //body += "感谢您的参与!<br>"; //body += "{4}"; //body = string.Format(body, advice.Name, advice.CreateDate.ToLongDateString(), advice.Title, reply.Content, GeneralConfigs.GetConfig().SiteFullName+ "|" + SiteConfigs.GetConfig().RootUrl); info.EmailContent = info.EmailContent.Replace("{UserName}", advice.Name).Replace("{DateTime}", advice.CreateDate.ToLongDateString()).Replace("{Title}", advice.Title).Replace("{EmailContent}", reply.Content).Replace("{SiteFullName}", GeneralConfigs.GetConfig().SiteFullName); string subject = info.EmailTitle.Replace("{SiteTitle}", GeneralConfigs.GetConfig().SiteTitle.Trim().Replace("\n", "")).Replace("{AdviceTitle}", advice.Title); string priority = "Normal";//过期提示,优先级别 mailHelper.Send(userEmail, mailHelper.AdminEmail, subject, info.EmailContent, priority); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 发送通知邮件给办理人(带办理备注和优先级) /// </summary> /// <param name="id">反馈实体ID</param> /// <param name="replyUserID"></param> /// <param name="adviceType"></param> /// <param name="remark">办理备注</param> /// <param name="priority">优先级</param> public void SendHandleMail(string id, string replyUserID, AdviceType adviceType, string remark, string priority, AdviceEmailConfigInfo info) { Advice a = GetAdvice(id);; string userEmail = AccountHelper.GetAccount(replyUserID, new string[] { "Email", "ID" }).Email; MailHelper mailHelper = GetMailHelper(adviceType); string body = BuildHandleMail(id, remark, info); string subject = ""; string must = "";//必须回复 //priority = "Low";//过期提示,优先级别 if (a.MustHandle >= 1) { must = "此信息为必须回复;"; int days = GetWorkingDays(a.CreateDate); if (days >= adviceType.RemindDays) { priority = "High"; } subject = must + " " + info.EmailTitle.Replace("{EmailTitle}", "#" + a.SN.ToString()); } else { subject = " " + info.EmailTitle.Replace("{EmailTitle}", "#" + a.SN.ToString()); } mailHelper.Send(userEmail, mailHelper.AdminEmail, subject, body, priority); }
/// <summary> /// 邮件配置信息 /// </summary> /// <param name="adviceType"></param> public MailHelper GetMailHelper(AdviceType adviceType) { MailHelper mailHelper = new MailHelper(); //取得邮件服务器信息 if (adviceType.UseSystemMail == 0) { GeneralConfigInfo ci = GeneralConfigs.GetConfig(); if (ci != null) { mailHelper.SmtpServer = ci.SysMailServer; mailHelper.AdminEmail = ci.SystemMail; mailHelper.UserName = ci.SysMailUser; mailHelper.Password = ci.SysMailPassword; mailHelper.PopServer = ci.SysPopServer; } } else if (adviceType.UseSystemMail == 1) { mailHelper.SmtpServer = adviceType.MailSMTPServer; mailHelper.AdminEmail = adviceType.MailAddress; mailHelper.UserName = adviceType.MailUser; mailHelper.Password = adviceType.MailPassword; mailHelper.PopServer = adviceType.POPServer; } return(mailHelper); }
/// <summary> /// 界面加载 /// </summary> void InitializePage() { ContentModelCollection cmc = new ContentModelCollection(); ContentModelCollection orcmc = ModelHelper.GetAllContentModel(); foreach (We7.Model.Core.ContentModel c in orcmc) { if (c.Type == ModelType.ADVICE) { cmc.Add(c); } } ddlAdviceType.DataSource = cmc; ddlAdviceType.DataTextField = "label"; ddlAdviceType.DataValueField = "name"; ddlAdviceType.DataBind(); ddlAdviceType.Items.Insert(0, new ListItem("请选择", "")); adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID); if (adviceType != null) { ConfigNameTextBox.Text = adviceType.Title.ToString(); ddlAdviceType.SelectedValue = adviceType.ModelName; } }
/// <summary> /// 删除一个类型 /// </summary> /// <param name="id"></param> public void DeleteAdviceType(string id) { AdviceType at = GetAdviceType(id); Assistant.Delete(at); SaveToConfigFile(); }
/// <summary> /// 转办 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ToOtherButton_Click(object sender, EventArgs e) { UpdateAdviceTag(); if (OperationInfo(AdviceState.WaitHandle)) { AdviceType adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID); if (adviceType != null) { if (adviceType.ParticipateMode == (int)AdviceParticipateMode.Mail || adviceType.ParticipateMode == (int)AdviceParticipateMode.All) { List <string> contents = AccountHelper.GetPermissionContents(AccountID, AdviceTypeID); if (contents.Contains("Advice.Admin") || We7Helper.IsEmptyID(AccountID)) { ToOtherReplyUser(); } } } Messages.ShowMessage(" :) 转办成功!"); //记录日志 string content = string.Format("转办了留言反馈:“{0}”的详细信息", AdviceID); AddLog("留言反馈详细信息", content); BindReplayList(); actionTable.Visible = false; } }
public ActionResult DeleteConfirmed(int id) { AdviceType adviceType = db.AdviceTypes.Find(id); db.AdviceTypes.Remove(adviceType); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// 更新一个留言类别 /// </summary> /// <param name="adviceType">留言类别实体</param> public void UpdateAdviceType(AdviceType adviceType) { if (adviceType != null) { Assistant.Update(adviceType); SaveToConfigFile(); } }
/// <summary> /// 更新一个留言类别 /// </summary> /// <param name="adviceType">留言类别实体</param> /// <param name="fields">要更新的字段集合</param> public void UpdateAdviceType(AdviceType adviceType, string[] fields) { if (adviceType != null) { Assistant.Update(adviceType, fields); SaveToConfigFile(); } }
public ActionResult Edit([Bind(Include = "AdviceTypeID,Type")] AdviceType adviceType) { if (ModelState.IsValid) { db.Entry(adviceType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adviceType)); }
public ActionResult Create([Bind(Include = "AdviceTypeID,Type")] AdviceType adviceType) { if (ModelState.IsValid) { db.AdviceTypes.Add(adviceType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adviceType)); }
/// <summary> /// 更新反馈类型 /// </summary> /// <param name="id">id类型ID</param> /// <param name="adviceXml">类型的xml的更新</param> public void UpdateAdviceType(string id, string modelName) { AdviceType adviceType = GetAdviceType(id); if (adviceType != null) { adviceType.Updated = DateTime.Now; adviceType.ModelName = modelName; Assistant.Update(adviceType, new string[] { "ModelName", "Updated" }); } }
/// <summary> /// 反馈模型名称 /// </summary> void SetTitleName() { if (AdviceTypeID != null && AdviceTypeID != "") { AdviceType a = AdviceTypeHelper.GetAdviceType(AdviceTypeID); if (a != null) { NameLabel.Text = a.Title + "列表"; } } }
public void GetNamesTest() { string aspectXml = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\ExinScada.Aop\TestXml\bin\Debug\configuration\aspect.xml"; // TODO: 初始化为适当的值 string aspectName = "LogAOP"; // TODO: 初始化为适当的值 AdviceType type = AdviceType.After; // TODO: 初始化为适当的值 string[] expected = null; // TODO: 初始化为适当的值 string[] actual; actual = ConfigurationXml.GetNames(aspectXml, aspectName, type); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// 取得当前反馈的模型名称 /// </summary> /// <returns></returns> protected virtual string GetModelName() { if (String.IsNullOrEmpty(ModelName)) { if (String.IsNullOrEmpty(AdviceTypeID)) { throw new Exception("反馈类型为空"); } AdviceType adviceType = HelperFactory.GetHelper <AdviceTypeHelper>().GetAdviceType(AdviceTypeID); ModelName = adviceType != null ? adviceType.ModelName : String.Empty; } return(ModelName); }
// GET: AdviceTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AdviceType adviceType = db.AdviceTypes.Find(id); if (adviceType == null) { return(HttpNotFound()); } return(View(adviceType)); }
/// <summary> /// 更新时初始化页面数据 /// </summary> void InitializePage() { // 问题hideExtraProperties AdviceType adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID); if (adviceType != null) { AdviceNameText.Text = adviceType.Title; RemarkText.Text = adviceType.Description; StartTimeText.Text = adviceType.CreateDate.ToString(); AdviceCreatedText.Text = GetAccountNameText(adviceType.AccountID); } }
/// <summary> /// 取得反馈类型名称 /// </summary> /// <param name="typeID"></param> /// <returns></returns> protected string GetAdviceTypeName(string typeID) { if (String.IsNullOrEmpty(typeID)) { return("当前类型不存在"); } if (!dicTypeNames.ContainsKey(typeID)) { AdviceType type = HelperFactory.GetHelper <AdviceTypeHelper>().GetAdviceType(typeID); dicTypeNames.Add(typeID, typeID != null ? type.Title : String.Empty); } return(dicTypeNames[typeID]); }
string GetChannelProcessLayerNO(string id) { string adviceTypeID = AdviceHelper.GetAdvice(id).TypeID; AdviceType adviceType = AdviceTypeHelper.GetAdviceType(adviceTypeID); if (adviceType.FlowSeries != null) { return(adviceType.FlowSeries.ToString()); } else { return(""); } }
/// <summary> /// 获取邮件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ReceiveBtn_Click(object sender, EventArgs e) { if (AdviceTypeID != null && AdviceTypeID != "") { AdviceType adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID); //try //{ MailHelper mailHelper = AdviceHelper.GetMailHelper(adviceType); string typeName = typeof(AdviceHelper).ToString(); bool delete = false; if (DeleteEmailTextBox.Text == "1") { delete = true; } string stateText = adviceType.StateText; MailResult result = mailHelper.ReceiveMail("We7.CMS.Utils.dll", typeName, "HandleReceiveMail", delete, stateText); LoadAdvices(); string errorRoot = "<a href=\"/admin/Advice/AdviceProcessManage.aspx\" >反馈监控管理</a>"; string message = ""; if (result.Count > 0) { message = "您共获取到了" + result.Count + "封邮件"; } else { message = "Sorry,没有邮件可以获取..."; } if (result.Success > 0) { message += ",并成功受理了" + result.Success + "条反馈信息。"; } else if (result.Count > 0 && result.Success == 0) { message += ",有" + result.Count + "封回复邮件存在错误信息,不可直接对应回复到反馈信息,请到" + errorRoot + " <邮件回复>下进行处理。"; } Messages.ShowMessage(message); //} //catch (Exception ex) //{ // Messages.ShowMessage("系统繁忙,请稍后在试!错误信息:"+ex.Message); //} } else { Messages.ShowMessage("请先选择反馈模型后再获取回复邮件!"); } }
/// <summary> /// 发送通知邮件给系统管理员"新反馈邮件通知受理人" /// </summary> /// <param name="adviceID">咨询投诉ID</param> public void SendNotifyMail(string adviceID) { //得到反馈类型 Advice advice = GetAdvice(adviceID); AdviceType adviceType = AdviceTypeHelper.GetAdviceType(advice.TypeID); if (advice != null) { if (adviceType.MailMode != null && adviceType.MailMode != "") { string[] mailMode = adviceType.MailMode.Split(new string[] { "0" }, StringSplitOptions.None); //判断是否需要发送邮件 for (int i = 0; i < mailMode.Length; i++) { if (mailMode[i].Trim() != "") { if (Convert.ToInt32(mailMode[i]) == (int)MailMode.MailNotify) { AdviceEmailConfigs adviceEmailConfigs = new AdviceEmailConfigs(); AdviceEmailConfigInfo info = adviceEmailConfigs["Accept"]; //取得所有受理人 string content = "Advice.Accept"; List <string> receivers = GetAllReceivers(adviceType.ID, content); //转化为接收人列表 string toEmail = GetEmailByAccountID(receivers); MailHelper mailHelper = GetMailHelper(adviceType); string body = BuildSingleMailBody(advice.ID, "", info); string must = ""; //必须回复 string priority = "Low"; //过期提示,优先级别 if (advice.MustHandle >= 1) { must = "<b>此信息为必须回复;</b>"; int days = GetWorkingDays(advice.CreateDate); if (days >= adviceType.RemindDays) { priority = "High"; } } string subject = info.EmailTitle.Replace("{EmailTitle}", advice.Title) + must; //发送邮件 mailHelper.Send(toEmail, mailHelper.AdminEmail, subject, body, priority); } } } } } }
protected void SubmitButton_Click(object sender, EventArgs e) { AdviceType adviceType = new AdviceType(); adviceType.CreateDate = DateTime.Now; int index; if (int.TryParse(SortNumber.Text, out index)) { adviceType.Index = index; } adviceType.Title = AdviceNameText.Text.Trim(); adviceType.Description = RemarkText.Text.Trim(); if (string.IsNullOrEmpty(adviceType.Title)) { Messages.ShowError("模型名称不能为空"); return; } if (AdviceTypeID == null || AdviceTypeID == "") // 新建 { adviceType.AccountID = AccountID; string adviceTypeID = We7Helper.CreateNewID(); adviceType.ID = adviceTypeID; AdviceTypeHelper.AddAdviceType(adviceType); } else // 修改 { adviceType.ID = AdviceTypeID; AdviceTypeHelper.UpdateAdviceType(adviceType); Messages.ShowMessage("" + AdviceNameText.Text + " 模型修改成功!!"); } //记录日志 string content = string.Format("编辑了模型“{0}”的信息", adviceType.Title); AddLog("编辑反馈模型", content); if (AdviceTypeID == null || AdviceTypeID == "") { string rawurl = We7Helper.AddParamToUrl(Request.RawUrl, "saved", "1"); rawurl = We7Helper.RemoveParamFromUrl(rawurl, "adviceTypeID"); rawurl = We7Helper.AddParamToUrl(rawurl, "adviceTypeID", We7Helper.GUIDToFormatString(adviceType.ID)); Response.Redirect(rawurl); } }
/// <summary> /// 操作按钮状态初始化 /// </summary> private void InitializeButtons() { bool canAccept = false; //反馈受理 bool canAdmin = false; //反馈管理 bool canHandle = false; //反馈办理 bool canRead = false; //查看 bool canCheck = false; //审核 //模型不为空,并且是用户登陆时验证是否具有权限 if (AdviceTypeID != null && !We7Helper.IsEmptyID(AccountID)) { List <string> contents = AccountHelper.GetPermissionContents(AccountID, AdviceTypeID); canAccept = contents.Contains("Advice.Accept"); canAdmin = contents.Contains("Advice.Admin"); canHandle = contents.Contains("Advice.Handle"); canRead = contents.Contains("Advice.Read"); //canAccept = AccountHelper.HavePermission(AccountID, AdviceTypeID, "Advice.Accept"); //canAdmin = AccountHelper.HavePermission(AccountID, AdviceTypeID, "Advice.Admin"); //canHandle = AccountHelper.HavePermission(AccountID, AdviceTypeID, "Advice.Handle"); //canRead = AccountHelper.HavePermission(AccountID, AdviceTypeID, "Advice.Read"); AdviceType adviceType = AdviceTypeHelper.GetAdviceType(AdviceTypeID); string stateText = adviceType.StateText; if (adviceType.FlowSeries > 0) { canCheck = true; } if (adviceType.ParticipateMode == (int)AdviceParticipateMode.Mail) { ReceiveHyperLink.Visible = false; } } else { canAccept = canAdmin = canCheck = canHandle = true; } DeleteHyperLink.Visible = canAdmin; //删除 HastenHyperLink.Visible = canAdmin; //催办 MustHandleHyperLink.Visible = canAccept || canAdmin; //必须办理 ReceiveHyperLink.Visible = canAdmin; //接收反馈回复邮件 DisplayHyperLink.Visible = canAdmin; //前台显示 UndisplayHyperLink.Visible = canAdmin; //前台不显示 UnControlDisplayHyperLink.Visible = canAdmin; //前台不控制 }
public void TestRetryRequeueAdvice() { const bool expectedRetryOnFail = true; const AdviceType expectedAdviceType = AdviceType.RetryRequeue; const string expectedExceptionType = "System.Data.SqlClient.SqlException"; var expectedTimeoutException = typeof(SqlException); var objectFactory = ParserTestsHelper.LoadConfig(ConfigConventionPrefix, 1); var timedErrorAdvice = objectFactory.GetObject <ErrorAdvice>("advice2"); Assert.NotNull(timedErrorAdvice); Assert.AreEqual(expectedRetryOnFail, timedErrorAdvice.RetryOnFail); Assert.AreEqual(expectedAdviceType, timedErrorAdvice.AdviceType); Assert.AreEqual(expectedExceptionType, timedErrorAdvice.ExceptionType); Assert.AreEqual(expectedTimeoutException, timedErrorAdvice.GetExceptionType()); }
/// <summary> /// 发送通知邮件给办理人(带办理备注) /// </summary> /// <param name="list">反馈信息ID集合</param> /// <param name="replyUserID"></param> /// <param name="adviceTypeID"></param> /// <param name="remark">办理备注</remark> /// <param name="priority">邮件优先级</remark> public void SendMailToHandler(List <string> list, string replyUserID, string adviceTypeID, string remark, string priority) { AdviceType adviceType = AdviceTypeHelper.GetAdviceType(adviceTypeID); string tmpMailMode = adviceType.MailMode; if (tmpMailMode == null || tmpMailMode == "") { return; } string[] mailMode = tmpMailMode.Split(new string[] { "0" }, StringSplitOptions.None); for (int i = 0; i < mailMode.Length; i++) { AdviceEmailConfigs adviceEmailConfigs = new AdviceEmailConfigs(); AdviceEmailConfigInfo info = adviceEmailConfigs["Handle"]; //判断是否需要发送邮件 if (Convert.ToInt32("0" + mailMode[i]) == (int)MailMode.MailHyperLink) { //发送链接 if (replyUserID.Trim() != "") { string userEmail = AccountHelper.GetAccount(replyUserID, new string[] { "Email", "ID" }).Email; Dictionary <string, string> dictionary = GetAdviceIDAndHtml(list); MailHelper mailHelper = GetMailHelper(adviceType); StringBuilder sbBody = new StringBuilder(""); if (!string.IsNullOrEmpty(remark)) { sbBody.Append("办理备注:<br/>"); sbBody.Append(remark + "<br/>"); } sbBody.Append(BuildEmailBody(dictionary, info)); string subject = info.EmailTitle.Replace("{EmailTitle}", "数量:" + dictionary.Count.ToString()); mailHelper.Send(userEmail, mailHelper.AdminEmail, subject, sbBody.ToString(), priority); } } else if (Convert.ToInt32("0" + mailMode[i]) == (int)MailMode.HandleByMail) { //发送直接办理邮件 foreach (string id in list) { SendHandleMail(id, replyUserID, adviceType, remark, priority, info); //等待几秒 } } } }
/// <summary> /// 初始化页面信息 /// </summary> void LoadAdvices() { AdviceUPager.PageIndex = PageNumber; AdviceUPager.ItemCount = AdviceHelper.QueryAdviceCountByAll(CurrentQuery); AdviceUPager.UrlFormat = We7Helper.AddParamToUrl(Request.RawUrl.Replace("{", "{{").Replace("}", "}}"), Keys.QRYSTR_PAGEINDEX, "{0}"); AdviceUPager.PrefixText = "共 " + AdviceUPager.MaxPages + " 页 · 第 " + AdviceUPager.PageIndex + " 页 · "; List <Advice> list = new List <Advice>(); list = AdviceHelper.GetAdviceByQuery(CurrentQuery, AdviceUPager.Begin - 1, AdviceUPager.Count); AdviceType adviceType = new AdviceType(); foreach (Advice a in list) { if (a.MustHandle > 1) { HasMustHandle = true; } if (a.TypeID != null && a.TypeID != "") { adviceType = AdviceTypeHelper.GetAdviceType(a.TypeID); if (adviceType != null) { a.TypeTitle = adviceType.Title; } } if (a.UserID != null && a.UserID.Length > 0) { a.Name = AccountHelper.GetAccount(a.UserID, new string[] { "LastName" }).LastName; } if (a.Name == null || a.Name == "") { a.Name = "匿名用户"; } a.TimeNote = GetTimeNote(a.CreateDate); a.AlertNote = GetAlertNote(a.ToHandleTime, adviceType.RemindDays, a.MustHandle); } AdviceGridView.DataSource = list; AdviceGridView.DataBind(); BuildStateLinks();//刷新状态统计栏 }
void DeleteTypeList(string[] ids) { List <Advice> list = new List <Advice>(); string aTitle = ""; foreach (string id in ids) { list = AdviceHelper.GetAdvices(id); foreach (Advice a in list) { AdviceHelper.DeleteAdvice(a.ID); aTitle += String.Format("{0};", a.Title); } } //记录日志 string content = string.Format("删除了{0}个反馈模型:“{1}”", ids.Length.ToString(), aTitle); AddLog("反馈模型管理", content); string titles = ""; List <string> listString = new List <string>(); foreach (string id in ids) { AdviceType at = AdviceTypeHelper.GetAdviceType(id); AdviceTypeHelper.DeleteAdviceType(id); titles += String.Format("{0};", at.Title); string menuName = at.Title + "管理"; We7.CMS.Common.MenuItem menuItem = MenuHelper.GetMenuItemByTitle(menuName); if (menuItem != null) { listString.Add(menuItem.ID); } } if (listString != null) { MenuHelper.DeleteMenuItem(listString); } //记录日志 string atContent = string.Format("删除了{0}个反馈模型:“{1}”", ids.Length.ToString(), titles); AddLog("反馈模型管理", atContent); }
public AdviceRequestedEventArgs(AdviceType type) { Type = type; }