public List <object> SMSFormat(SmsPdu SmsPdu)
        {
            List <object> SmsFormat = new List <object>();

            try
            {
                if (SmsPdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu Fpdu               = (SmsDeliverPdu)SmsPdu;
                    string        Text               = Fpdu.UserDataText.ToUpper();
                    string        PhoneNumber        = Fpdu.OriginatingAddress;
                    string        SMSCode            = string.Empty;
                    long          Output_RegCustCode = 0;
                    Output_RegCustCode = Convert.ToInt32(objData.GetCustCodeFromPhoneNo(Fpdu.OriginatingAddress));

                    if (Output_RegCustCode != 0)
                    {
                        SMSCode = SMSCommadCode.Format_RegCustCode;
                    }
                    else
                    {
                        SMSCode = SMSCommadCode.IPODefault_Code;
                    }
                }
            }
            catch
            {
            }
            return(SmsFormat);
        }
 private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     try
     {
         IMessageIndicationObject obj = e.IndicationObject;
         if (obj is MemoryLocation)
         {
             MemoryLocation loc = (MemoryLocation)obj;
             Output(string.Format("New message received in storage \"{0}\", index {1}.",
                                  loc.Storage, loc.Index));
             Output("");
             return;
         }
         if (obj is ShortMessage)
         {
             ShortMessage msg = (ShortMessage)obj;
             SmsPdu       pdu = comm.DecodeReceivedMessage(msg);
             Output("New message received.");
             Output("");
             ShowMessage(pdu);
             return;
         }
         Output("Error: Unknown notification object!");
     }
     catch (Exception ex)
     {
         Output(ex.ToString());
     }
 }
 /// <summary>
 /// Gets the concatenation information of a message.
 /// </summary>
 /// <param name="pdu">The message to get the information of.</param>
 /// <returns>An object implementing <see cref="T:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo" />, if
 /// the message is a part of a concatenated message, null otherwise.</returns>
 /// <remarks>
 /// <para>The returned information can be used to discover the parts of a concatenated message
 /// or recombine the parts back into one message.</para>
 /// </remarks>
 public static IConcatenationInfo GetConcatenationInfo(SmsPdu pdu)
 {
     if (pdu != null)
     {
         IConcatenationInfo concatenationInfo = null;
         if (pdu.UserDataHeaderPresent)
         {
             byte[] userDataHeader = pdu.GetUserDataHeader();
             InformationElement[] informationElementArray  = SmartMessageDecoder.DecodeUserDataHeader(userDataHeader);
             InformationElement[] informationElementArray1 = informationElementArray;
             int num = 0;
             while (num < (int)informationElementArray1.Length)
             {
                 InformationElement informationElement = informationElementArray1[num];
                 if (informationElement as IConcatenationInfo == null)
                 {
                     num++;
                 }
                 else
                 {
                     concatenationInfo = (IConcatenationInfo)informationElement;
                     break;
                 }
             }
         }
         return(concatenationInfo);
     }
     else
     {
         throw new ArgumentNullException("pdu");
     }
 }
示例#4
0
        private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            try
            {
                IMessageIndicationObject obj = e.IndicationObject;
                if (obj is MemoryLocation)
                {
                    MemoryLocation loc    = (MemoryLocation)obj;
                    string         logmsg = string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index);

                    logger(logmsg);

                    DecodedShortMessage msg = comm.ReadMessage(loc.Index, loc.Storage);
                    ShowMessage(msg.Data);
                    return;
                }

                if (obj is ShortMessage)
                {
                    ShortMessage msg = (ShortMessage)obj;
                    SmsPdu       pdu = comm.DecodeReceivedMessage(msg);
                    logger("New message received:");
                    ShowMessage(pdu);

                    return;
                }
                logger("Error: Unknown notification object!");
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GsmComm.GsmCommunication.ShortMessageFromPhone" />class.
 /// </summary>
 /// <param name="index">The index where the message is saved in the device in the <see cref="F:GsmComm.GsmCommunication.DecodedShortMessage.storage" />.</param>
 /// <param name="data">The decoded message.</param>
 /// <param name="status">The parsed message status.</param>
 /// <param name="storage">The phone storage the message was read from.</param>
 public DecodedShortMessage(int index, SmsPdu data, PhoneMessageStatus status, string storage)
 {
     this.index   = index;
     this.data    = data;
     this.status  = status;
     this.storage = storage;
 }
