/// <summary> /// 构造验证邮件链接 /// </summary> /// <param name="step"></param> /// <returns></returns> private string buldValidateEmail(MessageStep step, string email, string code, out int expiredTime) { string url = LoadSettingsByKeys(Settings.ValidateEmailLink).Value; //var user = DataOperateBasic<Base_User>.Get().GetModel(receiveId); string sourceData = step.ToString() + "#" + email + "#" + code; //处理时解密校验 string encryptData = DesTool.DesEncrypt(sourceData); expiredTime = 0; //构造链接 switch (step) { case MessageStep.RegisterActive: expiredTime = LoadSettingsByKeys(Settings.RegisterActiveUrlValidity).Value.ToInt32Req() * 60; break; case MessageStep.CertificationValid: expiredTime = LoadSettingsByKeys(Settings.CertificationValidTime).Value.ToInt32Req(); break; case MessageStep.FindPwd: expiredTime = LoadSettingsByKeys(Settings.FindPwdUrlValidity).Value.ToInt32Req(); break; default: throw new Exception("该消息类型不支持生成Email链接类邮件"); } string strLink = string.Format("{0}?code={1}", url, encryptData); return(strLink); }
/// <summary> /// 验证码校验 /// 如果是邮件链接,步骤/接收人/邮箱无须传入 /// 如果是验证码,则接收人和邮箱二者必须传入一个 /// </summary> /// <param name="code"></param> /// <param name="receiveId"></param> /// <param name="email"></param> /// <returns></returns> private Result <Msg_EmailValidate> ValidateEmailCode(string code, MessageStep step, long receiveId = 0, string email = "") { Result <Msg_EmailValidate> result = new Result <Msg_EmailValidate>(); try { string strStep = step.ToString(); //链接里的验证码校验 if (receiveId == 0 && string.IsNullOrEmpty(email)) { //解密校验 string sourceData = DesTool.DesDecrypt(code); IList <string> decryptData = sourceData.SplitString("#"); strStep = decryptData[0]; email = decryptData[1]; code = decryptData[2]; } var model = DataOperateMsg <Msg_EmailValidate> .Get().Single(i => (i.ReceiveId == receiveId || i.ReceiveEmail == email) && i.Code == code && i.ValidateType == strStep); if (model == null) { throw new Exception("验证码错误"); } else { if (model.State == ValCodeState.Used.ToString()) { throw new Exception("验证码已经使用过"); } if (model.ExpiredTime < DateTime.Now) { throw new Exception("验证码已过期"); } //更新验证码 model.State = ValCodeState.Used.ToString(); DataOperateMsg <Msg_EmailValidate> .Get().Update(model); result.Data = model; result.Flag = EResultFlag.Success; } } catch (Exception ex) { result.Data = null; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "ValidateEmailCode"); } return(result); }
public void MyTestMethod2() { LoggerHandler.WriteToLog("Start MyTestMethod1NUnit"); //1 LoginPageStep.SignIn(user2.Email, user2.Password); //2 InBoxPageStep.ChooseSettings(); //4 SettingPageStep.ForwardMail(); //5 ForwardPageStep.AddForwordingAddress(user3.Email); //6 InBoxPageStep.SignOutAccount(); LoginPageStep.SignIn(user3.Email, user3.Password); //7 InBoxPageStep.ClickOnLinkInMail("*****@*****.**"); MessageStep.ConfirmForwarding(); //8 InBoxPageStep.SignOutAccount(); LoginPageStep.SignIn(user2.Email, user2.Password); //9,10 InBoxPageStep.ChooseSettings(); SettingPageStep.ForwardMail(); ForwardPageStep.SaveRBChange(); //11,12 ForwardPageStep.SetFilterSettings(user1.Email); //13 InBoxPageStep.SignOutAccount(); LoginPageStep.SignIn(user1.Email, user1.Password); //15 InBoxPageStep.SendMassage(user2.Email, "Test3", "Hello"); //14 InBoxPageStep.SendMassageWithAttach(user2.Email, "Test4", "File", Resource1.PathToFile); //16 InBoxPageStep.SignOutAccount(); LoginPageStep.SignIn(user2.Email, user2.Password); //asssert Assert.IsTrue(TrashPageStep.CheckLetterInTrash(user1.Email, "Test4")); //Assert.IsTrue(ImportantPageStep.CheckLetterInImportant(user1.Email, "Test4", "Test3")); Assert.IsTrue(InBoxPageStep.CheckLetter(user1.Email, "Test3")); InBoxPageStep.SignOutAccount(); LoginPageStep.SignIn(user3.Email, user3.Password); Assert.IsTrue(InBoxPageStep.CheckLetter(user1.Email, "Test3")); LoggerHandler.WriteToLog("Finish MyTestMethod1NUnit"); }
/// <summary> /// 验证码校验,接收人和电话二者需要传入一个 /// </summary> /// <param name="code"></param> /// <param name="receiveId"></param> /// <param name="phone"></param> /// <returns></returns> public Result <Msg_SMSValidate> ValidateSMSCode(string code, MessageStep step, string phone, long receiveId = -1) { Result <Msg_SMSValidate> result = new Result <Msg_SMSValidate>(); try { string strStep = step.ToString(); var model = DataOperateMsg <Msg_SMSValidate> .Get().Single(i => (i.ReceiveId == receiveId || i.ReceivePhone == phone) && i.Code == code && i.ValidateType == strStep); if (model == null) { throw new Exception("验证码错误"); } else { if (model.State == ValCodeState.Used.ToString()) { throw new Exception("验证码已经使用过"); } if (model.ExpiredTime < DateTime.Now) { throw new Exception("验证码已过期"); } //更新验证码 model.State = ValCodeState.Used.ToString(); DataOperateMsg <Msg_SMSValidate> .Get().Update(model); result.Data = model; result.Flag = EResultFlag.Success; } } catch (Exception ex) { result.Data = null; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "ValidateSMSCode"); } return(result); }
/// <summary> /// 短信验证码 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddSMSValCode(string phone, MessageStep step, Dictionary <string, string> parameters) { return(base.Channel.AddSMSValCode(phone, step, parameters)); }
private void CreateTextPoll() { MessageStep msgStep = new MessageStep(); int CurrentStep = base.Intent.GetIntExtra("CurrentStep", 1); msgStep.StepType = MessageStep.StepTypes.Polling; PollingStep pollStep = new PollingStep(); pollStep.PollingQuestion = txtPollMessage.Text; pollStep.PollingAnswer1 = txtPollOption1.Text; pollStep.PollingAnswer2 = txtPollOption2.Text; pollStep.PollingAnswer3 = txtPollOption3.Text; pollStep.PollingAnswer4 = txtPollOption4.Text; if (CurrentStep > ComposeMessageMainUtil.msgSteps.Count) { msgStep.StepNumber = ComposeMessageMainUtil.msgSteps.Count + 1; ComposeMessageMainUtil.msgSteps.Add(msgStep); } else { msgStep.StepNumber = CurrentStep; ComposeMessageMainUtil.msgSteps [CurrentStep - 1] = msgStep; } pollStep.StepNumber = msgStep.StepNumber; if (ComposeMessageMainUtil.pollSteps != null) { ComposeMessageMainUtil.pollSteps [pollStep.StepNumber - 1] = pollStep; } else { ComposeMessageMainUtil.pollSteps = new PollingStep[6]; ComposeMessageMainUtil.pollSteps [0] = new PollingStep(); ComposeMessageMainUtil.pollSteps [1] = new PollingStep(); ComposeMessageMainUtil.pollSteps [2] = new PollingStep(); ComposeMessageMainUtil.pollSteps [3] = new PollingStep(); ComposeMessageMainUtil.pollSteps [4] = new PollingStep(); ComposeMessageMainUtil.pollSteps [5] = new PollingStep(); ComposeMessageMainUtil.pollSteps [pollStep.StepNumber - 1] = pollStep; } //if (CurrentStep == 1) { StartActivity(typeof(ComposeMessageMainActivity)); Finish(); //} else { // Finish (); //} }
/// <summary> /// 消息发送通用方法 /// </summary> /// <param name="sendId"></param> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <param name="linkURL"></param> /// <returns></returns> public async void SendMsg(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, Dictionary <string, string> parameters, string linkURL = "") { await Task.Run(() => { Result <int> result = new Result <int>(); int rows = 0; //try //{ using (MsgDataContext db = new MsgDataContext()) { //parameters.Add("Phone", LoadSettingsByKeys(Settings.WebPhone).Value); //parameters.Add("WebURL", LoadSettingsByKeys(Settings.WebUrl).Value); //查询消息环节配置 var section = db.Msg_MessageSection.FirstOrDefault(i => i.IsConfirm && i.IsEnable && i.Name == step.ToString()); if (section != null) { var types = section.MsgTypes.SplitString(","); foreach (var item in types) { var type = item.ToEnumReq <MessageType>(); switch (type) { case MessageType.Message: rows += AddMessage(sendId, sendCompanyId, receiveId, receiveCompanyId, step, string.Empty, parameters, linkURL).Data; break; //case MessageType.Email: // rows += AddEmail(sendId, sendCompanyId, receiveId, receiveCompanyId, step, parameters).Data; // break; //case MessageType.SMS: // rows += AddSMS(sendId, sendCompanyId, receiveId, receiveCompanyId, step, parameters).Data; // break; default: break; } } result.Data = rows; result.Flag = EResultFlag.Success; } } // else // { // throw new Exception("未查询到消息环节配置"); // } // } //} //catch (Exception ex) //{ // result.Data = -1; // result.Flag = EResultFlag.Failure; // result.Exception = new ExceptionEx(ex, "SendMsg"); //} }); }
public static MessageStepDB ConvertFromMessageStep(MessageStep item) { MessageStepDB toReturn = new MessageStepDB (); toReturn.ContentPackItemID = item.ContentPackItemID; toReturn.Errors = item.Errors; toReturn.MessageID = item.MessageID; toReturn.MessageText = item.MessageText; toReturn.StepID = item.StepID; toReturn.StepNumber = item.StepNumber; toReturn.StepType = item.StepType; return toReturn; }
/// <summary> /// 短信验证码 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddSMSValCode(string phone, MessageStep step, Dictionary <string, string> parameters) { //生成验证码 string code = ConstString.CreateRandomNum(ConstString.RANDOMNUMCOUNT); parameters.Add("Code", code); Result <int> result = new Result <int>(); try { //查找模板 var templete = DataOperateMsg <Msg_SMSTemplete> .Get().Single(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { Msg_SMS model = new Msg_SMS(); string con = templete.TemplateCon; if (parameters != null && parameters.Any()) { //替换内容参数 foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); } } var receive = DataOperateBasic <Base_User> .Get().Single(i => i.Phone == phone); long receiveId = 0; if (receive != null && receive.Id > 0) { receiveId = receive.Id; } model.ReceivePhone = phone; model.ReceiveId = receiveId; model.SendeCompanyId = 0; model.ReceiveCompanyId = 0; model.SenderId = 0; model.SenderPhone = ""; model.SenderTime = null; model.SmsCon = con; model.State = false; model.SubmissionTime = DateTime.Now; model.Step = step.ToString(); model.TemplateId = templete.Id; model.ServerNo = templete.ServerNo; model.Params = UtilitySendMessage.CreateSmsParam(parameters).Data; model.SignName = templete.SignName; var splitTime = (LoadSettingsByKeys(Settings.SendRegisterCodeTime)); //验证是否频繁发送 var last = DataOperateMsg <Msg_SMSValidate> .Get().GetList(i => i.ReceivePhone == phone).OrderByDescending(i => i.Id).FirstOrDefault(); if (last != null && (DateTime.Now - last.RecordTime).TotalSeconds < splitTime.Value.ToInt32Req()) { throw new Exception("不能频繁发送验证码"); } var rows = DataOperateMsg <Msg_SMS> .Get().Add(model); //添加验证码数据 Msg_SMSValidate valModel = new Msg_SMSValidate(); valModel.Code = code; valModel.SMSId = model.Id; valModel.ReceivePhone = model.ReceivePhone; valModel.ReceiveId = model.ReceiveId; valModel.SendId = model.SenderId; valModel.SendTime = model.SubmissionTime; valModel.State = ValCodeState.UNUse.ToString(); valModel.ValidateType = step.ToString(); var seconds = LoadSettingsByKeys(Settings.SMSCodeDuration).Value.ToInt32Req(); valModel.ExpiredTime = DateTime.Now.AddSeconds(seconds); rows = DataOperateMsg <Msg_SMSValidate> .Get().Add(valModel); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(AdminModule.SMSHistory.GetText(), SystemRight.Add.GetText(), "新增短信验证码:" + model.Id + ":" + model.SmsCon); } else { throw new Exception("未查找到对应短信模板"); } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddSMSValCode"); } return(result); }
/// <summary> /// 验证邮件验证码 /// </summary> /// <param name="code"></param> /// <param name="step"></param> /// <param name="email"></param> /// <param name="receiveId"></param> /// <returns></returns> public Result <Msg_EmailValidate> ValidateEmailCode(string code, MessageStep step, string email, long receiveId = 0) { return(ValidateEmailCode(code, step, receiveId, email)); }
/// <summary> /// 发送邮件,TODO:扩展附件方法 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddEmail(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, Dictionary <string, string> parameters) { Result <int> result = new Result <int>(); try { using (MsgDataContext db = new MsgDataContext()) { //查找模板 var templete = db.Msg_EmailTemplete.FirstOrDefault(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { Msg_Email model = new Msg_Email(); string con = templete.TemplateCon; string title = templete.TitleCon; if (parameters != null && parameters.Any()) { //替换标题和内容参数 foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); title = title.Replace("{" + item.Key + "}", item.Value); } } BasicDataContext basicData = new BasicDataContext(); model.EmailCon = con; model.ReceiveId = receiveId; model.ReceiveEmaile = basicData.Base_User.FirstOrDefault(i => i.Id == model.ReceiveId).Email; model.SenderId = sendId; model.SenderEmail = db.Msg_EmailSetting.FirstOrDefault(i => i.IsConfirm && i.IsEnable).UserName; model.SendeCompanyId = sendCompanyId; model.ReceiveCompanyId = receiveCompanyId; model.State = false; model.Step = step.ToString(); model.TemplateId = templete.Id; model.Title = title; model.SenderTime = null; model.SubmissionTime = DateTime.Now; model.SendCount = 0; db.Msg_Email.Add(model); var rows = db.SaveChanges(); result.Data = rows; result.Flag = EResultFlag.Success; //WriteLog(AdminModule.EmailHistory.GetText(), SystemRight.Add.GetText(), "新增邮件:" + model.Id + ":" + model.Title); } else { throw new Exception("未查找到对应邮件模板"); } } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddEmail"); } return(result); }
private void ShowModalPreviewDialog(int itemId) { isPreview = true; ProgressBar pb = null; ImageButton ib = null; ModalPreviewDialog = new Dialog(this, Resource.Style.lightbox_dialog); if (packType == LOLCodeLibrary.GenericEnumsContentPackType.Emoticon) { ModalPreviewDialog.SetContentView(Resource.Layout.ModalPreviewGIFDialog); if (wowZapp.LaffOutOut.Singleton.resizeFonts) { layouts [0] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout1)); layouts [1] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout2)); layouts [3] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout3)); layouts [2] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout4)); previewWebImage = ((WebView)ModalPreviewDialog.FindViewById(Resource.Id.webPreview)); } ((WebView)ModalPreviewDialog.FindViewById(Resource.Id.webPreview)).VerticalScrollBarEnabled = false; ((WebView)ModalPreviewDialog.FindViewById(Resource.Id.webPreview)).HorizontalScrollBarEnabled = false; ((WebView)ModalPreviewDialog.FindViewById(Resource.Id.webPreview)).LoadDataWithBaseURL(null, "<body style=\"margin:0;padding:0;background:#8e8f8f;\"><div style=\"margin:10px;\">Loading...</div></body>", "text/html", "UTF-8", null); LOLConnectClient connect = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); connect.ContentPackItemGetDataCompleted += new EventHandler<ContentPackItemGetDataCompletedEventArgs>(connect_ContentPackItemGetDataCompleted); connect.ContentPackItemGetDataAsync(result [itemId].ContentPackItemID, ContentPackItem.ItemSize.Small, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } else { ModalPreviewDialog.SetContentView(Resource.Layout.ModalPreviewDialog); pb = ((ProgressBar)ModalPreviewDialog.FindViewById(Resource.Id.timerBar)); ib = ((ImageButton)ModalPreviewDialog.FindViewById(Resource.Id.playButton)); if (packType != LOLCodeLibrary.GenericEnumsContentPackType.Comicon && packType != LOLCodeLibrary.GenericEnumsContentPackType.SoundFX) pb.Visibility = ib.Visibility = ViewStates.Invisible; else ib.Click += delegate { playAudio(pb, packType); }; if (wowZapp.LaffOutOut.Singleton.resizeFonts) { layouts [0] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout1)); layouts [1] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout2)); layouts [3] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout3)); layouts [2] = ((LinearLayout)ModalPreviewDialog.FindViewById(Resource.Id.linearLayout4)); previewImage = ((ImageView)ModalPreviewDialog.FindViewById(Resource.Id.imgItemPic)); } using (MemoryStream stream = new MemoryStream (result [itemId].ContentPackItemIcon)) { using (Android.Graphics.Drawables.Drawable draw = Android.Graphics.Drawables.Drawable.CreateFromStream (stream, "Profile")) { ((ImageView)ModalPreviewDialog.FindViewById(Resource.Id.imgItemPic)).SetImageDrawable(draw); } } } ((TextView)ModalPreviewDialog.FindViewById(Resource.Id.txtItemTitle)).Text = result [itemId].ContentItemTitle; ((Button)ModalPreviewDialog.FindViewById(Resource.Id.btnAdd)).Click += delegate { if (!isAnimation) { MessageStep msgStep = new MessageStep(); switch (packType) { case LOLCodeLibrary.GenericEnumsContentPackType.Comicon: msgStep.StepType = MessageStep.StepTypes.Comicon; break; case LOLCodeLibrary.GenericEnumsContentPackType.Comix: msgStep.StepType = MessageStep.StepTypes.Comix; break; case LOLCodeLibrary.GenericEnumsContentPackType.Emoticon: msgStep.StepType = MessageStep.StepTypes.Emoticon; break; case LOLCodeLibrary.GenericEnumsContentPackType.SoundFX: msgStep.StepType = MessageStep.StepTypes.SoundFX; break; } ComposeMessageMainUtil.contentPackID [currentStep] = msgStep.ContentPackItemID = ContentPackItemsUtil.contentPackItemID = result [itemId].ContentPackItemID; if (currentStep > ComposeMessageMainUtil.msgSteps.Count) { msgStep.StepNumber = ComposeMessageMainUtil.msgSteps.Count + 1; ComposeMessageMainUtil.msgSteps.Add(msgStep); } else { msgStep.StepNumber = currentStep; ComposeMessageMainUtil.msgSteps [currentStep - 1] = msgStep; } ContentPackItemsUtil.content = result [itemId].ContentPackItemIcon; if (currentStep == 1) { DismissModalPreviewDialog(); isSet = true; sendBack(); } else { DismissModalPreviewDialog(); isSet = true; isPreview = false; sendBack(); } } else { DismissModalPreviewDialog(); isSet = true; sendBack(); } }; ((Button)ModalPreviewDialog.FindViewById(Resource.Id.btnCancel)).Click += delegate { DismissModalPreviewDialog(); }; ModalPreviewDialog.Show(); if (packType == LOLCodeLibrary.GenericEnumsContentPackType.Comicon || packType == LOLCodeLibrary.GenericEnumsContentPackType.SoundFX) { LOLConnectClient connect = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); connect.ContentPackItemGetDataCompleted += new EventHandler<ContentPackItemGetDataCompletedEventArgs>(connect_ContentPackItemGetDataCompleted); connect.ContentPackItemGetDataAsync(result [itemId].ContentPackItemID, ContentPackItem.ItemSize.Small, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } }
private void AddToMessages() { ar.EndRecording(); MessageStep msgStep = new MessageStep(); msgStep.StepType = MessageStep.StepTypes.Voice; if (CurrentStepInc > ComposeMessageMainUtil.msgSteps.Count) { msgStep.StepNumber = ComposeMessageMainUtil.msgSteps.Count + 1; ComposeMessageMainUtil.msgSteps.Add(msgStep); } else { msgStep.StepNumber = CurrentStepInc; ComposeMessageMainUtil.msgSteps [CurrentStepInc - 1] = msgStep; } if (CurrentStepInc == 1) { StartActivity(typeof(ComposeMessageMainActivity)); Finish(); } else { Finish(); } }
private void AddToMessages(object s, EventArgs e) { MessageStep msgStep = new MessageStep(); switch (option) { case 1: msgStep.StepType = MessageStep.StepTypes.Comix; break; case 2: msgStep.StepType = MessageStep.StepTypes.Comicon; break; case 3: msgStep.StepType = MessageStep.StepTypes.Voice; break; case 4: msgStep.StepType = MessageStep.StepTypes.Video; break; case 5: msgStep.StepType = MessageStep.StepTypes.SoundFX; break; case 6: msgStep.StepType = MessageStep.StepTypes.Emoticon; break; case 7: msgStep.StepType = MessageStep.StepTypes.Animation; break; } if (currentStep > ComposeMessageMainUtil.msgSteps.Count) { msgStep.StepNumber = ComposeMessageMainUtil.msgSteps.Count + 1; ComposeMessageMainUtil.msgSteps.Add(msgStep); } else { msgStep.StepNumber = currentStep; ComposeMessageMainUtil.msgSteps [currentStep - 1] = msgStep; } if (currentStep == 1) { StartActivity(typeof(ComposeMessageMainActivity)); Finish(); } else { Finish(); } }
/// <summary> /// 短信验证码校验 /// </summary> /// <param name="code"></param> /// <param name="step"></param> /// <param name="phone"></param> /// <param name="receiveId"></param> /// <returns></returns> public Result <Msg_SMSValidate> ValidateSMSCode(string code, MessageStep step, string phone, long receiveId = -1) { return(base.Channel.ValidateSMSCode(code, step, phone, receiveId)); }
/// <summary> /// 邮件验证码 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddEmailValCode(string email, MessageStep step, Dictionary <string, string> parameters) { //生成验证码 string code = ConstString.CreateRandomNum(ConstString.RANDOMNUMCOUNT); parameters.Add("Code", code); Result <int> result = new Result <int>(); try { //查找模板 var templete = DataOperateMsg <Msg_EmailTemplete> .Get().Single(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { Msg_Email model = new Msg_Email(); string con = templete.TemplateCon; string title = templete.TitleCon; if (parameters != null && parameters.Any()) { //替换标题和内容参数 foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); title = title.Replace("{" + item.Key + "}", item.Value); } } var receive = DataOperateBasic <Base_User> .Get().Single(i => i.Email == email); long receiveId = 0; if (receive != null && receive.Id > 0) { receiveId = receive.Id; } model.EmailCon = con; model.ReceiveId = receiveId; model.SendeCompanyId = 0; model.ReceiveCompanyId = 0; model.ReceiveEmaile = email; model.SenderId = 0;//管理员 model.SenderEmail = DataOperateMsg <Msg_EmailSetting> .Get().Single(i => i.IsConfirm && i.IsEnable).UserName; model.State = false; model.Step = step.ToString(); model.TemplateId = templete.Id; model.Title = title; model.SenderTime = null; model.SubmissionTime = DateTime.Now; var rows = DataOperateMsg <Msg_Email> .Get().Add(model); //添加验证码数据 Msg_EmailValidate valModel = new Msg_EmailValidate(); valModel.Code = code; valModel.EmailId = model.Id; valModel.ReceiveEmail = model.ReceiveEmaile; valModel.ReceiveId = model.ReceiveId; valModel.SendId = model.SenderId; valModel.SendTime = model.SubmissionTime; valModel.State = ValCodeState.UNUse.ToString(); valModel.ValidateType = step.ToString(); var seconds = LoadSettingsByKeys(Settings.EmailCodeDuration).Value.ToInt32Req(); valModel.ExpiredTime = DateTime.Now.AddSeconds(seconds); rows = DataOperateMsg <Msg_EmailValidate> .Get().Add(valModel); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(AdminModule.EmailHistory.GetText(), SystemRight.Add.GetText(), "新增邮件验证码:" + model.Id + ":" + model.Title); } else { throw new Exception("未查找到对应邮件模板"); } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddEmailValCode"); } return(result); }
/// <summary> /// 更新状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result <int> ChangeMaterielState(long id, ConfirmState state) { Result <int> result = new Result <int>(); try { var model = DataOperateBusiness <Epm_Materiel> .Get().GetModel(id); model.State = (int)state; var rows = DataOperateBusiness <Epm_Materiel> .Get().Update(model); MessageStep step = MessageStep.MaterielAudit; //处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } string title = ""; if (state == ConfirmState.Discarded) { title = model.CreateUserName + "提报的材料设备验收单,已废弃"; #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的材料设备验收单,已废弃"; app.Content = model.CreateUserName + "提报的材料设备验收单,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Track.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Track.GetText(); app.BusinessState = (int)(ConfirmState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Track.GetText(), SystemRight.Invalid.GetText(), "废弃物料验收生成待办: " + model.Id); #endregion } else if (state == ConfirmState.Confirm) { #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的材料设备验收单已审核通过"; app.Content = model.CreateUserName + "提报的材料设备验收单已审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Track.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Track.GetText(); app.BusinessState = (int)(ConfirmState.Confirm); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Track.GetText(), SystemRight.Check.GetText(), "审核通过物料验收生成待办: " + model.Id); #endregion } else if (state == ConfirmState.ConfirmFailure) { title = model.CreateUserName + "提报的材料设备验收已被驳回,请处理"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的材料设备验收已被驳回,请处理"; app.Content = model.CreateUserName + "提报的材料设备验收已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Track.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Track.GetText(); app.BusinessState = (int)(ConfirmState.ConfirmFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Track.GetText(), SystemRight.UnCheck.GetText(), "驳回物料验收生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.MaterielReject, null); #endregion } #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Track.ToString(); modelMsg.ProjectId = model.ProjectId; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Track.GetText(), SystemRight.Modify.GetText(), "更新状态: " + rows); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "ChangeMaterielState"); } return(result); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="sendId"></param> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddEmail(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, Dictionary <string, string> parameters) { return(base.Channel.AddEmail(sendId, sendCompanyId, receiveId, receiveCompanyId, step, parameters)); }
/// <summary> /// 发送短信 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddSMS(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, Dictionary <string, string> parameters) { Result <int> result = new Result <int>(); try { using (MsgDataContext db = new MsgDataContext()) { //查找模板 var templete = db.Msg_SMSTemplete.FirstOrDefault(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { Msg_SMS model = new Msg_SMS(); string con = templete.TemplateCon; if (parameters != null && parameters.Any()) { //替换内容参数 foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); } } BasicDataContext basicData = new BasicDataContext(); var receive = basicData.Base_User.FirstOrDefault(i => i.Id == receiveId); model.ReceivePhone = receive.Phone; model.ReceiveId = receiveId; model.SenderId = sendId; model.SendeCompanyId = sendCompanyId; model.ReceiveCompanyId = receiveCompanyId; model.SenderPhone = ""; model.SenderTime = null; model.SmsCon = con; model.State = false; model.SubmissionTime = DateTime.Now; model.Step = step.ToString(); model.TemplateId = templete.Id; model.ServerNo = templete.ServerNo; model.Params = UtilitySendMessage.CreateSmsParam(parameters).Data; model.SignName = templete.SignName; db.Msg_SMS.Add(model); var rows = db.SaveChanges(); result.Data = rows; result.Flag = EResultFlag.Success; //WriteLog(AdminModule.SMSHistory.GetText(), SystemRight.Add.GetText(), "新增短信:" + model.Id + ":" + model.SmsCon); } else { throw new Exception("未查找到短信模板"); } } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddSMS"); } return(result); }
/// <summary> /// 站内信发送 /// </summary> /// <param name="sendId"></param> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <param name="linkURL"></param> /// <returns></returns> public Result <int> AddMessage(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, string businessUrl, Dictionary <string, string> parameters, string linkURL = "") { return(base.Channel.AddMessage(sendId, sendCompanyId, receiveId, receiveCompanyId, step, businessUrl, parameters, linkURL)); }
public static Message ConvertFromMessageDB(MessageDB item) { Message toReturn = new Message (); toReturn.Errors = item.Errors; toReturn.FromAccountID = item.FromAccountID; toReturn.MessageID = item.MessageID; toReturn.MessageSent = item.MessageSent; toReturn.MessageConfirmed = item.MessageConfirmed; if (null != item.MessageStepDBList && item.MessageStepDBList.Count > 0) { MessageStep[] messageSteps = new MessageStep[item.MessageStepDBList.Count]; for (int i = 0; i < item.MessageStepDBList.Count; i++) { messageSteps [i] = MessageStepDB.ConvertFromMessageStepDB (item.MessageStepDBList [i]); }//end for toReturn.MessageSteps = messageSteps.ToList (); }//end if if (null != item.MessageRecipientDBList && item.MessageRecipientDBList.Count > 0) { Message.MessageRecipient[] recipients = new MessageRecipient[item.MessageRecipientDBList.Count]; for (int i = 0; i < item.MessageRecipientDBList.Count; i++) { recipients [i] = MessageRecipientDB.ConvertFromMessageRecipientDB (item.MessageRecipientDBList [i]); }//end for toReturn.MessageRecipients = recipients.ToList (); }//end if return toReturn; }
public Result <int> AddMessageBatch(long sendId, long sendCompanyId, Dictionary <long, long> recDic, MessageStep step, Dictionary <string, string> parameters, string linkURL = "") { return(base.Channel.AddMessageBatch(sendId, sendCompanyId, recDic, step, parameters, linkURL)); }
/// <summary> /// 新增站内信 /// </summary> /// <param name="sendId"></param> /// <param name="sendCompanyId"></param> /// <param name="recDic">接收信息字典类型 key:接收人Id;value:接收人单位Id</param> /// <param name="step"></param> /// <param name="parameters"></param> /// <param name="linkURL"></param> /// <returns></returns> public Result <int> AddMessageBatch(long sendId, long sendCompanyId, Dictionary <long, long> recDic, MessageStep step, Dictionary <string, string> parameters, string linkURL = "") { Result <int> result = new Result <int>(); try { using (MsgDataContext db = new MsgDataContext()) { //查找模板 var templete = db.Msg_MessageTemplete.FirstOrDefault(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { if (recDic != null && recDic.Any()) { List <Msg_Message> list = new List <Msg_Message>(); Msg_Message model = null; foreach (var dic in recDic) { model = new Msg_Message(); string con = templete.TemplateCon; string title = templete.TitleCon; if (parameters != null && parameters.Any()) { foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); title = title.Replace("{" + item.Key + "}", item.Value); } } model.Contents = con; model.LinkURL = string.IsNullOrEmpty(linkURL) ? templete.LinkURL : linkURL; model.ReadTime = null; model.ReceiveId = dic.Key; model.SenderId = sendId; model.SendeCompanyId = sendCompanyId; model.ReceiveCompanyId = dic.Value; model.State = false; model.Step = step.ToString(); model.TemplateId = templete.Id; model.Title = title; model.SendTime = DateTime.Now; list.Add(model); } db.Msg_Message.AddRange(list); var rows = db.SaveChanges(); result.Data = rows; result.Flag = EResultFlag.Success; } else { throw new Exception("未找到接收人"); } } else { throw new Exception("未查找到对应站内信模板"); } } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddMessage"); } return(result); }
/// <summary> /// 邮件链接 /// </summary> /// <param name="receiveId"></param> /// <param name="step"></param> /// <param name="parameters"></param> /// <returns></returns> public Result <int> AddEmailValLink(string email, MessageStep step, Dictionary <string, string> parameters) { return(base.Channel.AddEmailValLink(email, step, parameters)); }
/// <summary> /// 新增站内信 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <int> AddMessage(long sendId, long sendCompanyId, long receiveId, long receiveCompanyId, MessageStep step, string businessUrl, Dictionary <string, string> parameters, string linkURL = "") { Result <int> result = new Result <int>(); try { using (MsgDataContext db = new MsgDataContext()) { //查找模板 var templete = db.Msg_MessageTemplete.FirstOrDefault(i => i.Step == step.ToString() && i.IsConfirm && i.IsEnable); if (templete != null) { Msg_Message model = new Msg_Message(); string con = templete.TemplateCon; string title = templete.TitleCon; if (parameters != null && parameters.Any()) { //替换标题和内容参数 foreach (var item in parameters) { con = con.Replace("{" + item.Key + "}", item.Value); title = title.Replace("{" + item.Key + "}", item.Value); } } model.Contents = con; model.LinkURL = string.IsNullOrEmpty(linkURL) ? templete.LinkURL : linkURL; model.ReadTime = null; model.ReceiveId = receiveId; model.SenderId = sendId; model.SendeCompanyId = sendCompanyId; model.ReceiveCompanyId = receiveCompanyId; model.State = false; model.Step = step.ToString(); model.TemplateId = templete.Id; model.Title = title; model.SendTime = DateTime.Now; model.BusinessUrl = businessUrl; db.Msg_Message.Add(model); var rows = db.SaveChanges(); result.Data = rows; result.Flag = EResultFlag.Success; //WriteLog(AdminModule.MessageHistory.GetText(), SystemRight.Add.GetText(), "新增站内信:" + model.Id + ":" + model.Title); } else { throw new Exception("未查找到对应站内信模板"); } } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddMessage"); } return(result); }
/// <summary> /// 邮件验证码校验 /// </summary> /// <param name="code"></param> /// <param name="step"></param> /// <param name="email"></param> /// <param name="receiveId"></param> /// <returns></returns> public Result <Msg_EmailValidate> ValidateEmailCode(string code, MessageStep step, string email, long receiveId = 0) { return(base.Channel.ValidateEmailCode(code, step, email, receiveId)); }
public static MessageStep ConvertFromMessageStepDB(MessageStepDB item) { MessageStep toReturn = new MessageStep (); toReturn.ContentPackItemID = item.ContentPackItemID; toReturn.Errors = item.Errors; toReturn.MessageID = item.MessageID; toReturn.MessageText = item.MessageText; toReturn.StepID = item.StepID; toReturn.StepNumber = item.StepNumber; toReturn.StepType = item.StepType; toReturn.AnimationData = item.AnimationData; return toReturn; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.ComposeTextMessageScreen); string passedIn = base.Intent.GetStringExtra ("text"); ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewloginHeader); TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader); RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1); ImageHelper.setupTopPanel (btns, header, relLayout, header.Context); context = header.Context; Header.headertext = Application.Context.Resources.GetString (Resource.String.sendMessageTextTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; dbm = wowZapp.LaffOutOut.Singleton.dbm; mmg = wowZapp.LaffOutOut.Singleton.mmg; CurrentStepInc = base.Intent.GetIntExtra ("CurrentStep", 0); Button addContent = FindViewById<Button> (Resource.Id.btnAddContent); Button sendMessage = FindViewById<Button> (Resource.Id.btnMessageSend); ImageView useVoice = FindViewById<ImageView> (Resource.Id.imgVoice); text = FindViewById<EditText> (Resource.Id.editTextMessage); if (wowZapp.LaffOutOut.Singleton.resizeFonts) { float fSize = text.TextSize; text.SetTextSize (Android.Util.ComplexUnitType.Dip, ImageHelper.getNewFontSize (fSize, context)); } if (!string.IsNullOrEmpty (passedIn)) text.Text = passedIn; string rec = Android.Content.PM.PackageManager.FeatureMicrophone; if (rec != "android.hardware.microphone") useVoice.SetBackgroundResource (Resource.Drawable.nomicrophone2); else useVoice.Click += new EventHandler (recordVoice); text.TextChanged += delegate { if (text.Text.Length > 500) text.Text = text.Text.Substring (0, 500); }; sendMessage.Click += delegate { SendTextMessage (); }; ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack); btnBack.Click += delegate { Finish (); }; addContent.Click += delegate { if (!string.IsNullOrEmpty (text.Text)) { MessageStep msgStep = new MessageStep (); msgStep.MessageText = text.Text; msgStep.StepType = MessageStep.StepTypes.Text; if (CurrentStepInc > ComposeMessageMainUtil.msgSteps.Count) { msgStep.StepNumber = ComposeMessageMainUtil.msgSteps.Count + 1; ComposeMessageMainUtil.msgSteps.Add (msgStep); } else { msgStep.StepNumber = CurrentStepInc; ComposeMessageMainUtil.msgSteps [CurrentStepInc - 1] = msgStep; } if (CurrentStepInc == 1) { StartActivity (typeof(ComposeMessageMainActivity)); Finish (); } else { Finish (); } ComposeGenericResults.success = true; } else Finish (); }; }