private void RelayStatus(List <Message> messages)
        {
            string        response      = string.Empty;
            PrivateNumber privateNumber = new PrivateNumber();

            foreach (Message msg in messages)
            {
                response        = string.Empty;
                deliveryMessage = new DeliveryMessage();
                msg.Formatter   = new BinaryMessageFormatter();
                deliveryMessage = (DeliveryMessage)msg.Body;

                privateNumber = Arad.SMS.Gateway.Facade.PrivateNumber.LoadNumber(deliveryMessage.PrivateNumberGuid);
                deliveryMessage.DeliveryRelayGuid = privateNumber.DeliveryTrafficRelayGuid;

                LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay,
                                                       string.Format(@"On DeliveryRelay{5}BatchId : {0},{5}PrivateNumberGuid : {1},{5}DeliveryRelayGuid : {2},{5}Mobile :{3},{5}Status : {4},{5}",
                                                                     deliveryMessage.BatchId,
                                                                     deliveryMessage.PrivateNumberGuid,
                                                                     deliveryMessage.DeliveryRelayGuid,
                                                                     deliveryMessage.Mobile,
                                                                     deliveryMessage.Status,
                                                                     Environment.NewLine));


                if (deliveryMessage.DeliveryRelayGuid == Guid.Empty)
                {
                    deliveryMessage.DeliveryRelayGuid = Helper.GetGuid(Arad.SMS.Gateway.Facade.UserSetting.GetSettingValue(deliveryMessage.UserGuid, Arad.SMS.Gateway.Business.AccountSetting.DeliveryTrafficRelay));
                }

                if (deliveryMessage.DeliveryRelayGuid != Guid.Empty)
                {
                    TrafficRelay relay = Arad.SMS.Gateway.Facade.TrafficRelay.LoadUrl(deliveryMessage.DeliveryRelayGuid);

                    if (!string.IsNullOrEmpty(relay.Url))
                    {
                        relay.Url = Regex.Replace(relay.Url, "\\$batchid", deliveryMessage.BatchId, RegexOptions.IgnoreCase);
                        relay.Url = Regex.Replace(relay.Url, "\\$mobile", deliveryMessage.Mobile, RegexOptions.IgnoreCase);
                        relay.Url = Regex.Replace(relay.Url, "\\$status", deliveryMessage.Status.ToString(), RegexOptions.IgnoreCase);
                        LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay, string.Format("URL : {0}", relay.Url));

                        using (var wb = new WebClient())
                        {
                            response = wb.DownloadString(relay.Url);
                        }

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay,
                                                               string.Format(@"On ParseDeliveryMessage{0}Response : {1},{0}",
                                                                             Environment.NewLine, response));
                    }
                }
            }
            //Facade.OutboxNumber.GetDeliveryRelayInfo(lstDeliveryMessages.Where);
        }
Exemplo n.º 2
0
        private void RelaySms(List <Message> messages)
        {
            string response = string.Empty;

            foreach (Message msg in messages)
            {
                response       = string.Empty;
                receiveMessage = new ReceiveMessage();
                msg.Formatter  = new BinaryMessageFormatter();
                receiveMessage = (ReceiveMessage)msg.Body;

                LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay,
                                                       string.Format(@"On ParseReceivedMessage{6}SmsGuid : {0},{6}NumberGuid : {1},{6}SmsTrafficRelayGuid : {2},{6},Sender :{3},{6}Receiver : {4},{6}Text:{5}{6}",
                                                                     receiveMessage.Guid,
                                                                     receiveMessage.PrivateNumberGuid,
                                                                     receiveMessage.SmsTrafficRelayGuid,
                                                                     receiveMessage.Sender,
                                                                     receiveMessage.Receiver,
                                                                     receiveMessage.SmsText,
                                                                     Environment.NewLine));

                if (receiveMessage.SmsTrafficRelayGuid == Guid.Empty)
                {
                    receiveMessage.SmsTrafficRelayGuid = Helper.GetGuid(Arad.SMS.Gateway.Facade.UserSetting.GetSettingValue(receiveMessage.UserGuid, Arad.SMS.Gateway.Business.AccountSetting.SmsTrafficRelay));
                }

                if (receiveMessage.SmsTrafficRelayGuid != Guid.Empty)
                {
                    TrafficRelay relay = Arad.SMS.Gateway.Facade.TrafficRelay.LoadUrl(receiveMessage.SmsTrafficRelayGuid);

                    if (!string.IsNullOrEmpty(relay.Url))
                    {
                        relay.Url = Regex.Replace(relay.Url, "\\$to", receiveMessage.Receiver, RegexOptions.IgnoreCase);
                        relay.Url = Regex.Replace(relay.Url, "\\$from", receiveMessage.Sender, RegexOptions.IgnoreCase);
                        relay.Url = Regex.Replace(relay.Url, "\\$text", receiveMessage.SmsText, RegexOptions.IgnoreCase);
                        LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay, string.Format("URL : {0}", relay.Url));

                        using (var wb = new WebClient())
                        {
                            response = wb.DownloadString(relay.Url);
                        }

                        LogController <ServiceLogs> .LogInFile(ServiceLogs.TrafficRelay,
                                                               string.Format(@"On ParseReceivedMessage{0}Response : {1},{0}",
                                                                             Environment.NewLine, response));
                    }
                }
            }
        }