public void SendSMS05(string RefNo, long UserID, bool NotifySMS, string ApproveFlag) { try { if (ParameterServices.EnableSMS) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(UserID); if (sendToUser.SMSApproveOrReject) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + sendToUser.MobilePhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyApprovedCompleted, RefNo, ApproveFlag.ToLower())); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode("To approve Ref." + RefNo + " was " + ApproveFlag.ToLower() + " completed"); } this.sendSMSStatus = SMSService.Send(smsDto, NotifySMS); } } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
/// <summary> /// กรณี ส่งมา approve ผิด format login ไม่ได้ /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS07(string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyApproveWrongFormat, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("To approve Refno. {0} format error, Please approve again. Try send XXXXXXY=Approve or XXXXXXN=Reject", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public void SendSMS03(long workFlowID, string RequestID, IList <long> ReciverList) { try { if (ParameterServices.EnableSMS) { Document document = WorkFlowQueryProvider.WorkFlowQuery.GetDocumentByWorkFlowID(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.FindByIdentity(document.DocumentID); FnAutoPayment autoPayment = ScgeAccountingQueryProvider.FnAutoPaymentQuery.GetFnAutoPaymentByDocumentID(document.DocumentID); foreach (long userID in ReciverList) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(userID); if (sendToUser.SMSReadyToReceive) { string ToPhoneNo = sendToUser.MobilePhoneNo.ToString(); SMSDTO smsDto = new SMSDTO(); string Mobile = "66" + ToPhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.PaymentDate = autoPayment.PaymentDate.Value; smsDto.Amount = autoPayment.Amount.ToString(); smsDto.Requestor = RequestID; smsDto.DocumentNo = scgDocument.DocumentNo; smsDto.UseProxy = true; smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS03, SMSBusinessCase.Cheque); this.sendSMSStatus = SMSService.Send(smsDto); } } } } catch (Exception ex) { Utilities.WriteLogs("SendSMS03 : ==> " + ex.Message, "smslog", "Logs", "txt"); } }
/// <summary> /// ใช้กรณี มีการ approve ผ่านเบอร์คนอื่นที่ไม่ใช่ เบอร์ที่รับ message /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS10(string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyWrongMobileNumber, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("Can use mobile number's message box owner for approve/reject refno.{0} only", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public bool SendSMS(SMSDTO message) { OracleConnection conn = new OracleConnection(oradb); string language = string.Empty; string languageLetter = string.Empty; if (message.Language == SMSLanguage.Arabic) { language = "SMS_MESSAGE_A"; languageLetter = "A"; } else { language = "SMS_MESSAGE_E"; languageLetter = "E"; } conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO SMS_INTERFACE (MOBILE_NO," + language + ", SENDERID,SMS_LANG) VALUES(" + message.RecipientNumber + ",N'" + message.MessageBody + "','2259','" + languageLetter + "')"; cmd.CommandType = CommandType.Text; OracleDataReader dr = cmd.ExecuteReader(); dr.Read(); conn.Close(); return(doCommit()); }
/// <summary> /// 把短信发送到MQ /// 负责拆包,递交出去的PlainSMS /// </summary> /// <param name="sms"></param> public void SendSMS(SMSDTO sms) { foreach (var smsnumber in sms.SMSNumbers) { if (smsnumber.NumberCount > this.GatewayConfig.MaxPackageSize) { List <string> Numbers = smsnumber.Numbers.Split(',').ToList(); for (int i = 0; i < Numbers.Count; i = i + this.GatewayConfig.MaxPackageSize) { var numbers = Numbers.Skip(i).Take(this.GatewayConfig.MaxPackageSize).ToList(); PlainSMS tmp = PlainSMS.CreatePlainSMS(sms.Message, numbers, smsnumber.Operator); this.SendMQHelper.PublishMessage(JsonConvert.SerializeObject(tmp), sms.Message.SMSLevel); } } else { PlainSMS tmp = PlainSMS.CreatePlainSMS(sms.Message, smsnumber); this.SendMQHelper.PublishMessage(JsonConvert.SerializeObject(tmp), sms.Message.SMSLevel); } } }
/// <summary> /// กรณี login failed ทำให้ไม่สามารถ approve ได้ /// </summary> /// <param name="Refno"></param> /// <param name="UserID"></param> /// <param name="NotifySMS"></param> public void SendSMS06(string Refno, long UserID, bool NotifySMS) { try { if (ParameterServices.EnableSMS) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(UserID); if (sendToUser.SMSApproveOrReject) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + sendToUser.MobilePhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyLoginFailed, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("To approve Ref.{0} via sms was login failed, Please contact admin. Send by: SCG Account", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NotifySMS); } } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
/// <summary> /// ใช้กรณี มีการ approve ผ่านช่องทางอื่นที่ไม่ใช่ sms แต่ว่าเพิ่งได้รับ message แล้ว approve มาจะทำให้ work flow เกิด error ไม่สามารถ approve ได้ /// </summary> /// <param name="Refno"></param> /// <param name="mobilePhone"></param> /// <param name="NoitfySMS"></param> public void SendSMS09(string Message, string Refno, string mobilePhone, bool NoitfySMS) { try { if (ParameterServices.EnableSMS) { SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + mobilePhone.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.UseProxy = true; try { smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format(ParameterServices.NotifyDocStatusChanged, Refno)); } catch (Exception ex) { string error = ex.Message; smsDto.Content = System.Web.HttpUtility.HtmlEncode(string.Format("This refno. {0} has been changed on work flow event.", Refno)); } this.sendSMSStatus = SMSService.Send(smsDto, NoitfySMS); } } catch (Exception ex) { Utilities.WriteLogs("To approve Failed : " + ex.Message, "smslog", "Logs", "txt"); } }
public void HandleReports() { var reports = PrepareReports(); if (reports == null || !reports.Any()) { return; } // Utility.WriteLog("Handle Reports : After Prepare Reports"); var reportLogs = new List <AutomaticReportLogDTO>(); foreach (var item in reports) { foreach (var group in item.Groups) { foreach (var user in group.AssignedUsers) { var log = new AutomaticReportLogDTO(); log.UserId = user.UserId; log.ReportGroupId = group.ReportGroupId; if (item.IsSMS && item.Template != null && user.PhoneNumber != "") { var sms = new SMSDTO { RecipientNumber = user.PhoneNumber }; var smsEn = new SMSDTO { RecipientNumber = user.PhoneNumber }; log.MobileNumber = user.PhoneNumber; if (item.IsArabic && item.Template.SMSTextArabic != "") { sms.Language = SMSLanguage.Arabic; sms.MessageBody = item.Template.SMSTextArabic; log.SMSText = sms.MessageBody; new CommunicationService().SendSMS(sms); } if (item.IsEnglish && item.Template.SMSTextEnglish != "") { smsEn.Language = SMSLanguage.English; smsEn.MessageBody = item.Template.SMSTextEnglish; log.EnglishSMSText = smsEn.MessageBody; Utility.WriteLog("Send SMS with text = " + smsEn.MessageBody); new CommunicationService().SendSMS(smsEn); } } log.SendDate = DateTime.Now; reportLogs.Add(log); } } } RecordLogs(reportLogs); }
/// <summary> /// 收到RabbitMQ消息的回调 /// </summary> /// <param name="smsDto"></param> private void HandleMessage(SMSDTO smsDto) { try { SendSMS(smsDto); } catch (Exception ex) { loger.Error("短信发送异常--SMSId:{0}--Exception:{1}".FormatWith(new object[] { smsDto.Id, ex })); } }
protected void Send_Click(object sender, EventArgs e) { SMSDTO smsDTO = new SMSDTO(); smsDTO.To = TO.Text; smsDTO.Content = CONTENT.Text; smsDTO.UseProxy = true; bool result = SMSService.Send(smsDTO); string xx = result.ToString(); }
public bool SendSMS(SMSDTO message) { try { return(new CommunicationDAL(smsConnectionString).SendSMS(message)); } catch (Exception ex) { Utility.WriteErrorLog(ex); } return(false); }
public bool Send(SMSDTO smsDTO, bool NotifySMS) { try { smsManager = new SMS(); content = smsDTO.Content; date = DateTime.Now; smsManager.CONTENT = content; smsManager.FROM = SMSPhoneNumber; smsManager.TO = smsDTO.To; smsManager.SMSGateWayServer = SMSGateWayServer; smsManager.SMSGateWayPort = Utilities.Utilities.ParseInt(SMSGateWayPort); smsManager.REPORT = SMSReport; smsManager.CHARGE = SMSCharge; smsManager.ProxyUserName = ProxyUserName; smsManager.ProxyPassword = ProxyPassword; smsManager.TRANSID = SMSTRANSID; smsManager.ProxyServer = ProxyServer; smsManager.ProxyPort = Utilities.Utilities.ParseInt(ProxyPort); smsManager.useProxy = smsDTO.UseProxy; SMSContainer smsContainer = new SMSContainer(); smsContainer.sms = smsManager; smsContainer.NotifySMS = NotifySMS; SMSSerializer serializer = new SMSSerializer(); string serialObject = serializer.SerializeObject(smsContainer); SuEmailResending resending = new SuEmailResending(); resending.Creby = UserAccount.UserID; resending.CreDate = DateTime.Now; resending.emailtype = "SMS+Notify"; resending.lastsenddate = DateTime.Now.AddMinutes(ParameterServices.EmailPendingDuration * -1); resending.mailcontent = serialObject; resending.retry = 0; resending.sendto = smsManager.TO; resending.status = "New"; resending.subject = content; SuEmailResendingService.Save(resending); smsSendStatus = true; smsSendStatus = true; } catch (Exception ex) { smsSendStatus = false; SS.Standard.Utilities.Utilities.WriteLogs("SMSService : " + ex.Message.Replace("remote", "SMS remote"), "smslog", "Logs", "txt"); } return(smsSendStatus); }
private static bool SMSMQHelper_RecieveMessage(RabbitMQHelper mq, string message) { try { MessageTools.MessageHelper.Instance.WirteTest(message); var sms = JsonConvert.DeserializeObject <SMSDTO>(message); SMSOriginalSend.Send(sms); foreach (var smsnumber in sms.SMSNumbers) { try { GatewayHelper gateway = GetGatewayByOperator(sms.Message.Channel, smsnumber.Operator); if (gateway == null) { SendFail(PlainSMS.CreatePlainSMS(sms.Message, smsnumber), "没有找到可用网关!", 2022); continue; } SMSDTO dto = new SMSDTO() { Message = sms.Message }; dto.SMSNumbers = new List <SMSNumber>() { smsnumber }; gateway.SendSMS(dto); } catch (Exception ex) { //记录异常 LogHelper.LogError("SendQueue", "SMSMQHelper_RecieveMessage", "发送短信时发生异常:" + ex.ToString()); SendFail(PlainSMS.CreatePlainSMS(sms.Message, smsnumber), "发送时失败!", 99); } } return(true); } catch (Exception ex) { LogHelper.LogError("SendQueue", "SMSMQHelper_RecieveMessage", "解析短信时发生异常:" + ex.ToString()); LogHelper.LogError("SendQueue", "SMSMQHelper_RecieveMessage", message); // throw ex; return(true); } }
internal void Send(SMSDTO sms) { ReportStatisticsDB.AddSMSHistory(new ReportStatistics(sms.Message)); fqSMS.PublishMessage(JsonConvert.SerializeObject(sms), sms.Message.SMSLevel); }
/// <summary> /// 依据SMSDTO对象内容发送短信 /// </summary> /// <param name="smsDto">SMSDTO对象</param> private void SendSMS(SMSDTO smsDto) { var smsId = smsDto.Id; loger.Info("开始发送--SMSId:{0}".FormatWith(smsId)); var sms = new SMS { SMSId = smsDto.Id, AppId = smsDto.AppId, SMSContent = smsDto.Content, SMSErrMsg = "", SMSMobile = smsDto.Mobile, SMSReceivedTime = DateTime.Now, SMSSentTime = DateTime.Now, SMSStatus = SMSStatus.Received.ToString() }; var smsFacade = new SMSFacade(); //发送短信 bool result = false; string mobile = smsDto.Mobile; string content = smsDto.Content; //申讯短信内容需加签名 if (ConfigMgr.SmsChannel == 2) { if (smsDto.AppId == "100204")//OEM项目,负责人:张业华 { content += "【登机宝】"; } else { content += "【今日天下通】"; } } var sender = SMSSenderFactory.CreateSender(ConfigMgr.SmsChannel); try { result = sender.SendSMS(mobile, content); } catch (Exception ex) { sms.SMSErrMsg = ex.Message; loger.Error("短信发送异常--SMSId:{0}--Exception:{1}".FormatWith(new object[] { smsId, ex })); } if (result) { sms.SMSErrMsg = ""; } //保存数据库 sms.SMSStatus = result ? SMSStatus.Sent.ToString() : SMSStatus.Fail.ToString(); sms.SMSSentTime = DateTime.Now; try { smsFacade.UpdateSMS(sms); } catch (Exception ex) { loger.Error("数据库更新SMS记录失败--SMSId:{0}--Exception:{1}".FormatWith(new object[] { smsId, ex })); } loger.Info("结束发送--SMSId:{0}--发送结果{1}".FormatWith(new object[] { smsId, result? "成功":"失败" })); }
public void SendSMS(SMSDTO sms) { string message = JsonConvert.SerializeObject(sms); mq.PublishMessage(message, sms.Message.SMSLevel); }
public static void Send(SMSDTO sms) { ReportStatisticsDB.AddSMSHistory(new ReportStatistics(sms.Message)); }
private string BuildContentBody(SMSDTO smsDTO, SMSContenFormat ContentFormat, SMSBusinessCase BusinessCase) { smsContentBody = new StringBuilder(string.Empty); try { if (ContentFormat == SMSContenFormat.SMS01) { if (BusinessCase == SMSBusinessCase.AdvanceDomesticDocument) { try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveAdvance, smsDTO.Requestor, smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception) { smsContentBody.AppendFormat("Please approve advance of {0} {1} {2} {3} Ref.{4}", smsDTO.Requestor, "THB " + smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID); } } else if (BusinessCase == SMSBusinessCase.AdvanceForeignDocument) { IList <SMSCurrencyDTO> advnItemList = smsDTO.CurrencyItemList; StringBuilder strAmount = new StringBuilder(); string smsAmount = string.Empty; if (advnItemList != null && advnItemList.Count > 0) { foreach (SMSCurrencyDTO itemCurrency in advnItemList) { strAmount.AppendFormat("{0} {1},", itemCurrency.Currency.ToString(), itemCurrency.Amount.ToString()); } smsAmount = strAmount.ToString().TrimEnd(','); } else { smsAmount = smsDTO.Amount; } try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveAdvance, smsDTO.Requestor, smsAmount, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception) { smsContentBody.AppendFormat("Please approve advance of {0} {1} {2} {3} Ref.{4}", smsDTO.Requestor, "THB", smsAmount, smsDTO.DocumentNo, smsDTO.ReferenceID); } } else if (BusinessCase == SMSBusinessCase.ExpenseDomesticDocument) { try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveExpense, smsDTO.Requestor, smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Please approve expense of {0} THB {1} {2} Ref.{3} ", smsDTO.Requestor, smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID); } } else if (BusinessCase == SMSBusinessCase.ExpenseForeignDocument) { try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveExpense, smsDTO.Requestor, smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Please approve expense of {0} THB {1} {2} Ref.{3} ", smsDTO.Requestor, smsDTO.Amount, smsDTO.DocumentNo, smsDTO.ReferenceID); } } else if (BusinessCase == SMSBusinessCase.TADocumentDomestic || BusinessCase == SMSBusinessCase.TADocumentForeign) { IList <SMSCurrencyDTO> advnItemList = smsDTO.CurrencyItemList; StringBuilder strAmount = new StringBuilder(); string smsAmount = string.Empty; if (advnItemList != null && advnItemList.Count > 0) { foreach (SMSCurrencyDTO itemCurrency in advnItemList) { strAmount.AppendFormat("{0}{1},", itemCurrency.Currency.ToString(), itemCurrency.Amount.ToString()); } smsAmount = strAmount.ToString().TrimEnd(','); try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveTAandAdvance, smsDTO.Requestor, smsAmount, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Please approve TA+ADV of {0}{1} {2} Ref.{3}", smsDTO.Requestor, smsAmount, smsDTO.DocumentNo, smsDTO.ReferenceID); } } else { try { smsContentBody.Append(string.Format(ParameterServices.NotifyRequestApproveTA, smsDTO.Requestor, smsDTO.DocumentNo, smsDTO.ReferenceID)); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Please approve TA of {0}{1} Ref.{2}", smsDTO.Requestor, smsDTO.DocumentNo, smsDTO.ReferenceID); } } } } else if (ContentFormat == SMSContenFormat.SMS02) { if (BusinessCase == SMSBusinessCase.Cash) { try { smsContentBody.Append(string.Format(ParameterServices.NotifyCashReceive, smsDTO.DocumentNo, smsDTO.Amount)); } catch (Exception ex) { string errer = ex.Message; smsContentBody.AppendFormat("Your payment request has been made,RefID:{0} Amount {1} Please contact counter cashier. Sent by: SCG Account", smsDTO.DocumentNo, smsDTO.Amount); } } else if (BusinessCase == SMSBusinessCase.Cheque) { try { //smsContentBody.Append(string.Format(ParameterServices.NotifyChequeReceive, smsDTO.DocumentNo, smsDTO.Amount)); //comment for edit format by desh : log no. smsContentBody.Append(string.Format(ParameterServices.NotifyChequeReceive, smsDTO.PaymentDate.ToString("dd/MM/yyyy"), smsDTO.Amount, smsDTO.DocumentNo)); } catch (Exception ex) { string errer = ex.Message; //smsContentBody.AppendFormat("Your payment request has been made,RefID:{0} Amount {1} Sent by: SCG Account", smsDTO.DocumentNo,smsDTO.Amount); smsContentBody.AppendFormat("Your payment request has been made,Payment date: {0} Amount. {1} baht RefID: {2}. Please contact counter cashier. Send by: SCG Account", smsDTO.PaymentDate.ToString("dd/MM/yyyy"), smsDTO.Amount, smsDTO.DocumentNo); } } } else if (ContentFormat == SMSContenFormat.SMS03) { if (BusinessCase == SMSBusinessCase.Cheque) { try { smsContentBody.Append(string.Format(ParameterServices.NotifyChequeReceive, smsDTO.PaymentDate.ToString("dd/MM/yyyy"), smsDTO.Amount, smsDTO.DocumentNo)); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Your payment request has been made,Payment date: {0} Amount. {1} baht RefID: {2}. Please contact counter cashier. Send by: SCG Account", smsDTO.PaymentDate.ToString("dd/MM/yyyy"), smsDTO.Amount, smsDTO.DocumentNo); } } else { try { smsContentBody.Append(string.Format(ParameterServices.NotifyChequeReceive, smsDTO.DocumentNo, smsDTO.Amount, smsDTO.PaymentDate.ToString("dd/MM/yyyy"))); } catch (Exception ex) { string error = ex.Message; smsContentBody.AppendFormat("Your payment request has been made,Payment date: {0} Amount. {1} baht RefID: {2}. Sent by: SCG Account", smsDTO.PaymentDate.ToString("dd/MM/yyyy"), smsDTO.Amount, smsDTO.DocumentNo); } } } else { smsContentBody.AppendFormat(smsDTO.Content); } } catch (Exception ex) { Utilities.WriteLogs("BuildSMSContentBody : " + BusinessCase.ToString() + "==>" + ex.Message, "smslog", "Logs", "txt"); } return(System.Web.HttpUtility.HtmlEncode(smsContentBody.ToString())); }
public void SendSMS01(long workFlowID, long sendToUserID) { try { if (ParameterServices.EnableSMS) { string tokenSMSCode = SaveResponseTokenSMS(workFlowID, sendToUserID); SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(sendToUserID); if (sendToUser.SMSApproveOrReject) { IList <WorkFlowResponseToken> responseTokens = WorkFlowQueryProvider.WorkFlowResponseTokenQuery.FindByTokenCode(tokenSMSCode); Document document = WorkFlowQueryProvider.WorkFlowQuery.GetDocumentByWorkFlowID(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.FindByIdentity(document.DocumentID); SuUser RequesterUser = QueryProvider.SuUserQuery.FindByIdentity(scgDocument.RequesterID.Userid); SMSDTO smsDto = new SMSDTO(); smsDto.From = SS.DB.Query.ParameterServices.SMSPhoneNumber; string Mobile = "66" + sendToUser.MobilePhoneNo.ToString().Remove(0, 1); smsDto.To = Mobile; smsDto.ReferenceID = tokenSMSCode; smsDto.Requestor = RequesterUser.UserName; smsDto.DocumentNo = scgDocument.DocumentNo; smsDto.UseProxy = true; if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.AdvanceDomesticDocument) || scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.AdvanceForeignDocument)) { AvAdvanceDocument avanceDocument = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.GetAvAdvanceByDocumentID(scgDocument.DocumentID); if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.AdvanceForeignDocument)) { //ต่างประเทศจะต้องไป get Currency Symbol ออกมา if (avanceDocument != null) { smsDto.Amount = avanceDocument.Amount.ToString(); } else { smsDto.Amount = "0"; } IList <AvAdvanceItem> advanceItemList = ScgeAccountingQueryProvider.AvAdvanceItemQuery.FindByAvAdvanceItemAdvanceID(avanceDocument.AdvanceID); IList <SMSCurrencyDTO> advItemList = new List <SMSCurrencyDTO>(); foreach (AvAdvanceItem advanceItem in advanceItemList) { string dbStatus = ScgDbQueryProvider.SCGDbStatusLangQuery.GetStatusLang("PaymentTypeFRN", ParameterServices.DefaultLanguage, advanceItem.PaymentType); SMSCurrencyDTO advItem = new SMSCurrencyDTO(); advItem.PaymentType = dbStatus; if (advanceItem.CurrencyID != null) { advItem.Currency = advanceItem.CurrencyID.Symbol; } advItem.Amount = advanceItem.Amount.ToString(); advItemList.Add(advItem); } smsDto.CurrencyItemList = advItemList; smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS01, SMSBusinessCase.AdvanceForeignDocument); } else { //ในประเทศ Currency Symbol THB เท่านั้น if (avanceDocument != null) { smsDto.Amount = avanceDocument.Amount.ToString(); } else { smsDto.Amount = "0"; } smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS01, SMSBusinessCase.AdvanceDomesticDocument); } this.sendSMSStatus = SMSService.Send(smsDto); } else if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.ExpenseDomesticDocument) || scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.ExpenseForeignDocument)) { FnExpenseDocument expenseDocument = ScgeAccountingQueryProvider.FnExpenseDocumentQuery.GetExpenseDocumentByDocumentID(scgDocument.DocumentID); if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.ExpenseForeignDocument)) { FnExpenseDocument expense = ScgeAccountingQueryProvider.FnExpenseDocumentQuery.GetExpenseDocumentByDocumentID(scgDocument.DocumentID); //EmailValueObject expenseDoc = new EmailValueObject(); // expenseDoc.RequestID = expense.Document.DocumentNo; smsDto.Amount = expense.TotalExpense.ToString(); smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS01, SMSBusinessCase.ExpenseDomesticDocument); } else { if (expenseDocument != null) { smsDto.Amount = expenseDocument.TotalExpense.ToString(); } else { smsDto.Amount = "0"; } smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS01, SMSBusinessCase.ExpenseDomesticDocument); } this.sendSMSStatus = SMSService.Send(smsDto); } else if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.TADocumentDomestic) || scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.TADocumentForeign)) { TADocument ta = ScgeAccountingQueryProvider.TADocumentQuery.GetTADocumentByDocumentID(scgDocument.DocumentID); IList <Advance> advanceList = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.FindAdvanceDocumentByTADocumentID(ta.TADocumentID); if (advanceList.Count > 0) { IList <AdvanceData> advanceDataList = new List <AdvanceData>(); foreach (Advance advance in advanceList) { AdvanceData advanceData = new AdvanceData(); AvAdvanceDocument advDocument = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.FindByIdentity(advance.AdvanceID); if (advDocument != null) { //advanceData.RequestID = advDocument.DocumentID.RequesterID; advanceData.Subject = advDocument.DocumentID.Subject; advanceData.RequestDateOfAdvance = advDocument.RequestDateOfAdvance; advanceData.Amount = advDocument.Amount; if (advDocument.AdvanceType.Equals("FR")) { IList <AvAdvanceItem> advItemList = ScgeAccountingQueryProvider.AvAdvanceItemQuery.FindByAvAdvanceItemAdvanceID(advDocument.AdvanceID); IList <SMSCurrencyDTO> advanceFrList = new List <SMSCurrencyDTO>(); foreach (AvAdvanceItem advItem in advItemList) { SMSCurrencyDTO advanceFR = new SMSCurrencyDTO(); advanceFR.Currency = advItem.CurrencyID.Symbol; advanceFR.Amount = advItem.Amount.ToString(); advanceFrList.Add(advanceFR); } smsDto.CurrencyItemList = advanceFrList; } advanceDataList.Add(advanceData); } } // html.SetAttribute("advList", advanceDataList); } // html.SetAttribute("ta", taDoc); smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS01, SMSBusinessCase.TADocumentDomestic); this.sendSMSStatus = SMSService.Send(smsDto); } } } } catch (Exception ex) { Utilities.WriteLogs("SendSMS01 : " + ex.Message, "smslog", "Logs", "txt"); } }
public void SendSMS02(long workFlowID, string RequestID, IList <long> ReciverList, bool isAutoPayment) { double netAmount = 0; try { if (ParameterServices.EnableSMS) { Document document = WorkFlowQueryProvider.WorkFlowQuery.GetDocumentByWorkFlowID(workFlowID); SCGDocument scgDocument = ScgeAccountingQueryProvider.SCGDocumentQuery.FindByIdentity(document.DocumentID); if (!isAutoPayment) // Cash { #region Cash if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.ExpenseDomesticDocument) || (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.ExpenseForeignDocument))) { FnExpenseDocument expense = ScgeAccountingQueryProvider.FnExpenseDocumentQuery.GetExpenseDocumentByDocumentID(scgDocument.DocumentID); if (expense != null) { netAmount = expense.DifferenceAmount; } } else if (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.AdvanceDomesticDocument) || (scgDocument.DocumentType.DocumentTypeID.Equals(DocumentTypeID.AdvanceForeignDocument))) { AvAdvanceDocument advance = ScgeAccountingQueryProvider.AvAdvanceDocumentQuery.GetAvAdvanceByDocumentID(scgDocument.DocumentID); if (advance != null) { netAmount = advance.Amount; } } #endregion Cash foreach (long userID in ReciverList) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(userID); if (sendToUser.SMSReadyToReceive) { string ToPhoneNo = sendToUser.MobilePhoneNo.ToString(); SMSDTO smsDto = new SMSDTO(); string Mobile = "66" + ToPhoneNo.ToString().Remove(0, 1); smsDto.Requestor = RequestID; smsDto.DocumentNo = scgDocument.DocumentNo; smsDto.Amount = netAmount.ToString(); smsDto.To = Mobile; smsDto.UseProxy = true; smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS02, SMSBusinessCase.Cash); this.sendSMSStatus = SMSService.Send(smsDto); } } } else // Cheque { #region Cheque FnAutoPayment autoPayment = ScgeAccountingQueryProvider.FnAutoPaymentQuery.GetFnAutoPaymentByDocumentID(document.DocumentID); netAmount = autoPayment.Amount; #endregion Cheque foreach (long userID in ReciverList) { SuUser sendToUser = QueryProvider.SuUserQuery.FindByIdentity(userID); if (sendToUser.SMSReadyToReceive) { string ToPhoneNo = sendToUser.MobilePhoneNo.ToString(); SMSDTO smsDto = new SMSDTO(); string Mobile = "66" + ToPhoneNo.ToString().Remove(0, 1); smsDto.Requestor = RequestID; smsDto.DocumentNo = scgDocument.DocumentNo; smsDto.PaymentDate = autoPayment.PaymentDate.Value; smsDto.Amount = netAmount.ToString(); smsDto.To = Mobile; smsDto.UseProxy = true; smsDto.Content = BuildContentBody(smsDto, SMSContenFormat.SMS02, SMSBusinessCase.Cheque); this.sendSMSStatus = SMSService.Send(smsDto); } } } } } catch (Exception ex) { Utilities.WriteLogs("SendSMS02 : ==> " + ex.Message, "smslog", "Logs", "txt"); } }