Exemple #1
0
        public bool SubmitTextMessage(ulong messageId, uint textMessageId, String textMessage, uint[] replies, int ackEvent)
        {
            STrace.Debug(typeof(Parser).FullName, Id, "SubmitTextMessage: messageId=" + messageId.ToString() + ",textMessageId=" + textMessageId.ToString() + ",textMessage=" + textMessage + ",replies=" + (replies == null?"null":String.Join(",", replies.Select(b => b.ToString()).ToArray())));
            var md = GetMessagingDevice();

            switch (md)
            {
            case MessagingDevice.Garmin:
            {
                var cnf = new StringBuilder();
//			            cnf.Append(GarminFmi.EncodeDeleteTextmessage(textMessageId).ToTraxFM(this, false));
                if (replies != null && replies.Length > 0)
                {
                    cnf.Append(GarminFmi.EncodeCannedResponseList(textMessageId, replies).ToTraxFM(this, false));
                }
                else
                {
                    cnf.Append(GarminFmi.EncodeDeleteTextmessage(textMessageId).ToTraxFM(this, false));
                }

                cnf.Append(GarminFmi.EncodeOpenTextMessage(textMessageId, textMessage, true).ToTraxFM(this, false));

                if (ackEvent != -1)
                {
                    cnf.Append(Fota.VirtualMessageFactory((MessageIdentifier)ackEvent, NextSequence));
                }

                var cmd = cnf.ToString();
                SendMessages(cmd, messageId, md);
                break;
            }

            case MessagingDevice.Mpx01:
            {
                var cmd = EncodeMpx01Msg(textMessage, messageId, this);
                SendMessages(cmd, messageId, md);
                break;
            }

            case MessagingDevice.Sms:
            {
                var cmd = EncodeSmsMsg(textMessage, messageId, this);
                SendMessages(cmd, messageId, md);
                break;
            }
            }
            return(true);
        }
Exemple #2
0
        public bool SubmitCannedMessage(ulong messageId, int codeMessageId, int[] replies)
        {
            //var messageM = daoFactory.MensajeDAO.GetCannedMessagesTable(DeviceId, 0).Where(m => m.Codigo == codeMessageId.ToString()).SingleOrDefault();
            var messageM = DataProvider.GetCannedMessagesTable(Id, 0).SingleOrDefault(m => m.Codigo == codeMessageId.ToString(CultureInfo.InvariantCulture));

            if (messageM == null)
            {
                STrace.Error(typeof(Parser).FullName, Id, String.Format("Se intento enviar un mensaje predefinido no existente con codigo={0}", codeMessageId));
                return(false);
            }
            var message = messageM.Texto;

            var md = GetMessagingDevice();

            switch (md)
            {
            case MessagingDevice.Garmin:
            {
                //envio sin id por que si el id se repite el envio da error y no hay canned messages hacia garmin, solo hacia server, que el usuario se encargue de borrar los mensajes
                /*(UInt32)codeMessageId*/
                var cmd = GarminFmi.EncodeOpenTextMessage(0, message, true).ToTraxFM(this);
                SendMessages(new[] { cmd }, md);
                break;
            }

            case MessagingDevice.Mpx01:
            {
                var cmd = EncodeMpx01Msg(message, messageId, this);
                SendMessages(cmd, messageId, md);
                break;
            }

            case MessagingDevice.Sms:
            {
                var cmd = EncodeSmsMsg(message, messageId, this);
                SendMessages(cmd, messageId, md);
            }
            break;
            }
            return(true);
        }