Exemple #1
0
        public Updater(string serverIP, int serverPort)
        {
            this.UpdateStarted    += new CbGeneric(Updater_UpdateStarted);
            this.UpdateDisruptted += new CbGeneric <string>(Updater_UpdateDisruptted);
            this.UpdateCompleted  += new CbGeneric(Updater_UpdateCompleted);

            DirectoryInfo dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

            this.appDirPath = dir.FullName + "\\";

            this.rapidPassiveEngine = RapidEngineFactory.CreatePassiveEngine();
            this.rapidPassiveEngine.AutoReconnect = true;
            Random random = new Random();
            //初始化引擎并登录,返回登录结果
            bool canLogon = false;

            for (int i = 0; i < 100; i++)
            {
                string        userid        = random.Next(1000000).ToString("00000");
                LogonResponse logonResponse = rapidPassiveEngine.Initialize(userid, "", serverIP, serverPort, null);
                if (logonResponse.LogonResult == LogonResult.Succeed)
                {
                    canLogon = true;
                    break;
                }
            }
            if (!canLogon)
            {
                throw new Exception("连接自动更新服务器失败 !");
            }

            this.rapidPassiveEngine.ConnectionInterrupted += new CbGeneric(rapidPassiveEngine_ConnectionInterrupted);
            this.rapidPassiveEngine.RelogonCompleted      += new CbGeneric <LogonResponse>(rapidPassiveEngine_RelogonCompleted);
        }
Exemple #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Updater()
        {
            mRapidPassiveEngine = RapidEngineFactory.CreatePassiveEngine();
            mRapidPassiveEngine.AutoReconnect          = true;
            mRapidPassiveEngine.ConnectionInterrupted += new CbGeneric(RapidPassiveEngine_ConnectionInterrupted);
            mRapidPassiveEngine.RelogonCompleted      += new CbGeneric <LogonResponse>(RapidPassiveEngine_RelogonCompleted);

            Event_UpdateStarted    += new CbGeneric(Updater_UpdateStarted);
            Event_UpdateDisruptted += new CbGeneric <string>(Updater_UpdateDisruptted);
            Event_UpdateCompleted  += new CbGeneric(Updater_UpdateCompleted);
        }
Exemple #3
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GlobalResourceManager.PreInitialize();

                //ESPlus.GlobalUtil.SetMaxLengthOfUserID(20);
                ESPlus.GlobalUtil.SetMaxLengthOfMessage(1024 * 1024 * 10);
                //OMCS.GlobalUtil.SetMaxLengthOfUserID(20);
                MainForm            mainForm      = new MainForm();
                IRapidPassiveEngine passiveEngine = RapidEngineFactory.CreatePassiveEngine();

                NDiskPassiveHandler     nDiskPassiveHandler = new NDiskPassiveHandler();                                  //V 2.0
                ComplexCustomizeHandler complexHandler      = new ComplexCustomizeHandler(nDiskPassiveHandler, mainForm); //V 2.0
                LoginForm loginForm = new LoginForm(passiveEngine, complexHandler);

                if (loginForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                #region 初始化OMCS
                Program.MultimediaManager = MultimediaManagerFactory.GetSingleton();
                Program.MultimediaManager.CameraDeviceIndex     = SystemSettings.Singleton.WebcamIndex;
                Program.MultimediaManager.MicrophoneDeviceIndex = SystemSettings.Singleton.MicrophoneIndex;
                Size?okSize = OMCS.Tools.Camera.MatchCameraVideoSize(SystemSettings.Singleton.WebcamIndex, GlobalConsts.CommonQualityVideo);
                Program.MultimediaManager.CameraVideoSize     = okSize == null ? new Size(320, 240) : okSize.Value;
                Program.MultimediaManager.OmcsLogger          = GlobalResourceManager.Logger;
                Program.MultimediaManager.CameraEncodeQuality = 10;
                Program.MultimediaManager.Initialize(passiveEngine.CurrentUserID, "", ConfigurationManager.AppSettings["ServerIP"], int.Parse(ConfigurationManager.AppSettings["OmcsServerPort"]));
                #endregion

                nDiskPassiveHandler.Initialize(passiveEngine.FileOutter, null);
                mainForm.Initialize(passiveEngine, loginForm.LoginStatus, loginForm.StateImage);
                Application.Run(mainForm);
            }
            catch (Exception ee)
            {
                MessageBoxEx.Show(ee.Message);
                ee = ee;
            }
        }