Esempio n. 1
0
        public string ajaxSend(string phone)
        {
            var randomCode         = new Random().Next(100000).ToString("D6");
            CheckMobileModel model = new CheckMobileModel()
            {
                Phone   = phone,
                Message = string.Format(SmsConfig.Instance.RgistetSmsText, randomCode)
            };

            YG.SC.Common.SendMessageHelper smsHelper = new Common.SendMessageHelper();
            try
            {
                string smsResult = smsHelper.SendMessage(phone, model.Message);
                YG.SC.OpenShop.PCnCache.Instance.Add(model.Phone, randomCode);
                // 更新短信通道

                SmsLog smsModel = new SmsLog()
                {
                    PhoneNumber = model.Phone,
                    SendStatus  = smsResult
                    ,
                    Content = model.Message
                };
                _iCustomerService.SendSmsSaveLog(smsModel);
                return
                    ("ok");
            }
            catch (Exception ex)
            {
                return("-1");
            }
        }
Esempio n. 2
0
        private void Get_ParameterList()
        {
            string strSql = "";
            SmsLog bllSms = new SmsLog();
            int    Counts = this.NetPagerParameter.RecordCount;

            strSql += "SmsLog.SmsShopID = SysShop.ShopID and SmsLog.SmsUserID = SysUser.UserID ";
            strSql  = PubFunction.GetShopAuthority(this._UserShopID, "SmsShopID", strSql);
            DataTable db = bllSms.GetListSP(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[]
            {
                strSql
            }).Tables[0];

            this.NetPagerParameter.RecordCount    = Counts;
            this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[]
            {
                this.NetPagerParameter.CurrentPageIndex,
                this.NetPagerParameter.PageCount,
                this.NetPagerParameter.RecordCount,
                this.NetPagerParameter.PageSize
            });
            this.gvSendList.DataSource = db;
            this.gvSendList.DataBind();
            PageBase.BindSerialRepeater(this.gvSendList, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
        }
Esempio n. 3
0
        public ActionResult Index(SmsSendVm smsVm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }

            var    contacts = smsVm.Contacts;
            var    messages = smsVm.Messages;
            string result   = _smsbll.SendSms(contacts, messages);
            bool   status   = result.ToLower().Contains("error") ? false : true;

            SmsLog sendSms = new SmsLog();

            //1 = groupwise, 2 = bulk
            sendSms.SmsType       = 2;
            sendSms.Status        = status ? Convert.ToInt16(1) : Convert.ToInt16(0);
            sendSms.SendUser      = "******";
            sendSms.SendDate      = DateTime.Now;
            sendSms.MessageStatus = result;

            db.SmsLogs.Add(sendSms);
            db.SaveChanges();

            TempData["message"] = status ? "success" : "failed";

            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        private void Get_ParameterList(string strShopID)
        {
            SmsLog    bllSms = new SmsLog();
            DataTable db     = bllSms.GetSmsShopReportDetail(strShopID).Tables[0];

            this.gvSmsShopReportDetail.DataSource = db;
            this.gvSmsShopReportDetail.DataBind();
            PageBase.BindSerialRepeater(this.gvSmsShopReportDetail, 0);
        }
Esempio n. 5
0
        /// <summary>
        /// 手机注册:申请验证码
        /// </summary>
        /// <param name="mobilePhone">接收验证码的手机号,同时也是注册号</param>
        /// <param name="errMsg">请求失败时的错误提示</param>
        /// <returns></returns>
        public static bool RequestRegisterVerificationCode(string mobilePhone, out string errMsg)
        {
            errMsg = String.Empty;

            try
            {
                //1.检查手机是否已经注册
                if (SellerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg) != null)
                {
                    errMsg = string.Format("手机号:{0}已经被注册过,请使用其它手机号注册!", mobilePhone);
                    return(false);
                }
                if (!string.IsNullOrEmpty(errMsg))
                {
                    //访问出错
                    return(false);
                }
                //2.检查该手机今日接收短信业务条数
                var count = SmsLogBll.GetSmsCount(mobilePhone, ESmsLogType.SellerRegister);
                if (count >= Laplace.LiteCOS.Global.ApplicationParms.SmsMaxCount)
                {
                    errMsg = string.Format("手机号:{0}今日接收验证码过多,请明天再试!", mobilePhone);
                    return(false);
                }
                //3.生成手机验证码
                var code = SmsLogBll.CreateSmsVerificationCode();
                //code = "123456";
                string smsContent;
                //4.发送短信,调用短信接口
                //#if !DEBUG
                if (!SmsLogBll.SendSms4RegisterVerificationCode(mobilePhone, code, out smsContent, out errMsg))
                {
                    errMsg = string.Format("发送验证码短信失败,请稍后重试!\r\n错误描述:{0}", errMsg);
                    return(false);
                }
                //#endif
                //5.保存日志
                var log = new SmsLog()
                {
                    MobilePhone = mobilePhone,
                    SmsTime     = DateTime.Now,
                    SmsContent  = smsContent,
                    UserId      = 0,
                    Config      = code,      //注册码
                    LogType     = ESmsLogType.SellerRegister
                };
                SmsLogBll.Insert(log);
            }
            catch (Exception ex)
            {
                errMsg = string.Format("异常:{0}", ex.Message);
                Logger.LogError4Exception(ex, "AppLogger");
            }

            return(true);
        }
