private void Window_Loaded(object sender, RoutedEventArgs e) { try { longBuildLCID = CMLanguage.LongBuildLCID; originalLCID = GetOriginalOSLCID(); currentSessionID = Process.GetCurrentProcess().SessionId; PreDoRegistry(); dictSystemLang = CMLanguage.CMLanguagesDict; BindAdminConsoleDataGrid(); BindClientDataGrid(); BindCPAppletDataGrid(); BindReportingDataGrid(); StartBindingTimer(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } try { ToolVersion version = new ToolVersion(); if (version.GetNewFiles().Count > 0 || version.GetDeletedFiles().Count() > 0) { btnNewVersion.Visibility = Visibility.Visible; } } catch { btnNewVersion.Visibility = Visibility.Hidden; } if (IsAdminConsoleInstalled) { try { LaunchDefaultAdminConsole(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { object objToolPath = ConfigurationManager.AppSettings["ToolPath"]; if (objToolPath == null || string.IsNullOrEmpty(objToolPath.ToString())) { MessageBox.Show("There is an error in configuration file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); } else { string toolPath = objToolPath.ToString(); if (toolPath.LastIndexOf("\\") != toolPath.Length - 1) { toolPath += "\\"; } if (AppDomain.CurrentDomain.BaseDirectory.ToLower() == toolPath.ToLower()) { (new frmBlock()).ShowDialog(); } else { worker = new BackgroundWorker(); worker.DoWork += (o, ea) => { Thread.Sleep(2000); ToolVersion version = new ToolVersion(); hsDeleted = version.GetDeletedFiles(); foreach (FileSystemInfo f in hsDeleted) { if (string.IsNullOrEmpty(f.Extension)) { if (Directory.Exists(f.FullName)) { Directory.Delete(f.FullName, true); } } else { if (File.Exists(f.FullName)) { File.Delete(f.FullName); } } } hsNew = version.GetNewFiles(); string oldPath = ""; foreach (string s in hsNew.Keys) { oldPath = s.Replace(ToolVersion.NewVersionPathRoot, ToolVersion.OldVersionPathRoot); if (string.IsNullOrEmpty(hsNew[s])) { if (!Directory.Exists(oldPath)) { Directory.CreateDirectory(oldPath); } } else { File.Copy(s, oldPath, true); } } }; worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); worker.RunWorkerAsync(); } } }
protected override void OnStartup(StartupEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } base.OnStartup(e); try { object objToolPath = ConfigurationManager.AppSettings["ToolPath"]; if (objToolPath == null || string.IsNullOrEmpty(objToolPath.ToString())) { MessageBox.Show("There is an error in configuration file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); } else { string toolPath = objToolPath.ToString(); if (toolPath.LastIndexOf("\\") != toolPath.Length - 1) { toolPath += "\\"; } if (AppDomain.CurrentDomain.BaseDirectory.ToLower() == toolPath.ToLower()) { (new frmBlock()).ShowDialog(); } else { ToolVersion version = new ToolVersion(); if (version.GetNewFiles().Count > 0 || version.GetDeletedFiles().Count() > 0) { bool autoUpgrade = Settings.GetAutoUpgrade(); if (autoUpgrade) { Upgrade(); } else { object obj = Settings.GetSameAction(); if (obj == null) { StartVersionCheck(); } else { if (obj.ToString().ToLower() == "no") { StartTool(); } else { Upgrade(); } } } } else { StartTool(); } } } } catch (Exception ex) { //MessageBox.Show(ex.Message); StartTool(); } }