示例#6
0
        private void ReceiveMessage(SmsPdu pdu)
        {
            try
            {
                if (pdu is SmsDeliverPdu)
                {
                    // Received message
                    SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                    varmessage = data.UserDataText;
                    string[] message = varmessage.Split(' ');
                    if (message.Length == 3)
                    {
                        for (int i = 0; i < message.Length; i++)
                        {
                            string[] tmp_msg = message[i].Split('/');

                            if (tmp_msg[0].ToUpper() == "RM")
                            {
                                OutputMeerVotes(tmp_msg[1]);
                            }
                            else if (tmp_msg[0].ToUpper() == "ES")
                            {
                                OutputSanchezVotes(tmp_msg[1]);
                            }
                            else if (tmp_msg[0].ToUpper() == "AM")
                            {
                                OutputMarasiganVotes(tmp_msg[1]);
                            }
                        }
                        OutputCPnumber(data.OriginatingAddress);
                        return;
                    }
                    else if (message.Length == 1)
                    {
                        if (message[0].ToUpper() == "VERIFY")
                        {
                            OutputMeerVotes("VERIFY");
                            OutputSanchezVotes("VERIFY");
                            OutputMarasiganVotes("VERIFY");
                            OutputCPnumber(data.OriginatingAddress);
                            return;
                        }
                    }
                    else
                    {
                        OutputMeerVotes("0");
                        OutputSanchezVotes("0");
                        OutputMarasiganVotes("0");
                        OutputCPnumber(data.OriginatingAddress);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#7
0
        private void Read_message()
        {
            //pb.IsIndeterminate = true;
            string storage = GetMessageStorage();

            //txtmessage.Text = "";
            try
            {
                // Read all SMS messages from the storage
                DecodedShortMessage[] messages = comm.ReadMessages(PhoneMessageStatus.All, "SM");

                foreach (DecodedShortMessage msg in messages)
                {
                    SmsPdu pdu = msg.Data;
                    Database.DBMessages.DBInbox obj1 = new Database.DBMessages.DBInbox();
                    // Database.DBMessages.DBInboxLog obj2 = new Database.DBMessages.DBInboxLog();
                    if (pdu is SmsDeliverPdu)
                    {
                        // Received message
                        SmsDeliverPdu data = (SmsDeliverPdu)pdu;

                        String SenderNo  = data.OriginatingAddress.ToString();
                        String SenderNo2 = SenderNo;
                        SenderNo = SenderNo.Replace("+63", "0");
                        string sdate = "20" + data.SCTimestamp.Year + "-" + data.SCTimestamp.Month + "-" + data.SCTimestamp.Day + " " + data.SCTimestamp.Hour + ":" + data.SCTimestamp.Minute + ":" + data.SCTimestamp.Second;


                        Class.Message m = new Class.Message();

                        m.watchers(SenderNo, data.UserDataText.ToString());
                        //m.VoteParsed(data.UserDataText.ToString());

                        obj1.Add(DateTime.Parse(sdate), SenderNo, data.UserDataText.ToString());

                        //if (m.MessageParsing(data.UserDataText.ToString(), SenderNo) == true)
                        //{

                        //    obj2.Add(DateTime.Parse(sdate), SenderNo, data.UserDataText.ToString(), "Valid");
                        //}
                        //else
                        //{
                        //    obj1.Add(DateTime.Parse(sdate), SenderNo, data.UserDataText.ToString());
                        //}

                        cntmessageReceived++;
                        ReceiveUpdates();
                    }
                }
                // delete all messages
                DeleteAllMessages();
            }
            catch (Exception e)
            {
                e.ToString();
                ReceiveUpdatesError();
            }
            //pb.IsIndeterminate = false;
        }
示例#8
0
 private void ShowMessage(SmsPdu pdu)
 {
     if (pdu is SmsSubmitPdu)
     {
         // Stored (sent/unsent) message
         SmsSubmitPdu data = (SmsSubmitPdu)pdu;
         Output("SENT/UNSENT MESSAGE");
         Output("Recipient: " + data.DestinationAddress);
         Output("Message text: " + data.UserDataText);
         Output("-------------------------------------------------------------------");
         return;
     }
     if (pdu is SmsDeliverPdu)
     {
         // Received message
         SmsDeliverPdu data = (SmsDeliverPdu)pdu;
         Output("Mensaje Recibido");
         Output("Emisor: " + data.OriginatingAddress);
         Output("Hora de envio: " + data.SCTimestamp.ToString());
         Output("Texto del mensaje: " + data.UserDataText);
         Output("-------------------------------------------------------------------");
         try
         {
             var request  = (HttpWebRequest)WebRequest.Create(Constants.getServer() + "/api/v1/sms/create");
             var postData = MessageToJson(data.SCTimestamp.ToString(), data.OriginatingAddress, data.UserDataText, DateTime.Now.Ticks.ToString());
             var data2    = Encoding.UTF8.GetBytes(postData);
             request.Method        = "POST";
             request.ContentType   = "application/json";
             request.ContentLength = data2.Length;
             using (var stream = request.GetRequestStream())
             {
                 stream.Write(data2, 0, data2.Length);
             }
             var response       = (HttpWebResponse)request.GetResponse();
             var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
             response.Close();
         }
         catch (System.Net.WebException wx)
         {
             MessageBox.Show(wx.Message);
         }
         CommSetting.comm.DeleteMessages(DeleteScope.All, PhoneStorageType.Sim);
         return;
     }
     if (pdu is SmsStatusReportPdu)
     {
         // Status report
         SmsStatusReportPdu data = (SmsStatusReportPdu)pdu;
         Output("STATUS REPORT");
         Output("Recipient: " + data.RecipientAddress);
         Output("Status: " + data.Status.ToString());
         Output("Timestamp: " + data.DischargeTime.ToString());
         Output("Message ref: " + data.MessageReference.ToString());
         Output("-------------------------------------------------------------------");
         return;
     }
     Output("Unknown message type: " + pdu.GetType().ToString());
 }
示例#9
0
文件: GSM.cs 项目: Arnold-Caleb/GSM
        private Dictionary <string, string> MessageDetails(SmsPdu pdu)
        {
            Dictionary <string, string> messageDetails = new Dictionary <string, string>();

            if (pdu is SmsSubmitPdu)
            {
                // Stored (sent/unsent) message
                SmsSubmitPdu data = (SmsSubmitPdu)pdu;

                string recipient = data.DestinationAddress.ToString();
                string message   = data.UserDataText.ToString();

                messageDetails.Add("recipient", recipient);
                messageDetails.Add("message", message);

                return(messageDetails);
            }
            else if (pdu is SmsDeliverPdu)
            {
                // Received message
                SmsDeliverPdu data = (SmsDeliverPdu)pdu;

                string sender    = data.OriginatingAddress.ToString();
                string timeStamp = data.SCTimestamp.ToString();
                string message   = data.UserDataText.ToString();

                messageDetails.Add("sender", sender);
                messageDetails.Add("timeStamp", timeStamp);
                messageDetails.Add("message", message);

                return(messageDetails);
            }
            else if (pdu is SmsStatusReportPdu)
            {
                // Status report
                SmsStatusReportPdu data = (SmsStatusReportPdu)pdu;

                string recipient  = data.RecipientAddress;
                string status     = data.Status.ToString();
                string timeStamp  = data.DischargeTime.ToString();
                string messageRef = data.MessageReference.ToString();

                messageDetails.Add("recipient", recipient);
                messageDetails.Add("status", status);
                messageDetails.Add("timeStamp", timeStamp);
                messageDetails.Add("messageRef", messageRef);

                return(messageDetails);
            }

            else
            {
                return(messageDetails);
            }
            /* Error Message showing unknown message type */
            //Console.WriteLine("Unknown message type: " + pdu.GetType().ToString());
        }
示例#10
0
        private void ShowMessage(SmsPdu pdu, int MessageIndex)
        {// Received message
            SmsDeliverPdu data = (SmsDeliverPdu)pdu;

            string SenderNumber = data.OriginatingAddress;
            string MessageQuery = data.UserDataText;

            SetSomeText(SenderNumber, MessageQuery, MessageIndex);

            return;
        }
示例#11
0
        private void BindGrid(SmsPdu pdu)
        {
            DataRow       dr   = dt.NewRow();
            SmsDeliverPdu data = (SmsDeliverPdu)pdu;

            dr[0] = data.OriginatingAddress.ToString();
            dr[1] = data.SCTimestamp.ToString();
            dr[2] = data.UserDataText;
            dt.Rows.Add(dr);

            dataGrid1.DataSource = dt;
        }
示例#12
0
        private static bool HaveSameReferenceNumber(SmsPdu pdu1, SmsPdu pdu2)
        {
            bool flag = false;

            if (SmartMessageDecoder.IsPartOfConcatMessage(pdu1) && SmartMessageDecoder.IsPartOfConcatMessage(pdu2))
            {
                IConcatenationInfo concatenationInfo  = SmartMessageDecoder.GetConcatenationInfo(pdu1);
                IConcatenationInfo concatenationInfo1 = SmartMessageDecoder.GetConcatenationInfo(pdu2);
                if (concatenationInfo.ReferenceNumber == concatenationInfo1.ReferenceNumber)
                {
                    flag = true;
                }
            }
            return(flag);
        }
示例#13
0
        private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            IMessageIndicationObject obj = e.IndicationObject;
            MemoryLocation           loc = (MemoryLocation)obj;

            DecodedShortMessage[] messages;
            messages = comm.ReadMessages(PhoneMessageStatus.ReceivedUnread, loc.Storage);

            foreach (DecodedShortMessage message in messages)
            {
                SmsDeliverPdu data = new SmsDeliverPdu();

                SmsPdu smsrec = message.Data;
                ShowMessage(smsrec, message.Index);
            }
        }
示例#14
0
        private void Read_message()
        {
            //pb.IsIndeterminate = true;
            string storage = GetMessageStorage();

            //txtmessage.Text = "";
            try
            {
                // Read all SMS messages from the storage
                DecodedShortMessage[] messages = comm.ReadMessages(PhoneMessageStatus.All, "SM");

                if (messages.Length == 0)
                {
                    messages = comm.ReadMessages(PhoneMessageStatus.All, "ME");
                }

                foreach (DecodedShortMessage msg in messages)
                {
                    SmsPdu pdu = msg.Data;

                    if (pdu is SmsDeliverPdu)
                    {
                        // Received message
                        SmsDeliverPdu data = (SmsDeliverPdu)pdu;

                        String SenderNo = data.OriginatingAddress.ToString();
                        SenderNo = SenderNo.Replace("+63", "0");
                        string sdate = "20" + data.SCTimestamp.Year + "-" + data.SCTimestamp.Month + "-" + data.SCTimestamp.Day + " " + data.SCTimestamp.Hour + ":" + data.SCTimestamp.Minute + ":" + data.SCTimestamp.Second;

                        //add to database
                        //Database.DBMessages.DBInbox obj = new Database.DBMessages.DBInbox();
                        //obj.Add(DateTime.Parse(sdate), SenderNo, data.UserDataText.ToString());

                        cntmessageReceived++;
                        ReceiveUpdates();
                    }
                }
                // delete all messages
                DeleteAllMessages();
            }
            catch (Exception ex)
            {
                ex.ToString();
                ReceiveUpdatesError();
            }
            //pb.IsIndeterminate = false;
        }
示例#15
0
        private void ExtractSMSText(SmsPdu pdu)
        {
            if (pdu is SmsSubmitPdu)
            {
                // Stored (sent/unsent) message
                SmsSubmitPdu data = (SmsSubmitPdu)pdu;
                Debug.WriteLine("SENT/UNSENT MESSAGE");
                Debug.WriteLine("Recipient: " + data.DestinationAddress);
                Debug.WriteLine("Message text: " + data.UserDataText);
                Debug.WriteLine("-------------------------------------------------------------------");
                return;
            }
            if (pdu is SmsDeliverPdu)
            {
                // Received message
                SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                Debug.WriteLine("RECEIVED MESSAGE");
                Debug.WriteLine("Sender: " + data.OriginatingAddress);
                Debug.WriteLine("Sent: " + data.SCTimestamp.ToString());
                Debug.WriteLine("Message text: " + data.UserDataText);

                var checkNInfo = Newtonsoft.Json.JsonConvert
                                 .DeserializeObject <CheckInInfo>(data.UserDataText);

                Messenger.Default.Send(new Messages.NewCheckInMessage
                {
                    CheckInInfo = checkNInfo
                });

                Debug.WriteLine("-------------------------------------------------------------------");
                return;
            }
            if (pdu is SmsStatusReportPdu)
            {
                // Status report
                SmsStatusReportPdu data = (SmsStatusReportPdu)pdu;
                Debug.WriteLine("STATUS REPORT");
                Debug.WriteLine("Recipient: " + data.RecipientAddress);
                Debug.WriteLine("Status: " + data.Status.ToString());
                Debug.WriteLine("Timestamp: " + data.DischargeTime.ToString());
                Debug.WriteLine("Message ref: " + data.MessageReference.ToString());
                Debug.WriteLine("-------------------------------------------------------------------");
                return;
            }
            Debug.WriteLine("Unknown message type: " + pdu.GetType().ToString());
        }
示例#16
0
 private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     try
     {
         IMessageIndicationObject obj = e.IndicationObject;
         if (obj is ShortMessage)
         {
             ShortMessage msg = (ShortMessage)obj;
             SmsPdu       pdu = comm.DecodeReceivedMessage(msg);
             ReceiveMessage(pdu);
             return;
         }
         MessageBox.Show("Error: Unknown notification object!");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#17
0
        private void SaveMessage(SmsPdu smsPdu)
        {
            string        pesan = string.Empty;
            SmsDeliverPdu data  = (SmsDeliverPdu)smsPdu;

            try
            {
                _tMsgRepository.DbContext.BeginTransaction();

                // Received message
                TMsg msg = new TMsg();
                msg.SetAssignedIdTo(Guid.NewGuid().ToString());
                msg.MsgDate = data.SCTimestamp.ToDateTime();
                msg.MsgFrom = data.OriginatingAddress;
                msg.MsgTo   = "";
                msg.MsgText = data.UserDataText;

                // save both stores, this saves everything else via cascading
                _tMsgRepository.Save(msg);

                //split string
                SaveTransHelper hlp = new SaveTransHelper(_tSalesRepository, _tSalesDetRepository, _mGameRepository, _mAgentRepository, _tMsgRepository);
                hlp.SaveToTrans(data.UserDataText);
                _tMsgRepository.DbContext.CommitTransaction();
                pesan = "\nBerhasil.";
            }
            catch (Exception ex)
            {
                _tMsgRepository.DbContext.RollbackTransaction();
                pesan = "\nGagal.\n" + ex.GetBaseException().Message;
                //throw ex;
            }
            if (data.UserDataText.Length >= 150)
            {
                SendMessage(data.OriginatingAddress, data.UserDataText.Substring(0, 150) + pesan);
            }
            else
            {
                SendMessage(data.OriginatingAddress, data.UserDataText + pesan);
            }

            //make delay to send sms
        }
示例#18
0
        private void ShowMessage(SmsPdu pdu)
        {
            if (pdu is SmsSubmitPdu)
            {
                // Stored (sent/unsent) message
                SmsSubmitPdu data = (SmsSubmitPdu)pdu;
                Output("SENT/UNSENT MESSAGE");
                Output("Recipient: " + data.DestinationAddress);
                Output("Message text: " + data.UserDataText);
                Output("-------------------------------------------------------------------");
                return;
            }
            if (pdu is SmsDeliverPdu)
            {
                // Received message
                SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                Output("RECEIVED MESSAGE");
                Output("Sender: " + data.OriginatingAddress);
                Output("Sent: " + data.SCTimestamp.ToString());
                Output("Message text: " + data.UserDataText);
                Output("-------------------------------------------------------------------");

                BindGrid(pdu);

                return;
            }
            if (pdu is SmsStatusReportPdu)
            {
                // Status report
                SmsStatusReportPdu data = (SmsStatusReportPdu)pdu;
                Output("STATUS REPORT");
                Output("Recipient: " + data.RecipientAddress);
                Output("Status: " + data.Status.ToString());
                Output("Timestamp: " + data.DischargeTime.ToString());
                Output("Message ref: " + data.MessageReference.ToString());
                Output("-------------------------------------------------------------------");
                return;
            }
            Output("Unknown message type: " + pdu.GetType().ToString());
        }
示例#19
0
 /// <summary>
 /// Determines whether two messages are part of the same concatenated message.
 /// </summary>
 /// <param name="pdu1">The first message to compare.</param>
 /// <param name="pdu2">The second message to compare.</param>
 /// <returns>true if both messages appear to belong to the same concatenated message, false otherwise.</returns>
 /// <remarks>
 /// <para>This comparison is supported for <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> and <see cref="T:GSMCommunication.PDUDecoder.SmsDeliverPdu" /> objects.
 /// For all other objects, this comparison always returns false.</para>
 /// <para>For <see cref="T:GSMCommunication.PDUDecoder.SmsSubmitPdu" /> objects, the <see cref="P:GSMCommunication.PDUDecoder.SmsSubmitPdu.DestinationAddress" />,
 /// <see cref="P:GSMCommunication.PDUDecoder.SmsSubmitPdu.DestinationAddressType" /> and <see cref="P:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo.ReferenceNumber" /> properties are compared.</para>
 /// <para>For <see cref="T:GSMCommunication.PDUDecoder.SmsDeliverPdu" /> objects, the <see cref="P:GSMCommunication.PDUDecoder.SmsDeliverPdu.OriginatingAddress" />,
 /// <see cref="P:GSMCommunication.PDUDecoder.SmsDeliverPdu.OriginatingAddressType" /> and <see cref="P:GSMCommunication.PDUDecoder.SmartMessaging.IConcatenationInfo.ReferenceNumber" /> properties are compared.</para>
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException">pdu1 or pdu2 is null.</exception>
 public static bool ArePartOfSameMessage(SmsPdu pdu1, SmsPdu pdu2)
 {
     if (pdu1 != null)
     {
         if (pdu2 != null)
         {
             bool flag = false;
             if (pdu1 as SmsDeliverPdu == null || pdu2 as SmsDeliverPdu == null)
             {
                 if (pdu1 is SmsSubmitPdu && pdu2 is SmsSubmitPdu)
                 {
                     SmsSubmitPdu smsSubmitPdu  = (SmsSubmitPdu)pdu1;
                     SmsSubmitPdu smsSubmitPdu1 = (SmsSubmitPdu)pdu2;
                     if (smsSubmitPdu.DestinationAddress == smsSubmitPdu1.DestinationAddress && smsSubmitPdu.DestinationAddressType == smsSubmitPdu1.DestinationAddressType)
                     {
                         flag = SmartMessageDecoder.HaveSameReferenceNumber(pdu1, pdu2);
                     }
                 }
             }
             else
             {
                 SmsDeliverPdu smsDeliverPdu  = (SmsDeliverPdu)pdu1;
                 SmsDeliverPdu smsDeliverPdu1 = (SmsDeliverPdu)pdu2;
                 if (smsDeliverPdu.OriginatingAddress == smsDeliverPdu1.OriginatingAddress && smsDeliverPdu.OriginatingAddressType == smsDeliverPdu1.OriginatingAddressType)
                 {
                     flag = SmartMessageDecoder.HaveSameReferenceNumber(pdu1, pdu2);
                 }
             }
             return(flag);
         }
         else
         {
             throw new ArgumentNullException("pdu2");
         }
     }
     else
     {
         throw new ArgumentNullException("pdu1");
     }
 }
示例#20
0
 private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     try
     {
         IMessageIndicationObject obj = e.IndicationObject;
         if (obj is GsmComm.GsmCommunication.ShortMessage)
         {
             GsmComm.GsmCommunication.ShortMessage msg = (GsmComm.GsmCommunication.ShortMessage)obj;
             SmsPdu pdu = comm.DecodeReceivedMessage(msg);
         }
         if (obj is MemoryLocation)
         {
             MemoryLocation loc = (MemoryLocation)obj;
             //statusBar1.Text = "New message received in storage "+loc.Storage + ", index " + loc.Index;
         }
         Read_message();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
示例#21
0
        private void GetAllMessagesByStorage(int storage)
        {
            try
            {
                if (Gsm.IsConnected() && Gsm.IsOpen())
                {
                    DecodedShortMessage[] messages = Gsm.ReadMessages(PhoneMessageStatus.All, GetMessageStorage((MessageLocation)storage));
                    Gsm.DeleteMessages(DeleteScope.All, GetMessageStorage((MessageLocation)storage));

                    foreach (DecodedShortMessage message in messages)
                    {
                        SmsPdu pdu = (SmsPdu)message.Data;

                        if (pdu is SmsDeliverPdu)
                        {
                            // Received message
                            SmsDeliverPdu data = (SmsDeliverPdu)pdu;

                            string   msg          = data.UserDataText;
                            DateTime receive_date = data.SCTimestamp.ToDateTime();
                            string   phone_num    = data.OriginatingAddress;

                            //insert statement here
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError("GetAllMessagesByStorage " + ex.Source + " " + ex.Message);

                if (Gsm.IsConnected() && Gsm.IsOpen())
                {
                    Gsm.Close();
                }
            }
        }
示例#22
0
文件: Delete.cs 项目: briverac/SMS
        private void ShowMessage(SmsPdu pdu, int index)
        {
            if (pdu is SmsSubmitPdu)
            {
                // Stored (sent/unsent) message
                SmsSubmitPdu data = (SmsSubmitPdu)pdu;
                return;
            }
            if (pdu is SmsDeliverPdu)
            {
                // Received message
                SmsDeliverPdu data = (SmsDeliverPdu)pdu;

                BindGrid(pdu, index);

                return;
            }
            if (pdu is SmsStatusReportPdu)
            {
                // Status report
                SmsStatusReportPdu data = (SmsStatusReportPdu)pdu;
                return;
            }
        }
示例#23
0
        private void BindGrid(SmsPdu pdu, int index)
        {
            //DataRow dr = dt.NewRow();
            SmsDeliverPdu data = (SmsDeliverPdu)pdu;

            //dr[0] = index.ToString();
            //dr[1] = data.OriginatingAddress.ToString();
            //dr[2] = DateTime.Parse(data.SCTimestamp.ToString()).ToShortDateString();
            //dr[3] = DateTime.Parse(data.SCTimestamp.ToString()).ToLongTimeString();
            //dr[4] = data.UserDataText;
            //dt.Rows.Add(dr);
            //dgvMessage.DataSource = dt;

            oDataSet = (DataSet)m_oCSQLCommandExecutor.DataAdapterQueryRequest("Select * From ReceivedMessage Where MmrMobileNo = '" + data.OriginatingAddress.ToString() + "' And MmrDate = '" + DateTime.Parse(data.SCTimestamp.ToString()).ToShortDateString() + "' And MmrTime = '" + DateTime.Parse(data.SCTimestamp.ToString()).ToLongTimeString() + "'", oCommon.DBCon).Data;
            if (oDataSet.Tables[0].Rows.Count == 0)
            {
                SqlCommand oSqlCommand = new SqlCommand("insert into ReceivedMessage (MmrMobileNo,MmrDate,MmrTime,MmrMessage,MmrUser,MmrRemarks) values('" + data.OriginatingAddress.ToString() + "','" + DateTime.Parse(data.SCTimestamp.ToString()).ToShortDateString() + "','" + DateTime.Parse(data.SCTimestamp.ToString()).ToLongTimeString() + "','" + data.UserDataText + "','" + oCommon.UserName + "','')", oCommon.DBCon);
                try
                {
                    int i = oSqlCommand.ExecuteNonQuery();
                }
                catch (Exception ex) { }
            }
        }
        public List <object> IPORequest(SmsPdu pdu)
        {
            List <object> resultList = new List <object>();

            //===================================================
            try
            {
                if (pdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu dpdu               = (SmsDeliverPdu)pdu;
                    String        Text               = dpdu.UserDataText.ToLower();
                    string        SMSCode            = string.Empty;
                    string        output_PaymentType = string.Empty;
                    string        output_RefundType  = string.Empty;
                    string        output_CompanyCode = string.Empty;
                    string        ErrorMsg           = string.Empty;
                    string[]      output_CustCode    = null;
                    string        output_Message     = dpdu.UserDataText;
                    string        output_PnoneNumber = dpdu.OriginatingAddress;


                    if (dpdu.OriginatingAddress.Length > 11 || dpdu.OriginatingAddress.Length == 11)
                    {
                        dpdu.OriginatingAddress = dpdu.OriginatingAddress.Replace("+880", "0");
                    }

                    var RegCode = (objData.GetCustCodeMultipleFromPhoneNo(dpdu.OriginatingAddress));

                    string Output_RegCustCode = string.Join(",", RegCode.ToArray());
                    if (Output_RegCustCode != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPORegCust_Code + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-";
                    }

                    char[]   delimiterChars = { ' ', ',', '.', ':', '\t', '/', '_', ';', '.', };
                    string[] Word           = Text.Split(delimiterChars);

                    List <string> listCustCodeforMessage = new List <string>();
                    string[]      Input_CustCode         = null;
                    var           listtmp = new List <string>(Regex.Split(Text, @"\D+"));
                    Input_CustCode = listtmp.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray();

                    string[] RegCodeforarray = Output_RegCustCode.Split(',');

                    #region NewWork

                    var listRegCustCode          = string.Join(",", RegCodeforarray);
                    var listMessageplaceCustCode = string.Join(",", Input_CustCode);
                    if (listRegCustCode.Contains(listMessageplaceCustCode))
                    {
                        output_CustCode = Input_CustCode;
                        SMSCode         = SMSCode + SMSCommadCode.IPOCustomerFound + "-";
                    }
                    else if (listRegCustCode.Length == listMessageplaceCustCode.Length)
                    {
                        List <string> ValidationRegCode = new List <string>();
                        foreach (string value in Input_CustCode)
                        {
                            if (!RegCodeforarray.Contains(value))
                            {
                                ValidationRegCode.Add((value).ToString());
                            }
                        }
                        if (ValidationRegCode.Count == 0)
                        {
                            output_CustCode = Input_CustCode;
                            SMSCode         = SMSCode + SMSCommadCode.IPOCustomerFound + "-";
                        }
                    }
                    else
                    {
                        string[] RegCodeforParentAndChildCode = null;
                        //---------- Parent Child ------------------------

                        List <KeyValuePair <string, string[]> > objectsGot = new List <KeyValuePair <string, string[]> >();
                        foreach (string Rreg in RegCodeforarray)
                        {
                            var PRegcode = (objData.GetParentChildCheckFormCustCode(Rreg.ToString()));
                            RegCodeforParentAndChildCode = PRegcode.ToArray();
                            objectsGot.Add(new KeyValuePair <string, string[]>(Rreg.ToString(), (string[])RegCodeforParentAndChildCode));
                        }

                        string Code = string.Empty;
                        if (RegCodeforParentAndChildCode.Length != 0)
                        {
                            foreach (var tmp in objectsGot)
                            {
                                DataSqlQuery objdataSqlQuery = new DataSqlQuery();
                                string       ErrorMsg_Tmp    = MessageGenerate.IPORegErrorMessage(tmp.Key);
                                int          l            = 1;
                                int          invalidFound = 0;
                                foreach (string value in Input_CustCode)
                                {
                                    if (!tmp.Value.Contains(value) && l < Input_CustCode.Length)
                                    {
                                        ErrorMsg_Tmp = ErrorMsg_Tmp + value + ",";
                                        invalidFound++;
                                    }
                                    else if (!tmp.Value.Contains(value))
                                    {
                                        ErrorMsg_Tmp = ErrorMsg_Tmp + value;
                                        invalidFound++;
                                    }
                                    l++;
                                }
                                if (invalidFound == 0)
                                {
                                    output_CustCode    = Input_CustCode;
                                    SMSCode            = SMSCode + SMSCommadCode.IPOCustomerFound + "-";
                                    Output_RegCustCode = tmp.Key;
                                    break;
                                }
                                else
                                {
                                    string SMSCodelastPart = "SMS07";
                                    string sMessage        = objdataSqlQuery.GetNotRegisterMessage(SMSCodelastPart);
                                    ErrorMsg = ErrorMsg_Tmp + sMessage;
                                }
                            }
                        }
                        else
                        {
                            output_CustCode = Input_CustCode;
                            SMSCode         = SMSCode + SMSCommadCode.DefaultCode + "-";
                        }
                    }
                    resultList.Add(Output_RegCustCode);

                    if (ErrorMsg != "")
                    {
                        output_CustCode = Input_CustCode;
                        SMSCode         = SMSCode + SMSCommadCode.DefaultCode + "-";
                    }

                    //---------- End Parent Child -------------------

                    #endregion
                    //- ---------- IPO Company Select ------------------
                    string Comapnt_ShortCode   = "";
                    string IpoCompanyShortCode = string.Empty;
                    Comapnt_ShortCode = Word[0].ToLower();
                    if (Comapnt_ShortCode != "")
                    {
                        IpoCompanyShortCode = GetCompany_Short_Code_FromReg(Comapnt_ShortCode);
                    }
                    if (IpoCompanyShortCode != "")
                    {
                        output_CompanyCode = Comapnt_ShortCode;
                        resultList.Add(output_CompanyCode);
                        SMSCode = SMSCode + SMSCommadCode.IPOCompanyFound + "-";
                    }
                    else if (IpoCompanyShortCode == "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-";
                    }
                    //--------------------  End Company Select -----------------

                    if (ErrorMsg == "")
                    {
                        resultList.Add(Input_CustCode);
                    }
                    else
                    {
                        resultList.Add(Input_CustCode);
                    }

                    string   IPO_PaymentType = "pIPO,ptrade,pmIPO,PmTrade";
                    string[] IPO_paymenttype = IPO_PaymentType.Split(',');
                    foreach (string PType in IPO_paymenttype)
                    {
                        if (Word.Contains(PType.ToLower()))
                        {
                            output_PaymentType = PType.ToLower();
                        }
                    }
                    resultList.Add(output_PaymentType);
                    if (output_PaymentType != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPOPaymentType + "-";
                    }
                    else if (output_PaymentType == "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-";
                    }
                    string   IPO_RefundType = "rIPO,rtrade,rEFT,rmIPO,rmTrade";
                    string[] IPO_refundtype = IPO_RefundType.Split(',');
                    foreach (string RType in IPO_refundtype)
                    {
                        if (Word.Contains(RType.ToLower()))
                        {
                            output_RefundType = RType.ToLower();
                        }
                    }
                    resultList.Add(output_RefundType);
                    if (output_RefundType != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPORefundType;
                    }
                    else if (output_RefundType == "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPODefault_Code;
                    }
                    string ReceiveID = objData.ReceiveID();

                    resultList.Add(output_Message);
                    resultList.Add(output_PnoneNumber);
                    resultList.Add(ReceiveID);
                    resultList.Add(ErrorMsg);
                    resultList.Add(SMSCode);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            //========================
            return(resultList);
        }
        public List <object> IPOInformation(SmsPdu SmsPdu)
        {
            List <object> resultIpoInformation = new List <object>();

            try
            {
                if (SmsPdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu Ipdu               = (SmsDeliverPdu)SmsPdu;
                    String        Text               = Ipdu.UserDataText.ToUpper();
                    char[]        delimiterChars     = { ' ', ',', '.', ':', '\t', '/', ';', '.', };
                    string[]      Word               = Text.Split(delimiterChars);
                    string        PhoneNumber        = Ipdu.OriginatingAddress;
                    long          Output_RegCustCode = 0;
                    string        Output_Message     = string.Empty;
                    string        SMSCode            = string.Empty;
                    Output_RegCustCode = Convert.ToInt32(objData.GetCustCodeFromPhoneNo(Ipdu.OriginatingAddress));
                    //var RegCode = (objData.GetCustCodeMultipleFromPhoneNo(Ipdu.OriginatingAddress));
                    //Output_RegCustCode = string.Join(",", RegCode.ToArray());
                    string IPOInformation = "IPO";
                    if (Output_RegCustCode != 0)
                    {
                        SMSCode = SMSCommadCode.IPOInfoRegCustCOde + "-";
                    }
                    else
                    {
                        SMSCode = SMSCommadCode.IPODefault_Code + "-";
                    }


                    if (Word.Length == 1 || Word.Length <= 1)
                    {
                        if (Word.Contains(IPOInformation))
                        {
                            Output_Message = IPOInformation;
                        }
                    }
                    if (Output_Message != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPOInfoCode;
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.IPODefault_Code;
                    }
                    DateTime ReceiveTime = System.DateTime.Now;
                    string   ReceiveID   = objData.ReceiveID();
                    string   IPOType     = objData.IPOSMSType("3");



                    resultIpoInformation.Add(Output_RegCustCode);
                    resultIpoInformation.Add(Output_Message);
                    resultIpoInformation.Add(PhoneNumber);
                    resultIpoInformation.Add(ReceiveTime);
                    resultIpoInformation.Add(ReceiveID);
                    resultIpoInformation.Add(IPOType);
                    resultIpoInformation.Add(SMSCode);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(resultIpoInformation);
        }
        public List <object> SMSforSummery(SmsPdu pdu)
        {
            List <object> ResultListShareSummert = new List <object>();

            try
            {
                if (pdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu Apdu = (SmsDeliverPdu)pdu;
                    String        text = Apdu.UserDataText.ToUpper();
                    string        Output_PhoneNumber = Apdu.OriginatingAddress;
                    string        Output_message     = Apdu.UserDataText.ToUpper();
                    char[]        delimiterChars     = { ' ', ',', '.', ':', '\t', '/', ';', '.', };
                    string[]      message            = Output_message.Split(delimiterChars);
                    string        SMSCode            = string.Empty;

                    long   Output_RegCustCode = 0;
                    string Output_ShortCode   = string.Empty;
                    Output_RegCustCode = Convert.ToInt32(objData.GetCustCodeFromPhoneNo(Apdu.OriginatingAddress));

                    if (Output_RegCustCode != 0)
                    {
                        SMSCode = SMSCommadCode.SM_RegCustCode + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.SM_DefaultCode + "-";
                    }

                    if (message.Length == 1)
                    {
                        string   defaultMessage = "SS,AS,LPR,CB";
                        string[] InputMessage   = defaultMessage.Split(',');
                        foreach (string ShortCode in InputMessage)
                        {
                            if (Output_message.Contains(ShortCode.ToUpper()))
                            {
                                Output_ShortCode = ShortCode.ToUpper();
                            }
                        }
                    }
                    if (Output_ShortCode != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.SM_ShortCode;
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.SM_DefaultCode;
                    }


                    DateTime ReceiveTime = Convert.ToDateTime(System.DateTime.Now);
                    ResultListShareSummert.Add(Output_RegCustCode);
                    ResultListShareSummert.Add(Output_PhoneNumber);
                    ResultListShareSummert.Add(Output_ShortCode);
                    ResultListShareSummert.Add(Output_message);
                    ResultListShareSummert.Add(ReceiveTime);
                    ResultListShareSummert.Add(SMSCode);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(ResultListShareSummert);
        }
        public List <object> Deposite_Withdraw(SmsPdu SmsPdu)
        {
            List <object> Result_Deposite_Withdraw = new List <object>();

            try
            {
                if (SmsPdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu Dpdu              = (SmsDeliverPdu)SmsPdu;
                    string        Text              = Dpdu.UserDataText.ToUpper();
                    char[]        delimiterChars    = { ' ', ',', '.', ':', '\t', '/', '_', ';', '.', };
                    string[]      Word              = Text.Split(delimiterChars);
                    string        RegCustCode       = string.Empty;
                    string        Deposite_Withdraw = string.Empty;
                    string        Trade_IPO         = string.Empty;
                    string        Amount            = string.Empty;
                    string        ErrorMsg          = string.Empty;
                    string[]      output_CustCode   = null;
                    string        SMSCode           = String.Empty;
                    string        Search_ReceiveID  = string.Empty;
                    string[]      Cust_Code         = null;
                    string        PhoneNumber       = string.Empty;

                    if (Dpdu.OriginatingAddress.Length > 11 || Dpdu.OriginatingAddress.Length == 11)
                    {
                        PhoneNumber = Dpdu.OriginatingAddress.Replace("+880", "0");
                    }

                    var RegCode = (objData.GetCustCodeMultipleFromPhoneNo(Dpdu.OriginatingAddress));
                    RegCustCode = string.Join(",", RegCode.ToArray());
                    if (RegCustCode != "")
                    {
                        SMSCode = SMSCommadCode.Deposite_Withdraw_RegCustCode + "-";
                    }
                    else
                    {
                        SMSCode = SMSCommadCode.Deposite_Withdraw_Default + "-";
                    }


                    //-------------- Deposite/Withdraw Check---------
                    string   DefaultText      = "D,W,Deposite,Withdraw";
                    string[] DefaulttextArray = DefaultText.ToUpper().Split(',');

                    foreach (string Value in DefaulttextArray)
                    {
                        if (Word.Contains(Value.ToUpper()))
                        {
                            if (Value == "D" || Value == "DEPOSITE")
                            {
                                Deposite_Withdraw = "Deposite";
                                break;
                            }
                            else if (Value == "W" || Value == "WITHDRAW")
                            {
                                Deposite_Withdraw = "Withdraw";
                                break;
                            }
                        }
                    }

                    if (Deposite_Withdraw != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Found + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Default + "-";
                    }
                    //--------------- End Deposite/Withdraw Check ------------


                    //--------------- Check Trade / IPO ----------------------
                    string   message = "Trade,Ipo,I,P";
                    string[] Message = message.ToUpper().Split(',');
                    foreach (string Value in Message)
                    {
                        if (Word.Contains(Value.ToUpper()))
                        {
                            if (Value == "TRADE" || Value == "T")
                            {
                                Trade_IPO = "Trade";
                                break;
                            }
                            else if (Value == "IPO" || Value == "I")
                            {
                                Trade_IPO = "IPO";
                                break;
                            }
                        }
                    }
                    if (Trade_IPO != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Trade_Ipo + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Default + "-";
                    }
                    //---------------END Trade / IPO ----------

                    //----------------  Search Amount ------

                    List <string> listAmount = new List <string>();
                    listAmount = Word.ToList();

                    foreach (string value in Word)
                    {
                        if (value == "TRADE" || value == "T")
                        {
                            break;
                        }
                        else if (value == "IPO" || value == "I")
                        {
                            break;
                        }
                        else
                        {
                            listAmount.Remove(value);
                        }
                    }

                    string[] TAmount       = listAmount.ToArray();
                    string   textAmount    = string.Join(",", TAmount);
                    string[] Input_Amount  = null;
                    var      listtmpAmount = new List <string>(Regex.Split(textAmount, @"\D+"));
                    Input_Amount = listtmpAmount.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray();
                    Amount       = string.Join(",", Input_Amount);
                    if (Amount != "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Amount + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.Deposite_Withdraw_Default + "-";
                    }

                    //---------------- End Search Amount ----



                    //--------- Check Cust_Code --------------

                    List <string> listCust_Code = new List <string>();

                    foreach (string value in Word)
                    {
                        if (value == "TRADE" || value == "T")
                        {
                            break;
                        }
                        else if (value == "IPO" || value == "I")
                        {
                            break;
                        }
                        else
                        {
                            listCust_Code.Add(value);
                        }
                    }
                    string[] CustCode       = listCust_Code.ToArray();
                    string[] Input_CustCode = null;
                    string   textCustCode   = string.Join(",", CustCode);
                    var      listtmp        = new List <string>(Regex.Split(textCustCode, @"\D+"));
                    Input_CustCode = listtmp.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray();

                    string[] ARegCode          = RegCode.ToArray();
                    var      listRegCode       = string.Join(",", ARegCode);
                    var      listPlaceCustCode = string.Join(",", Input_CustCode);
                    if (listPlaceCustCode == listRegCode)
                    {
                        output_CustCode = Input_CustCode;
                        SMSCode         = SMSCode + SMSCommadCode.Deposite_Withdraw_CustCode;
                    }
                    else
                    {
                        string[] RegCodeforParentAndChildCode = null;
                        //---------- Parent Child ------------------------
                        string[] Reg_CustCode = RegCode.ToArray();
                        List <KeyValuePair <string, string[]> > objectsGot = new List <KeyValuePair <string, string[]> >();
                        foreach (string Rreg in Reg_CustCode)
                        {
                            var PRegcode = (objData.GetParentChildCheckFormCustCode(Rreg.ToString()));
                            RegCodeforParentAndChildCode = PRegcode.ToArray();
                            objectsGot.Add(new KeyValuePair <string, string[]>(Rreg.ToString(), (string[])RegCodeforParentAndChildCode));
                        }

                        if (Reg_CustCode.Length > 0)
                        {
                            string Code = string.Empty;
                            if (RegCodeforParentAndChildCode.Length != 0)
                            {
                                foreach (var tmp in objectsGot)
                                {
                                    DataSqlQuery objdataSqlQuery = new DataSqlQuery();



                                    string ErrorMsg_Tmp = MessageGenerate.IPORegErrorMessage(tmp.Key);
                                    int    l            = 1;
                                    int    invalidFound = 0;
                                    foreach (string value in Input_CustCode)
                                    {
                                        if (!tmp.Value.Contains(value) && l < Input_CustCode.Length)
                                        {
                                            ErrorMsg_Tmp = ErrorMsg_Tmp + value + ",";
                                            invalidFound++;
                                        }
                                        else if (!tmp.Value.Contains(value))
                                        {
                                            ErrorMsg_Tmp = ErrorMsg_Tmp + value;
                                            invalidFound++;
                                        }
                                        l++;
                                    }
                                    if (invalidFound == 0)
                                    {
                                        output_CustCode = Input_CustCode;
                                        SMSCode         = SMSCode + SMSCommadCode.Deposite_Withdraw_CustCode;
                                        RegCustCode     = tmp.Key;
                                        break;
                                    }
                                    else
                                    {
                                        string FirstSMSCode      = "SMS07";
                                        string sMessageFirstpart = objdataSqlQuery.GetNotRegisterMessage(FirstSMSCode);
                                        ErrorMsg = ErrorMsg_Tmp + sMessageFirstpart;
                                    }
                                }
                            }
                        }
                        else
                        {
                            output_CustCode = Input_CustCode;
                            SMSCode         = SMSCode + SMSCommadCode.Deposite_Withdraw_Default;
                        }
                    }

                    if (ErrorMsg != "")
                    {
                        output_CustCode = Input_CustCode;
                        SMSCode         = SMSCode + SMSCommadCode.Deposite_Withdraw_Default;
                    }
                    //--------- End Cust_ Code ----------------


                    //---------  Receive ID ------------------
                    string ReceiveID = string.Empty;
                    Search_ReceiveID = objData.ReceiveID();
                    string ReceiveMessage = objData.GetReceiveMessage(Search_ReceiveID);
                    string Phone_Message  = Dpdu.UserDataText;
                    if (Phone_Message.Contains(ReceiveMessage))
                    {
                        ReceiveID = Search_ReceiveID;
                    }
                    //------------  End receive ID ------------


                    Result_Deposite_Withdraw.Add(RegCustCode);
                    Result_Deposite_Withdraw.Add(Deposite_Withdraw);
                    Result_Deposite_Withdraw.Add(Trade_IPO);
                    Result_Deposite_Withdraw.Add(Amount);
                    Result_Deposite_Withdraw.Add(output_CustCode);
                    Result_Deposite_Withdraw.Add(PhoneNumber);
                    Result_Deposite_Withdraw.Add(ReceiveID);
                    Result_Deposite_Withdraw.Add(Phone_Message);
                    Result_Deposite_Withdraw.Add(ErrorMsg);
                    Result_Deposite_Withdraw.Add(SMSCode);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Result_Deposite_Withdraw);
        }
示例#28
0
        private void ShowMessage(SmsPdu pdu)
        {
            if (pdu is SmsSubmitPdu)
            {
                // Stored (sent/unsent) message
                SmsSubmitPdu data = (SmsSubmitPdu)pdu;
                OutputSent("SENT MESSAGE");
                OutputSent("Recipient: " + data.DestinationAddress);
                OutputSent("Message text: " + data.UserDataText);
                OutputSent("-------------------------------------------------------------------");
                return;
            }
            if (pdu is SmsDeliverPdu)
            {
                // Received message
                SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                UpdateLog("Received", "Reply", data.OriginatingAddress, data.UserDataText);
                OutputReceived("RECEIVED MESSAGE");
                OutputReceived("Sender: " + data.OriginatingAddress);
                OutputReceived("Area: " + GetArea(data.OriginatingAddress.ToString()));
                OutputReceived("Sent: " + data.SCTimestamp.ToString());
                OutputReceived("Message text: " + data.UserDataText);
                OutputReceived("-------------------------------------------------------------------");

                OutputCPnumber(data.OriginatingAddress);
                varmessage = data.UserDataText;
                string[] message = varmessage.Split('/');

                if (message[0].ToUpper() == "AREA")
                {
                    if (message.Length == 2)
                    {
                        OutputAreaMobileNumber(message[1]);
                        OutputCode(message[0]);

                        return;
                    }
                    else
                    {
                        SendMessage("Invalid Keywords", cpnumberTxtBox.Text, "Sorry, You Texted An Invalid Command.");
                    }
                }
                else if (message[0].ToUpper() == "TB")
                {
                    if (message.Length == 3)
                    {
                        OutputGroup(message[1]);
                        OutputMessage(message[2]);
                        OutputCode(message[0]);

                        return;
                    }
                    else
                    {
                        SendMessage("Invalid Keywords", cpnumberTxtBox.Text, "Sorry, You Texted An Invalid Command. Text HELP For More Information.");
                    }
                }
                else if (message[0].ToUpper() == "TBALL")
                {
                    if (message.Length == 2)
                    {
                        OutputMessage(message[1]);
                        OutputCode(message[0]);

                        return;
                    }
                    else
                    {
                        SendMessage("Invalid Keywords", cpnumberTxtBox.Text, "Sorry, You Texted An Invalid Command. Text HELP For More Information.");
                    }
                }
            }
            else
            {
                Output("Unknown message type: " + pdu.GetType().ToString());
            }
        }
        public List <object> BuyOrderRequest(SmsPdu pdu)
        {
            List <object> ResultList = new List <object>();

            try
            {
                if (pdu is SmsDeliverPdu)
                {
                    SmsDeliverPdu bpdu    = (SmsDeliverPdu)pdu;
                    string        Text    = bpdu.UserDataText.ToUpper();
                    string        SMSCode = string.Empty;
                    string        Output_CompanyShortCode = string.Empty;
                    long          Output_ShareQuantity    = 0;
                    string        Output_BuyorSellOrder   = string.Empty;
                    string        Output_MarketPrice      = string.Empty;
                    long          Output_RegCustCode      = 0;
                    string        OutPut_OrderRange       = string.Empty;
                    long          OutPut_OrderID          = 0;
                    string        Output_Message          = bpdu.UserDataText;
                    string        Output_PhoneNumber      = bpdu.OriginatingAddress;
                    char[]        delimiterChars          = { ' ', ',', '.', ':', '\t', '/', ';', '.', };
                    string[]      Word    = Text.Split(delimiterChars);
                    string[]      Message = Word.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray();


                    Output_RegCustCode = Convert.ToInt64(objData.GetCustCodeFromPhoneNo(bpdu.OriginatingAddress));
                    if (Output_RegCustCode != 0)
                    {
                        SMSCode = SMSCode + SMSCommadCode.RegCust_Code + "-";
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                    }


                    string CompanyShortCode = Message[0].ToUpper();
                    string ComShortCode     = objData.GetCompanyShortCodeFromCompanyShortCode(CompanyShortCode);
                    if (ComShortCode != "")
                    {
                        Output_CompanyShortCode = ComShortCode;
                        SMSCode = SMSCode + SMSCommadCode.CompanyShortCode + "-";
                    }
                    else if (ComShortCode == "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                    }



                    if (Message.Length > 2)
                    {
                        if (IsTextValidated(Message[1].ToString()) == true)
                        {
                            long Quentaty = Convert.ToInt64(Message[1]);
                            if (Quentaty != 0)
                            {
                                Output_ShareQuantity = Convert.ToInt64(Quentaty);
                                SMSCode = SMSCode + SMSCommadCode.ShareQuentity + "-";
                            }
                            else if (Quentaty == 0)
                            {
                                SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                            }
                        }
                    }
                    if (Output_ShareQuantity == 0)
                    {
                        SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                    }



                    string   BuyandSellOrder = "B,S";
                    string   Order           = "";
                    string[] BuyorSellOrder  = BuyandSellOrder.Split(',');

                    foreach (string OrderType in BuyorSellOrder)
                    {
                        if (Message.Contains(OrderType))
                        {
                            Order = OrderType;
                            if (Order == "B")
                            {
                                Output_BuyorSellOrder = "Buy";
                                SMSCode = SMSCode + SMSCommadCode.BuyOrder + "-";
                            }
                            else if (Order == "S")
                            {
                                Output_BuyorSellOrder = "Sell";
                                SMSCode = SMSCode + SMSCommadCode.BuyOrder + "-";
                            }
                            else
                            {
                                SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                            }
                        }
                    }
                    if (Output_BuyorSellOrder == "")
                    {
                        SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-";
                    }


                    string MarketPrise = "MP";
                    string PriceRange  = "";
                    if (Message.Length == 4)
                    {
                        PriceRange = Message[3].ToString();
                        if (Message.Length > 4)
                        {
                            string[] Input_PriceRange = null;
                            var      listtmp          = new List <string>(Regex.Split(Text, @"\D+"));
                            Input_PriceRange = listtmp.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray();
                            PriceRange       = Input_PriceRange[1].ToString() + "-" + Input_PriceRange[2].ToString();
                        }

                        if (Message.Contains(MarketPrise))
                        {
                            Output_MarketPrice = "Market Price";
                            SMSCode            = SMSCode + SMSCommadCode.MarketPrice;
                        }
                        else if (PriceRange != "")
                        {
                            Output_MarketPrice = PriceRange;
                            SMSCode            = SMSCode + SMSCommadCode.MarketPrice;
                        }
                        else
                        {
                            SMSCode = SMSCode + SMSCommadCode.DefaultCode;
                        }
                    }
                    else
                    {
                        SMSCode = SMSCode + SMSCommadCode.DefaultCode;
                    }



                    OutPut_OrderID = objData.GenerateOrderID("tbl_order_place", "Order_ID");


                    ResultList.Add(Output_RegCustCode);
                    ResultList.Add(Output_CompanyShortCode);
                    ResultList.Add(Output_ShareQuantity);
                    ResultList.Add(Output_BuyorSellOrder);
                    ResultList.Add(Output_MarketPrice);
                    ResultList.Add(Output_PhoneNumber);
                    ResultList.Add(OutPut_OrderID);
                    ResultList.Add(SMSCode);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(ResultList);
        }
示例#30
0
        private static void ModemPollingLoop()
        {
            //Find a port where the modem is at
            _logger.Info("Searching for a modem...");
            for (int i = 1; i <= 256; i++)
            {
                if (TestConnection($"COM{i}"))
                {
                    break;
                }
            }

            if (_comm.IsOpen() && _comm.IsConnected())
            {
                _logger.Info("Modem found");
                _logger.Info("Setting modem settings...");
                _comm.SelectCharacterSet("ucs2"); //Use UTF-16 encoding when getting data from modem

                //Hook debugging event if user wants to debug modem commands
                if (_config.GetValue("Debug/ModemCommands", false))
                {
                    _comm.LoglineAdded += comm_LoglineAdded;
                }

                try
                {
                    _comm.SetSmscAddress(_config.GetValue("General/SMSCenter", ""));
                }
                catch (Exception)
                {
                    _logger.Warn("Invalid SMS Center number or this feature is not supported by current modem");
                }

                _logger.Info("Listening for incoming messages...");
                while (_comm.IsOpen())
                {
                    if (_comm.IsConnected())
                    {
                        try
                        {
                            //Get all messages saved on SIM
                            DecodedShortMessage[] messages = _comm.ReadMessages(PhoneMessageStatus.All,
                                                                                PhoneStorageType.Sim);

                            foreach (DecodedShortMessage message in messages)
                            {
                                SmsPdu pdu = message.Data;
                                if (pdu is SmsDeliverPdu) // Check if it's SMS and not some kind of a service message
                                {
                                    SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                                    _logger.Debug($"Received message from {data.OriginatingAddress}: " +
                                                  data.UserDataText + $" [TIMESTAMP: {data.SCTimestamp.ToSortableString()}]");

                                    ChangePassword(data.OriginatingAddress, data.UserDataText);

                                    //Delete message so it won't be parsed again
                                    //and so we don't have a problem with free space on SIM
                                    //in the future
                                    _comm.DeleteMessage(message.Index, message.Storage);
                                }
                                else
                                {
                                    _logger.Warn($"Received unknown message type: {pdu.GetType()}");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.Warn($"Cannot read messages: {ex.Message} ({ex.GetType()})");
                            break;
                        }

                        //Sleep 5 seconds between message checks
                        Thread.Sleep(5000);
                    }
                    else
                    {
                        _logger.Error("Lost cellular network connection");
                        break;
                    }
                }
            }
            else
            {
                _logger.Fatal("No modem found");
            }

            //Close modem connection
            try
            {
                _comm.Close();
            }
            catch (Exception) { }
        }