Esempio n. 6
0
        public static bool Insert(SmsLog model)
        {
            string errMsg;

            if (SmsLogRedisBll.Insert(model))
            {
                return(dal.Insert(model, Global.ApplicationParms.ConnectionString, out errMsg));
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 写短线记录
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="code"></param>
        private void WriteLog(string phone, string code)
        {
            Task.Run(() =>
            {
                SmsLog sms     = new SmsLog();
                sms.Code       = code;
                sms.CreateTime = DateTime.Now;
                sms.IsSend     = 1;
                sms.Phone      = phone;

                _smsLogBiz.Insert(sms);
            });
        }
        public async Task Consume(ConsumeContext <IUserActivated> context)
        {
            await _smsLogRepository.LogAsync(SmsLog.CreateInitialLog(context.Message));

            await _notificationFacade.SendEmailAsync(
                context.Message,
                Template.AccountActivationEmailUser,
                context.Message.Email);

            await _notificationFacade.SendSmsAsync(
                context.Message,
                Template.AccountActivationSmsUser,
                context.Message.Phone);
        }
Esempio n. 9
0
        public async Task Consume(ConsumeContext <ISmsCreditAdded> context)
        {
            await _smsLogRepository.LogAsync(SmsLog.CreateSmsAdditionLog(context.Message));

            await _notificationFacade.SendEmailAsync(
                context.Message,
                Template.SmsCreditAddedEmailUser,
                context.Message.Email);

            await _notificationFacade.SendSmsAsync(
                context.Message,
                Template.SmsCreditAddedSmsUser,
                context.Message.Phone);
        }
Esempio n. 10
0
        /// <summary>
        /// 短信发送
        /// </summary>
        /// <returns></returns>
        public async Task SendAsync(string tel, INotify notify)
        {
            if (string.IsNullOrEmpty(tel))
            {
                return;
            }
            var httpClient = _httpFactory.CreateClient();

            var msg     = notify.Execute();
            var request = new Cloud253SmsRequest()
            {
                Account  = _config.Account,
                Password = _config.Password,
                Phone    = tel,
                Msg      = msg,
                Report   = true
            };

            var log = new SmsLog
            {
                Tel      = tel,
                Message  = msg,
                Createat = DateTime.Now
            };

            try
            {
                var context = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
                using (var response = await httpClient.PostAsync(_config.Url, context))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string jsonBody = await response.Content.ReadAsStringAsync();

                        var result = JsonConvert.DeserializeObject <Cloud243SmsResponse>(jsonBody);

                        log.Code     = result.Code;
                        log.ErrorMsg = result.ErrorMsg;
                        log.Time     = result.Time;
                        log.MsgId    = result.MsgId;
                    }

                    await _smsLogRepository.InsertAsync(log);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 修改密码:申请验证码
        /// </summary>
        /// <param name="mobilePhone">接收验证码的手机号,同时也是注册号</param>
        /// <param name="errMsg">请求失败时的错误提示</param>
        /// <returns></returns>
        public static bool RequestChangePasswordVerificationCode(string mobilePhone, out string errMsg)
        {
            errMsg = String.Empty;

            try
            {
                //1.检查手机是否已经注册
                var customer = BuyerInfoBll.GetModelByMobilePhone(mobilePhone, out errMsg);
                if (customer == null)
                {
                    errMsg = string.Format("手机号:{0}不存在!", mobilePhone);
                    return(false);
                }
                //2.检查该手机今日接收短信业务条数
                var count = SmsLogBll.GetSmsCount(mobilePhone, ESmsLogType.BuyerGetPassword);
                if (count >= Laplace.LiteCOS.Global.ApplicationParms.SmsMaxCount)
                {
                    errMsg = string.Format("手机号:{0}今日接收验证码过多,请明天再试!", mobilePhone);
                    return(false);
                }
                //3.生成手机验证码
                var code = SmsLogBll.CreateSmsVerificationCode();
                //4.发送短信
                string smsContent = string.Empty;
                //调用短信接口
                if (!SmsLogBll.SendSms4ModifyPassword(mobilePhone, code, out smsContent, out errMsg))
                {
                    errMsg = string.Format("发送密码通知短信失败,请稍后重试!\r\n错误描述:{0}", errMsg);
                    return(false);
                }
                //5.保存日志
                var log = new SmsLog()
                {
                    MobilePhone = mobilePhone,
                    SmsTime     = DateTime.Now,
                    SmsContent  = smsContent,
                    UserId      = 0,
                    Config      = code,      //注册码
                    LogType     = ESmsLogType.BuyerChangePassword
                };
                return(SmsLogBll.Insert(log));
            }
            catch (Exception ex)
            {
                errMsg = string.Format("异常:{0}", ex.Message);
                Logger.LogError4Exception(ex, "AppLogger");
            }
            return(false);
        }
Esempio n. 12
0
        public IEnumerable <SmsLog> Index()
        {
            Console.WriteLine("HttpGet");

            const string accountSid = "";
            const string authToken  = "";


            TwilioClient.Init(accountSid, authToken);


            var messages = MessageResource.Read(
                //dateSentAfter: new DateTime(2020, 4, 4, 0, 0, 0),
                dateSentAfter: DateTime.Now.AddMinutes(-10),
                //dateSentBefore: new DateTime(2019, 3, 1, 0, 0, 0),
                limit: 20
                );
            List <SmsLog> smsLog = new List <SmsLog>();

            Console.WriteLine(messages);
            using (var db = new PharmTwilioDbContext())
            {
                //pack into a dataset.
                foreach (var record in messages)
                {
                    var log = new SmsLog();
                    //
                    Console.Write(record.Sid.ToString());
                    log.msgID        = record.Sid.ToString();
                    log.to           = record.To.ToString();
                    log.from         = record.From.ToString();
                    log.dateCreated  = record.DateCreated.ToString();
                    log.body         = record.Body.ToString();
                    log.status       = record.Status.ToString();
                    log.direction    = record.Direction.ToString();
                    log.wasContacted = false;
                    db.Add(log);
                    db.SaveChanges();
                    //smsLog.Add(log);
                    //logSms.Add(JsonSerializer.Serialize<SmsLog>(log));
                }
            }
            Console.WriteLine("Fetched record");
            using (var db = new PharmTwilioDbContext())
            {
                smsLog = db.SmsLogs.Where(e => e.from != "").Where(e => e.wasContacted == false).ToList();
            }
            return(smsLog);
        }
Esempio n. 13
0
        private void Get_ParameterList()
        {
            SmsLog bllSms = new SmsLog();
            string strSql = PubFunction.GetShopAuthority(this._UserShopID, "ShopID", "1=1");

            this.lblMonthNumber.Text = bllSms.GetSmsMonthNumber(strSql).ToString();
            this.lblTotalNumber.Text = bllSms.GetSmsTotalNumber(strSql).ToString();
            try
            {
                SysParameter sds = new SysParameter();
                if (sds.GetModel(1).Sms)
                {
                    this.lblNotificationSMSBalance.Text = SMSInfo.GetBalance(false);
                }
                else
                {
                    this.TongZhiduanxin.Attributes.Add("style", "display:none");
                }
                if (sds.GetModel(1).MarketingSMS)
                {
                    this.lblMarketingSMSBalance.Text = SMSInfo.GetBalance(true);
                }
                else
                {
                    this.Yinxiaoduanxin.Attributes.Add("style", "display:none");
                }
            }
            catch
            {
            }
            int       Counts = this.NetPagerParameter.RecordCount;
            DataTable db     = bllSms.GetSmsShopReport(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[]
            {
                strSql
            }).Tables[0];

            this.NetPagerParameter.RecordCount    = Counts;
            this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[]
            {
                this.NetPagerParameter.CurrentPageIndex,
                this.NetPagerParameter.PageCount,
                this.NetPagerParameter.RecordCount,
                this.NetPagerParameter.PageSize
            });
            this.gvSmsShopReport.DataSource = db;
            this.gvSmsShopReport.DataBind();
            PageBase.BindSerialRepeater(this.gvSmsShopReport, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1));
        }
Esempio n. 14
0
        public IActionResult Index([FromBody] TargetPhones targetPhone)
        {
            Console.WriteLine(targetPhone.targetPhoneNumber);
            Console.WriteLine("A Twilio message was just sent to that number.");
            // do a try catch
            var id = Int32.Parse(targetPhone.targetPhoneNumber);

            Console.WriteLine(id);
            using (var db = new PharmTwilioDbContext())
            {
                SmsLog rec = db.SmsLogs.Find(id);
                rec.wasContacted = true;
                db.SaveChanges();
            }
            return(View());
        }
Esempio n. 15
0
        public async Task <SmsLog> Insert(string mobileNumber, string message, int statusCode, int appId, string exceptionMessage = null, string responseJson = null)
        {
            var smsLog = new SmsLog
            {
                MobileNumber     = mobileNumber,
                Message          = message,
                StatusCode       = statusCode,
                AppId            = appId,
                ExceptionMessage = exceptionMessage,
                ResponseJson     = responseJson
            };

            _context.SmsLog.Add(smsLog);
            await _context.SaveChangesAsync();

            return(await Task.FromResult(smsLog));
        }
Esempio n. 16
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="phones">多个号码用;号隔开</param>
        /// <param name="content">内容</param>
        /// <returns></returns>
        public BaseObject SendSms(string phones, string content, string userName, int?idss)
        {
            var obj = new BaseObject();

            try
            {
                //Thread objThread = new Thread(new ThreadStart(delegate{ ConnectSend(phones, content, userName, idss, ref obj)};));

                //objThread.Start();
            }
            catch (Exception e)
            {
                //Console.WriteLine("argumentNullException: {0}", e);
                obj.Tag     = -1;
                obj.Message = e.Message;
            }
            if (idss == null)
            {
                var log = new SmsLog();
                log.IsSuccess    = obj.Tag == 1 ? "Y" : "N";
                log.Number       = phones;
                log.ErrorMessage = obj.Message;
                log.DateCreated  = DateTime.Now;
                log.Content      = content;
                log.OperaUser    = userName;
                db.SmsLogs.Add(log);
            }
            else
            {
                var log = GetSmsLog((int)idss);
                log.IsSuccess = obj.Tag == 1 ? "Y" : "N";
                //log.Number = phones;
                log.ErrorMessage = obj.Message;
                log.DateCreated  = DateTime.Now;
                //log.Content = content;
                log.OperaUser = userName;
            }

            Save();

            return(obj);
        }
Esempio n. 17
0
        public string SendSms(SmsModel entity)
        {
            var credentials = Credentials.FromApiKeyAndSecret(SmsSettings.NEXMO_API_KEY, SmsSettings.NEXMO_API_SECRET);
            var client      = new SmsClient(credentials);
            var request     = new SendSmsRequest {
                To = entity.To, From = SmsSettings.BROJ_MOBITELA, Text = entity.Text
            };
            var response = client.SendAnSms(request);

            // if we sent the sms succesfully save the details to database.
            if (response != null)
            {
                SmsLog log = new SmsLog {
                    Broj = entity.To, Poruka = entity.Text, Dodatnisadrzaj = response.Messages[0].MessageId
                };
                SmsRepository.Insert(log);
                return(response.Messages[0].MessageId);
            }

            return(null);
        }
        public async Task Consume(ConsumeContext <ISendSmsRequestReceived> context)
        {
            await _smsLogRepository.LogAsync(SmsLog.CreateUsageLog(context.Message));

            var smsList = context.Message.SmsMessages.Select(s => new Sms(context.Message, s));

            await StoreAsync(smsList);

            foreach (var message in smsList)
            {
                try
                {
                    await _smsClient.SendAsync(message);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Error while sending sms");
                    await UpdateSmsStatusAsync(ex, message);
                    await PublishSmsRequestFailedEventAsync(context, message, ex);
                }
            }
        }
Esempio n. 19
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            HeContext heContext = Global.App.OsContext;
            // Session[\"Hits\"] = 1 + ( int) Session[\"Hits\"];
            bool processedOk = false;

            try {
                heContext.Session.TenantId = Convert.ToInt32(Request.QueryString["tenantid"]);
                if (heContext.MOMsg != null)
                {
                    heContext.MOMsg = SmsUtils.BuildMsgFromRequest(Request);
                }
                AppUtils.DoOnMobileOriginatedMessage(heContext, ref heContext.MOMsg);
                Global.App.OsContext.Session.MSISDN = heContext.MOMsg.MSISDN;
                SmsLog.Write(DateTime.Now, heContext.AppInfo.eSpaceId, heContext.AppInfo.Tenant.Id, heContext.AppInfo.OsContext.Session.UserId, heContext.AppInfo.eSpaceName, "", 0, "", heContext.MOMsg);
                handleRequest(heContext);
                processedOk = true;
            } finally {
                DatabaseAccess.FreeupResources(processedOk);
            }
            Response.End();
        }
