Esempio n. 1
0
        public SubscriptionService(int id)
        {
            CDB           DB     = new CDB("GetActiveServices");
            SqlDataReader reader = (SqlDataReader)DB.Execute("SUB_GetActiveSubscriptionService " + id, CDB.exmReturnTypes.RETURN_READER);

            if (reader.Read())
            {
                var service = new SubscriptionService(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), (BillingFrequencies)reader.GetInt32(3), (BillingTimes)reader.GetInt32(4), reader.GetDecimal(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetString(8), (Statuses)reader.GetInt32(9));
                _ID                    = service.ID;
                _Description           = service.Description;
                _GroupID               = service.GroupID;
                _BillingFrequency      = service.BillingFrequency;
                _BillingTime           = service.BillingTime;
                _BillingAmount         = service.BillingAmount;
                _BillingDayOfMonth     = service.BillingDayOfMonth;
                _PaymentSystemClientID = service.PaymentSystemClientID;
                _ResponseQueue         = new CQueueWrapper(service.ResponseQueue.QueueName);
                _Status                = service.Status;
            }

            reader.Close();
            reader = null;

            DB.Close();
            DB = null;
        }
Esempio n. 2
0
        public bool SendUnsubscribeRequest(string mobileNumber, int subscriptionServiceID, out string returnMessage)
        {
            bool hasSent = false;
            SubscriptionServiceInfo subscriptionService = new SubscriptionServiceInfo(subscriptionServiceID);

            returnMessage = string.Empty;
            if (subscriptionService != null && subscriptionService.Id > 0 && !string.IsNullOrEmpty(subscriptionService.UnsubscribeKeyword))
            {
                CQueueWrapper cq     = new CQueueWrapper(subscriptionService.RequestQueue);
                CXMLCapsule   xmlcap = new CXMLCapsule();

                xmlcap.SetParameter("INPUTMECHANISM", "20", true);//USSD input mechanism.
                xmlcap.SetParameter("SOURCEADDRESS", mobileNumber, true);
                xmlcap.SetParameter("SHORTMESSAGE", subscriptionService.UnsubscribeKeyword, true);
                cq.Send(xmlcap);
                returnMessage = String.Format("An unsubscribe request has been sent for {0}. A confirmation SMS will be sent to you when successful", subscriptionService.Name);
                hasSent       = true;
            }
            else
            {
                if (subscriptionService == null || subscriptionService.Id < 0)
                {
                    returnMessage = "Subscription service does not exist.";
                }
                else if (String.IsNullOrEmpty(subscriptionService.UnsubscribeKeyword))
                {
                    returnMessage = "Unsubscribe keyword is not set up";
                }
            }

            return(hasSent);
        }
Esempio n. 3
0
        public static void sendSMS(string Msisdn, string message)
        {
            CQueueWrapper smsSender = new CQueueWrapper("CUSTOM_CAMP_BUILDEROUTQ");
            CSMSCapsule   sms       = new CSMSCapsule(Msisdn, "", false, CSMSCapsule.MessageTypes.DEFAULT, 1, 5, 7, 5, CUtility.GetNetworkID(Msisdn), false, CUtility.ToHex(message), false);

            smsSender.Send(sms);
            smsSender = null;
            sms       = null;
        }
Esempio n. 4
0
        public static void sendSMS(int campaignId, string recipient, string message)
        {
            CQueueWrapper smsSender = new CQueueWrapper("smsSterkinekorQ");
            CSMSCapsule   sms       = new CSMSCapsule(recipient, "", false, CSMSCapsule.MessageTypes.DEFAULT, 1, 5, 7, 5, CUtility.GetNetworkID(recipient), false, CUtility.ToHex(message), false);

            smsSender.Send(sms);
            smsSender = null;
            sms       = null;

            Transaction.InsertSMS(campaignId, recipient, message);
        }
