using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase.Command;
using SuperSocket.SocketBase.Protocol;
using log4net;
using System.Reflection;
using TZONE.GPSSocketServer.Common;

namespace TZONE.GPSSocketServer.Command.ASAV
{
    public class DataHandle : CommandBase<GPSSession, BinaryRequestInfo>
    {
        public override string Name
        {
            get
            {
                return "40-53-41-56";//@SAV 0x40, 0x53, 0x41, 0x56 
            }
        }
        ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public override void ExecuteCommand(GPSSession session, BinaryRequestInfo requestInfo)
        {
            try
            {
                //3
                //@SAV,0503,123456789012345#
                //string msg = Encoding.Default.GetString(requestInfo.Body, 0, requestInfo.Body.Length).Trim('\0');
                //string[] s = msg.Split(',');
                if ("1" == System.Configuration.ConfigurationManager.AppSettings["isUPG"].ToString())
                    session.Send("@UPG,2,1#");
                else
                    session.Send("@UPG,1,0#");
                DownCommand.update_OrderExec_IsExec(session.IMEI, DownCommand.Exec_FW_OK);
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message);
            }
        }
    }
}
