Exemplo n.º 1
0
        static void Main(string[] args)
        {
            GatewayAPIHandler handler = new GatewayAPIHandler("apiToken");

            // Create message
            SMSMessage message = new SMSMessage()
                                 .SetMessage("Hello World")
                                 .SetRecipient(new SMSRecipient(4512345678));

            // Send message
            try
            {
                Result result = handler.SendMessage(message);
                Console.WriteLine(result.Ids); // Returns a list of ids.
            }
            catch (UnauthorizedException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (ServerException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (MessageException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
        public static string SendOneSms(SMSMessage sms)
        {
            if (!string.IsNullOrEmpty(sms.SenderId))
            {
                sms.SenderId.Trim();
            }

            SmsMessage input = new SmsMessage()
            {
                MessageId = sms.Id,
                SenderId  = sms.SenderId,
                Phone     = sms.Phone,
                Message   = sms.Message
            };

            SmsSendingResult result = new SmsSendingResult();

            using (EasySmsServiceClient client = new EasySmsServiceClient())
            {
                client.Open();
                result = client.SendMessage(input);
                client.Close();
            }
            return(result.ErrorMessage);
        }
Exemplo n.º 3
0
        private async Task SendOfflineMessagesAsync()
        {
            try
            {
                string message = await Utility.GetDistressMessage();

                if (Globals.CurrentProfile.CanSMS) //TODO
                {
                    //TODO: Issue: When SMS is shown, SendEmail and InitiateCall are executed without waiting for user action and with ignore behavior.
                    SMSMessage smsMgs = new SMSMessage();
                    smsMgs.PhoneNumbers = Utility.GetBuddyNumbers();
                    smsMgs.Message      = message;

                    Utility.SendSMS(smsMgs);
                }
                if (Globals.IsDataNetworkAvailable && Globals.CurrentProfile.CanFBPost && Globals.User.FBAuthId.GetValue() != string.Empty && Globals.CurrentProfile.FBGroupId.GetValue() != string.Empty)
                {
                    Utility.PostMessagetoFacebook(Globals.CurrentProfile.FBGroupId, Globals.User.FBAuthId, message);
                }
            }
            catch (Exception exception)
            {
                ExceptionHandler.ShowExceptionMessageAndLog(exception, true);
            }
        }
Exemplo n.º 4
0
        protected void OnTimedEvent(SMSProvider smsProvider)
        {
            string text       = $"Message {++messageCounter} received. ";
            var    smsMessage = new SMSMessage(Guid.NewGuid(), _phoneNumber, text, DateTime.Now, smsProvider);

            RaiseSMSReceivedEvent(this, smsMessage);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostTwilio(string data)
        {
            var message = new SMSMessage()
            {
                ToNumber = Mobile,
                Content  = $"Forecast: {data}"
            };

            var result = await _notification.SendSmsWithTwilio(message);

            TempData["Mobile"]      = Mobile;
            TempData["WeatherData"] = data;

            if (result.IsSuccess)
            {
                TempData["SuccessMessage"] = $"SMS notification was sent to {message.ToNumber} via Twilio";
                _logger.LogDebug("SMS notification was sent to {toNumber} via Twilio", message.ToNumber);
            }
            else
            {
                TempData["ErrorMessage"] = $"Failed to send notification to {Mobile} via Twilio. Please see the log.";
                _logger.LogWarning("Failed to send notification to {toNumber} via Twilio. Error: {error}", message.ToNumber, result.Errors);
            }

            return(RedirectToPage());
        }
Exemplo n.º 6
0
        public void SendSMS(SendSMSParameter param)
        {
            var client = GetSMSSender(param);

            client.Form["to"]      = param.ReceiveMobile;
            client.Form["content"] = param.SendMessage;
            client.Form["time"]    = string.Empty;
            client.SetRequest(client.BuildUri(client.Form["url"], client.Form));
            using (var context = base.CreateContext())
            {
                int maxSentPreDay = 3;
                var q             = from t in context.SMSMessages
                                    where t.ReceiveMobile == param.ReceiveMobile && t.AppID == param.AppID &&
                                    DateTime.UtcNow.AddDays(-1D) <= t.SendDate && t.SendDate <= DateTime.UtcNow.AddDays(1D)
                                    select t;
                int count = q.Count();
                if (count > maxSentPreDay)
                {
                    throw new InvalidInvokeException("SendSMS");
                }

                var pObj = new SMSMessage();
                EntityMapper.Map <SendSMSParameter, SMSMessage>(param, pObj);
                pObj.RowID      = Guid.NewGuid();
                pObj.CreateDate = DateTime.Now;
                pObj.Status     = (int)MessageStatusKind.Unsent;
                context.SMSMessages.Add(pObj);
                context.SaveChanges();
                TaskHelper.Factory.StartNew(sender_SendCompleted, new object[] { pObj.RowID, client });
            }
        }
Exemplo n.º 7
0
    //public SmsMgr.SmsResult SendSms(string to, string text, int objectId)
    //{
    //    SmsMgr.SmsResult result = null;

    //    try
    //    {
    //        if (string.IsNullOrEmpty(to))
    //        {
    //            throw new Exception("A 'to' phone number was not specified");
    //        }
    //        if (string.IsNullOrEmpty(text))
    //        {
    //            throw new Exception("A blank text message cannot be sent");
    //        }

    //        result = new SmsMgr.SmsResult();

    //        string from = ConfigurationManager.AppSettings["twilio-from-no"];

    //        var msg = this.SmsClient.SendSmsMessage(from, to, text);

    //        result.AccountSid = msg.AccountSid;
    //        result.Sid = msg.Sid;
    //        result.Status = msg.Status;

    //        if (msg.RestException != null)
    //        {
    //            result.ExceptionMsg = msg.RestException.Message;
    //        }

    //    }
    //    catch (Exception e)
    //    {
    //        HeadSpin.App.Core.MGR.Instance.LogDebugMsg("error sending sms: " + e.Message);
    //    }

    //    return result;
    //}

    public SmsMgr.SmsResult SendSms(string to, string text, string fromPhoneNum = "")
    {
        SmsMgr.SmsResult result = null;

        try
        {
            if (string.IsNullOrEmpty(to))
            {
                throw new Exception("A 'to' phone number was not specified");
            }
            if (string.IsNullOrEmpty(text))
            {
                throw new Exception("A blank text message cannot be sent");
            }

            result = new SmsMgr.SmsResult();

            string from = fromPhoneNum;

            if (string.IsNullOrWhiteSpace(fromPhoneNum))
            {
                from = ConfigurationManager.AppSettings["twilio-from-no"];
            }

            HeadSpin.App.Core.MGR.Instance.LogDebugMsg(string.Format("try send twillio client from {0} to {1} txt {2}", from, to, text));

            SMSMessage msg = null;

            Boolean sendTexts = false;
            var     send      = System.Configuration.ConfigurationManager.AppSettings["send-text"];

            if (send != null)
            {
                sendTexts = Boolean.Parse(send);
            }

            if (sendTexts == true)
            {
                msg = this.SmsClient.SendSmsMessage(from, to, text);

                result.AccountSid = msg.AccountSid;
                result.Sid        = msg.Sid;
                result.Status     = msg.Status;

                if (msg.RestException != null)
                {
                    result.ExceptionMsg = msg.RestException.Message;
                }

                HeadSpin.App.Core.MGR.Instance.LogDebugMsg("result status " + result.Status);
            }
        }
        catch (Exception e)
        {
            HeadSpin.App.Core.MGR.Instance.LogException(e);
            throw;
        }

        return(result);
    }
Exemplo n.º 8
0
        public ActionResult SendTestSms(SmsTemplateModel model)
        {
            SmsTemplate smsTemplate = smsBusinessLogic.SmsTemplate_Get();

            smsTemplate.Phone = model.Phone;
            model.GetSmsTemplate(smsTemplate);
            smsTemplate = model.SetSmsTemplate();

            SMSMessage smsMessage = new SMSMessage()
            {
                Id       = 1,//в тестовой отправке смс ID не критично
                SenderId = smsTemplate.SenderId,
                Phone    = smsTemplate.Phone,
                Message  = smsTemplate.Message
            };

            if (!string.IsNullOrEmpty(smsMessage.Phone))
            {
                model.Result = SmsSender.SmsSender.SendOneSms(smsMessage);
                if (string.IsNullOrEmpty(model.Result))
                {
                    model.Result = "Смс успешно отправлено.";
                }
            }
            else
            {
                model.Result = "Введите номер телефона!";
            }

            return(View("Index", model));
        }
        public async void Send_WithDefaultFromNumber_Success()
        {
            _twilioHttpClient.Setup(client => client.MakeRequestAsync(It.IsAny <TwilioHttp.Request>()))
            .ReturnsAsync(new TwilioHttp.Response(System.Net.HttpStatusCode.OK, "{'sid': '111'}"));

            var message = new SMSMessage
            {
                ToNumber = "0321",
                Content  = "Test"
            };

            var provider = new TwilioProvider(
                new TwilioOptions()
            {
                DefaultFromNumber = "000"
            },
                _twilioHttpClient.Object,
                _loggerFactory.Object);
            var result = await provider.Send(message.ToParameters());

            var sid = result.ReturnedValues["Sid"].ToString();

            Assert.True(result.IsSuccess);
            Assert.Equal("111", sid);
            Assert.Empty(result.Errors);
        }
Exemplo n.º 10
0
        public SMSIsSendMessage SendSMS(SMSMessage message, ref SMSIsNotSendMessage smsIsNotSend)
        {
            var random = new Random();
            int exep   = random.Next(0, 10);

            if (exep == 6 || exep == 3)
            {
                //_logger.ForContext<SmsProcessor>().Error("Message :{@text} - not send", message.Text);
                _logger.LogFormat(LoggingLevel.Error, "Message :{@text} - not send", message.Text);
                smsIsNotSend = new SMSIsNotSendMessage()
                {
                    Text    = message.Text,
                    Problem = exep.ToString()
                };
                return(null);
            }
            //_logger.ForContext<SmsProcessor>().Information("Message :{@text} - is send.Processor: {@NameProcessor}. Provider: {@provider}", message.Text, Name.GetName(), _provider);
            _logger.LogFormat(LoggingLevel.Info, "Message :{@text} - is send.Processor: {@NameProcessor}. Provider: {@provider}", message.Text, Name.GetName(), _provider);
            var smsIsSend = new SMSIsSendMessage()
            {
                Text     = message.Text,
                DateTime = DateTime.Now
            };

            return(new SMSIsSendMessage {
                Text = smsIsSend.Text, DateTime = smsIsSend.DateTime
            });
        }
        public async void Send_Failed()
        {
            _twilioHttpClient.Setup(client => client.MakeRequestAsync(It.IsAny <TwilioHttp.Request>()))
            .ReturnsAsync(new TwilioHttp.Response(System.Net.HttpStatusCode.BadRequest, "Error01"));

            var message = new SMSMessage
            {
                FromNumber = "0123",
                ToNumber   = "0321",
                Content    = "Test"
            };

            var provider = new TwilioProvider(new TwilioOptions(), _twilioHttpClient.Object, _loggerFactory.Object);
            var result   = await provider.Send(message.ToParameters());

            Assert.False(result.IsSuccess);
            Assert.NotEmpty(result.Errors);
            Assert.Contains("Error01", result.Errors[0]);

            var startMessage = LoggerHelper.FormatLogValues(TwilioLogMessages.Sending_Start, message.ToNumber);

            _logger.VerifyLog(LogLevel.Debug, startMessage);

            var warningMessage = LoggerHelper.FormatLogValues(TwilioLogMessages.Sending_Failed, message.ToNumber, result.Errors);

            _logger.VerifyLog(LogLevel.Warning, warningMessage);
        }
        public async void Send_Success()
        {
            _twilioHttpClient.Setup(client => client.MakeRequestAsync(It.IsAny <TwilioHttp.Request>()))
            .ReturnsAsync(new TwilioHttp.Response(System.Net.HttpStatusCode.OK, "{'sid': '111'}"));

            var message = new SMSMessage
            {
                FromNumber = "0123",
                ToNumber   = "0321",
                Content    = "Test"
            };

            var provider = new TwilioProvider(new TwilioOptions(), _twilioHttpClient.Object, _loggerFactory.Object);
            var result   = await provider.Send(message.ToParameters());

            var sid = result.ReturnedValues["Sid"].ToString();

            Assert.True(result.IsSuccess);
            Assert.Equal("111", sid);
            Assert.Empty(result.Errors);

            var startMessage = LoggerHelper.FormatLogValues(TwilioLogMessages.Sending_Start, message.ToNumber);

            _logger.VerifyLog(LogLevel.Debug, startMessage);

            var endMessage = LoggerHelper.FormatLogValues(TwilioLogMessages.Sending_End, message.ToNumber, sid);

            _logger.VerifyLog(LogLevel.Debug, endMessage);
        }
Exemplo n.º 13
0
        public bool SendMessage(SMSMessage msg, bool immediate, out String status)
        {
            int rs = 0;

            status = String.Empty;
            if (msg.id == 0)
            {
                //billable, bulkbillable, astStatus, batchID, status, nextPolled, pollCount
                msg.id = dh.SaveQueuedMessage(msg.building, msg.customer, msg.cbal, msg.smsType, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                              msg.batchID, msg.status);
                msg.reference = String.Format("{0}/{1}", msg.customer, msg.id);
                rs            = dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                                       msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
                if (msg.smsType == "Disconnection SMS" || immediate)
                {
                    String bid;
                    bool   success = SendSMS(msg.number, String.Format("{0}", msg.message), out status, out bid);
                    if (success)
                    {
                        msg.batchID = bid;
                        msg.status  = "SENT";
                        dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                               msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
                    }
                    else
                    {
                        MessageBox.Show("Cannot send sms to " + msg.customer);
                    }
                }
            }
            return(rs != -1 ? true : false);
        }
Exemplo n.º 14
0
        public JsonResult SendOTP(int id)
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                string query = @"SELECT
                                coalesce(std_contact,std_contact1,std_contact2)
                            FROM
                                sr_register
                            WHERE
                                std_active = 'Y' AND sr_number = @sr_number";

                string std_number = con.Query <string>(query, new { sr_number = id }).SingleOrDefault();

                SMSMessage sm = new SMSMessage();

                Random rdm = new Random();

                string password = rdm.Next(1000, 9999).ToString();

                string txt = @"Your ward take away OTP is " + password;

                sm.SendOTP(txt, std_number, false);

                return(Json(password));
            }
        }
Exemplo n.º 15
0
        public SentSmsMessageLogEntry Send(string phoneNumber, string message)
        {
            SentSmsMessageLogEntry result = new SentSmsMessageLogEntry
            {
                Date        = DateTime.UtcNow,
                Message     = message,
                Destination = phoneNumber,
            };

            SMSMessage msg = Client.SendSmsMessage(_Configuration.FromNumber, phoneNumber, message);

            if (msg.Status == "failed")
            {
                result.Status = (int)MessageSendStatus.Error;

                if (msg.RestException != null)
                {
                    result.Details = string.Format(CultureInfo.InvariantCulture, "Code: {0} : Status: {1}",
                                                   msg.RestException.Code,
                                                   msg.RestException.Status);
                }
                else
                {
                    result.Details = "Unknown error (Twilio did not report a RestException)";
                }
            }
            else
            {
                result.MessageId = msg.Sid;
                result.Status    = (int)MessageSendStatus.Success;
            }

            return(result);
        }
Exemplo n.º 16
0
    public bool SendImmediateMessage(SMSMessage msg, out String status)
    {
        if (msg.id == 0)
        {
            //billable, bulkbillable, astStatus, batchID, status, nextPolled, pollCount
            msg.id = dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                            msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
            msg.reference = String.Format("{0}/{1}", msg.customer, msg.id);
            dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                   msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
        }
        else
        {
            dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                   msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
        }
        String bid     = "";
        bool   success = SMS.SendSMS(msg.number, String.Format("{0} - Reply with ref:{1}", msg.message, msg.reference), out status, out bid);

        if (success)
        {
            msg.batchID = bid;
            dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                   msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
        }
        return(success);
    }
Exemplo n.º 17
0
        public bool SendBulkMessage(SMSMessage msg, bool immediate, out String status)
        {
            if (msg.id == 0)
            {
                //billable, bulkbillable, astStatus, batchID, status, nextPolled, pollCount
                msg.id = dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                                msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
            }
            else
            {
                dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                       msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
            }
            String bid = "";

            String[] numbers = msg.number.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            if (immediate)
            {
                foreach (String number in numbers)
                {
                    bool success = SendSMS(number, String.Format("{0}", msg.message), out status, out bid);
                    if (success)
                    {
                        msg.batchID += bid + ";";
                    }
                }
                dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus,
                                       msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status);
            }
            return(true);
        }
Exemplo n.º 18
0
        public void SendSMS(string number, string text)
        {
            if (number.Length != 12)
            {
                throw new Exception("Number must be formatted like this: +19175551212");
            }

            // Use your account SID and authentication token instead
            // of the placeholders shown here.
            string accountSID = "AC83c411cb030e7d110630044dafbc5d4a";
            string authToken  = "bd5c06eec0eb4a93625eb44791b1e096";

            // Create an instance of the Twilio client.
            TwilioRestClient client;

            client = new TwilioRestClient(accountSID, authToken);

            // Send an SMS message.
            SMSMessage result = client.SendSmsMessage("+18048843269", number, text);

            if (result.RestException != null)
            {
                //an exception occurred making the REST call
                string message = result.RestException.Message;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 插入记录到ReviewMT 中
        /// </summary>
        /// <param name="sms"></param>
        /// <param name="Numbers"></param>
        /// <param name="tran"></param>
        private static void AddReviewMT(SMSMessage sms, SMSNumber Numbers, IDbTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ReviewMT(");
            strSql.Append("SMSID,AccountID,Phones,SMSContent,StatusReport,SMSLevel,SendTime,Audit,ContentFilter,PhoneCount,SendGateway,PriorityDate,AuditResult,Signature,SPNumber,@WapURL,SMSTimer,Source)");
            strSql.Append(" values (");
            strSql.Append("@SMSID,@AccountID,@Phones,@SMSContent,@StatusReport,@SMSLevel,@SendTime,@Audit,@ContentFilter,@PhoneCount,@SendGateway,@PriorityDate,@AuditResult,@Signature,@SPNumber,@WapURL,@SMSTimer,@Source)");

            DBHelper.Instance.Execute(strSql.ToString(),
                                      new
            {
                SMSID         = Numbers.ID,
                AccountID     = sms.AccountID,
                Phones        = Numbers.Numbers,
                SMSContent    = sms.Content,
                StatusReport  = (ushort)sms.StatusReportType,
                SMSLevel      = (ushort)sms.SMSLevel,
                SendTime      = sms.SendTime,
                Audit         = (ushort)(sms.AuditType == AuditType.Template ? AuditType.Manual : sms.AuditType),
                ContentFilter = 0,
                PhoneCount    = Numbers.NumberCount,
                SendGateway   = sms.Channel,
                PriorityDate  = sms.SendTime,
                AuditResult   = sms.AuditType == AuditType.Manual ? 0 : 1,
                Signature     = sms.Signature,
                SPNumber      = sms.SPNumber,
                WapURL        = sms.WapURL,
                SMSTimer      = sms.SMSTimer,
                Source        = sms.Source
            }, tran);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Notifies subscribed SMS receive listeners that a new XBee SMS packet has been received
        /// in form of an <see cref="SMSMessage"/>.
        /// </summary>
        /// <param name="smsMessage">The message to be sent to subscribed data listeners.</param>
        /// <seealso cref="SMSMessage"/>
        private void NotifySMSReceived(SMSMessage smsMessage)
        {
            logger.InfoFormat(connectionInterface.ToString() + "SMS received from {0} >> {1}.",
                              smsMessage.PhoneNumber, smsMessage.Data);

            try
            {
                lock (SMSReceived)
                {
                    var handler = SMSReceived;
                    if (handler != null)
                    {
                        var args = new SMSReceivedEventArgs(smsMessage);

                        handler.GetInvocationList().AsParallel().ForAll((action) =>
                        {
                            action.DynamicInvoke(this, args);
                        });
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
            }
        }
Exemplo n.º 21
0
        public override void OnReceive(Context context, Intent intent)
        {
            try
            {
                if (intent.Action == IntentAction)
                {
                    var bundle = intent.Extras;
                    if (bundle != null)
                    {
                        var pdus       = bundle.Get("pdus");
                        var castedPdus = JNIEnv.GetArray <Object>(pdus.Handle);
                        var msgs       = new SmsMessage[castedPdus.Length];
                        var sb         = new StringBuilder();

                        var    smsArray = (Java.Lang.Object[])bundle.Get("pdus");
                        string format   = bundle.GetString("format");
                        foreach (var item in smsArray)
                        {
                            var        sms        = SmsMessage.CreateFromPdu((byte[])item, format);
                            SMSMessage sMSMessage = new SMSMessage
                            {
                                From    = sms.OriginatingAddress,
                                Message = sms.MessageBody
                            };
                            MessagingCenter.Send <Page, SMSMessage>(App.Current.MainPage, "SMSReceived", sMSMessage);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                //Toast.MakeText(context, ex.Message, ToastLength.Long).Show();
            }
        }
Exemplo n.º 22
0
        public static EzbobSmsMessage FromMessage(SMSMessage smsMessage)
        {
            DateTime now = DateTime.UtcNow;

            if (smsMessage == null)
            {
                return(new EzbobSmsMessage {
                    Status = "null",
                    DateCreated = now,
                    DateSent = now,
                    DateUpdated = now
                });
            }

            var model = new EzbobSmsMessage {
                AccountSid  = smsMessage.AccountSid,
                Sid         = smsMessage.Sid,
                DateCreated = smsMessage.DateCreated == default(DateTime) ? now : smsMessage.DateCreated,
                DateSent    = smsMessage.DateSent == default(DateTime) ? now : smsMessage.DateSent,
                DateUpdated = smsMessage.DateUpdated == default(DateTime) ? now : smsMessage.DateUpdated,
                From        = smsMessage.From,
                To          = smsMessage.To,
                Body        = smsMessage.Body == null ? "" : (smsMessage.Body.Length > 255 ? smsMessage.Body.Substring(0, 255) : smsMessage.Body),
                Status      = smsMessage.Status,
                Direction   = smsMessage.Direction,
                Price       = smsMessage.Price,
                ApiVersion  = smsMessage.ApiVersion,
            };

            return(model);
        }
Exemplo n.º 23
0
        //public static void SendFuelSMS(decimal amount, long contact, string ownername, string bunumber, decimal quantity)
        //{

        //    string sNumber = "9412965801";
        //    // string sMessage = "Dear Sir, abcg12344 / abcdef Advance Amount has been taken for Rs.1200 on Date : 28/3/17 Thanks, GMOU LTD";
        //    // string sSenderID = "SMSHUB";
        //   // string emaaseg = CreateMEssage(SMSMessage.Vivrani, amount, ownername, bunumber, contact, totalamount, vivranid);
        //    string sURL = "http://103.16.142.110/vendorsms/pushsms.aspx?user=sbisht&password=P9890242125&msisdn=" + contact + "&sid=GMOULT&msg=" + emaaseg + "&fl=0&gwid=2";
        //    //string sURL = "http://cloud.smsindiahub.in/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn =" + sNumber + "&sid =" + sSenderID + "&msg =" + sMessage + "&fl =1 & gwid = 2";
        //    string sResponse = GetResponse(sURL);
        //    // Response.Write(sResponse);
        //}
        public static string CreateMEssage(SMSMessage op, decimal amount, string ownername, string busnumber, long?contact, decimal totalamount, string vivranid)
        {
            string vivraniamount      = string.Format("Rs." + amount);
            string vivranitotalamount = string.Format("Rs." + totalamount);

            switch (op)
            {
            case SMSMessage.Advance:
            {
                string emssage = String.Format("Dear Sir, {0} / {1} Advance Amount has been taken for {2} on Date : {3} Thanks, GMOU LTD", "UK12PA-090", "Mr.Kamal kumar", "Rs.5000", DateTime.Now.ToShortDateString());
                return(emssage);
            }

            case SMSMessage.Vivrani:
            {
                string emssage = String.Format("Dear Sir, {0}/ {1} Vivrani No. {2} has been generated for {3} on Date : {4}. Total {5} Vivrani Generated till on this {6} Thanks, GMOU LTD", busnumber, ownername, vivranid, amount, DateTime.Now.ToShortDateString(), totalamount, DateTime.Now.Month.ToString());
                return(emssage);
            }

            case SMSMessage.Fuel:
            {
                string emssage = String.Format("Dear Sir, {0} / {1} Advance Amount has been taken for {2} on Date : {3} Thanks, GMOU LTD", "UK12PA-090", "Mr.Kamal kumar", "Rs.5000", DateTime.Now.ToShortDateString());
                return(emssage);
            }
            }
            return(null);
        }
Exemplo n.º 24
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //string s = this.ASPxHtmlEditor1.Html;
        string EmailMessage, SMSMessage;

        //string[] SResult = Temp.data.Split(';');
        using (SqlConnection con = new SqlConnection(strcon))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = @"select d.NameD, d.lat, d.long, d.IP, EMessage, Subject, SMessage,
                                u.Name+ ' ' +u.lastName AS FullName,
		                        u.Cell, u.Email, a.Type, a.IDD , dg.AnnouncingType
		                        from tblDeviceGroup dg inner join tblGroup g on dg.IDGroup=g.ID left join tblEmail e 
		                        on e.IDGroup=g.ID left join tblSMS s on s.IDGroup=g.ID left join tblUsersGroups ug 
		                        on ug.IDg=g.ID left join tblusers u
		                        on u.idUser=ug.IDu left join tblDeviceIO a on dg.IDDevice=a.IDD inner join tblDevice d on 
		                        a.IDD=d.idD where a.Type=@Type 
                                and dg.IDDevice=@IDD";
                cmd.Connection  = con;
                con.Open();
                cmd.Parameters.AddWithValue("@Type", "RFID");
                cmd.Parameters.AddWithValue("@IDD", 32);
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        if (sdr["AnnouncingType"].ToString() == "ES")
                        {
                            EmailMessage = sdr["EMessage"].ToString();
                            EmailMessage = EmailMessage.Replace("%DeviceName%", sdr["NameD"].ToString());
                            EmailMessage = EmailMessage.Replace("%Name%", sdr["FullName"].ToString());

                            SMSMessage = sdr["SMessage"].ToString();
                            SMSMessage = SMSMessage.Replace("%DeviceName%", sdr["NameD"].ToString());
                            SMSMessage = SMSMessage.Replace("%Name%", sdr["FullName"].ToString());

                            SendEmail(sdr["Email"].ToString(), sdr["Subject"].ToString(), EmailMessage);
                            SendSMS(sdr["Cell"].ToString(), SMSMessage);
                        }
                        else if (sdr["AnnouncingType"].ToString() == "SMS")
                        {
                            SMSMessage = sdr["SMessage"].ToString();
                            SMSMessage = SMSMessage.Replace("%DeviceName%", sdr["NameD"].ToString());
                            SMSMessage = SMSMessage.Replace("%Name%", sdr["FullName"].ToString());
                            SendSMS(sdr["Cell"].ToString(), SMSMessage);
                        }
                        else if (sdr["AnnouncingType"].ToString() == "Email")
                        {
                            EmailMessage = sdr["EMessage"].ToString();
                            EmailMessage = EmailMessage.Replace("%DeviceName%", sdr["NameD"].ToString());
                            EmailMessage = EmailMessage.Replace("%Name%", sdr["FullName"].ToString());
                            SendEmail(sdr["Email"].ToString(), sdr["Subject"].ToString(), EmailMessage);
                        }
                    }
                }
            }
            con.Close();
        }
    }
Exemplo n.º 25
0
        private async Task SendReplyToSender(SMSMessage message, string destinationNumber)
        {
            var sendRequest = new SendMessagesRequest
            {
                ApplicationId  = projectId,
                MessageRequest = new MessageRequest
                {
                    Addresses = new Dictionary <string, AddressConfiguration>
                    {
                        { destinationNumber, new AddressConfiguration {
                              ChannelType = "SMS"
                          } }
                    },
                    MessageConfiguration = new DirectMessageConfiguration {
                        SMSMessage = message
                    }
                }
            };

            try
            {
                Console.WriteLine($"Sending message: {message.Body} to {destinationNumber}");
                var response = await client.SendMessagesAsync(sendRequest).ConfigureAwait(false);

                Console.WriteLine("Message sent!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("The message wasn't sent. Error message: " + ex.Message);
            }
        }
Exemplo n.º 26
0
        public static SmsStatus ProcessResponse(SMSMessage twilioResponse)
        {
            if ((string.IsNullOrWhiteSpace(twilioResponse.Status) && twilioResponse.RestException != null) ||
                twilioResponse.Status.Equals("failed", StringComparison.CurrentCultureIgnoreCase))
            {
                var e = twilioResponse.RestException;
                return(new SmsFailed(twilioResponse.Sid, e.Code, e.Message, e.MoreInfo, e.Status));
            }

            if (twilioResponse.Status.Equals("sent", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new SmsSent(new SmsConfirmationData(twilioResponse.Sid, twilioResponse.DateSent, twilioResponse.Price)));
            }

            if (twilioResponse.Status.Equals("sending", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new SmsSending(twilioResponse.Sid));
            }

            if (twilioResponse.Status.Equals("queued", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new SmsQueued(twilioResponse.Sid));
            }

            return(null);
        }
Exemplo n.º 27
0
        private void SendEmail(SMSMessage sms, ExchangeData callerDetails)
        {
            if (sms == null)
            {
                sms = new SMSMessage();
            }
            if (callerDetails == null)
            {
                callerDetails = new ExchangeData();
            }

            var fromAddress = new MailAddress(Properties.Settings.Default.EmailTo, "Incoming SMS");
            var toAddress   = new MailAddress(Properties.Settings.Default.EmailTo, "SMS Email Queue");
            var ccAddress   = new MailAddress(Properties.Settings.Default.EmailCC);

            var subject = string.Format("Incoming SMS: {0}", sms.From ?? "Unknown");
            var getBody = CreateHtmlBody(sms, callerDetails);

            var smtp = new SmtpClient();


            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = getBody,
                IsBodyHtml = true
            })
            {
                message.Bcc.Add(ccAddress);
                smtp.Send(message);
            }
        }
        public void Insert(SMSMessage model)
        {
            model.SMSID = new aers_sys_seedSqlMapDao().GetMaxID("SMSMessage");
            String stmtId = "SMSMessage_Insert"; // Message_Insert

            ExecuteInsert(stmtId, model);
        }
Exemplo n.º 29
0
        public async Task <IHttpActionResult> ForgetPassword(RentoRequest <string> request)
        {
            Logger.Debug("ForgetPassword", request.Data);

            return(Ok(await TryCatchResponse(request, ValidateType.None, async(RentoResponse <string> response) =>
            {
                if (!ValidateRequirdField(request.Data))
                {
                    response.ErrorCode = ErrorCode.RequirdField; return;
                }
                var forgetPassword = await Database.AccountManager.SelectMobile(request.Data);
                if (forgetPassword != null)
                {
                    var code = StringHelper.GenerateRandomNumber(6);
                    RunActionAsync(() =>
                    {
                        SMSMessage.Send(forgetPassword.Mobile, code.ToString());
                    });
                    RentoCache.Set(FORGET_PASSWORD_KEY + forgetPassword.Token, new ForgetPasswordCacheObject()
                    {
                        Code = code,
                        UserId = forgetPassword.UserId
                    }, 1);
                    response.Data = forgetPassword.Token.ToString();
                }
            })));
        }
            public ISPService()
            {
                var emailMessage = new EmailMessage();

                emailMessage.Message   = "awd";
                emailMessage.Recipient = new List <string> {
                    "awd"
                };
                emailMessage.BCCRecipient = new List <string> {
                    "BCCawd"
                };
                emailMessage.Subject = "sub";

                Console.WriteLine("ISP Email " + emailMessage.BCCRecipient[0]);

                var smsMessage = new SMSMessage();

                smsMessage.Message   = "awd";
                smsMessage.Recipient = new List <string> {
                    "awd"
                };
                smsMessage.Subject = "sub";

                Console.WriteLine("ISP SMS " + smsMessage.Recipient[0]);
            }
Exemplo n.º 31
0
		public void SendSMS(string userPhone, int appraiserOrderId, SMSTemplateType smsType, Dictionary<string, string> replaceDictionary = null)
		{
			if (!_config.IsSMSEnabled)
				throw new SystemException("SMS sending is disabled");
			if (string.IsNullOrWhiteSpace(userPhone))
				throw new ArgumentNullException("User phone cannot be blank for SMS notification");

			string clearedPhoneType = string.Empty;
			var phoneValidationResult = Messaging.MessageController.PhoneNumberIsValid(userPhone, out clearedPhoneType);
			if (phoneValidationResult == PhoneNumberValidity.Invalid)
				throw new ArgumentOutOfRangeException("Incorrect mobile phone format: " + userPhone);

			SetupAccount();
			CheckAccount();
			var template = _smsRepository.GetBySMSTemplateType(smsType);
			var smsBody = new StringBuilder(template.Body);
			if (replaceDictionary != null)
			{
				foreach (var replacePair in replaceDictionary)
					smsBody.Replace(replacePair.Key, replacePair.Value);
			}

			var smsMessage = new SMSMessage();
			smsMessage.PhoneNumber = clearedPhoneType;
			smsMessage.MessageText = smsBody.ToString();
			smsMessage.MessageID = appraiserOrderId;

			MessageQueue batch = new MessageQueue();
			batch.Add(smsMessage);
			string smsTypeString = smsType.ToString();
			Logger.WriteInfo(string.Format("Sending {0} sms to {1} ", smsTypeString, userPhone));
			var result = Messaging.MessageController.SendMessageBatchSynchronous(batch);

			if (result.Success)
				Logger.WriteInfo(string.Format("Sending {0} sms to {1} success", smsTypeString, userPhone));
			else
			{
				Logger.WriteInfo(string.Format("Sending {0} sms to {1} failed", smsTypeString, userPhone));
				if (result.Exception != null)
					throw new Exception(string.Format("Error occured during ending {0} sms to {1}.", smsTypeString, userPhone), result.Exception);
			}
		}
Exemplo n.º 32
0
        private void MissedQueueSendingSMS()
        {
            SMSView smsview = new SMSView();
            SMSController smscontroller = new SMSController();
            DataTable MissedQueue = new DataTable();
            DataTable MissedQueueSentSMS = new DataTable();
            MissedQueue = null;
            //WebClient oWeb = new WebClient();
            //Byte[] bytHeaders;
            MissedQueueSentSMS = null;
            smsview = new SMSView();
            MissedQueue = smscontroller.GetMissedQueueSendingSMS();
            foreach (DataRow dr in MissedQueue.Rows)
            {
                smsview.QueueTransaction = (Convert.ToInt32(dr["queue_visit_tnxid"].ToString()));
                int qti = (Convert.ToInt32(dr["queue_visit_tnxid"].ToString()));
                string MissedQueueNo = (dr["visit_queue_no_show"].ToString());
                string MissedPhoneNo = (Convert.ToString(dr["customer_mobile"].ToString()));
                long CustId = (Convert.ToInt64(dr["customer_id"].ToString()));
                // string mobileno = (Custname["members_mobile"].ToString());
                // string MissedPhoneNo = 61 + MissedPhoneNo1;
                string SmsStatusMsg = string.Empty;
                string SmsDeliveryStatus = string.Empty;

                // SMSView smsview = new SMSView();
                string cname = dr["visit_customer_name"].ToString();
                string appt = dr["customer_appointment_time"].ToString();

                DateTime apt = Convert.ToDateTime(appt);
                string cappt = apt.ToString("HH:mm");
                string custaptime = apt.ToShortTimeString();
                string mobnum = "61"+ dr["customer_mobile"].ToString();

                try
                {
                    DataTable CheckMessage = new DataTable();
                    // CheckMessage = smscontroller.GetMessedQMessageExistance(smsview);
                    // if (CheckMessage.Rows.Count <= 0)
                    // {
                    if (MissedPhoneNo != "")
                    {

                        if (MissedPhoneNo.Length == 11)
                        {
                            //string strmsg = "Hi " + " " + Cname + ", It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au";
                            // string strmsg = "Hi " + " " + MissedQueueNo +",It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au";
                            string strmsg = "Hi " + cname + ", It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au.";
                            //Hi Kara, It seems you missed your appointment at the Samsung Experience Store at XX:XX, Should you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au
                            //"Hi " + cname + "It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au."; 
                            smsview.SmsDesc = strmsg;
                            //string strmsg = "Hi: " + MissedQueueNo + " has been called but due to no show your number has been moved to missed queue. \r\nPlease contact reception for assistance";
                            //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + MissedPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                            //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + MissedPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                            //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                            //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                            //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                            ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                            //string URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + MissedPhoneNo + "&text=" + strmsg1 + "";

                            #region Samsung SMS gateway
                            //SMS for Samsung gateway
                            // Set the username of the account holder.
                            Messaging.MessageController.UserAccount.User = "******";
                            // Set the password of the account holder.
                            Messaging.MessageController.UserAccount.Password = "******";
                            // Set the first name of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactFirstName = "David";
                            // Set the last name of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                            // Set the mobile phone number of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                            // Set the landline phone number of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                            // Set the contact email of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                            // Set the country of origin of the account holder (optional).
                            Messaging.MessageController.UserAccount.Country = Countries.Australia;
                            bool testOK = false;
                            try
                            {
                                // Test the user account settings.
                                Account testAccount = Messaging.MessageController.UserAccount;
                                testOK = Messaging.MessageController.TestAccount(testAccount);
                            }
                            catch (Exception ex)
                            {
                                // An exception was thrown. Display the details of the exception and return.
                                string message = "There was an error testing the connection details:\n" +
                                ex.Message;
                                // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                return;
                            }
                            if (testOK)
                            {
                                // The user account settings were valid. Display a success message
                                // box with the number of credits.
                                int balance = Messaging.MessageController.UserAccount.Balance;
                                string message = string.Format("You have {0} message credits available.",
                                balance);
                                // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                            }
                            else
                            {
                                // The username or password were incorrect. Display a failed message box.
                                //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                // "Connection Failed", MessageBoxButtons.OK);
                            }

                            Messaging.MessageController.Settings.TimeOut = 60;
                            // Set the batch size (number of messages to be sent at once) to 200.
                            Messaging.MessageController.Settings.BatchSize = 200;
                            //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                            //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                            //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                            Messaging.MessageController.Settings.DeliveryReport = true;
                            SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                            //SMSMessage smsobj = new SMSMessage(mobileno, strmsg);
                            Messaging.MessageController.AddToQueue(smsobj);
                            Messaging.MessageController.SendMessages();

                            //end of Samsung SMS
                            #endregion Samsung SMS gateway
                           
                           
                            #region inserting to tbl_sms_tnx
                            smsview.CustId = CustId;
                            smsview.SmsDesc = strmsg;
                            smsview.PhoneNo = mobnum;
                            smsview.DeliveryReport = "y";
                            smsview.SmsDesc = strmsg;
                            smsview.IncomingsmsFlag = "M";
                            smsview.SmsVisittnxId = 2;
                            smsview.SMSDateTime = System.DateTime.Now;
                            smsview.SMSStatusFlag = "M";
                            smsview.QueueNo = Convert.ToString("1");
                            smsview.CentreId = "";
                            smsview.SMSDateTime = System.DateTime.Now;
                            string i;
                            i = smscontroller.getInsertAppointmentAlertSms(smsview);
                            #endregion into tbl_sms_tnx

                            #region Updating sms_status_flag='D' for MissQ
                            smsview.Qvisittnxid = qti;
                            //smsview.SMSalert = 'E';

                            smscontroller.updatesmsstatusflag(smsview);
                            #endregion End Updating sms_status_flag

                        }
                        //}
                        else
                        {
                            if (MissedPhoneNo.Length == 9)
                            {
                                MissedPhoneNo = 61 + MissedPhoneNo;
                                //string strmsg1 = "Your ticket number: " + MissedQueueNo + " has been called but due to no show your number has been moved to missed queue. \r\nPlease contact reception for assistance";
                                //string strmsg = "Hi " + " " + MissedQueueNo + ",It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au";
                                string strmsg = "Hi " + cname + " It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\n Should you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au.";
                                smsview.SmsDesc = strmsg;
                                // string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + MissedPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + MissedPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                //string URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + MissedPhoneNo + "&text=" + strmsg1 + "";

                                #region Samsung SMS gateway
                                //SMS for Samsung gateway
                                // Set the username of the account holder.
                                Messaging.MessageController.UserAccount.User = "******";
                                // Set the password of the account holder.
                                Messaging.MessageController.UserAccount.Password = "******";
                                // Set the first name of the account holder (optional).
                                Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                // Set the last name of the account holder (optional).
                                Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                // Set the mobile phone number of the account holder (optional).
                                Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                // Set the landline phone number of the account holder (optional).
                                Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                // Set the contact email of the account holder (optional).
                                Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                // Set the country of origin of the account holder (optional).
                                Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                bool testOK = false;
                                try
                                {
                                    // Test the user account settings.
                                    Account testAccount = Messaging.MessageController.UserAccount;
                                    testOK = Messaging.MessageController.TestAccount(testAccount);
                                }
                                catch (Exception ex)
                                {
                                    // An exception was thrown. Display the details of the exception and return.
                                    string message = "There was an error testing the connection details:\n" +
                                    ex.Message;
                                    // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                    return;
                                }
                                if (testOK)
                                {
                                    // The user account settings were valid. Display a success message
                                    // box with the number of credits.
                                    int balance = Messaging.MessageController.UserAccount.Balance;
                                    string message = string.Format("You have {0} message credits available.",
                                    balance);
                                    // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                }
                                else
                                {
                                    // The username or password were incorrect. Display a failed message box.
                                    //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                    // "Connection Failed", MessageBoxButtons.OK);
                                }

                                Messaging.MessageController.Settings.TimeOut = 60;
                                // Set the batch size (number of messages to be sent at once) to 200.
                                Messaging.MessageController.Settings.BatchSize = 200;
                                //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                Messaging.MessageController.Settings.DeliveryReport = true;
                                SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                Messaging.MessageController.AddToQueue(smsobj);
                                Messaging.MessageController.SendMessages();
                                //end of Samsung SMS
                                #endregion Samsung SMS gateway

                                //SmsStatusMsg = oWeb.DownloadString(URL);
                                //if (SmsStatusMsg.Contains("<br>"))
                                //{
                                //    SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                //}
                                //smsview.SMSStatusFlag = "S";
                                //smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                ////Thread.Sleep(100);
                                //DataTable dt1 = new DataTable();
                                //dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                //foreach (DataRow dr123 in dt1.Rows)
                                //{
                                //    string Sflag = (dr123["message_status_flag"].ToString());
                                //    string uflag = Convert.ToString("M");
                                //    if (Sflag == uflag)
                                //    {
                                //        smsview.SMSStatusFlag = "S";
                                //        smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                //    }
                                //    else
                                //    {
                                //        #region delivery Report
                                //        //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                //        //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                //        //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                //        //XmlDocument xml = new XmlDocument();
                                //        //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                //        //XmlNodeList xnList = xml.SelectNodes("smslist");
                                //        //foreach (XmlNode xn in xnList)
                                //        //{
                                //        //    XmlNode example = xn.SelectSingleNode("sms");
                                //        //    if (example != null)
                                //        //    {
                                //        //        string na = example["messageid"].InnerText;
                                //        //        string no = example["smsclientid"].InnerText;
                                //        //        string mobileno = example["mobile-no"].InnerText;
                                //        //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                //        //        SmsDeliveryStatus = client.DownloadString(URL1);
                                //        //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                //        //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                //        //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                //        //        XmlDocument xml1 = new XmlDocument();
                                //        //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                //        //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                //        //        //foreach (XmlNode xn1 in xnList1)
                                //        //        //{
                                //        //        XmlNode example1 = xml.SelectSingleNode("response");
                                //        //        if (example1 != null)
                                //        //        {
                                //        //            //string rscode = example1["responsecode"].InnerText;
                                //        //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                //        //            //string dlrcount = example1["dlristcount"].InnerText;
                                //        //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                //        //        }
                                //        //    }
                                //        #endregion delivery Report
                                // smsview.QueueTransaction = Qtnxid;
                               // smsview.CustId = CustId;
                               // smsview.SmsDesc = strmsg;
                               // smsview.QueueNo = MissedQueueNo;
                               // smsview.PhoneNo = MissedPhoneNo;
                               //// smsview.IncomingsmsFlag = "M";
                               // smsview.SMSDateTime = System.DateTime.Now;
                               // // string d;
                               // // d = smscontroller.GetInsertMissedQSMS(smsview);
                               // // DataTable QueueTokenGenerationSentSMS = new DataTable();
                               // // }
                               // //smsview.SmsUpdatedDateTime = System.DateTime.Now;
                               // smsview.SmsActive ='Y';
                               // smsview.SMSContentTypeId = 2;
                               // smsview.SmsAlert = 2;
                               // smsview.SmsUpdatedBy = "Admin";
                               // string i;
                               // i = smscontroller.getInsertAppointmentAlertSms(smsview);
                                // }
                                // }
                                // }
                                // }
                                #region inserting to tbl_sms_tnx
                                smsview.CustId = CustId;
                                smsview.SmsDesc = strmsg;
                                smsview.PhoneNo = mobnum;
                                smsview.DeliveryReport = "y";
                                smsview.SmsDesc = strmsg;
                                smsview.IncomingsmsFlag = "M";
                                smsview.SmsVisittnxId = 2;
                                smsview.SMSDateTime = System.DateTime.Now;
                                smsview.SMSStatusFlag = "M";
                                smsview.QueueNo = Convert.ToString("1");
                                smsview.CentreId = "";
                                smsview.SMSDateTime = System.DateTime.Now;
                                string i;
                                i = smscontroller.getInsertAppointmentAlertSms(smsview);
                                #endregion into tbl_sms_tnx

                                #region Updating sms_status_flag='D' for MissQ
                                smsview.Qvisittnxid = qti;
                                //smsview.SMSalert = 'E';

                                smscontroller.updatesmsstatusflag(smsview);
                                #endregion End Updating sms_status_flag
                            }
                        }
                    }
                }
                catch (WebException e1)
                {
                    //  SmsStatusMsg = e1.Message;
                }
                catch (Exception e2)
                {
                    // SmsStatusMsg = e2.Message;
                }

                //smsview.SMSStatusFlag = "S";

                //MissedQueueSentSMS = smscontroller.GetMissedQueueSentSMS(smsview);
            }
        }
Exemplo n.º 33
0
        public void ExpiredAppointmentNotification()
        {
            SMSView smsview = new SMSView();
            try
            {
                DataTable appointment = new DataTable();
                SMSController sms = new SMSController();
                appointment = sms.appointmentexpired(smsview);

                foreach (DataRow dr in appointment.Rows)
                {
                    SMSView smsview1 = new SMSView();
                    string cname = dr["customer_firstname"].ToString();
                    int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                    string app = dr["appointment_time"].ToString();
                    DateTime adt = Convert.ToDateTime(app);
                    string mobileno = "61" + dr["appointment_mobileno"].ToString();
                    long custid = Convert.ToInt64(dr["appointment_customer_id"].ToString());
                    DateTime syst = DateTime.Now;
                    string apptime = adt.ToString("HH:mm");
                    DateTime timeapp1 = Convert.ToDateTime(app);
                    TimeSpan t1 = new TimeSpan(01, 00, 00);
                    timeapp1 = timeapp1 + t1;
                    string timeapp = timeapp1.ToString("HH:mm");
                    string systemtime = syst.ToString("HH:mm");
                    //string systemtime = "22:19";
                    //DateTime re = Convert.ToDateTime("10:31");
                    //String ret = re.ToString("HH:mm");
                    DataTable dtsmsview = new DataTable();
                    dtsmsview = smscontroller.appointmenTranstexpired(smsview1);
                    if (dtsmsview.Rows.Count == 0)
                    {
                        if (timeapp == systemtime)
                        {
                            string strmsg = "Dear " + cname + ",\r\n  your appointment for " + apptime + " has been Expired, please contact 18xxxxxx to reschedule";
                            smsview.SmsDesc = strmsg;
                            #region Samsung SMS gateway
                            //SMS for Samsung gateway
                            // Set the username of the account holder.
                            Messaging.MessageController.UserAccount.User = "******";
                            // Set the password of the account holder.
                            Messaging.MessageController.UserAccount.Password = "******";
                            // Set the first name of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactFirstName = "David";
                            // Set the last name of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                            // Set the mobile phone number of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                            // Set the landline phone number of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                            // Set the contact email of the account holder (optional).
                            Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                            // Set the country of origin of the account holder (optional).
                            Messaging.MessageController.UserAccount.Country = Countries.Australia;
                            bool testOK = false;

                            try
                            {
                                // Test the user account settings.
                                Account testAccount = Messaging.MessageController.UserAccount;
                                testOK = Messaging.MessageController.TestAccount(testAccount);
                            }
                            catch (Exception ex)
                            {
                                // An exception was thrown. Display the details of the exception and return.
                                string message = "There was an error testing the connection details:\n" +
                                ex.Message;
                                // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                return;
                            }
                            if (testOK)
                            {
                                // The user account settings were valid. Display a success message
                                // box with the number of credits.
                                int balance = Messaging.MessageController.UserAccount.Balance;
                                string message = string.Format("You have {0} message credits available.",
                                balance);
                                // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                            }
                            else
                            {
                                // The username or password were incorrect. Display a failed message box.
                                //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                // "Connection Failed", MessageBoxButtons.OK);
                            }

                            Messaging.MessageController.Settings.TimeOut = 5;
                            // Set the batch size (number of messages to be sent at once) to 200.
                            Messaging.MessageController.Settings.BatchSize = 200;
                            Messaging.MessageController.Settings.DeliveryReport = true;
                            SMSMessage smsobj = new SMSMessage(mobileno, strmsg);
                            Messaging.MessageController.AddToQueue(smsobj);
                            Messaging.MessageController.SendMessages();
                            #endregion Samsung SMS gateway

      
                            #region inserting to tbl_sms_tnx
                            smsview.CustId = custid;
                            smsview.SmsDesc = strmsg;
                            smsview.PhoneNo = mobileno;
                            smsview.DeliveryReport = "y";
                            smsview.SmsDesc = strmsg;
                            smsview.IncomingsmsFlag = "M";
                            smsview.SmsVisittnxId = 2;
                            smsview.SMSDateTime = System.DateTime.Now;
                            smsview.SMSStatusFlag = "M";
                            smsview.QueueNo = Convert.ToString("1");
                            smsview.CentreId = "";
                            smsview.SMSDateTime = System.DateTime.Now;
                            string i;
                            i = smscontroller.getInsertAppointmentAlertSms(smsview);
                            #endregion into tbl_sms_tnx

                            #region Update SMS_Alert statsus flag

                            smsview.AppointmentID = appid;
                            smsview.SMSalert = 'E';
                            sms.updatesmsalert(smsview);

                            #endregion Update SMS_Alert statsus flag

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 34
0
        public void AppRemender()
        {
            try
            {
                DataTable Appdetails = new DataTable();
                SMSController smscont = new SMSController();
                Appdetails = smscont.AppRemender();

                DateTime re = Convert.ToDateTime("07:00");//Every Day at 7:00 AUS Time
                //DateTime re = Convert.ToDateTime("23:10");
                String ret = re.ToString("hh:mm");
                DateTime syst = DateTime.Now;
                string systime = syst.ToString("hh:mm");
                if (ret == systime)
                {
                    foreach (DataRow dr in Appdetails.Rows)
                    {
                        SMSView smsview = new SMSView();
                        int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                        int custid = Convert.ToInt32(dr["appointment_customer_id"].ToString());
                        string cname = dr["customer_firstname"].ToString();
                        string appt = dr["appointment_time"].ToString();
                        int centreid = Convert.ToInt32(dr["appointment_centre_id"].ToString());
                        DateTime apt = Convert.ToDateTime(appt);
                        string cappt = apt.ToString("HH:mm");
                        string custaptime = apt.ToShortTimeString();
                        string mobnum = "61"+ dr["customer_mobile"].ToString();
                        string centrename;
                        if (centreid==1)
                        {
                            centrename = "Sydney";
                        }
                        else if (centreid == 58)
                        {
                            centrename = "Melbourne central";
                        }
                        else
                        {
                            centrename = "Highpoint";
                        }


                        string strmsg = "Dear " + cname + ",\r\nReminder your appointment with the Samsung Experience Store, " + centrename + " is at " + cappt + " today.\r\nPlease bring a copy of your purchase invoice and back-up your data before your appointment to avoid data loss, Looking forward to seeing you.";
                        //“Hi Kara, Reminder your appointment with the Samsung Experience Store, Sydney is at 11:15 today. Please bring a copy of your purchase invoice and back-up your data before your appointment to avoid data loss. Look forward to seeing you.”
                        smsview.SmsDesc = strmsg;
                        #region Samsung SMS gateway
                        //SMS for Samsung gateway
                        // Set the username of the account holder.
                        Messaging.MessageController.UserAccount.User = "******";
                        // Set the password of the account holder.
                        Messaging.MessageController.UserAccount.Password = "******";
                        // Set the first name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                        // Set the last name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                        // Set the mobile phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                        // Set the landline phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                        // Set the contact email of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                        // Set the country of origin of the account holder (optional).
                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                        bool testOK = true;

                        try
                        {
                            // Test the user account settings.
                            Account testAccount = Messaging.MessageController.UserAccount;
                            testOK = Messaging.MessageController.TestAccount(testAccount);
                        }
                        catch (Exception ex)
                        {
                            // An exception was thrown. Display the details of the exception and return.
                            string message = "There was an error testing the connection details:\n" +
                            ex.Message;
                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                            return;
                        }
                        if (testOK)
                        {
                            // The user account settings were valid. Display a success message
                            // box with the number of credits.
                            int balance = Messaging.MessageController.UserAccount.Balance;
                            string message = string.Format("You have {0} message credits available.",
                            balance);
                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                        }
                        else
                        {
                            // The username or password were incorrect. Display a failed message box.
                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                            // "Connection Failed", MessageBoxButtons.OK);
                        }

                        Messaging.MessageController.Settings.TimeOut = 60;
                        // Set the batch size (number of messages to be sent at once) to 200.
                        Messaging.MessageController.Settings.BatchSize = 200;
                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                        Messaging.MessageController.Settings.DeliveryReport = true;
                        SMSMessage smsobj = new SMSMessage(mobnum, strmsg);
                        Messaging.MessageController.AddToQueue(smsobj);
                        Messaging.MessageController.SendMessages();
                        //end of Samsung SMS

                        //smsview.SmsUpdatedDateTime = System.DateTime.Now;
                        //smsview.SmsActive = 'Y';
                        //smsview.SMSContentTypeId = 1;
                        //smsview.SmsAlert = 1;
                        //smsview.SmsUpdatedBy="Admin";
                        //string i;
                        //i = smscontroller.getInsertAppointmentAlertSms(smsview);
                        #endregion Samsung SMS gateway

                        #region Update SMS_Alert statsus flag

                        smsview.AppointmentID = appid;
                        smsview.SMSalert = 'B';
                        smscont.updatesmsalert(smsview);
                        #endregion Update SMS_Alert statsus flag
                        
                        #region inserting to tbl_sms_tnx
                        smsview.CustId = custid;
                        smsview.SmsDesc = strmsg;
                        smsview.PhoneNo = mobnum;
                        smsview.DeliveryReport = "y";
                        smsview.SmsDesc = strmsg;
                        smsview.IncomingsmsFlag = "M";
                        smsview.SmsVisittnxId = 2;
                        smsview.SMSDateTime = System.DateTime.Now;
                        smsview.SMSStatusFlag = "M";
                        smsview.QueueNo = Convert.ToString("1");
                        smsview.CentreId = "";
                        smsview.SMSDateTime = System.DateTime.Now;
                        string i;
                        i = smscontroller.getInsertAppointmentAlertSms(smsview);
                       #endregion into tbl_sms_tnx
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 35
0
        public void appointmentalert()
        {
            try
            {
                DataTable Qtokendt = new DataTable();
                SMSController smscont = new SMSController();
                Qtokendt = smscont.appointmentalert();


                foreach (DataRow dr in Qtokendt.Rows)
                {
                    SMSView smsview = new SMSView();
                    // int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                    // string adt = dr["appointment_time"].ToString();
                    // TimeSpan t1 = new TimeSpan(1, 0, 0);
                    // DateTime dtime1 = Convert.ToDateTime(adt);
                    // DateTime dtime2 = dtime1 - t1;              //appointment time adjustment for before one hour
                    // string apptime = dtime2.ToString("HH:mm:ss");
                    // string cmobn = dr["appointment_mobileno"].ToString();
                    // string cname = dr["customer_firstname"].ToString();
                    //// string cdt = DateTime.Now.ToString("HH:mm:ss");         //current system time
                    // string cdt = "::00";  //      Manual system time for testing
                    // if (apptime == cdt)
                    // {
                    int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                    string appt = dr["appointment_time"].ToString();
                    DateTime apt = Convert.ToDateTime(appt);
                    string custaptime = apt.ToShortTimeString();
                    //string cmobn = dr["appointment_customer_id"].ToString();
                    string cname = dr["customer_firstname"].ToString();
                    string mobnum = dr["customer_mobile"].ToString();
                    //DateTime crrsysdate = DateTime.Now;
                    DateTime fdt = DateTime.Now;//Convert.ToDateTime("06:01");
                    string fd = fdt.ToString("HH:mm");
                    //DateTime onehour = Convert.ToDateTime("01:00");
                    string sfd = fdt.ToString("HH:mm");
                    //string sonehour = onehour.ToString("HH:MM");

                    string cappt = apt.ToString("HH:mm");
                    DateTime Result = apt.AddMinutes(-59);
                    //DateTime r=Convert.ToDateTime(Result);
                    string Resultdt = Result.ToString();
                    DateTime re = Convert.ToDateTime(Resultdt);
                    string r = re.ToString("HH:mm");
                    string cdt = fdt.ToString();//DateTime.Now.ToString();
                    if (r == fd)
                    {

                        string strmsg = "Dear " + cname + ",\r\n Your appointment with Samsung is an hour to go, If you are away, please return back to the waiting room.";
                        smsview.SmsDesc = strmsg;
                        #region Samsung SMS gateway
                        //SMS for Samsung gateway
                        // Set the username of the account holder.
                        Messaging.MessageController.UserAccount.User = "******";
                        // Set the password of the account holder.
                        Messaging.MessageController.UserAccount.Password = "******";
                        // Set the first name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                        // Set the last name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                        // Set the mobile phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                        // Set the landline phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                        // Set the contact email of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                        // Set the country of origin of the account holder (optional).
                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                        bool testOK = false;

                        try
                        {
                            // Test the user account settings.
                            Account testAccount = Messaging.MessageController.UserAccount;
                            testOK = Messaging.MessageController.TestAccount(testAccount);
                        }
                        catch (Exception ex)
                        {
                            // An exception was thrown. Display the details of the exception and return.
                            string message = "There was an error testing the connection details:\n" +
                            ex.Message;
                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                            return;
                        }
                        if (testOK)
                        {
                            // The user account settings were valid. Display a success message
                            // box with the number of credits.
                            int balance = Messaging.MessageController.UserAccount.Balance;
                            string message = string.Format("You have {0} message credits available.",
                            balance);
                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                        }
                        else
                        {
                            // The username or password were incorrect. Display a failed message box.
                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                            // "Connection Failed", MessageBoxButtons.OK);
                        }

                        Messaging.MessageController.Settings.TimeOut = 60;
                        // Set the batch size (number of messages to be sent at once) to 200.
                        Messaging.MessageController.Settings.BatchSize = 200;
                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                        Messaging.MessageController.Settings.DeliveryReport = true;
                        SMSMessage smsobj = new SMSMessage(mobnum, strmsg);
                        Messaging.MessageController.AddToQueue(smsobj);
                        Messaging.MessageController.SendMessages();
                        //end of Samsung SMS

                        //smsview.SmsUpdatedDateTime = System.DateTime.Now;
                        //smsview.SmsActive = 'Y';
                        //smsview.SMSContentTypeId = 1;
                        //smsview.SmsAlert = 1;
                        //smsview.SmsUpdatedBy="Admin";
                        //string i;
                        //i = smscontroller.getInsertAppointmentAlertSms(smsview);
                        #endregion Samsung SMS gateway

                        #region Update SMS_Alert statsus flag

                        smsview.AppointmentID = appid;
                        smsview.SMSalert = 'B';
                        smscont.updatesmsalert(smsview);
                        #endregion Update SMS_Alert statsus flag

                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 36
0
        public void SendAlertSMS()
        {
            SMSView smsview = new SMSView();
            DataTable dt = new DataTable();
            WebClient oWeb = new WebClient();
            // Byte[] bytHeaders;
            dt = smscontroller.GetQueuePosition(smsview);
            foreach (DataRow dr in dt.Rows)
            {
                //Thread.Sleep(100);
                try
                {
                    smsview.MySms = (dr["visit_queue_no_show"].ToString());
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                // smsview.MySms = QueueToken1;
                DataTable dt11 = new DataTable();
                dt11 = smscontroller.Getvisittnxidbyusingrepliedsms(smsview);
                foreach (DataRow dr11 in dt11.Rows)
                {
                    smsview.QueueTransaction = (Convert.ToInt32(dr11["visit_tnx_id"].ToString()));
                    DataTable dt12 = new DataTable();
                    dt12 = smscontroller.GetDeptid(smsview);
                    foreach (DataRow dr12 in dt12.Rows)
                    {
                        smsview.DepartmentID = (Convert.ToInt32(dr12["queue_department_id"].ToString()));
                        int dept = smsview.DepartmentID;
                        DataTable btnevent = new DataTable();
                        btnevent = smscontroller.GetButtonEvent(smsview);
                        if (btnevent.Rows.Count > 0)
                        {
                            foreach (DataRow dr1x in btnevent.Rows)
                            {
                                DataTable dbe = new DataTable();
                                smsview.ButtonVisitTnx = Convert.ToInt32(dr1x["visit_tnx_id"].ToString());
                                int dep1 = Convert.ToInt32(dr1x["queue_department_id"].ToString());
                                if (dept == dep1)
                                {
                                    smsview.ButtonEventFlag = "N";
                                    dbe = smscontroller.getUpdatebuttoneventflag(smsview);


                                    DataTable dt13 = new DataTable();
                                    dt13 = smscontroller.GetStatusCount(smsview);
                                    foreach (DataRow dr13 in dt13.Rows)
                                    {
                                        QueueToken = (dr13["visit_queue_no_show"].ToString());
                                        // SMSController smscontroller = new SMSController();
                                        DataTable dt14 = new DataTable();
                                        dt14 = smscontroller.GetStatusCount123(smsview);
                                        foreach (DataRow dr14 in dt14.Rows)
                                        {

                                            string qtoken = (dr14["visit_queue_no_show"].ToString());

                                            for (j = 0; j < dt14.Rows.Count; j++)
                                            {
                                                if (dt14 != null && dt14.Rows.Count > 0 && Convert.ToString(dt14.Rows[j]["visit_queue_no_show"]).Equals(QueueToken))
                                                {
                                                    smsview.MySms = QueueToken;
                                                    int pos = 0;
                                                    DataTable CheckMessage = smscontroller.GetAlertQMessageExistance(smsview);
                                                    if (CheckMessage.Rows.Count <= 0)
                                                    {


                                                        for (i = 0; i < dt13.Rows.Count; i++)
                                                        {
                                                            if (qtoken == QueueToken)
                                                            {


                                                                if (dt13 != null && dt13.Rows.Count > 0 && Convert.ToString(dt13.Rows[i]["visit_queue_no_show"]).Equals(qtoken))
                                                                {
                                                                    pos = j;
                                                                    if (pos == 2)
                                                                    {
                                                                        DataTable dt111 = new DataTable();
                                                                        dt111 = smscontroller.Getvisittnxidbyusingrepliedsms(smsview);
                                                                        foreach (DataRow dr111 in dt111.Rows)
                                                                        {

                                                                            smsview.QueueTransaction = (Convert.ToInt32(dr111["visit_tnx_id"].ToString()));

                                                                            DataTable dt157 = new DataTable();
                                                                            dt157 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                            foreach (DataRow dr1234 in dt157.Rows)
                                                                            {
                                                                                string Sflag3 = (dr1234["message_status_flag"].ToString());
                                                                                string uflag2 = Convert.ToString("A");
                                                                                if (Sflag3 == uflag2)
                                                                                {

                                                                                    DataTable dt1 = new DataTable();
                                                                                    smsview.MySms = qtoken;
                                                                                    dt1 = smscontroller.GetCustIDByUsingQueueno(smsview);
                                                                                    foreach (DataRow dr1 in dt1.Rows)
                                                                                    {
                                                                                        smsview.CustId = (Convert.ToInt64(dr1["visit_customer_id"].ToString()));
                                                                                        smsview.MenberId = (Convert.ToInt32(dr1["members_id"].ToString()));
                                                                                        DataTable dt2 = new DataTable();
                                                                                        dt2 = smscontroller.GetCustomerNameMobile(smsview);
                                                                                        foreach (DataRow dr2 in dt2.Rows)
                                                                                        {
                                                                                            string fname = (dr2["customer_firstname"].ToString());
                                                                                            string lname = (dr2["customer_lastname"].ToString());
                                                                                            string cname = fname + " " + lname;
                                                                                            string phonenumber = (dr2["members_mobile"].ToString());
                                                                                            // string phonenumber = phonenumber1;
                                                                                            string SmsStatusMsg = string.Empty;
                                                                                            string SmsDeliveryStatus = string.Empty;
                                                                                            if (phonenumber != "")
                                                                                            {

                                                                                                if (phonenumber.Length == 11)
                                                                                                {
                                                                                                    string strmsg = "Dear " + cname + ",\r\nYour ticket number is in 3rd position. If you are away, please return back to the waiting room.";
                                                                                                    //create Request
                                                                                                    //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + phonenumber + "&text=" + strmsg1 + "");
                                                                                                    //oWeb.Credentials = new NetworkCredential("*****@*****.**", "EqMs2015");

                                                                                                    //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + phonenumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                                                    //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + phonenumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                                                    //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                                                                                    // bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");

                                                                                                    //string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("*****@*****.**" + ":" + "EqMs2015"));

                                                                                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                                                    // oWeb.Headers[HttpRequestHeader.Authorization] = "Basic" + credentials;
                                                                                                    //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + phonenumber + "&text=" + strmsg1 + "";

                                                                                                    #region Samsung SMS gateway
                                                                                                    //SMS for Samsung gateway
                                                                                                    // Set the username of the account holder.
                                                                                                    Messaging.MessageController.UserAccount.User = "******";
                                                                                                    // Set the password of the account holder.
                                                                                                    Messaging.MessageController.UserAccount.Password = "******";
                                                                                                    // Set the first name of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                                                    // Set the last name of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                                                    // Set the mobile phone number of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                                                    // Set the landline phone number of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                                                    // Set the contact email of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                                                    // Set the country of origin of the account holder (optional).
                                                                                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                                                    bool testOK = false;
                                                                                                    try
                                                                                                    {
                                                                                                        // Test the user account settings.
                                                                                                        Account testAccount = Messaging.MessageController.UserAccount;
                                                                                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                                                    }
                                                                                                    catch (Exception ex)
                                                                                                    {
                                                                                                        // An exception was thrown. Display the details of the exception and return.
                                                                                                        string message = "There was an error testing the connection details:\n" +
                                                                                                        ex.Message;
                                                                                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                                                        return;
                                                                                                    }
                                                                                                    if (testOK)
                                                                                                    {
                                                                                                        // The user account settings were valid. Display a success message
                                                                                                        // box with the number of credits.
                                                                                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                                                                                        string message = string.Format("You have {0} message credits available.",
                                                                                                        balance);
                                                                                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        // The username or password were incorrect. Display a failed message box.
                                                                                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                                                        // "Connection Failed", MessageBoxButtons.OK);
                                                                                                    }

                                                                                                    Messaging.MessageController.Settings.TimeOut = 60;
                                                                                                    // Set the batch size (number of messages to be sent at once) to 200.
                                                                                                    Messaging.MessageController.Settings.BatchSize = 200;
                                                                                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                                                                                    SMSMessage smsobj = new SMSMessage(phonenumber, strmsg);
                                                                                                    Messaging.MessageController.AddToQueue(smsobj);
                                                                                                    Messaging.MessageController.SendMessages();
                                                                                                    //end of Samsung SMS
                                                                                                    #endregion Samsung SMS gateway
                                                                                                    //SmsStatusMsg = oWeb.DownloadString(URL);

                                                                                                    oWeb.Dispose();
                                                                                                    smsview.SMSStatusFlag = "S";
                                                                                                    smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                                                    if (SmsStatusMsg.Contains("<br>"))
                                                                                                    {
                                                                                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                                                    }

                                                                                                    // Thread.Sleep(100);
                                                                                                    DataTable dt15 = new DataTable();
                                                                                                    dt15 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                                                    foreach (DataRow dr123 in dt15.Rows)
                                                                                                    {
                                                                                                        string Sflag = (dr123["message_status_flag"].ToString());
                                                                                                        string uflag = Convert.ToString("A");
                                                                                                        if (Sflag == uflag)
                                                                                                        {
                                                                                                            smsview.SMSStatusFlag = "S";
                                                                                                            smsview.ButtonEventFlag = "N";
                                                                                                            smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                                                        }
                                                                                                        else
                                                                                                        {

                                                                                                            #region Delivery Report
                                                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                                                            //XmlDocument xml = new XmlDocument();
                                                                                                            //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                                            //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                                                            //foreach (XmlNode xn in xnList)
                                                                                                            //{
                                                                                                            //    XmlNode example = xn.SelectSingleNode("sms");
                                                                                                            //    if (example != null)
                                                                                                            //    {
                                                                                                            //        string na = example["messageid"].InnerText;
                                                                                                            //        string no = example["smsclientid"].InnerText;
                                                                                                            //        string mobileno = example["mobile-no"].InnerText;
                                                                                                            //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                                                                            //        SmsDeliveryStatus = client.DownloadString(URL1);
                                                                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                                                            //        XmlDocument xml1 = new XmlDocument();
                                                                                                            //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                                            //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                                                            //        //foreach (XmlNode xn1 in xnList1)
                                                                                                            //        //{
                                                                                                            //        XmlNode example1 = xml.SelectSingleNode("response");
                                                                                                            //        if (example1 != null)
                                                                                                            //        {
                                                                                                            //            //string rscode = example1["responsecode"].InnerText;
                                                                                                            //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                                                            //            //string dlrcount = example1["dlristcount"].InnerText;
                                                                                                            //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                                                                                            //        }
                                                                                                            //    }

                                                                                                            //}
                                                                                                            #endregion Delivery report


                                                                                                            smsview.MySms = QueueToken;
                                                                                                            DataTable dt5 = new DataTable();
                                                                                                            dt5 = smscontroller.Getvisittnxidbyusingrepliedsms(smsview);
                                                                                                            foreach (DataRow dr5 in dt5.Rows)
                                                                                                            {
                                                                                                                smsview.QueueTransaction = (Convert.ToInt32(dr5["visit_tnx_id"].ToString()));
                                                                                                            }
                                                                                                            smsview.QueueNo = QueueToken;
                                                                                                            smsview.PhoneNo = phonenumber;
                                                                                                            smsview.IncomingsmsFlag = "A";
                                                                                                            smsview.SMSDateTime = System.DateTime.Now;
                                                                                                            smsview.MySms = strmsg;
                                                                                                            string a;
                                                                                                            a = smscontroller.GetInsertAlertSMS(smsview);

                                                                                                            // DataTable QueueTokenGenerationSentSMS = new DataTable();

                                                                                                            // Thread.Sleep(100);
                                                                                                        }

                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (phonenumber.Length == 9)
                                                                                                    {
                                                                                                        phonenumber = 61 + phonenumber;
                                                                                                        string strmsg = "Dear " + cname + ",\r\nYour ticket number is in 3rd position. If you are away, please return back to the waiting room.";

                                                                                                        //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + phonenumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                                                        //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + phonenumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                                                        //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                                                                                        //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                                                                        //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                                                        //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                                                        //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(@"https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + phonenumber + "&text=" + strmsg1 + "");
                                                                                                        //oWeb.Credentials = new NetworkCredential("*****@*****.**", "EqMs2015");

                                                                                                        //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + phonenumber + "&text=" + strmsg1 + "";


                                                                                                        //SmsStatusMsg = oWeb.DownloadString(URL);
                                                                                                        #region Samsung SMS gateway
                                                                                                        //SMS for Samsung gateway
                                                                                                        // Set the username of the account holder.
                                                                                                        Messaging.MessageController.UserAccount.User = "******";
                                                                                                        // Set the password of the account holder.
                                                                                                        Messaging.MessageController.UserAccount.Password = "******";
                                                                                                        // Set the first name of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                                                        // Set the last name of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                                                        // Set the mobile phone number of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                                                        // Set the landline phone number of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                                                        // Set the contact email of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                                                        // Set the country of origin of the account holder (optional).
                                                                                                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                                                        bool testOK = false;
                                                                                                        try
                                                                                                        {
                                                                                                            // Test the user account settings.
                                                                                                            Account testAccount = Messaging.MessageController.UserAccount;
                                                                                                            testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                                                        }
                                                                                                        catch (Exception ex)
                                                                                                        {
                                                                                                            // An exception was thrown. Display the details of the exception and return.
                                                                                                            string message = "There was an error testing the connection details:\n" +
                                                                                                            ex.Message;
                                                                                                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                                                            return;
                                                                                                        }
                                                                                                        if (testOK)
                                                                                                        {
                                                                                                            // The user account settings were valid. Display a success message
                                                                                                            // box with the number of credits.
                                                                                                            int balance = Messaging.MessageController.UserAccount.Balance;
                                                                                                            string message = string.Format("You have {0} message credits available.",
                                                                                                            balance);
                                                                                                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            // The username or password were incorrect. Display a failed message box.
                                                                                                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                                                            // "Connection Failed", MessageBoxButtons.OK);
                                                                                                        }

                                                                                                        Messaging.MessageController.Settings.TimeOut = 60;
                                                                                                        // Set the batch size (number of messages to be sent at once) to 200.
                                                                                                        Messaging.MessageController.Settings.BatchSize = 200;
                                                                                                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                                                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                                                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                                                        Messaging.MessageController.Settings.DeliveryReport = true;
                                                                                                        SMSMessage smsobj = new SMSMessage(phonenumber, strmsg);
                                                                                                        Messaging.MessageController.AddToQueue(smsobj);
                                                                                                        Messaging.MessageController.SendMessages();
                                                                                                        //end of Samsung SMS
                                                                                                        #endregion Samsung SMS gateway
                                                                                                        smsview.SMSStatusFlag = "S";
                                                                                                        smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                                                        if (SmsStatusMsg.Contains("<br>"))
                                                                                                        {
                                                                                                            SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                                                        }

                                                                                                        //Thread.Sleep(100);
                                                                                                        DataTable dt15 = new DataTable();
                                                                                                        dt15 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                                                        foreach (DataRow dr123 in dt15.Rows)
                                                                                                        {
                                                                                                            string Sflag = (dr123["message_status_flag"].ToString());
                                                                                                            string uflag = Convert.ToString("A");
                                                                                                            if (Sflag == uflag)
                                                                                                            {
                                                                                                                smsview.SMSStatusFlag = "S";
                                                                                                                smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                                                            }
                                                                                                            else
                                                                                                            {

                                                                                                                #region Delivery Report
                                                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                                                                //XmlDocument xml = new XmlDocument();
                                                                                                                //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                                                //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                                                                //foreach (XmlNode xn in xnList)
                                                                                                                //{
                                                                                                                //    XmlNode example = xn.SelectSingleNode("sms");
                                                                                                                //    if (example != null)
                                                                                                                //    {
                                                                                                                //        string na = example["messageid"].InnerText;
                                                                                                                //        string no = example["smsclientid"].InnerText;
                                                                                                                //        string mobileno = example["mobile-no"].InnerText;
                                                                                                                //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                                                                                //        SmsDeliveryStatus = client.DownloadString(URL1);
                                                                                                                //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                                                                //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                                                                //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                                                                //        XmlDocument xml1 = new XmlDocument();
                                                                                                                //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                                                //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                                                                //        //foreach (XmlNode xn1 in xnList1)
                                                                                                                //        //{
                                                                                                                //        XmlNode example1 = xml.SelectSingleNode("response");
                                                                                                                //        if (example1 != null)
                                                                                                                //        {
                                                                                                                //            //string rscode = example1["responsecode"].InnerText;
                                                                                                                //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                                                                //            //string dlrcount = example1["dlristcount"].InnerText;
                                                                                                                //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                                                                                                //        }
                                                                                                                //    }

                                                                                                                //}
                                                                                                                #endregion Delivery report


                                                                                                                smsview.MySms = QueueToken;
                                                                                                                DataTable dt5 = new DataTable();
                                                                                                                dt5 = smscontroller.Getvisittnxidbyusingrepliedsms(smsview);
                                                                                                                foreach (DataRow dr5 in dt5.Rows)
                                                                                                                {
                                                                                                                    smsview.QueueTransaction = (Convert.ToInt32(dr5["visit_tnx_id"].ToString()));
                                                                                                                }
                                                                                                                smsview.QueueNo = QueueToken;
                                                                                                                smsview.PhoneNo = phonenumber;
                                                                                                                smsview.IncomingsmsFlag = "A";
                                                                                                                smsview.SMSDateTime = System.DateTime.Now;
                                                                                                                smsview.MySms = strmsg;
                                                                                                                string a;
                                                                                                                a = smscontroller.GetInsertAlertSMS(smsview);

                                                                                                                // DataTable QueueTokenGenerationSentSMS = new DataTable();

                                                                                                                // Thread.Sleep(100);
                                                                                                            }

                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 37
0
        private void QueueTokenGenerationSMS()
        {
            SMSController smscontroller = new SMSController();
            SMSView smsview = new SMSView();
            DataTable QueueTokenGeneration = new DataTable();
            DataTable QueueTokenGenerationSentSMS = new DataTable();
            WebClient oWeb = new WebClient();
            Byte[] bytHeaders;


            try
            {
                QueueTokenGeneration = null;
                QueueTokenGenerationSentSMS = null;

                smsview = new SMSView();

                QueueTokenGeneration = smscontroller.GetGeneratedQueue();
                foreach (DataRow dr in QueueTokenGeneration.Rows)
                {
                    // ThreadRelease = 1;
                    // Thread.Sleep(2000);
                    DataTable dt = new DataTable();
                    smsview.QueueTransaction = (Convert.ToInt32(dr["queue_visit_tnxid"].ToString()));
                    string QueueTokenGenerationSMS = (dr["visit_queue_no_show"].ToString());
                    string QueueTokenGenerationPhoneNo = (Convert.ToString(dr["visit_customer_id"].ToString()));
                    long QueueCustomerId = (Convert.ToInt64(dr["visit_customer_id"].ToString()));
                    smsview.DepartmentID = (Convert.ToInt32(dr["queue_department_id"]));
                    string Cname = ((dr["visit_customer_name"]).ToString());
                    // dt = smscontroller.GetQueuePosition(smsview);
                    // string QueueTokenGenerationPhoneNo = 61 + QueueTokenGenerationPhoneNo1;
                    smsview.CustId = QueueCustomerId;
                    smsview.PhoneNo = QueueTokenGenerationPhoneNo;
                    int pos = 0;
                    dt = smscontroller.GetQueuePosition123(smsview);

                    foreach (DataRow dc in dt.Rows)
                    {
                        smsview.QueueTransaction = (Convert.ToInt32(dc["queue_visit_tnxid"].ToString()));
                        string dname = (dc["department_desc"].ToString());
                        // Thread.Sleep(100);
                        try
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                string queno = (dc["visit_queue_no_show"].ToString());
                                smsview.MySms = queno;
                                // QueueToken = (dc["visit_queue_no_show"].ToString());
                                if (queno == QueueTokenGenerationSMS)
                                {
                                    if (dt != null && dt.Rows.Count > 0 && Convert.ToString(dt.Rows[i]["visit_queue_no_show"]).Equals(queno))
                                    // if (dt.Rows[i]["visit_queue_no_show"] == QueueToken)
                                    {
                                        DataTable CheckMessage = new DataTable();

                                        CheckMessage = smscontroller.GetNewMessageExistance(smsview);
                                        if (CheckMessage.Rows.Count <= 0)
                                        {
                                            pos = i;
                                            #region f pos>0
                                            if (pos > 0)
                                            {
                                                DataTable dtCustName = new DataTable();
                                                smsview.QueueNo = QueueTokenGenerationSMS;
                                                DataTable dtc = new DataTable();
                                                dtc = smscontroller.GetCustId(smsview);
                                                foreach (DataRow drc in dtc.Rows)
                                                {
                                                    

                                                    //retrieve name
                                                    //dtCustName = smscontroller.GetCustomerName(smsview);
                                                    //foreach (DataRow Custname in dtCustName.Rows)
                                                    //{
                                                        
                                                        //string mobileno = 61 + mobileno1;
                                                        //retrieve name
                                                        string SmsStatusMsg = string.Empty;
                                                        string SmsDeliveryStatus = string.Empty;
                                                        try
                                                        {
                                                            #region email
                                                            //if (toAddress != "")
                                                            //{
                                                            //    string subject = "Q Number Details from Welcome to Ampulatory Care Centre";
                                                            //    string body = "Dear  " + Cname + ",<br> Welcome to Ampulatory Care Centre <br/> Your Queue Number is :" + QueueTokenGenerationSMS + "<br/>" + "Selected Department is :" + dname + "<br/>" + "Date Time :" + DateTime.Now + "<br/>" + "Please do not reply to this email. If you have any questions or " + "<br />" + "require further information about the operation of this site," + "<br />" + " please contact: Helpdesk" + "<br />" + "Ph: +61 422889101" + "<br />" + "Email: [email protected]" + "<br />" + "";
                                                            //    MailMessage msgMail = new MailMessage("*****@*****.**", toAddress, subject, body);
                                                            //    msgMail.IsBodyHtml = true;
                                                            //    SmtpClient smtp = new SmtpClient();
                                                            //    smtp.Host = "mail.attsystemsgroup.com";
                                                            //    smtp.UseDefaultCredentials = true;
                                                            //    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "User@123");
                                                            //    smtp.Send(msgMail);
                                                            //}
                                                            #endregion email
                                                            if (QueueTokenGenerationPhoneNo != "")
                                                            {

                                                                if (QueueTokenGenerationPhoneNo.Length == 11)
                                                                {
                                                                    int t = 5 * pos;

                                                                    TimeSpan span = TimeSpan.FromMinutes(t);
                                                                    string apxtime = span.ToString(@"hh\:mm");
                                                                    string strmsg = "Hi" + " " + Cname + ", Your ticket number is:" + QueueTokenGenerationSMS + " .Approximate time of service  at "+""+apxtime+", Thanks.";
                                                                    //Sample: "Hi Kara, your ticket number is 040, Approximate time of service  at 11.40 AM”
                                                                    //string strmsg1 = "Dear" + " " + Cname + ", Welcome to the Ambulatory Care Centre.\r\nYour ticket number is:" + QueueTokenGenerationSMS + " .\r\nTicket number will be called and displayed in the waiting room TV based on your appointment time. Please wait in the waiting room. Thanks";
                                                                    //\r\n\rTo track status of your queue no send SMS to 9214002002 e.g.: ATT<space><your Q number>";
                                                                    #region Proactive SMS Gateway
                                                                    //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + mobileno + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                    #endregion Proactive SMS Gateway

                                                                    #region AussieSMS Gateway

                                                                    // string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + mobileno + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                    //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + mobileno + "&text=" + strmsg1 + "";
                                                                    //Hospital Gateway

                                                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                    //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + mobileno + "&text=" + strmsg1 + "";

                                                                    //SMS for Samsung gateway
                                                                    // Set the username of the account holder.
                                                                    Messaging.MessageController.UserAccount.User = "******";
                                                                    // Set the password of the account holder.
                                                                    Messaging.MessageController.UserAccount.Password = "******";
                                                                    // Set the first name of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                    // Set the last name of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                    // Set the mobile phone number of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                    // Set the landline phone number of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                    // Set the contact email of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                    // Set the country of origin of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                    bool testOK = false;
                                                                    try
                                                                    {
                                                                        // Test the user account settings.
                                                                        Account testAccount = Messaging.MessageController.UserAccount;
                                                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                    }
                                                                    catch (Exception ex)
                                                                    {
                                                                        // An exception was thrown. Display the details of the exception and return.
                                                                        string message = "There was an error testing the connection details:\n" +
                                                                        ex.Message;
                                                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                        return;
                                                                    }
                                                                    if (testOK)
                                                                    {
                                                                        // The user account settings were valid. Display a success message
                                                                        // box with the number of credits.
                                                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                                                        string message = string.Format("You have {0} message credits available.",
                                                                        balance);
                                                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                    }
                                                                    else
                                                                    {
                                                                        // The username or password were incorrect. Display a failed message box.
                                                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                        // "Connection Failed", MessageBoxButtons.OK);
                                                                    }

                                                                    Messaging.MessageController.Settings.TimeOut = 60;
                                                                    // Set the batch size (number of messages to be sent at once) to 200.
                                                                    Messaging.MessageController.Settings.BatchSize = 200;
                                                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                                                    SMSMessage smsobj = new SMSMessage(QueueTokenGenerationPhoneNo, strmsg);
                                                                    Messaging.MessageController.AddToQueue(smsobj);
                                                                    Messaging.MessageController.SendMessages();
                                                                    //end of Samsung SMS
                                                                    #endregion AussieSMS Gateway

                                                                    //SmsStatusMsg = oWeb.DownloadString(URL);
                                                                    // if (SmsStatusMsg.Contains("<br>"))
                                                                    //  {
                                                                    //     SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                    //  }
                                                                    smsview.SMSStatusFlag = "A";
                                                                    QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                    Thread.Sleep(100);
                                                                    DataTable dt1 = new DataTable();
                                                                    dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                    foreach (DataRow dr123 in dt1.Rows)
                                                                    {
                                                                        string Sflag = (dr123["message_status_flag"].ToString());
                                                                        string uflag = Convert.ToString("N");
                                                                        if (Sflag == uflag)
                                                                        {
                                                                            smsview.SMSStatusFlag = "A";
                                                                            QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                        }
                                                                        else
                                                                        {
                                                                            #region xml for messageid
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                            //XmlDocument xml = new XmlDocument();
                                                                            //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                            //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                            //foreach (XmlNode xn in xnList)
                                                                            //{
                                                                            //    XmlNode example = xn.SelectSingleNode("sms");
                                                                            //    if (example != null)
                                                                            //    {
                                                                            //        string na = example["messageid"].InnerText;
                                                                            //        string no = example["smsclientid"].InnerText;
                                                                            //        string mobile_no = example["mobile-no"].InnerText;
                                                                            #endregion xml for messageid

                                                                            #region message id from Aussie Gateway

                                                                            //char[] delimiterChars = { ':' };

                                                                            //text = SmsStatusMsg;
                                                                            //System.Console.WriteLine("Original text: '{0}'", text);
                                                                            //string[] words = text.Split(delimiterChars);
                                                                            //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                            //foreach (string s in words)
                                                                            //{
                                                                            //    for (i = 0; i < words.Length; i++)
                                                                            //    {
                                                                            //        if (pos == 1)
                                                                            //        {
                                                                            //            string[] digits = Regex.Split(s, @"\D+");
                                                                            //            //
                                                                            //            // Now we have each number string.
                                                                            //            //
                                                                            //            foreach (string value in digits)
                                                                            //            {
                                                                            //                //
                                                                            //                // Parse the value to get the number.
                                                                            //                //
                                                                            //                int number;
                                                                            //                if (int.TryParse(value, out number))
                                                                            //                {
                                                                            //                    messageid = value;
                                                                            //                }
                                                                            //            }
                                                                            //        }
                                                                            //    }

                                                                            //    // rsbel.QueueNo = s;
                                                                            //    pos++;
                                                                            //}

                                                                            #endregion message id from Aussie Gateway

                                                                            #region proactive delivery report

                                                                            //string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                                            #endregion proactive delivery report

                                                                            #region Aussie Delivery report

                                                                            //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=20150617121452";
                                                                            //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=" + messageid + "";


                                                                            #endregion Aussie Delivery report

                                                                            // SmsDeliveryStatus = client.DownloadString(URL1);
                                                                            #region xml for delivery report
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                            //XmlDocument xml1 = new XmlDocument();
                                                                            //xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                            ////XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                            ////foreach (XmlNode xn1 in xnList1)
                                                                            ////{
                                                                            //XmlNode example1 = xml.SelectSingleNode("response");
                                                                            //if (example1 != null)
                                                                            //{
                                                                            //    //string rscode = example1["responsecode"].InnerText;
                                                                            //    smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                            //    //string dlrcount = example1["dlristcount"].InnerText;
                                                                            //    //string pendingcount = example1["pendingdrcount"].InnerText;

                                                                            //}

                                                                            // }
                                                                            #endregion xml for delivery report

                                                                            #region Aussie Delivery report

                                                                            //char[] delimiterChars1 = { ':' };
                                                                            //text = SmsDeliveryStatus;
                                                                            //System.Console.WriteLine("Original text: '{0}'", text);
                                                                            //words = text.Split(delimiterChars1);
                                                                            //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                            //foreach (string s in words)
                                                                            //{

                                                                            //    smsview.DeliveryReport = s;
                                                                            //}


                                                                            #endregion Aussie Delivery report
                                                                            smsview.MySms = strmsg;
                                                                            smsview.QueueNo = QueueTokenGenerationSMS;
                                                                            smsview.IncomingsmsFlag = "N";
                                                                            smsview.SMSDateTime = System.DateTime.Now;
                                                                            string success;
                                                                            success = smscontroller.GetInsertNewSMS(smsview);

                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (QueueTokenGenerationPhoneNo.Length == 9)
                                                                    {
                                                                        QueueTokenGenerationPhoneNo = 61 + QueueTokenGenerationPhoneNo;

                                                                        int t = 5 * pos;

                                                                        TimeSpan span = TimeSpan.FromMinutes(t);
                                                                        string apxtime = span.ToString(@"hh\:mm");
                                                                        //string strmsg = "Dear" + " " + Cname + ", Welcome to the Samsung Experience Store .\r\nYour ticket number is:" + QueueTokenGenerationSMS + " . Thanks";
                                                                        string strmsg = "Hi" + " " + Cname + ", Your ticket number is:" + QueueTokenGenerationSMS + " .Approximate time of service  at " + "" + apxtime + ", Thanks.";
                                                                        //\r\n\rTo track status of your queue no send SMS to 9214002002 e.g.: ATT<space><your Q number>";
                                                                        #region Proactive SMS Gateway
                                                                        //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + mobileno + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                        #endregion Proactive SMS Gateway

                                                                        #region AussieSMS Gateway

                                                                        // string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + mobileno + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                        //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + mobileno + "&text=" + strmsg1 + "";
                                                                        //Hospital Gateway

                                                                        //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                                        //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                        //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                        //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + mobileno + "&text=" + strmsg1 + "";

                                                                        #endregion AussieSMS Gateway

                                                                        #region Samsung SMS gateway
                                                                        //SMS for Samsung gateway
                                                                        // Set the username of the account holder.
                                                                        Messaging.MessageController.UserAccount.User = "******";
                                                                        // Set the password of the account holder.
                                                                        Messaging.MessageController.UserAccount.Password = "******";
                                                                        // Set the first name of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                        // Set the last name of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                        // Set the mobile phone number of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                        // Set the landline phone number of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                        // Set the contact email of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                        // Set the country of origin of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                        bool testOK = false;
                                                                        try
                                                                        {
                                                                            // Test the user account settings.
                                                                            Account testAccount = Messaging.MessageController.UserAccount;
                                                                            testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                        }
                                                                        catch (Exception ex)
                                                                        {
                                                                            // An exception was thrown. Display the details of the exception and return.
                                                                            string message = "There was an error testing the connection details:\n" +
                                                                            ex.Message;
                                                                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                            return;
                                                                        }
                                                                        if (testOK)
                                                                        {
                                                                            // The user account settings were valid. Display a success message
                                                                            // box with the number of credits.
                                                                            int balance = Messaging.MessageController.UserAccount.Balance;
                                                                            string message = string.Format("You have {0} message credits available.",
                                                                            balance);
                                                                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                        }
                                                                        else
                                                                        {
                                                                            // The username or password were incorrect. Display a failed message box.
                                                                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                            // "Connection Failed", MessageBoxButtons.OK);
                                                                        }

                                                                        Messaging.MessageController.Settings.TimeOut = 60;
                                                                        // Set the batch size (number of messages to be sent at once) to 200.
                                                                        Messaging.MessageController.Settings.BatchSize = 200;
                                                                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                        Messaging.MessageController.Settings.DeliveryReport = true;
                                                                        SMSMessage smsobj = new SMSMessage(QueueTokenGenerationPhoneNo, strmsg);
                                                                        Messaging.MessageController.AddToQueue(smsobj);
                                                                        Messaging.MessageController.SendMessages();
                                                                        //end of Samsung SMS
                                                                        #endregion Samsung SMS gateway

                                                                        //SmsStatusMsg = oWeb.DownloadString(URL);
                                                                        if (SmsStatusMsg.Contains("<br>"))
                                                                        {
                                                                            SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                        }
                                                                        smsview.SMSStatusFlag = "A";
                                                                        QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                        // Thread.Sleep(100);
                                                                        DataTable dt1 = new DataTable();
                                                                        dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                        foreach (DataRow dr123 in dt1.Rows)
                                                                        {
                                                                            string Sflag = (dr123["sms_status_flag"].ToString());
                                                                            string uflag = Convert.ToString("N");
                                                                            if (Sflag == uflag)
                                                                            {
                                                                                smsview.SMSStatusFlag = "A";
                                                                                QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                            }
                                                                            else
                                                                            {
                                                                                #region xml for messageid
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                                //XmlDocument xml = new XmlDocument();
                                                                                //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                                //foreach (XmlNode xn in xnList)
                                                                                //{
                                                                                //    XmlNode example = xn.SelectSingleNode("sms");
                                                                                //    if (example != null)
                                                                                //    {
                                                                                //        string na = example["messageid"].InnerText;
                                                                                //        string no = example["smsclientid"].InnerText;
                                                                                //        string mobile_no = example["mobile-no"].InnerText;
                                                                                #endregion xml for messageid

                                                                                #region message id from Aussie Gateway

                                                                                //char[] delimiterChars = { ':' };

                                                                                //text = SmsStatusMsg;
                                                                                //System.Console.WriteLine("Original text: '{0}'", text);
                                                                                //string[] words = text.Split(delimiterChars);
                                                                                //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                                //foreach (string s in words)
                                                                                //{
                                                                                //    for (i = 0; i < words.Length; i++)
                                                                                //    {
                                                                                //        if (pos == 1)
                                                                                //        {
                                                                                //            string[] digits = Regex.Split(s, @"\D+");
                                                                                //            //
                                                                                //            // Now we have each number string.
                                                                                //            //
                                                                                //            foreach (string value in digits)
                                                                                //            {
                                                                                //                //
                                                                                //                // Parse the value to get the number.
                                                                                //                //
                                                                                //                int number;
                                                                                //                if (int.TryParse(value, out number))
                                                                                //                {
                                                                                //                    messageid = value;
                                                                                //                }
                                                                                //            }
                                                                                //        }
                                                                                //    }

                                                                                //    // rsbel.QueueNo = s;
                                                                                //    pos++;
                                                                                //}

                                                                                #endregion message id from Aussie Gateway

                                                                                #region proactive delivery report

                                                                                //string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                                                #endregion proactive delivery report

                                                                                #region Aussie Delivery report

                                                                                //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=20150617121452";
                                                                                //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=" + messageid + "";


                                                                                #endregion Aussie Delivery report

                                                                                // SmsDeliveryStatus = client.DownloadString(URL1);
                                                                                #region xml for delivery report
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                                //XmlDocument xml1 = new XmlDocument();
                                                                                //xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                ////XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                                ////foreach (XmlNode xn1 in xnList1)
                                                                                ////{
                                                                                //XmlNode example1 = xml.SelectSingleNode("response");
                                                                                //if (example1 != null)
                                                                                //{
                                                                                //    //string rscode = example1["responsecode"].InnerText;
                                                                                //    smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                                //    //string dlrcount = example1["dlristcount"].InnerText;
                                                                                //    //string pendingcount = example1["pendingdrcount"].InnerText;

                                                                                //}

                                                                                // }
                                                                                #endregion xml for delivery report

                                                                                #region Aussie Delivery report

                                                                                //char[] delimiterChars1 = { ':' };
                                                                                //text = SmsDeliveryStatus;
                                                                                //System.Console.WriteLine("Original text: '{0}'", text);
                                                                                //words = text.Split(delimiterChars1);
                                                                                //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                                //foreach (string s in words)
                                                                                //{

                                                                                //    smsview.DeliveryReport = s;
                                                                                //}


                                                                                #endregion Aussie Delivery report
                                                                                smsview.MySms = strmsg;
                                                                                smsview.QueueNo = QueueTokenGenerationSMS;
                                                                                smsview.IncomingsmsFlag = "N";
                                                                                smsview.SMSDateTime = System.DateTime.Now;
                                                                                string success;
                                                                                success = smscontroller.GetInsertNewSMS(smsview);

                                                                            }
                                                                        }
                                                                    }
                                                                }

                                                            }


                                                            //smsview.SMSStatusFlag = "A";
                                                            //QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                        }
                                                        catch (WebException e1)
                                                        {
                                                            SmsStatusMsg = e1.Message;
                                                        }
                                                        catch (Exception e2)
                                                        {
                                                            SmsStatusMsg = e2.Message;
                                                        }
                                                    //}
                                                }
                                                // Thread.Sleep(2000);

                                            }
                                            #endregion if pos>0

                                            #region if pos<0
                                            else
                                            {
                                                DataTable dtCustName = new DataTable();
                                                smsview.QueueNo = QueueTokenGenerationSMS;
                                                DataTable dtc = new DataTable();
                                                dtc = smscontroller.GetCustId(smsview);
                                                foreach (DataRow drc in dtc.Rows)
                                                {
                                                    long custid = (Convert.ToInt64(drc["visit_customer_id"].ToString()));
                                                    smsview.MenberId = (Convert.ToInt32(drc["members_id"].ToString()));
                                                    smsview.CustId = custid;
                                                    //retrieve name
                                                    //dtCustName = smscontroller.GetCustomerName(smsview);
                                                    //foreach (DataRow Custname in dtCustName.Rows)
                                                    //{
                                                        //string custfname = (Custname["members_firstname"].ToString());
                                                        //string custlname = (Custname["members_lastname"].ToString());
                                                        //Cname = custfname + " " + custlname;
                                                        //string mobileno = (Custname["members_mobile"].ToString());
                                                        //toAddress = (Custname["members_email"].ToString());
                                                        //retrieve name
                                                        string SmsStatusMsg = string.Empty;
                                                        string SmsDeliveryStatus = string.Empty;

                                                        try
                                                        {
                                                            #region email
                                                            //if (toAddress != "")
                                                            //{
                                                            //    string subject = "Q Number Details from Welcome to Ampulatory Care Centre";
                                                            //    string body = " Dear  " + Cname + ",<br>Welcome to Ampulatory Care Centre <br/> Your Queue Number is :" + QueueTokenGenerationSMS + "<br/>" + "Selected Department is :" + dname + "<br/>" + "Date Time :" + DateTime.Now + "<br/>" + "<br/>Please do not reply to this email. If you have any questions or " + "<br />" + "require further information about the operation of this site," + "<br />" + " please contact: Helpdesk" + "<br />" + "Ph: +61 422889101" + "<br />" + "Email: [email protected]" + "<br />" + "";
                                                            //    MailMessage msgMail = new MailMessage("*****@*****.**", toAddress, subject, body);
                                                            //    msgMail.IsBodyHtml = true;
                                                            //    SmtpClient smtp = new SmtpClient();
                                                            //    smtp.Host = "mail.attsystemsgroup.com";
                                                            //    smtp.UseDefaultCredentials = true;
                                                            //    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "User@123");
                                                            //    smtp.Send(msgMail);
                                                            //}
                                                            #endregion email
                                                            if (QueueTokenGenerationPhoneNo != "")
                                                            {
                                                                if (QueueTokenGenerationPhoneNo.Length == 11)
                                                                {
                                                                    int t = 0;
                                                                    TimeSpan span = TimeSpan.FromMinutes(t);
                                                                    string apxtime = span.ToString(@"hh\:mm");
                                                                    string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";
                                                                    //\r\n\rTo track status of your queue no send SMS to 9214002002 e.g.: ATT<space><your Q number>";
                                                                    //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + QueueTokenGenerationPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                    //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                    //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "";


                                                                    //Hospital Gateway

                                                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                    //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "";

                                                                    #region Samsung SMS gateway
                                                                    //SMS for Samsung gateway
                                                                    // Set the username of the account holder.
                                                                    Messaging.MessageController.UserAccount.User = "******";
                                                                    // Set the password of the account holder.
                                                                    Messaging.MessageController.UserAccount.Password = "******";
                                                                    // Set the first name of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                    // Set the last name of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                    // Set the mobile phone number of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                    // Set the landline phone number of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                    // Set the contact email of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                    // Set the country of origin of the account holder (optional).
                                                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                    bool testOK = false;
                                                                    try
                                                                    {
                                                                        // Test the user account settings.
                                                                        Account testAccount = Messaging.MessageController.UserAccount;
                                                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                    }
                                                                    catch (Exception ex)
                                                                    {
                                                                        // An exception was thrown. Display the details of the exception and return.
                                                                        string message = "There was an error testing the connection details:\n" +
                                                                        ex.Message;
                                                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                        return;
                                                                    }
                                                                    if (testOK)
                                                                    {
                                                                        // The user account settings were valid. Display a success message
                                                                        // box with the number of credits.
                                                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                                                        string message = string.Format("You have {0} message credits available.",
                                                                        balance);
                                                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                    }
                                                                    else
                                                                    {
                                                                        // The username or password were incorrect. Display a failed message box.
                                                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                        // "Connection Failed", MessageBoxButtons.OK);
                                                                    }

                                                                    Messaging.MessageController.Settings.TimeOut = 60;
                                                                    // Set the batch size (number of messages to be sent at once) to 200.
                                                                    Messaging.MessageController.Settings.BatchSize = 200;
                                                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                                                    SMSMessage smsobj = new SMSMessage(QueueTokenGenerationPhoneNo, strmsg);
                                                                    Messaging.MessageController.AddToQueue(smsobj);
                                                                    Messaging.MessageController.SendMessages();
                                                                    //end of Samsung SMS
                                                                    #endregion Samsung SMS gateway

                                                                    //SmsStatusMsg = oWeb.DownloadString(URL);
                                                                    if (SmsStatusMsg.Contains("<br>"))
                                                                    {
                                                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                    }
                                                                    smsview.SMSStatusFlag = "A";
                                                                    smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                    // Thread.Sleep(100);
                                                                    DataTable dt1 = new DataTable();
                                                                    dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                    foreach (DataRow dr123 in dt1.Rows)
                                                                    {
                                                                        string Sflag = (dr123["sms_status_flag"].ToString());
                                                                        string uflag = Convert.ToString("N");
                                                                        if (Sflag == uflag)
                                                                        {
                                                                            smsview.SMSStatusFlag = "A";
                                                                            QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                        }
                                                                        else
                                                                        {

                                                                            #region xml for message id
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                            //XmlDocument xml = new XmlDocument();
                                                                            //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                            //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                            //foreach (XmlNode xn in xnList)
                                                                            //{
                                                                            //    XmlNode example = xn.SelectSingleNode("sms");
                                                                            //    if (example != null)
                                                                            //    {
                                                                            //        string na = example["messageid"].InnerText;
                                                                            //        string no = example["smsclientid"].InnerText;
                                                                            //        string mobileno = example["mobile-no"].InnerText;
                                                                            #endregion xml for message id

                                                                            #region message id from Aussie Gateway

                                                                            //char[] delimiterChars = { ':' };

                                                                            //text = SmsStatusMsg;
                                                                            //System.Console.WriteLine("Original text: '{0}'", text);
                                                                            //string[] words = text.Split(delimiterChars);
                                                                            //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                            //foreach (string s in words)
                                                                            //{
                                                                            //    for (i = 0; i < words.Length; i++)
                                                                            //    {
                                                                            //        if (pos == 1)
                                                                            //        {
                                                                            //            string[] digits = Regex.Split(s, @"\D+");
                                                                            //            //
                                                                            //            // Now we have each number string.
                                                                            //            //
                                                                            //            foreach (string value in digits)
                                                                            //            {
                                                                            //                //
                                                                            //                // Parse the value to get the number.
                                                                            //                //
                                                                            //                int number;
                                                                            //                if (int.TryParse(value, out number))
                                                                            //                {
                                                                            //                    messageid = value;
                                                                            //                }
                                                                            //            }
                                                                            //        }
                                                                            //    }

                                                                            //    // rsbel.QueueNo = s;
                                                                            //    pos++;
                                                                            //}

                                                                            #endregion message id from Aussie Gateway

                                                                            #region Proactive messageid
                                                                            //string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";
                                                                            #endregion Proactive messageid

                                                                            #region Aussie Delivery report

                                                                            //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=" + messageid + "";

                                                                            #endregion Aussie Delivery Report
                                                                            //SmsDeliveryStatus = client.DownloadString(URL1);
                                                                            #region Proactive Delivery report
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                            //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                            //XmlDocument xml1 = new XmlDocument();
                                                                            //xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                            ////XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                            ////foreach (XmlNode xn1 in xnList1)
                                                                            ////{
                                                                            //XmlNode example1 = xml.SelectSingleNode("response");
                                                                            //if (example1 != null)
                                                                            //{
                                                                            //    //string rscode = example1["responsecode"].InnerText;
                                                                            //    smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                            //    //string dlrcount = example1["dlristcount"].InnerText;
                                                                            //    //string pendingcount = example1["pendingdrcount"].InnerText;
                                                                            // }
                                                                            //}
                                                                            #endregion Proactive Delivery report

                                                                            #region Aussie Delivery report
                                                                            //char[] delimiterChars1 = { ':' };
                                                                            //text = SmsDeliveryStatus;
                                                                            //System.Console.WriteLine("Original text: '{0}'", text);
                                                                            //words = text.Split(delimiterChars1);
                                                                            //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                            //foreach (string s in words)
                                                                            //{

                                                                            //    smsview.DeliveryReport = s;
                                                                            //}
                                                                            #endregion Aussie Delivery report

                                                                            smsview.MySms = strmsg;
                                                                            smsview.QueueNo = QueueTokenGenerationSMS;
                                                                            smsview.IncomingsmsFlag = "N";
                                                                            smsview.SMSDateTime = System.DateTime.Now;
                                                                            string success;
                                                                            success = smscontroller.GetInsertNewSMS(smsview);

                                                                        }

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (QueueTokenGenerationPhoneNo.Length == 9)
                                                                    {
                                                                        QueueTokenGenerationPhoneNo = 61 + QueueTokenGenerationPhoneNo;

                                                                        int t = 20;
                                                                        TimeSpan span = TimeSpan.FromMinutes(t);
                                                                        string apxtime = span.ToString(@"hh\:mm");
                                                                        //string strmsg = "Dear" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";
                                                                        string strmsg = "Hi" + " " + Cname + ", Your ticket number is:" + QueueTokenGenerationSMS + " .Approximate time of service  at " + "" + apxtime + ", Thanks.";
                                                                        //\r\n\rTo track status of your queue no send SMS to 9214002002 e.g.: ATT<space><your Q number>";
                                                                        // string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + QueueTokenGenerationPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                                        //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                                        //string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "";
                                                                        //Hospital Gateway

                                                                        //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                                        //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                                        //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                                        //string URL = "https://tim.telstra.com/cgphttp/servlet/sendmsg?destination=" + QueueTokenGenerationPhoneNo + "&text=" + strmsg1 + "";

                                                                        #region Samsung SMS gateway
                                                                        //SMS for Samsung gateway
                                                                        // Set the username of the account holder.
                                                                        Messaging.MessageController.UserAccount.User = "******";
                                                                        // Set the password of the account holder.
                                                                        Messaging.MessageController.UserAccount.Password = "******";
                                                                        // Set the first name of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                                        // Set the last name of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                                        // Set the mobile phone number of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                                        // Set the landline phone number of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                                        // Set the contact email of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                                        // Set the country of origin of the account holder (optional).
                                                                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                                        bool testOK = false;
                                                                        try
                                                                        {
                                                                            // Test the user account settings.
                                                                            Account testAccount = Messaging.MessageController.UserAccount;
                                                                            testOK = Messaging.MessageController.TestAccount(testAccount);
                                                                        }
                                                                        catch (Exception ex)
                                                                        {
                                                                            // An exception was thrown. Display the details of the exception and return.
                                                                            string message = "There was an error testing the connection details:\n" +
                                                                            ex.Message;
                                                                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                            return;
                                                                        }
                                                                        if (testOK)
                                                                        {
                                                                            // The user account settings were valid. Display a success message
                                                                            // box with the number of credits.
                                                                            int balance = Messaging.MessageController.UserAccount.Balance;
                                                                            string message = string.Format("You have {0} message credits available.",
                                                                            balance);
                                                                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                                        }
                                                                        else
                                                                        {
                                                                            // The username or password were incorrect. Display a failed message box.
                                                                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                            // "Connection Failed", MessageBoxButtons.OK);
                                                                        }

                                                                        Messaging.MessageController.Settings.TimeOut = 60;
                                                                        // Set the batch size (number of messages to be sent at once) to 200.
                                                                        Messaging.MessageController.Settings.BatchSize = 200;
                                                                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                                        Messaging.MessageController.Settings.DeliveryReport = true;
                                                                        SMSMessage smsobj = new SMSMessage(QueueTokenGenerationPhoneNo, strmsg);
                                                                        Messaging.MessageController.AddToQueue(smsobj);
                                                                        Messaging.MessageController.SendMessages();
                                                                        //end of Samsung SMS
                                                                        #endregion Samsung SMS gateway

                                                                        //SmsStatusMsg = oWeb.DownloadString(URL);
                                                                        if (SmsStatusMsg.Contains("<br>"))
                                                                        {
                                                                            SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                                        }
                                                                        smsview.SMSStatusFlag = "A";
                                                                        smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                        // Thread.Sleep(100);
                                                                        DataTable dt1 = new DataTable();
                                                                        dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview);

                                                                        foreach (DataRow dr123 in dt1.Rows)
                                                                        {
                                                                            string Sflag = (dr123["message_status_flag"].ToString());
                                                                            string uflag = Convert.ToString("N");
                                                                            if (Sflag == uflag)
                                                                            {
                                                                                smsview.SMSStatusFlag = "A";
                                                                                QueueTokenGenerationSentSMS = smscontroller.GetQueueTokenGenerationSentSMS(smsview);
                                                                            }
                                                                            else
                                                                            {

                                                                                #region xml for message id
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                                                //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                                                //XmlDocument xml = new XmlDocument();
                                                                                //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                                                //foreach (XmlNode xn in xnList)
                                                                                //{
                                                                                //    XmlNode example = xn.SelectSingleNode("sms");
                                                                                //    if (example != null)
                                                                                //    {
                                                                                //        string na = example["messageid"].InnerText;
                                                                                //        string no = example["smsclientid"].InnerText;
                                                                                //        string mobileno = example["mobile-no"].InnerText;
                                                                                #endregion xml for message id

                                                                                #region message id from Aussie Gateway

                                                                                //char[] delimiterChars = { ':' };

                                                                                //text = SmsStatusMsg;
                                                                                //System.Console.WriteLine("Original text: '{0}'", text);
                                                                                //string[] words = text.Split(delimiterChars);
                                                                                //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                                //foreach (string s in words)
                                                                                //{
                                                                                //    for (i = 0; i < words.Length; i++)
                                                                                //    {
                                                                                //        if (pos == 1)
                                                                                //        {
                                                                                //            string[] digits = Regex.Split(s, @"\D+");
                                                                                //            //
                                                                                //            // Now we have each number string.
                                                                                //            //
                                                                                //            foreach (string value in digits)
                                                                                //            {
                                                                                //                //
                                                                                //                // Parse the value to get the number.
                                                                                //                //
                                                                                //                int number;
                                                                                //                if (int.TryParse(value, out number))
                                                                                //                {
                                                                                //                    messageid = value;
                                                                                //                }
                                                                                //            }
                                                                                //        }
                                                                                //    }

                                                                                //    // rsbel.QueueNo = s;
                                                                                //    pos++;
                                                                                //}

                                                                                #endregion message id from Aussie Gateway

                                                                                #region Proactive messageid
                                                                                //string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";
                                                                                #endregion Proactive messageid

                                                                                #region Aussie Delivery report

                                                                                //string URL1 = "https://api.aussiesms.com.au/?querymessage&mobileID=61422889101&password=att0424&msgid=" + messageid + "";

                                                                                #endregion Aussie Delivery Report
                                                                                //SmsDeliveryStatus = client.DownloadString(URL1);
                                                                                #region Proactive Delivery report
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                                                //SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                                                //XmlDocument xml1 = new XmlDocument();
                                                                                //xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                                                ////XmlNodeList xnList1 = xml.SelectNodes("response");

                                                                                ////foreach (XmlNode xn1 in xnList1)
                                                                                ////{
                                                                                //XmlNode example1 = xml.SelectSingleNode("response");
                                                                                //if (example1 != null)
                                                                                //{
                                                                                //    //string rscode = example1["responsecode"].InnerText;
                                                                                //    smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                                                //    //string dlrcount = example1["dlristcount"].InnerText;
                                                                                //    //string pendingcount = example1["pendingdrcount"].InnerText;
                                                                                // }
                                                                                //}
                                                                                #endregion Proactive Delivery report

                                                                                #region Aussie Delivery report
                                                                                //char[] delimiterChars1 = { ':' };
                                                                                //text = SmsDeliveryStatus;
                                                                                //System.Console.WriteLine("Original text: '{0}'", text);
                                                                                //words = text.Split(delimiterChars1);
                                                                                //System.Console.WriteLine("{0} words in text:", words.Length);

                                                                                //foreach (string s in words)
                                                                                //{

                                                                                //    smsview.DeliveryReport = s;
                                                                                //}
                                                                                #endregion Aussie Delivery report

                                                                                smsview.MySms = strmsg;
                                                                                smsview.QueueNo = QueueTokenGenerationSMS;
                                                                                smsview.IncomingsmsFlag = "N";
                                                                                smsview.SMSDateTime = System.DateTime.Now;
                                                                                string success;
                                                                                success = smscontroller.GetInsertNewSMS(smsview);

                                                                            }

                                                                        }

                                                                    }
                                                                }



                                                            }
                                                        }
                                                        catch (WebException e1)
                                                        {
                                                            SmsStatusMsg = e1.Message;
                                                        }
                                                        catch (Exception e2)
                                                        {
                                                            SmsStatusMsg = e2.Message;
                                                        }

                                                    //}
                                                }
                                                // Thread.Sleep(100);
                                            }
                                            #endregion if pos<0
                                        }

                                    }
                                }
                            }

                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    // Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            // Thread.Sleep(100);

        }