/// <summary>
        /// Get current version of client.
        /// </summary>
        public static int GetCurrentVersion()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "Upgrade\\UpdateConfiguration.xml";
            UpdateConfiguration updateConfiguration = (UpdateConfiguration)AgileConfiguration.Load(path);

            return(updateConfiguration.ClientVersion);
        }
Esempio n. 2
0
        /// <summary>
        /// Start.
        /// </summary>
        /// <param name="serverIP">server ip</param>
        /// <param name="serverPort">server port</param>
        /// <param name="callerExe">callerExe</param>
        public void Start(string serverIP, int serverPort, string callerExe)
        {
            try
            {
                Random random = new Random();
                for (int i = 0; i < 100; i++)
                {
                    string        userID        = random.Next(1000000).ToString("00000");
                    string        logonPassword = string.Empty;
                    LogonResponse logonResponse = mRapidPassiveEngine.Initialize(userID, logonPassword, serverIP, serverPort, null);
                    if (logonResponse.LogonResult == LogonResult.Succeed)
                    {
                        break;
                    }
                }

                if (!File.Exists(UpdateConfiguration.ConfigurationPath))
                {
                    mUpdateConfiguration.Save();
                }
                else
                {
                    mUpdateConfiguration = (UpdateConfiguration)AgileConfiguration.Load(UpdateConfiguration.ConfigurationPath);
                }

                GetUpdateInfo(out mFileRelativePathListNeedDownloaded, out mFileListNeedRemoved);
                mFileCountNeedUpdated = mFileRelativePathListNeedDownloaded.Count;
                Event_FileCountNeedUpdated?.Invoke(mFileCountNeedUpdated);

                if (mFileCountNeedUpdated == 0 && mFileListNeedRemoved.Count == 0)
                {
                    return;
                }
                Event_UpdateStarted?.Invoke();

                Process[] processes = Process.GetProcessesByName(callerExe.Substring(0, callerExe.Length - 4));
                foreach (Process process in processes)
                {
                    process.Kill();
                }

                CbGeneric cbGeneric = new CbGeneric(UdpateThread);
                cbGeneric.BeginInvoke(null, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Event_UpdateDisruptted?.Invoke(Resources.ConnectionFailed);
            }
        }
Esempio n. 3
0
        static void Main()
        {
            try
            {
                // ESFramework authorized user.
                GlobalUtil.SetAuthorizedUser("FreeUser", "");

                // Get update configuration.
                if (File.Exists(UpdateConfiguration.ConfigurationPath))
                {
                    mUpdateConfiguration = (UpdateConfiguration)AgileConfiguration.Load(UpdateConfiguration.ConfigurationPath);
                }
                else
                {
                    mUpdateConfiguration = new UpdateConfiguration();
                    mUpdateConfiguration.Save();
                }

                // Initialize rapid engine of server.
                int port = int.Parse(ConfigurationManager.AppSettings[Resources.CONFIG_KEY_PORT]);
                CustomizeHandler customizeHandler = new CustomizeHandler();
                mRapidServerEngine.WriteTimeoutInSecs = -1;
                mRapidServerEngine.Initialize(port, customizeHandler);
                customizeHandler.Initialize(mRapidServerEngine.FileController, mUpdateConfiguration);

                // Remote service.
                if (bool.Parse(ConfigurationManager.AppSettings[Resources.CONFIG_KEY_REMOTE]))
                {
                    ChannelServices.RegisterChannel(new TcpChannel(port + 2), false);
                    UpgradeService upgradeService = new UpgradeService(mUpdateConfiguration);
                    RemotingServices.Marshal(upgradeService, "UpgradeCenter");
                }

                // Create main form.
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                MainForm mainForm = new MainForm(mRapidServerEngine)
                {
                    Text = ConfigurationManager.AppSettings[Resources.CONFIG_KEY_FORM_TITLE]
                };
                Application.Run(mainForm);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }