public JsonResult Update(SMSTemplate model) { JsonResponse json = new JsonResponse { Status = false }; string MsgError = string.Empty; string path = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["SMSTemplate"].ToString()); var result = JsonConvert.DeserializeObject <List <SMSTemplate> >(System.IO.File.ReadAllText(path)); var list = new List <SMSTemplate>(); if (result != null) { foreach (var item in result) { if (item.id == model.id) { item.title = model.title; item.message = model.message; } } json.Status = true; System.IO.File.WriteAllText(path, new JavaScriptSerializer().Serialize(result)); } json.Message = Shared.GetMsg(json.Status, json.Message); return(Json(json)); }
public async Task Handle(SubscribtionChangedEvent notification, CancellationToken cancellationToken) { var result = new SendNotificationResult(); if (notification.SubscriptionType == SubscriptionType.Email) { var link = $"{jobsOptions.Value.ServiceFullUrl}confirm?token={notification.Token}&mail={notification.Contact}"; var message = MailTemplate.SubscriptionTemplate(link); result = await emailService.SendMessage(notification.Contact, "Potwierdzenie zapisu na powiadomienia", message); } else if (notification.SubscriptionType == SubscriptionType.Sms) { var notificationText = notification.ActionType == SubscribtionChangedEvent.SubriptionChangedType.Subscribe ? SMSTemplate.SubscribeTemplate(notification.Token) : SMSTemplate.UnsubscribeTemplate(notification.Token); result = await smsService.SendAsync(notificationText, new string[] { notification.Contact }); logger.Log(LogLevel.Information, result.LogMessage); } if (!result.IsSuccessful) { logger.Log(LogLevel.Error, result.LogMessage); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { ValidationManager.Validate(this.LayoutRoot); if (!viewModel.HasValidationErrors) { SMSTemplate request = viewModel.ConvertVM <ShipTypeSMSTemplateVM, SMSTemplate>(); if (request.SysNo.HasValue) { new ShipTypeSMSTemplateFacade(CPApplication.Current.CurrentPage).Update(request, (obj, args) => { if (args.FaultsHandle()) { return; } Dialog.ResultArgs.Data = viewModel; Dialog.ResultArgs.DialogResult = DialogResultType.OK; Dialog.Close(); }); } else { new ShipTypeSMSTemplateFacade(CPApplication.Current.CurrentPage).Create(request, (obj, args) => { if (args.FaultsHandle()) { return; } Dialog.ResultArgs.Data = viewModel; Dialog.ResultArgs.DialogResult = DialogResultType.OK; Dialog.Close(); }); } } }
public JsonResult AddSMSTemplate(SMSTemplateViewModel smsTemplate) { try { int languageId = smsTemplate.LanguageId; #region Add SMS Template var men = new SMSTemplate() { CreatedBy = User.Identity.Name, CreatedOn = DateTime.Now, DefaultLanguage = smsTemplate.DefaultTemplateLanguage > 0 ? smsTemplate.DefaultTemplateLanguage : CultureHelper.GetDefaultLanguageId(), Status = smsTemplate.Status, }; _db.SMSTemplates.Add(men); _db.SaveChanges(); var menTrans = new SMSTemplateTranslation() { SMSTemplateId = men.Id, Description = smsTemplate.Description, LanguageId = languageId, IsDefault = languageId == CultureHelper.GetDefaultLanguageId(), Name = smsTemplate.Name }; _db.SMSTemplateTranslations.Add(menTrans); if (!menTrans.IsDefault) { var menTrans1 = new SMSTemplateTranslation() { SMSTemplateId = men.Id, Description = smsTemplate.Description, LanguageId = CultureHelper.GetDefaultLanguageId(), IsDefault = true, Name = smsTemplate.Name }; _db.SMSTemplateTranslations.Add(menTrans1); } _db.SaveChanges(); #endregion return(Json(smsTemplate, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.LogException(User.Identity.Name, ex, "Error While adding new SMS"); return(null); } }
/// <summary> /// 绑定数据到DataGrid控件MyDataGrid上 /// </summary> private void BindDataGrid() { //创建操作员记录数据表类实例 SMSTemplate sms = new SMSTemplate(); //获取记录数据 DataTable dt = sms.Bind(); DataView dv = new DataView(); dt.TableName = "SMSTemplate"; if (dt != null) { dv.Table = dt; if (ViewState["Condition"] != null && ViewState["Condition"].ToString() != "") { dv.RowFilter = ViewState["Condition"].ToString(); } else { dv = dt.DefaultView; } //新增ID自增值列绑定 dt.Columns.Add(new DataColumn("idno", Type.GetType("System.Int32"))); int intCountRecNum = dv.Count; //获取数据表记录数 for (int i = 0; i < intCountRecNum; i++) { dv[i]["idno"] = i + 1; } MyDataGrid.DataSource = dv; int PageCount = 0; if (intCountRecNum % MyDataGrid.PageSize == 0) { PageCount = intCountRecNum / MyDataGrid.PageSize; } else { PageCount = intCountRecNum / MyDataGrid.PageSize + 1; } if (PageCount != 0 && MyDataGrid.CurrentPageIndex >= PageCount) { MyDataGrid.CurrentPageIndex = PageCount - 1; } MyDataGrid.DataBind(); lblRecNum.Text = intCountRecNum.ToString(); //显示总记录数 ShowStats(); //显示页数信息 } }
protected void ddlTemp_SelectedIndexChanged(object sender, EventArgs e) { if (ddlTemp.SelectedIndex == 0) { txtContent.Text = ""; } else { SMSTemplate sms = new SMSTemplate(); SMSTemplateDB smsdb = new SMSTemplateDB(); smsdb = sms.ShowTemp(ddlTemp.SelectedItem.Value.ToString()); txtContent.Text = Common.CCToEmpty(smsdb.TemplateContent); } }
public virtual BizEntity.Customer.SMSTemplate Load(int sysNo) { SMSTemplate entity = null; DataCommand cmd = DataCommandManager.GetDataCommand("GetSMSTemplateBySysNo"); cmd.SetParameterValue("@SysNo", sysNo); DataSet ds = cmd.ExecuteDataSet(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; entity = DataMapper.GetEntity <SMSTemplate>(row); } return(entity); }
protected void DropDownBoxSmsTemplate_TextChanged(object sender, EventArgs e) { if (DropDownBoxSmsTemplate.Value != null) { int id = Change.ToInt(DropDownBoxSmsTemplate.Values.First()); SMSTemplate template = DB.SMSTemplates.Find(id); if (template != null) { tbxSmsText.Text = template.Content; } } else { tbxSmsText.Text = "下拉框为空"; } }
public JsonResult Create(SMSTemplate model) { JsonResponse json = new JsonResponse { Status = false }; if (ModelState.IsValid) { string path = HttpContext.Server.MapPath(ConfigurationManager.AppSettings["SMSTemplate"].ToString()); var result = JsonConvert.DeserializeObject <List <SMSTemplate> >(System.IO.File.ReadAllText(path)); if (result != null) { result.Add(new SMSTemplate { id = result.Count + 1, title = model.title, message = model.message }); } else { result = new List <SMSTemplate>(); result.Add(new SMSTemplate { id = 1, title = model.title, message = model.message }); } System.IO.File.WriteAllText(path, new JavaScriptSerializer().Serialize(result)); json.Status = true; } else { json.Status = false; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { json.Message += error.ErrorMessage + " "; } } } json.Message = Shared.GetMsg(json.Status, json.Message); return(Json(json)); }
protected virtual async Task CreateTemplateAsync(CreateOrUpdateSMSTemplateInput input) { var template = new SMSTemplate() { Name = input.Name, TemplateCode = input.TemplateCode, SmsProvider = input.SmsProvider, IsActive = input.IsActive, Items = input.Items.Select(x => new SMSTemplateItem() { DataItemName = x.DataItemName, DataItemValue = x.DataItemValue }).ToList(), }; await _smsTemplateManager.CreateAsync(template); }
public SMSTemplate LoadMsgTemplate(string ActionCode) { var data = MessageCenter.Server.MessageSenderServer.GetTemplateByActionCode(ActionCode); SMSTemplate template = new SMSTemplate(); template.SMSTemplateVariableList = new Dictionary <string, string>(); if (data != null) { foreach (var paramItem in data.GetParmaterList()) { template.SMSTemplateVariableList.Add("{" + paramItem.Name + "}", paramItem.DisplayName); } template.SMSTemplateCode = data.TemplateCode; template.SMSTemplateName = data.TemplateName; template.MsgReceiverType = data.ReceiverType; } return(template); }
/// <summary> /// 填充数据到表单文本控件,下拉框控件 /// </summary> /// <param name="IsFill"></param> private void FillDataToCtrl(bool IsFill) { DBManager db = DBManager.Instance(); SMSTemplateDB smsdb = new SMSTemplateDB(); if (IsFill) { SMSTemplate sms = new SMSTemplate(); smsdb = sms.FindTemp(Request.QueryString["Id"].ToString()); txtSMSContent.Text = Common.CCToEmpty(smsdb.TemplateContent); txtSMSTempName.Text = Common.CCToEmpty(smsdb.TemplateName); } else { smsdb = new SMSTemplateDB(); } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { //创建用户数据表操作类对象 SMSTemplate sms = new SMSTemplate(); if (ViewState["OperateStatus"].ToString() == "AddData") { string count = this.txtSMSContent.Text.Trim(); string name = this.txtSMSTempName.Text.Trim(); //增加用户数据 if (sms.AddTemp(name, count)) { Common.ShowMsg("添加成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "系统功能", "增加短信模版"); } else { return; } } if (ViewState["OperateStatus"].ToString() == "EditData") { string count = this.txtSMSContent.Text.Trim(); string name = this.txtSMSTempName.Text.Trim(); //更新用户数据 if (sms.UpdateTEmp(name, count, Request.QueryString["Id"].ToString())) { Common.ShowMsg("更新成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "系统功能", "修改短信模版"); } else { return; } } } Server.Transfer("System_SMSTemplate_View.aspx"); }
protected void btnDelete_Click(object sender, EventArgs e) { //创建用户数据表操作类对象 SMSTemplate sms = new SMSTemplate(); string Id = Request.QueryString["Id"]; //删除用户数据 if (sms.DelSMSTemp(Id)) { Common.ShowMsg("删除成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "系统功能", "删除短信模版"); } else { return; } Server.Transfer("System_SMSTemplate_View.aspx"); }
public List <SMSTemplate> GetSMSTemplateList(CurrentUser user) { var template = MessageCenter.Server.MessageSenderServer.GetTemplateList(user.MasterSysNo.GetValueOrDefault()); List <SMSTemplate> list = new List <SMSTemplate>(); Dictionary <string, string> varList = new Dictionary <string, string>(); foreach (var item in template) { SMSTemplate temp = new SMSTemplate(); temp.SMSTemplateVariableList = new Dictionary <string, string>(); foreach (var paramItem in item.GetParmaterList()) { temp.SMSTemplateVariableList.Add("{" + paramItem.Name + "}", paramItem.DisplayName); } temp.SMSTemplateCode = item.TemplateCode; temp.SMSTemplateName = item.TemplateName; temp.MsgReceiverType = item.ReceiverType; list.Add(temp); } return(list); }
protected void MyDataGrid_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Delete") { //创建用户数据表操作类对象 SMSTemplate sms = new SMSTemplate(); string id = ((Label)e.Item.Cells[1].Controls[1]).Text; //删除用户数据 if (sms.DelSMSTemp(id)) { Common.ShowMsg("删除成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "系统功能", "删除短信模版"); } Server.Transfer("System_SMSTemplate_View.aspx"); } else { string Url = "System_SMSTemplate_Edit.aspx?Id=" + ((Label)e.Item.Cells[1].Controls[1]).Text; Server.Transfer(Url); } }
/// <summary> /// 创建短信模板 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual SMSTemplate Create(SMSTemplate entity) { return ObjectFactory<SMSTemplateProcessor>.Instance.Create(entity); }
private static string RenderSMSTemplate(BookingBusiness _business, BookingAppointment appointment, string _appointmentDateString, SMSTemplate sMSTemplate) { string smsTemplateBody = ConfigurationManager.AppSettings[sMSTemplate.ToString()]; // String.Format(, appointment.ServiceName, _appointmentDateString); string messageFooter = ConfigurationManager.AppSettings["SMSFooter"]; string message = (smsTemplateBody + messageFooter); message = message.Replace("%BookingAppointment.CustomerName%", appointment.CustomerName); message = message.Replace("%BookingAppointment.CustomerEmailAddress%", appointment.CustomerEmailAddress); message = message.Replace("%BookingAppointment.CustomerPhone%", appointment.CustomerPhone); message = message.Replace("%BookingAppointment.ServiceName%", appointment.ServiceName.ToLower()); message = message.Replace("%BookingAppointment.Start%", System.DateTime.Parse(appointment.Start.DateTime).ToLocalTime().ToString("dd.MM.yyyy HH:mm")); message = message.Replace("%BookingAppointment.End%", System.DateTime.Parse(appointment.End.DateTime).ToLocalTime().ToString("dd.MM.yyyy HH:mm")); message = message.Replace("%BookingAppointment.Duration%", appointment.Duration.Minutes.ToString()); message = message.Replace("%BookingAppointment.ServiceLocation.DisplayName%", appointment.ServiceLocation.DisplayName); message = message.Replace("%BookingAppointment.ServiceLocation.LocationEmailAddress%", appointment.ServiceLocation.LocationEmailAddress); message = message.Replace("%BookingAppointment.ServiceLocation.Address.Street%", appointment.ServiceLocation.Address.Street ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Address.City%", appointment.ServiceLocation.Address.City ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Address.State%", appointment.ServiceLocation.Address.State ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Address.CountryOrRegion%", appointment.ServiceLocation.Address.CountryOrRegion ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Address.PostalCode%", appointment.ServiceLocation.Address.PostalCode ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Coordinates.Altitude%", appointment.ServiceLocation.Coordinates.Altitude.ToString() ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Coordinates.Latitude%", appointment.ServiceLocation.Coordinates.Latitude.ToString() ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Coordinates.Longitude%", appointment.ServiceLocation.Coordinates.Longitude.ToString() ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Coordinates.Accuracy%", appointment.ServiceLocation.Coordinates.Accuracy.ToString() ?? ""); message = message.Replace("%BookingAppointment.ServiceLocation.Coordinates.AltitudeAccuracy%", appointment.ServiceLocation.Coordinates.AltitudeAccuracy.ToString() ?? ""); message = message.Replace("%BookingBusiness.Address.City%", _business.Address.City); message = message.Replace("%BookingBusiness.Address.Street%", _business.Address.Street); message = message.Replace("%BookingBusiness.Address.PostalCode%", _business.Address.PostalCode); message = message.Replace("%BookingBusiness.Address.State%", _business.Address.State); message = message.Replace("%BookingBusiness.Address.CountryOrRegion%", _business.Address.CountryOrRegion); message = message.Replace("%BookingBusiness.DisplayName%", _business.DisplayName); message = message.Replace("%BookingBusiness.Email%", _business.Email); message = message.Replace("%BookingBusiness.Phone%", _business.Phone); message = message.Replace("%BookingBusiness.PublicUrl%", _business.PublicUrl); message = message.Replace("%BookingBusiness.WebSiteUrl%", _business.WebSiteUrl); message = message.Replace("\\n", Environment.NewLine); return(message); }
private static void SendSMS(ViaNettSMS viaNettSMS, BookingBusiness _business, IEnumerable <BookingAppointment> _appointments, SMSTemplate sMSTemplate) { MD5 md5 = MD5.Create(); foreach (BookingAppointment appointment in _appointments) { // Send SMS to Customer Console.WriteLine("Sending SMS to CustomerName: {0}, CustomerPhone: {1}", appointment.CustomerName, appointment.CustomerPhone); ViaNettSMS.Result result; string _appointmentDateString = DateTime.Parse(appointment.Start.DateTime).ToString("dd.MM.yyyy HH:mm"); string message = RenderSMSTemplate(_business, appointment, _appointmentDateString, sMSTemplate); try { // Send SMS through HTTP API Console.WriteLine("{0} SendingSMS: {1} {2} {3}", Date.Now.ToString(), _SMSSenderFrom, appointment.CustomerPhone, message); result = viaNettSMS.SendSMS(_SMSSenderFrom, appointment.CustomerPhone, message); //result = viaNettSMS.SendSMS(_SMSSenderFrom, "40453626", message); // Show Send SMS response if (result.Success) { Debug.WriteLine("Message successfully sent"); using (BookingEntities context = new BookingEntities()) { context.SMSLog.Add(new SMSLog { appointmentId = appointment.Id , message = message , recipientPhone = appointment.CustomerPhone , sentDate = DateTime.Now , smsIsSent = true , sentResult = "OK" , smsTemplate = sMSTemplate.ToString() , md5hash = md5.ComputeHash(Encoding.Unicode.GetBytes(appointment.Id)) }); context.SaveChanges(); } } else { using (BookingEntities context = new BookingEntities()) { context.SMSLog.Add(new SMSLog { appointmentId = appointment.Id , message = message , recipientPhone = appointment.CustomerPhone , sentDate = DateTime.Now , smsIsSent = false , sentResult = $"Received error: {result.ErrorCode} {result.ErrorMessage}" , smsTemplate = sMSTemplate.ToString() , md5hash = md5.ComputeHash(Encoding.Unicode.GetBytes(appointment.Id)) }); context.SaveChanges(); } Debug.WriteLine($"Received error: {result.ErrorCode} {result.ErrorMessage}"); } } catch (System.Net.WebException ex) { //Catch error occurred while connecting to server. Debug.WriteLine(ex.Message); } } md5.Dispose(); }
private string GetTemplate(SMSTemplate template) { return(db.Tbl_SMSTemplate.Where(x => x.ST_ID == (int)template).SingleOrDefault().ST_Name); }
/// <summary> /// 加载短信模板 /// </summary> /// <param name="sysNo"></param> /// <returns></returns> public virtual SMSTemplate Load(int sysNo) { SMSTemplate entity = new SMSTemplate(); return(entity); }
/// <summary> /// 更新短信模板 /// </summary> /// <param name="entity"></param> public virtual void Update(SMSTemplate entity) { ObjectFactory <ISMSTemplateDA> .Instance.Update(entity); }
/// <summary> /// 创建短信模板 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual SMSTemplate Create(SMSTemplate entity) { return(ObjectFactory <ISMSTemplateDA> .Instance.Create(entity)); }
public void CreateShipTypeSMSTemplate(SMSTemplate entity) { ObjectFactory <SMSTemplateService> .Instance.Create(entity); }
public async Task <SendNotificationResult> SendMultiplesAsync(IEnumerable <string> contacts, DAL.Model.Auction auction) { return(await smsService.SendAsync( SMSTemplate.NewNotification($"{jobsOptions.Value?.ServiceShortUrl}/{auction.Id}"), contacts)); }
/// <summary> /// 更新短信模板 /// </summary> /// <param name="entity"></param> public virtual void Update(SMSTemplate entity) { ObjectFactory<SMSTemplateProcessor>.Instance.Update(entity); }
/// <summary> /// 更新 SMSTemplate /// </summary> /// <param name="request"></param> /// <param name="callback"></param> public void Update(SMSTemplate request, EventHandler <RestClientEventArgs <dynamic> > callback) { string relativeUrl = "/CustomerService/ShipTypeSMSTemplate/Update"; restClient.Update(relativeUrl, request, callback); }
public string SendServiceable(string receptor, string token, string token2, string token3, string token20, SMSTemplate template) { try { var api = new KavenegarApi(apikey); SendResult result = api.VerifyLookup(receptor, token, token2, token3, "", token20, GetTemplate(template), Kavenegar.Models.Enums.VerifyLookupType.Sms); InsertIntoDB(result, token, token2, token3); return(result.StatusText); } catch (ApiException ex) { return(ex.Message); } catch (HttpException ex) { return(ex.Message); } catch (Exception ex) { return(ex.Message); } }
public void UpdateShipTypeSMSTemplate(SMSTemplate query) { ObjectFactory <SMSTemplateService> .Instance.Update(query); }