Esempio n. 20
0
        public string ajaxSend(string phone)
        {
            var randomCode         = new Random().Next(100000).ToString("D6");
            CheckMobileModel model = new CheckMobileModel()
            {
                Phone   = phone,
                Message = string.Format(SmsConfig.Instance.RgistetSmsText, randomCode)
            };

            YG.SC.Common.SendMessageHelper smsHelper = new Common.SendMessageHelper();
            //if (!CommonValidator.IsValidPhoneNumber(PhoneNo))
            //{
            //    return SimpleResultModel.Conclude(SendCheckCodeStatus.手机号码无效);
            //}
            try
            {
                string smsResult = smsHelper.SendMessage(phone, model.Message);
                YG.SC.OpenShop.PCnCache.Instance.Add(model.Phone, randomCode);
                // 更新短信通道

                SmsLog smsModel = new SmsLog()
                {
                    PhoneNumber = model.Phone,
                    SendStatus  = smsResult
                    ,
                    Content = model.Message
                };
                _iCustomerService.SendSmsSaveLog(smsModel);
                return
                    ("ok");
                // SimpleResultModel.Conclude(ValidatePhoneStatus.验证码已发送);
            }
            catch (Exception ex)
            {
                return("-1");
                // return SimpleResultModel.Conclude(ValidatePhoneStatus.发送失败);
            }
        }
 public SmsLog SaveAsync(SmsLog cls)
 {
     try
     {
         var a = db.SmsLog.AsNoTracking()
                 .FirstOrDefault(q => q.Guid == cls.Guid);
         if (a == null)
         {
             db.SmsLog.Add(cls);
         }
         else
         {
             db.Entry(cls).State = EntityState.Modified;
         }
         db.SaveChanges();
         return(cls);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
        public async Task Consume(ConsumeContext <IReferredUserActivated> context)
        {
            await _smsLogRepository.LogAsync(SmsLog.CreateSmsPromotionLogs(context.Message));

            await _notificationFacade.SendEmailAsync(
                context.Message,
                Template.RefereeSmsCreditsAddedEmail,
                context.Message.RefereeEmail);

            await _notificationFacade.SendEmailAsync(
                context.Message,
                Template.ReferrerSmsCreditsAddedEmail,
                context.Message.ReferrerEmail);

            await _notificationFacade.SendSmsAsync(
                context.Message,
                Template.RefereeSmsCreditsAddedSms,
                context.Message.RefereePhone);

            await _notificationFacade.SendSmsAsync(
                context.Message,
                Template.ReferrerSmsCreditsAddedSms,
                context.Message.ReferrerPhone);
        }
Esempio n. 23
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Update(SmsLog model)
 {
     this._SmsLogBiz.Update(model);
 }
 partial void UpdateSmsLog(SmsLog instance);
 partial void DeleteSmsLog(SmsLog instance);
 partial void InsertSmsLog(SmsLog instance);
Esempio n. 27
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Delete(SmsLog model)
 {
     this._repoSmsLog.Delete(model);
 }
Esempio n. 28
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Update(SmsLog model)
 {
     this._repoSmsLog.Update(model);
 }
Esempio n. 29
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public SmsLog Insert(SmsLog model)
 {
     return(this._repoSmsLog.Insert(model));
 }
Esempio n. 30
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Delete(SmsLog model)
 {
     this._SmsLogBiz.Delete(model);
 }
Esempio n. 31
0
        public async Task <InsuranceClaim.Models.PaynowResponse> initiateTransaction(string id, string amount, string additionalinfo, string authemail, bool isRenew = false)
        {
            InsuranceClaim.Models.PaynowResponse paynowresponse = new InsuranceClaim.Models.PaynowResponse();

            var response = new HttpResponseMessage();
            FormUrlEncodedContent content;
            Uri    myuri     = new Uri(System.Web.HttpContext.Current.Request.Url.AbsoluteUri);
            string pathQuery = myuri.PathAndQuery;
            string hostName  = myuri.ToString().Replace(pathQuery, "");

            string PaymentId = "PAYNOW-" + Guid.NewGuid().ToString();

            HttpContext.Current.Session["PaymentId"] = PaymentId;

            //  authemail = "*****@*****.**";
            if (isRenew)
            {
                var values = new Dictionary <string, string>
                {
                    { "resulturl", hostName + "/Renew/SaveDetailList/" + id },
                    { "returnurl", hostName + "/Renew/SaveDetailList/" + id },
                    { "reference", PaymentId },
                    { "amount", Convert.ToString(amount) },
                    { "id", IntegrationID },
                    { "additionalinfo", additionalinfo },
                    { "authemail", authemail },
                    { "status", "Message" }
                };

                var generatedhash = GenerateTwoWayHash(values, new Guid(IntegrationKey));

                var _values = new Dictionary <string, string>
                {
                    { "resulturl", hostName + "/Renew/SaveDetailList/" + id },
                    { "returnurl", hostName + "/Renew/SaveDetailList/" + id },
                    { "reference", PaymentId },
                    { "amount", Convert.ToString(amount) },
                    { "id", IntegrationID },
                    { "additionalinfo", additionalinfo },
                    { "authemail", authemail },
                    { "status", "Message" },
                    { "hash", generatedhash.ToUpper() }
                };

                paynowresponse.generatedhash = generatedhash.ToUpper();

                content = new FormUrlEncodedContent(_values);

                response = await client.PostAsync("https://www.paynow.co.zw/interface/initiatetransaction", content);
            }
            else
            {
                var values = new Dictionary <string, string>
                {
                    { "resulturl", hostName + "/Paypal/SaveDetailList/" + id },
                    { "returnurl", hostName + "/Paypal/SaveDetailList/" + id },
                    { "reference", PaymentId },
                    { "amount", Convert.ToString(amount) },
                    { "id", IntegrationID },
                    { "additionalinfo", additionalinfo },
                    { "authemail", authemail },
                    { "status", "Message" }
                };

                var generatedhash = GenerateTwoWayHash(values, new Guid(IntegrationKey));

                var _values = new Dictionary <string, string>
                {
                    { "resulturl", hostName + "/Paypal/SaveDetailList/" + id },
                    { "returnurl", hostName + "/Paypal/SaveDetailList/" + id },
                    { "reference", PaymentId },
                    { "amount", Convert.ToString(amount) },
                    { "id", IntegrationID },
                    { "additionalinfo", additionalinfo },
                    { "authemail", authemail },
                    { "status", "Message" },
                    { "hash", generatedhash.ToUpper() }
                };

                paynowresponse.generatedhash = generatedhash.ToUpper();

                content = new FormUrlEncodedContent(_values);

                response = await client.PostAsync("https://www.paynow.co.zw/interface/initiatetransaction", content);
            }



            var responseString = await response.Content.ReadAsStringAsync();

            string decodedUrl = Uri.UnescapeDataString("http://dummyurl_to_decode_asURL.com?" + responseString);

            Uri responseUri = new Uri(decodedUrl);

            SmsLog objsmslog = new SmsLog()
            {
                Sendto   = "PAYNOW",
                Body     = content.ToString(),
                Response = decodedUrl
            };

            InsuranceContext.SmsLogs.Insert(objsmslog);

            if (decodedUrl.Contains("Status=Error"))
            {
                paynowresponse.status = HttpUtility.ParseQueryString(responseUri.Query).Get("status");
                paynowresponse.error  = HttpUtility.ParseQueryString(responseUri.Query).Get("error");

                //log error
                //display error
                return(paynowresponse);
            }
            else
            {
                paynowresponse.browserurl = HttpUtility.ParseQueryString(responseUri.Query).Get("browserurl");
                paynowresponse.pollurl    = HttpUtility.ParseQueryString(responseUri.Query).Get("pollurl");
                paynowresponse.status     = HttpUtility.ParseQueryString(responseUri.Query).Get("status");
                paynowresponse.hash       = HttpUtility.ParseQueryString(responseUri.Query).Get("hash");

                //log success
                //display success
                //It is vital that the merchant site verify the hash value contained in the message before redirecting the
                //Customer to the browserurl.
                return(paynowresponse);
            }
        }
Esempio n. 32
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public SmsLog Insert(SmsLog model)
 {
     return(this._SmsLogBiz.Insert(model));
 }
Esempio n. 33
0
 public void SaveSmsLog(SmsLog smsLog)
 {
     InsuranceContext.SmsLogs.Insert(smsLog);
 }