Esempio n. 1
0
        private void SendMessages(DataSet dsMsg)
        {
            DateTime now = DateTime.Now;

            if (now >= nextSendTime)
            {
                StatusChecker.SMSService checker = new StatusChecker.SMSService();

                if (NewMessageEvent != null)
                {
                    NewMessageEvent(this, new MessageArgs("Sending sms: " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
                }
                if (dsMsg != null && dsMsg.Tables.Count > 0 && dsMsg.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsMsg.Tables[0].Rows)
                    {
                        String id        = dr["id"].ToString();
                        String number    = dr["number"].ToString();
                        String message   = dr["number"].ToString();
                        String reference = dr["number"].ToString();
                        String batchID;
                        String status;
                        if (SendSMS(number, String.Format("{0} - Reply with ref:{1}", message, reference), out status, out batchID))
                        {
                            UpdateMessage(id, batchID);
                        }
                    }
                }
                nextSendTime = nextSendTime.AddDays(1);
            }
        }
Esempio n. 2
0
        private void QueryStatus(DataSet dsMsg)
        {
            DateTime now = DateTime.Now;

            if (now >= nextCheckTime)
            {
                if (NewMessageEvent != null)
                {
                    NewMessageEvent(this, new MessageArgs("Checking sms status: " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
                }
                if (dsMsg != null && dsMsg.Tables.Count > 0 && dsMsg.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsMsg.Tables[0].Rows)
                    {
                        String batchID = dr["batchID"].ToString().Replace("\n", "");
                        String number  = dr["number"].ToString().Replace("\n", "");
                        using (StatusChecker.SMSService checker = new StatusChecker.SMSService())
                        {
                            String msgStatus = checker.GetStatus(batchID);
                            //String msgStatus = dr["bsstatus"].ToString();
                            if (!String.IsNullOrEmpty(msgStatus))
                            {
                                if (msgStatus == "10" || msgStatus == "11")
                                {
                                    String[] bStuff       = GetBuildingStuff(dr["building"].ToString());
                                    String   pastelString = "";
                                    String   reference    = dr["reference"].ToString();
                                    String   description  = dr["message"].ToString();
                                    String   trustAcc     = "1115000";
                                    String   amt          = "5.00";
                                    //verify with Sheldon / Tertia
                                    try
                                    {
                                        String pastelReturn = frmMain.pastel.PostBatch(DateTime.Parse(dr["sent"].ToString()), int.Parse(bStuff[0]), "CENTRE19", bStuff[1], 5,
                                                                                       int.Parse(bStuff[2]), bStuff[3], dr["customer"].ToString(), bStuff[4], "9250000", reference, description, amt, trustAcc, "", out pastelString);
                                    }
                                    catch { }
                                }
                                UpdateMessage(batchID, getStatus(int.Parse(msgStatus)), DateTime.Now, 1);
                            }
                        }
                    }
                }
                nextCheckTime = nextCheckTime.AddDays(1);
            }
        }
Esempio n. 3
0
        private void ForceSendMessages(DataSet dsMsg)
        {
            StatusChecker.SMSService checker = new StatusChecker.SMSService();

            if (NewMessageEvent != null)
            {
                NewMessageEvent(this, new MessageArgs("Sending sms: " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
            }
            if (dsMsg != null && dsMsg.Tables.Count > 0 && dsMsg.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsMsg.Tables[0].Rows)
                {
                    String id        = dr["id"].ToString();
                    String number    = dr["number"].ToString();
                    String message   = dr["message"].ToString();
                    String reference = dr["reference"].ToString();
                    String batchID;
                    String status;
                    String messageS = String.Format("{0} - Reply with ref:{1}", message, reference);
                    if (messageS.Length > 160)
                    {
                        messageS = message;
                    }
                    if (SendSMS(number, messageS, out status, out batchID))
                    {
                        UpdateMessage(id, batchID);
                    }
                    else
                    {
                        if (NewMessageEvent != null)
                        {
                            NewMessageEvent(this, new MessageArgs(status));
                        }
                    }
                }
            }
        }