Esempio n. 5
0
 public SubscriptionService(int id, string description, int groupID, BillingFrequencies billingFrequency, BillingTimes billingTime, decimal billingAmount, int billingDatOfMonth, int paymentSystemClientID, string responseQueue, Statuses status)
 {
     _ID                    = id;
     _Description           = description;
     _GroupID               = groupID;
     _BillingFrequency      = billingFrequency;
     _BillingTime           = billingTime;
     _BillingAmount         = billingAmount;
     _BillingDayOfMonth     = billingDatOfMonth;
     _PaymentSystemClientID = paymentSystemClientID;
     _ResponseQueue         = new CQueueWrapper(responseQueue);
     _Status                = status;
 }
Esempio n. 6
0
        void Menu_ThirdPartyCommunicationEvent(object sender, MenuItem currentMenuItem)
        {
            if (currentMenuItem.IsSMS.HasValue)
            {
                if (currentMenuItem.IsSMS.Value)
                {
                    string communicationFeedback;
                    var recipients = currentMenuItem.ThirdPartyCommunicationRecipients.Replace(" ","").Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    string commsText = String.Format("{0}; Mobile Number: {1}", currentMenuItem.ThirdPartyCommunicationText,Session.MSISDN);
                    foreach (var number in recipients)
                    {
                        exactmobile.ussdcommon.MenuCommunication.SendCommunication(Session.Campaign.CampaignID, currentMenuItem.MenuId, Session.USSDTransactionID, MenuItem.CommunicationType.SMS, ussdcommon.utility.CommonUtility.ReturnNetworkID(number.Trim()), number.Trim(), commsText, (Session.USSDNumber.HasValue ? Convert.ToString(Session.USSDNumber.Value) : ""), currentMenuItem.WaitForHTTPResponse,false, out communicationFeedback);
                        
                    }
                }
                else
                {
                    string smtpServer;
                    if (!ussdcommon.utility.CommonUtility.TryGetAppSettings("SMTPServer", true, out smtpServer))
                        smtpServer = "192.168.1.110";
                    
                    CXMLCapsule capsule = new CXMLCapsule();

                    capsule.SetParameter("Sender", "*****@*****.**", true);
                    capsule.SetParameter("Recipients", currentMenuItem.ThirdPartyCommunicationRecipients.Replace(" ", ""), true);
                    capsule.SetParameter("Subject", "Exact USSD Notification Campaign #" + Session.Campaign.CampaignID.ToString(), true);
                    capsule.SetParameter("Priority", "2", true);
                    capsule.SetParameter("SMTPServer", smtpServer, true);                    
                    capsule.SetParameter("Body", string.Format("{0}. Mobile Number: {1}",currentMenuItem.ThirdPartyCommunicationText,Session.MSISDN), true);
                    capsule.SetParameter("BodyFormat", "", true);
                    capsule.SetParameter("CarbonCopies", "", true);
                    capsule.SetParameter("BlindCarbonCopies", "", true);

                    CQueueWrapper mailQueue = new CQueueWrapper("EmailOutQ");
                    mailQueue.Send(capsule);                    
                }
            }
        }
