Ejemplo n.º 1
0
        protected bool AllocateTKSNFromServer()
        {
            CommandMsgV2 cm = new CommandMsgV2();

            cm.TK_CommandType = Constants.TK_CommandType.ALLOCATE_TKSN;

            cm.SetValue(Constants.MSG_PARANAME_TKSN_NUM, 10000);

            try
            {
                CommandMsgV2 resp = m_CommClient.SendCommand(cm, 120) as CommandMsgV2;
                if (resp == null)
                {
                    return(false);
                }

                if (resp.GetValue(Constants.MSG_PARANAME_RESULT).ToString() != "OK")
                {
                    return(false);
                }

                lock (m_LockAllocation)
                {
                    m_TKSN_Begin = Convert.ToUInt64(resp.GetValue(Constants.MSG_PARANAME_TKSN_START));
                    m_TKSN_End   = Convert.ToUInt64(resp.GetValue(Constants.MSG_PARANAME_TKSN_END));
                }

                return(true);
            }
            catch (Exception ex)
            {
                SendLog(ex.ToString());
                return(false);
            }
        }
Ejemplo n.º 2
0
        protected bool AdapterLogin()
        {
            CommandMsgV2 cm = new CommandMsgV2();

            cm.TK_CommandType = Constants.TK_CommandType.ADAPTER_LOGIN;

            cm.SetValue(Constants.MSG_PARANAME_ADAPTER_NAME, Name);
            cm.SetValue(Constants.MSG_PARANAME_ADAPTER_ADDRESS, m_CommClient.LocalIP.ToString());
            cm.SetValue(Constants.MSG_PARANAME_ADAPTER_CONTROLLER_PORT, ControllerPort);

            try
            {
                CommandMsgV2 resp = m_CommClient.SendCommand(cm) as CommandMsgV2;
                if (resp == null)
                {
                    return(false);
                }

                if (resp.Contains(Constants.MSG_PARANAME_RESULT))
                {
                    switch (resp.GetValue(Constants.MSG_PARANAME_RESULT).ToString())
                    {
                    case "OK":
                        return(true);

                    default:
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                SendLog(ex.ToString());
                return(false);
            }
        }
Ejemplo n.º 3
0
        protected bool AdapterLogout()
        {
            CommandMsgV2 cm = new CommandMsgV2();

            cm.TK_CommandType = Constants.TK_CommandType.ADAPTER_LOGOUT;

            try
            {
                CommandMsgV2 resp = m_CommClient.SendCommand(cm) as CommandMsgV2;
                if (resp == null)
                {
                    return(false);
                }

                if (resp.Contains(Constants.MSG_PARANAME_RESULT))
                {
                    switch (resp.GetValue(Constants.MSG_PARANAME_RESULT).ToString())
                    {
                    case "OK":
                        return(true);

                    default:
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                SendLog(ex.ToString());
                return(false);
            }
        }