/// <summary> /// Check whether application is up-to-date /// </summary> private static bool CheckForUpdate(ApplicationForm mainForm) { if (!AppConfigManager.AppConfiguration.GetBooleanSetting(ConfigKeys.Web_AutoCheck)) { return(false); } string appName = mainForm.Text; string fileName; bool updateAvailable; try { updateAvailable = mainForm.CheckForUpdate(out fileName); } catch (Exception ex) { Log.WriteError("Update error", ex); mainForm.ShowServerError(); return(false); } if (updateAvailable) { string message = string.Format("An updated version of {0} is available now.\nWould you like to download and install the latest version?", appName); if (MessageBox.Show(message, appName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { return(mainForm.StartUpdateProcess(fileName)); } } return(false); }
/// <summary> /// Initializes application /// </summary> internal void InitializeApplication() { CheckForIllegalCrossThreadCalls = false; LifetimeServices.LeaseTime = TimeSpan.Zero; this.splitContainer.Panel2MinSize = 380; this.splitContainer.Panel1MinSize = 150; this.progressManager = new ProgressManager(this, this.statusBarLabel); instance = this; AddDefaultNodes(); }
/// <summary> /// Loads installed components from configuration file /// </summary> private void LoadInstalledComponents(ScopeNode node) { Log.WriteStart("Loading installed components"); node.Nodes.Clear(); foreach (ComponentConfigElement componentConfig in AppConfigManager.AppConfiguration.Components) { string instance = string.Empty; if (componentConfig.Settings["Instance"] != null && !string.IsNullOrEmpty(componentConfig.Settings["Instance"].Value)) { instance = "(" + componentConfig.Settings["Instance"].Value + ")"; } string title = string.Format("{0} {1} {2} {3}", componentConfig.Settings["ApplicationName"].Value, componentConfig.Settings["ComponentName"].Value, componentConfig.Settings["Release"].Value, instance); AddComponentNode(node, title, componentConfig); } node.Populated = true; Log.WriteEnd(string.Format("{0} installed component(s) loaded", AppConfigManager.AppConfiguration.Components.Count)); }
static void Main() { // Utils.FixConfigurationSectionDefinition(); //check security permissions if (!Utils.CheckSecurity()) { ShowSecurityError(); return; } //check administrator permissions if (!Utils.IsAdministrator()) { ShowSecurityError(); return; } //check for running instance if (!Utils.IsNewInstance()) { UiUtils.ShowRunningInstance(); return; } Log.WriteApplicationStart(); //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); Application.ApplicationExit += new EventHandler(OnApplicationExit); Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //check OS version Log.WriteInfo("{0} detected", Global.OSVersion); //check IIS version if (Global.IISVersion.Major == 0) { Log.WriteError("IIS not found."); } else { Log.WriteInfo("IIS {0} detected", Global.IISVersion); } ApplicationForm mainForm = new ApplicationForm(); if (!CheckCommandLineArgument("/nocheck")) { //Check for new versions if (CheckForUpdate(mainForm)) { return; } } // Load setup parameters from an XML file LoadSetupXmlFile(); //start application mainForm.InitializeApplication(); Application.Run(mainForm); // Utils.SaveMutex(); }