Esempio n. 7
0
        public static bool SendCommunication(int ussdCampaignID, int menuID, long ussdTransactionID, MenuItem.CommunicationType communicationType, int mobileNetworkID, string mobileNumber, string communicationText, string ussdNumber, bool waitForResponse, bool sendHTTPResponseBySMS, out string response)
        {
            bool hasSent = false;

            try
            {
                response = null;
                switch (communicationType)
                {
                case MenuItem.CommunicationType.SM2HTTP:
                    long transactionID = -1;
                    try
                    {
                        if (AddHTTPTransaction(ussdCampaignID, ussdTransactionID, menuID, mobileNumber, null, out transactionID))
                        {
                            StringBuilder url = new StringBuilder(communicationText);
                            url.AppendFormat("&MSISDN={0}&DESTADDRESS={1}&REFERENCE={2}", HttpUtility.UrlEncode(mobileNumber), HttpUtility.UrlEncode(ussdNumber), HttpUtility.UrlEncode(transactionID.ToString()));

                            UpdateHTTPTransaction(transactionID, url.ToString(), null, null, null, null);
                            WebResponse webResponse       = null;
                            string      webResponseString = string.Empty;
                            if (!waitForResponse)
                            {
                                var webRequest = HttpWebRequest.Create(url.ToString());
                                webRequest.Method = "GET";

                                var asyncStateObject = new AsyncHTTPRequestStateObject()
                                {
                                    Request                 = webRequest
                                    , TransactionID         = transactionID
                                    , MenuID                = menuID
                                    , MobileNetworkID       = mobileNetworkID
                                    , MobileNumber          = mobileNumber
                                    , USSDCampaignID        = ussdCampaignID
                                    , USSDNumber            = ussdNumber
                                    , USSDTransactionID     = ussdTransactionID
                                    , SendHTTPResponseBySMS = sendHTTPResponseBySMS
                                };


                                IAsyncResult asyncResult = webRequest.BeginGetResponse(new AsyncCallback(PerformAsynchronousHTTPRequestCallback), asyncStateObject);

                                System.Threading.ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, new System.Threading.WaitOrTimerCallback(AsynchronousHTTPRequestTimeoutCallback), asyncStateObject, asyncStateObject.Request.Timeout, true);
                                return(true);
                            }
                            else
                            {
                                try
                                {
                                    var webRequest = HttpWebRequest.Create(url.ToString());
                                    webRequest.Method = "GET";
                                    webResponse       = webRequest.GetResponse();

                                    using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
                                        webResponseString = streamReader.ReadToEnd();

                                    UpdateHTTPTransaction(transactionID, null, null, null, webResponseString, null);
                                }
                                finally
                                {
                                    if (webResponse != null)
                                    {
                                        webResponse.Close();
                                    }
                                }
                                string clientMessage   = string.Empty;
                                string clientReference = string.Empty;

                                XmlDocument responseXMLDoc = new XmlDocument();
                                responseXMLDoc.LoadXml(webResponseString);

                                if (TryGetXMLElement(responseXMLDoc, new string[] { "SM", "Message" }, out clientMessage))
                                {
                                    response = clientMessage;
                                    UpdateHTTPTransaction(transactionID, null, null, clientMessage, null, null);
                                }
                                if (TryGetXMLElement(responseXMLDoc, new string[] { "SessionReference", "RefNo" }, out clientReference))
                                {
                                    UpdateHTTPTransaction(transactionID, null, clientReference, null, null, null);
                                }

                                if (sendHTTPResponseBySMS && !String.IsNullOrEmpty(clientMessage))
                                {
                                    MenuCommunication.SendCommunication(ussdCampaignID, menuID, ussdTransactionID, MenuItem.CommunicationType.SMS, mobileNetworkID, mobileNumber, clientMessage, ussdNumber, false, false, out response);
                                    response = null;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (transactionID > 0)
                        {
                            UpdateHTTPTransaction(transactionID, null, null, null, null, ex.ToString());
                        }
                    }
                    break;

                case MenuItem.CommunicationType.SMS:
                case MenuItem.CommunicationType.MMS:
                    CQueueWrapper commsSendQueue = null;

                    if (communicationType == MenuItem.CommunicationType.MMS)
                    {
                        commsSendQueue = new CQueueWrapper("EXACTUSSDMMSCOMMUNICATIONQ");
                    }
                    else if (communicationType == MenuItem.CommunicationType.SMS)
                    {
                        commsSendQueue = new CQueueWrapper("EXACTUSSDSMSCOMMUNICATIONQ");
                    }

                    CXMLCapsule commsCapsule = new CXMLCapsule();
                    commsCapsule.SetParameter("USSDTransactionID", ussdTransactionID.ToString(), true);
                    commsCapsule.SetParameter("USSDCampaignID", ussdCampaignID.ToString(), true);
                    commsCapsule.SetParameter("USSDMenuID", menuID.ToString(), true);
                    commsCapsule.SetParameter("MobileNumber", mobileNumber, true);
                    commsCapsule.SetParameter("MobileNetworkID", mobileNetworkID.ToString(), true);
                    commsCapsule.SetParameter("CommunicationText", communicationText, true);
                    commsCapsule.SetParameter("CommunicationTypeID", Convert.ToInt32(communicationType).ToString(), true);
                    commsCapsule.SetParameter("USSDNumber", ussdNumber, true);
                    if (commsSendQueue != null)
                    {
                        commsSendQueue.Send(commsCapsule);
                        hasSent = true;
                    }
                    break;
                }
            }
            finally
            {
            }
            return(hasSent);
        }