Exemplo n.º 1
0
        private void NetworkOpen()
        {
            m_frmNetworkManager = new OVRNetworkManagerForm();
            //m_frmNetworkManager.Owner = this;
            m_frmNetworkManager.EventNetworkStatus += new OVRNetworkStatus(OnNetworkStatus);

            // We need show the form before it receive any event, else error will be occurred.
            int   xPos = (Screen.PrimaryScreen.WorkingArea.Size.Width - m_frmNetworkManager.Size.Width) / 2;
            int   yPos = (Screen.PrimaryScreen.WorkingArea.Size.Height - m_frmNetworkManager.Size.Height) / 2;
            Point pt   = new Point(xPos, yPos);

            m_frmNetworkManager.StartPosition = FormStartPosition.Manual;
            m_frmNetworkManager.Location      = new System.Drawing.Point(pt.X, pt.Y + Screen.PrimaryScreen.WorkingArea.Size.Height);
            m_frmNetworkManager.Show();
            m_frmNetworkManager.Hide();
            m_frmNetworkManager.Location = pt;

            m_frmNetworkManager.Initialize(m_bIsServer);
            if (m_bIsServer)
            {
                System.Net.IPAddress[] addr    = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList;
                System.Net.IPAddress   svrAddr = null;
                for (int i = 0; i < addr.Length; i++)
                {
                    string temp = addr[i].ToString();
                    if (addr[i].ToString() == m_strServer)
                    {
                        svrAddr = addr[i];
                        break;
                    }
                }

                if (svrAddr != null)
                {
                    m_frmNetworkManager.StartListen(svrAddr, m_iPort);
                }
                else
                {
                    m_EventGeneralData(this, new OVRFrame2ModuleEventArgs(OVRFrame2ModuleEventType.emNetworkStatus, "ERROR"));
                }
            }
            else
            {
                if (m_strServer != null && m_strServer.Length > 6 && m_iPort >= 0)
                {
                    m_frmNetworkManager.Connect(m_strServer, m_iPort);
                }
            }

            m_xmlPacker = new OVRXmlMessagePacker();
            m_xmlPacker.Initialize(SqlCon, m_strVenueCode);

            m_bIsNetworkOpen = true;
        }