public SqlObjectBrowser(ServerConnection serverConn) { InitializeComponent(); // Connect to SQL Server server = new Server(serverConn); try { server.ConnectionContext.Connect(); // In case connection succeeded we add the sql server node as root in object explorer (treeview) TreeNode tn = new TreeNode(); tn.Text = server.Name; tn.Tag = server.Urn; this.objUrn = server.Urn; objectBrowserTreeView.Nodes.Add(tn); AddDummyNode(tn); connected = true; } catch (ConnectionException) { ExceptionMessageBox emb = new ExceptionMessageBox(); emb.Text = Properties.Resources.ConnectionFailed; emb.Show(this); } catch (ApplicationException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
public void ShowExceptionMessage() { try { // Do something that you don't expect to generate an exception. throw new ApplicationException(ExceptionMessage); } catch (ApplicationException ex) { // Define a new top-level error message. string str = "An Error has ocurred in while logging the Exception Information on System. " + Environment.NewLine + "Please contact support"; // Add the new top-level message to the handled exception. ApplicationException exTop = new ApplicationException(str, ex); ExceptionMessageBox box = new ExceptionMessageBox(exTop); box.Buttons = ExceptionMessageBoxButtons.OK; box.Caption = title; box.ShowCheckBox = false; box.ShowToolBar = true; box.Symbol = ExceptionMessageBoxSymbol.Stop; box.Show(this); this.Close(); } }
private void RefreshStats(IList <BuildStatus> changedBuildStatuses) { try { RefreshUserStats(changedBuildStatuses); _viewBuilds.RefreshStats(); } catch (Exception ex) { ExceptionMessageBox.Show(this, "Drat", "This tricky, hard to reproduce bug just occurred while refreshing user stats. Would you mind please sending us the details?", ex); _log.Error("Error while trying to refresh stats", ex); } }
/// <summary>Shows the exception in a special form.</summary> /// <param name="ex">The exception.</param> public static void ShowException(Exception ex) { ex.HelpLink = Constants.HelpUrl; var msg = new ExceptionMessageBox(ex) { Beep = false, ShowToolBar = true, Symbol = ExceptionMessageBoxSymbol.Error }; msg.Show(null); }
private void ConnectToServer(string server) { try { Server srvr = new Server(server); srvr.ConnectionContext.ConnectTimeout = 5; srvr.ConnectionContext.Connect(); this.sqlServerSelection = srvr; } catch (ConnectionFailureException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); Cursor = Cursors.Default; this.sqlServerSelection = null; } this.serverVersionToolStripStatusLabel.Text = this.sqlServerSelection.Information.Version.ToString() + " " + this.sqlServerSelection.Information.Edition; this.SqlServerTreeView.Nodes.Clear(); // Add Server node TreeNode node = new TreeNode(this.sqlServerSelection.ConnectionContext.TrueName); node.Name = Properties.Resources.Server; root = node; node.Tag = this.sqlServerSelection; this.SqlServerTreeView.Nodes.Add(node); // Add Databases node node = new TreeNode(Properties.Resources.Databases); node.Name = Properties.Resources.Databases; node.Tag = this.sqlServerSelection.Databases; root.Nodes.Add(node); AddDummyNode(node); this.SqlServerTreeView.SelectedNode = root; // Optimizing code this.sqlServerSelection.SetDefaultInitFields(typeof(Database), "CreateDate", "IsSystemObject", "CompatibilityLevel"); this.sqlServerSelection.SetDefaultInitFields(typeof(Table), "CreateDate", "IsSystemObject"); this.sqlServerSelection.SetDefaultInitFields(typeof(Microsoft.SqlServer.Management.Smo.View), "CreateDate", "IsSystemObject"); this.sqlServerSelection.SetDefaultInitFields(typeof(StoredProcedure), "CreateDate", "IsSystemObject"); this.sqlServerSelection.SetDefaultInitFields(typeof(Column), true); }
public static void ShowTvChannel(Form owner, UiBroadcastService service, bool defaultPlayer = true) { TvPlayer player; if (service == null) { return; } if (service.IsHidden) { return; } if (service.IsInactive) { var box = new ExceptionMessageBox() { Caption = owner.Text, Text = string.Format(Properties.Texts.ShowTvChannelInactiveService, service.DisplayName), Beep = true, Symbol = ExceptionMessageBoxSymbol.Question, Buttons = ExceptionMessageBoxButtons.YesNo, DefaultButton = ExceptionMessageBoxDefaultButton.Button2, }; if (box.Show(owner) != System.Windows.Forms.DialogResult.Yes) { return; } } // if var tvPlayerSettings = TvPlayersSettingsRegistration.Settings; if (defaultPlayer) { player = tvPlayerSettings.GetDefaultPlayer(); } else { using (var dialog = new SelectTvPlayerDialog()) { if (dialog.ShowDialog(owner) != DialogResult.OK) { return; } // if player = dialog.SelectedPlayer; } // using } // if-else ExternalTvPlayer.Launch(player, service, !tvPlayerSettings.DirectLaunch); } // ShowTvChannel
private void DatabaseDefrag_Load(object sender, EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Limit the table properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Schema", "Name", "IsSystemObject" }); ShowDatabases(true); } } else { this.Close(); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
} // HandleException public static void HandleException(IWin32Window owner, string caption, string message, MessageBoxIcon icon, Exception ex) { AddExceptionAdvancedInformation(ex); var box = new ExceptionMessageBox() { Caption = caption ?? Properties.Resources.MyAppHandleExceptionDefaultCaption, Text = message, InnerException = ex, Beep = true, Symbol = TranslateIconToSymbol(icon), }; box.Show(owner); } // HandleException
private void DeleteTableButton_Click(object sender, System.EventArgs e) { Database db; Table tbl; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Show the current tables for the selected database db = (Database)DatabasesComboBox.SelectedItem; if (TablesComboBox.Items.Count > 0) { tbl = db.Tables[((Table)TablesComboBox.SelectedItem).Name, ((Table)TablesComboBox.SelectedItem).Schema]; if (tbl != null) { // Are you sure? Default to No to avoid accidents if (System.Windows.Forms.MessageBox.Show(this, string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.ReallyDrop, tbl.ToString()), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0) == DialogResult.No) { return; } tbl.Drop(); } // Refresh list and select first entry ShowTables(); if (TablesComboBox.Items.Count > 0) { TablesComboBox.SelectedIndex = 0; } } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) { _log.Error("Global error", e.Exception); // see http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/628ba445-bdcf-4a9c-abcd-ac6e34b19a0d bool splashscreenBug = (e.Exception is InvalidOperationException) && e.Exception.Message == "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."; if (splashscreenBug) { return; } ExceptionMessageBox.Show(null, "Drat", "Something crazy just happened.", e.Exception); }
private void ShowTables() { Database db; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear the tables list TablesComboBox.Items.Clear(); // Show the current tables for the selected database if (DatabasesComboBox.SelectedIndex >= 0) { db = (Database)DatabasesComboBox.SelectedItem; foreach (Table tbl in db.Tables) { if (tbl.IsSystemObject == false) { TablesComboBox.Items.Add(tbl); } } // Select the first item in the list if (TablesComboBox.Items.Count > 0) { TablesComboBox.SelectedIndex = 0; } else { // Clear the table detail list ColumnsListView.Items.Clear(); } } UpdateButtons(); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
/// <summary> /// Check that the subscription exists and create it if needed. /// </summary> public void CheckSubscription() { try { // We need connections to the Publisher and Distributor. subscriberConn = new ServerConnection(subscriberServer); subscriberConn.Connect(); } catch (Microsoft.SqlServer.Replication.ConnectionFailureException ex) { ExceptionMessageBox emb = new ExceptionMessageBox( Properties.Resources.ExceptionCannotConnectLocal, Properties.Resources.ExceptionSqlServerError, ExceptionMessageBoxButtons.OK); emb.InnerException = ex; emb.Show(this); // Shutdown the application because we can't continue. Application.Exit(); } // Create the subscription database using SMO if it does not exist. Server subServer = new Server(subscriberConn); // Instantiate a pull subscription object. mergePullSub = new MergePullSubscription(); // Set the properties needed to create the subscription. mergePullSub.ConnectionContext = subscriberConn; mergePullSub.PublicationName = publicationName; mergePullSub.PublisherName = publisherServer; mergePullSub.PublicationDBName = publicationDatabase; mergePullSub.DatabaseName = subscriptionDatabase; if (subServer.Databases.Contains(subscriptionDatabase)) { // If the database exists, check for replication objects. if (mergePullSub.IsExistingObject) { if (mergePullSub.UseWebSynchronization) { this.UseWebSynchronization = true; } this.Close(); return; } } CreateSubscription(); }
private void btnTest_Click(object sender, EventArgs e) { try { if (txtServerName.Text.Trim().Length == 0) { MessageBox.Show(ResStrings.Str_Enter_the_Server_Name, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else if (txtDatabaseName.Text.Trim().Length == 0) { MessageBox.Show(ResStrings.str_Enter_the_Database_Name, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { // string str = null; string str2; // string str3 = DB_Class_SQLServer.UtilSqlServer.EncryptPassword(this.txtPassword.Text); string str3 = txtPassword.Text; if (CboAuthentication.SelectedIndex == 0) { // str = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";Integrated Security=SSPI"; str2 = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";Integrated Security=SSPI;"; } else { // str = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";User ID=" + txtLogin.Text.Trim() + ";Password="******"Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";User ID=" + txtLogin.Text.Trim() + ";Password="******";"; } SqlConnection testCon = new SqlConnection(); testCon.ConnectionString = str2; testCon.Open(); if (testCon.State == ConnectionState.Open) { MessageBox.Show(ResStrings.DbSqlForm_btnTest_Click_Connected, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); testCon.Close(); } else { MessageBox.Show(ResStrings.DbSqlForm_btnTest_Click_, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } } } catch (Exception exp) { ExceptionMessageBox.Show(exp); } }
private void ProcedureParameterError(SqlConnection SqlConn, string ProcedureName, Exception ex) { string CommandText = " SELECT "; CommandText += " PA.Name as ParameterName, "; CommandText += " CASE WHEN PA.is_output = 1 THEN 'Output' "; CommandText += " ELSE "; CommandText += " 'Input' "; CommandText += " END AS [In/Output], "; CommandText += " UPPER(st.name) AS DataType, "; CommandText += " PA.max_length AS Length"; CommandText += " FROM Sys.Procedures AS PR "; CommandText += " JOIN Sys.Parameters AS PA "; CommandText += " ON PR.object_id = PA.object_id "; CommandText += " JOIN sys.types AS ST "; CommandText += " ON PA.user_type_id = ST.user_type_id "; CommandText += " WHERE PR.Name = '{0}' "; CommandText = string.Format(CommandText, ProcedureName); SqlCommand _cmd = new SqlCommand(CommandText, SqlConn); SqlDataAdapter adapter = new SqlDataAdapter(_cmd); DataSet ds = new DataSet(); adapter.Fill(ds, "ParameterListing"); string ParameterName = string.Empty; string ErrorMessage = string.Empty; if (ex.Message.Contains("expects parameter")) { // The table we are generating will be the source of truth foreach (DataRow dr in ds.Tables[0].Rows) { ParameterName = dr["ParameterName"].ToString(); SqlParameter param = InputParams.Find(x => x.ParameterName == ParameterName); if (param == null) // Parameter is missing { // ApplicationException exTop = new ApplicationException("Missing SQL Parameter", ex); ExceptionMessageBox MsgBox = new ExceptionMessageBox(); ErrorMessage = string.Format("Procedure call is missing parameter {0}" + Environment.NewLine, ParameterName); ErrorMessage += "Datatype: " + dr["DataType"] + "; " + dr["Length"] + " bytes; Direction: " + dr["In/Output"]; System.Windows.Forms.MessageBox.Show(ErrorMessage, "Missing SQL Parameter.", System.Windows.Forms.MessageBoxButtons.OK); } } } else { throw ex; } }
/// <summary> /// Occurs when the script is going to be run. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EventHandler_Run(object sender, System.EventArgs e) { try { compiler__.ClearCodes(); compiler__.AddCode(syntaxDocument1.Text); int ret = compiler__.Compile(); Output.Clear(); ErrorList.Clear(); if (ret > 0) { foreach (CompilerError error in compiler__.Errors) { ErrorLevel level = error.IsWarning ? ErrorLevel.elWarning : ErrorLevel.elError; ErrorList.Add(level, error.ErrorNumber, error.ErrorText, error.Line); } Output.Add(SunnyChen.Gulu.Win.Properties.Resources.TEXT_ERR_COMPILE); ErrorList.Show(); } else if (ret == 0) { Output.Add(SunnyChen.Gulu.Win.Properties.Resources.TEXT_COMPILE_OK); Output.Show(); try { compiler__.Run("Program", "Main"); } catch (Exception ex) { //ExceptionMessageBox.ShowDialog(ex); Exception param = ex.InnerException == null ? ex : ex.InnerException; ExceptionMessageBox.ShowDialog(param, true); } } else if (ret == -1) { Output.Add(SunnyChen.Gulu.Win.Properties.Resources.TEXT_ERR_NO_CODE); Output.Show(); } else { Output.Add(SunnyChen.Gulu.Win.Properties.Resources.TEXT_ERR_COMPILE_GENERAL); Output.Show(); } } catch { throw; } }
private void OnServerMessage(object sender, ServerMessageEventArgs args) { SqlError err = args.Error; ExceptionMessageBox emb = new ExceptionMessageBox(); emb.Text = String.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.SqlError, err.Source, err.Class, err.State, err.Number, err.LineNumber, err.Procedure, err.Server, err.Message); emb.Show(this); }
public static async Task <List <Device> > GetCabinets() { try { string serverIP = Properties.Settings.Default.ServerIp; int serverPort = Properties.Settings.Default.ServerPort; string urlServer = "http://" + serverIP + ":" + serverPort; var client = new RestClient(urlServer); client.Authenticator = new HttpBasicAuthenticator(publicApiLogin, publicApiMdp); var request = new RestRequest("cabinets", Method.GET); client.Timeout = timeout; client.ReadWriteTimeout = timeout; request.Timeout = timeout; request.ReadWriteTimeout = timeout; var response = await client.ExecuteTaskAsync(request); if (response.IsSuccessful) { List <Device> lstDevice = new List <Device>(); var devices = JsonDevice.DeserializedJsonList(response.Content); if ((devices != null) && (devices.Count() > 0)) { foreach (JsonDevice jd in devices) { Device newDev = new Device { DeviceName = jd.name, DeviceSerial = jd.serial_num, DeviceLocation = jd.Location, IpAddress = jd.IP_addr, }; lstDevice.Add(newDev); } } return(lstDevice); } else { return(null); } } catch (Exception error) { ExceptionMessageBox exp = new ExceptionMessageBox(error, "Get Cabinet "); exp.ShowDialog(); return(null); } }
private void tempHistory_FormClosing(object sender, FormClosingEventArgs e) { try { if (_db != null) { _db.CloseDB(); } } catch (Exception exp) { // On affiche l'erreur. ExceptionMessageBox.Show(exp); } }
private void runButton_Click(object sender, EventArgs e) { // Perform run on the connection // Connect to SQL Server Server server = new Server(serverConn); try { server.ConnectionContext.ExecuteNonQuery(collScript, ExecutionTypes.ContinueOnError); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (_exceptionMessageBox != null) { return; } string errorMessage = $"An unhandled exception occurred: {e.Exception.Message}"; _exceptionMessageBox = new ExceptionMessageBox(e.Exception, errorMessage); _exceptionMessageBox.Show(); _exceptionMessageBox.Closed += ExceptionViewerOnClosed; e.Handled = true; }
private void QueryStripButton_Click(object sender, EventArgs e) { if (this.ActiveEditObject != null) { try { this.QueryObject(this.ActiveEditObject.Configuration); } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtServerName.Text.Trim().Length == 0) { MessageBox.Show(ResStrings.Str_Enter_the_Server_Name, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else if (txtDatabaseName.Text.Trim().Length == 0) { MessageBox.Show(ResStrings.str_Enter_the_Database_Name, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else if (txtTableName.Text.Trim().Length == 0) { MessageBox.Show(ResStrings.str_Enter_the_Table_Name, ResStrings.str_Connect_Server, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { // string str = null; string str2 = null; string str3 = UtilSqlServer.EncryptPassword(txtPassword.Text); if (CboAuthentication.SelectedIndex == 0) { //str = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";Integrated Security=SSPI"; str2 = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";Integrated Security=SSPI;"; } else { //str = "Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";User ID=" + txtLogin.Text.Trim() + ";Password="******"Data Source=" + txtServerName.Text.Trim() + ";Initial Catalog=" + txtDatabaseName.Text.Trim() + ";User ID=" + txtLogin.Text.Trim() + ";Password="******";"; } if (_db.AddExportInfo(1, str2, txtTableName.Text.Trim(), Convert.ToInt32(checkBoxEnableSQL.Checked))) { _bChange = true; MessageBox.Show(ResStrings.str_Sql_Connection_Info_Saved, ResStrings.str_Info_SQL_Server, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(ResStrings.str_Error_While_Saving_Sql_Connection_Info_Saved, ResStrings.str_Info_SQL_Server, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } catch (Exception exp) { ExceptionMessageBox.Show(exp); } }
private void ShowAssemblies(bool selectDefault) { // Show the current assemblies in the selected database Database db; ListViewItem AssemblyListViewItem; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear control AssembliesListView.Items.Clear(); // Limit the properties returned to just those that we use mySqlServer.SetDefaultInitFields(typeof(SqlAssembly), new String[] { "Name", "VersionMajor", "VersionMinor", "VersionBuild", "VersionRevision" }); db = (Database)DatabasesComboBox.SelectedItem; foreach (SqlAssembly sqlAssem in db.Assemblies) { AssemblyListViewItem = AssembliesListView.Items.Add(sqlAssem.Name); AssemblyListViewItem.SubItems.Add( sqlAssem.Version.Major.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." + sqlAssem.Version.Minor.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." + sqlAssem.Version.Build.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." + sqlAssem.Version.Revision.ToString(System.Globalization.CultureInfo.InvariantCulture)); AssemblyListViewItem.SubItems.Add( sqlAssem.CreateDate.ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (selectDefault && (AssembliesListView.Items.Count > 0)) { AssembliesListView.Items[0].Selected = true; } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, System.EventArgs e) { using (new LengthyOperation(this)) { try { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Sets preference settings PreferenceConfigHandler preferenceHandler = (PreferenceConfigHandler)config.GetSection("PreferenceConfig"); preferenceHandler.SearchRecursivly = chkSearchRecursivly.Checked; preferenceHandler.FileTreeShowFiles = chkShowFiles.Checked; preferenceHandler.FileTreeShowHidden = chkShowHidden.Checked; preferenceHandler.FileTreeShowSystem = chkShowSystem.Checked; // Sets backup settings BackupConfigHandler backupHandler = (BackupConfigHandler)config.GetSection("BackupConfig"); backupHandler.BackupDirectory = txtBackupDirectory.Text; backupHandler.EnableBackup = chkEnableBackup.Checked; // Sets editor and compiler settings EditorCompilerConfigHandler editorCompilerConfigHandler = (EditorCompilerConfigHandler)config.GetSection("EditorCompilerConfig"); editorCompilerConfigHandler.CompilerTypeName = txtCodeDomCompilerType.Text; if (cbSimpleTemplate.SelectedItem.ToString().Equals(Resources.TEXT_NOT_SPECIFIED) || cbGTemplate.SelectedItem.ToString().Equals(Resources.TEXT_NOT_SPECIFIED) || cbSyntaxFile.SelectedItem.ToString().Equals(Resources.TEXT_NOT_SPECIFIED)) { MessageBox.Show(Resources.TEXT_SCRIPT_MUST_SPECIFY, Resources.TEXT_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); // forbid closing DialogResult = DialogResult.None; return; } editorCompilerConfigHandler.SimpleTemplate = cbSimpleTemplate.SelectedItem.ToString(); editorCompilerConfigHandler.GTemplate = cbGTemplate.SelectedItem.ToString(); editorCompilerConfigHandler.SyntaxFileName = cbSyntaxFile.SelectedItem.ToString(); config.Save(ConfigurationSaveMode.Full); DialogResult = DialogResult.OK; } catch (Exception ex) { ExceptionMessageBox.ShowDialog(ex, true); } } }
public bool CheckConEmuAndDisplay() { bool result = CheckConEmu(); if (result == false) { var conemu = GetConEmuExecutable(); ExceptionMessageBox box = new ExceptionMessageBox(); box.SetException("Unable to find the ConEmu installation", "Please set the paths of your ConEmu installation in the Visual Studio options pane" + Environment.NewLine + Environment.NewLine + "ConEmu Path: " + conemu + Environment.NewLine); box.ShowDialog(); } return(result); }
} // HandleException public static void HandleException(Form owner, string caption, string message, MessageBoxIcon icon, Exception ex) { BasicGoogleTelemetry.SendExtendedExceptionHit(ex, true, message, null); AddExceptionAdvancedInformation(ex); var box = new ExceptionMessageBox() { Caption = caption ?? Properties.Texts.MyAppHandleExceptionDefaultCaption, Text = message ?? Properties.Texts.MyAppHandleExceptionDefaultMessage, InnerException = ex, Beep = true, Symbol = TranslateIconToSymbol(icon), }; box.Show(owner); } // HandleException
private void DeleteButton_Click(object sender, System.EventArgs e) { String sDatabaseName; Cursor csr = null; Database db; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Use the selected database as the one to be deleted sDatabaseName = DatabasesListView.SelectedItems[0].Text; // Drop (Delete) the database db = SqlServerSelection.Databases[sDatabaseName]; if (db != null) { // Are you sure? Default to No. if (System.Windows.Forms.MessageBox.Show(this, string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.ReallyDrop, db.Name), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0) == DialogResult.No) { return; } db.Drop(); sbrStatus.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.DatabaseDeleted, sDatabaseName); } // Refresh database list ShowDatabases(false); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { UpdateControls(); this.Cursor = csr; // Restore the original cursor } }
private void ShowTables() { Database db; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear the tables list TablesComboBox.Items.Clear(); // Limit the properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Name", "CreateDate", "IsSystemObject" }); // Show the current tables for the selected database if (DatabasesComboBox.SelectedIndex >= 0) { db = (Database)DatabasesComboBox.SelectedItem; foreach (Table tbl in db.Tables) { if (tbl.IsSystemObject == false) { TablesComboBox.Items.Add(tbl); } } // Select the first item in the list if (TablesComboBox.Items.Count > 0) { TablesComboBox.SelectedIndex = 0; } } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private static void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { try { MatchCollection matchCollection = Regex.Matches(e.Result, WebMatchPatternViewState.Current.WebRegex); WebMatchPatternViewState.Current.Matches.Clear(); WebMatchPatternViewState.Current.Groups.Clear(); foreach (Match match in matchCollection) { WebRegexMatch webRegexMatch = new WebRegexMatch("Match", match.Value); foreach (Group group in match.Groups) { if (group.Name != "0" && !WebMatchPatternViewState.Current.Groups.Contains(group.Name)) { WebMatchPatternViewState.Current.Groups.Add(group.Name); } WebRegexMatch webGroupMatch = new WebRegexMatch(group.Name, group.Value); webRegexMatch.Children.Add(webGroupMatch); } WebMatchPatternViewState.Current.Matches.Add(webRegexMatch); } WebMatchPatternViewState.Current.LastWebRegex = WebMatchPatternViewState.Current.WebRegex; } catch (ArgumentException argumentEx) { ExceptionMessageBox.Show(WebMatchPatternViewState.Title, "The format of the expression " + $"{Environment.NewLine}{Environment.NewLine}{WebMatchPatternViewState.Current.WebRegex}{Environment.NewLine}{Environment.NewLine}" + " is not correct.", argumentEx); } } else { ExceptionMessageBox.Show(WebMatchPatternViewState.Title, $"The following error occurred when retrieving the content from {WebMatchPatternViewState.Current.WebURL}:", e.Error); } WebMatchPatternViewState.Current.IsReady = true; WebMatchPatternViewState.Current.SelectedGroupIndex = (WebMatchPatternViewState.Current.Groups.Count > 0) ? 0 : -1; }
private void ShowDatabases(Boolean selectDefault) { // Show the current databases on the server Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor DatabasesComboBox.Enabled = false; // Clear control DatabasesComboBox.Items.Clear(); // Limit the properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Database), new String[] { "Name", "IsSystemObject", "IsAccessible" }); // Add database objects to combobox // The default ToString() will display the database name in the list foreach (Database db in SqlServerSelection.Databases) { if (db.IsSystemObject == false && db.IsAccessible == true) { DatabasesComboBox.Items.Add(db); } } if (selectDefault == true && DatabasesComboBox.Items.Count > 0) { DatabasesComboBox.SelectedIndex = 0; } DatabasesComboBox.Enabled = true; } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; try { var logger = SimpleIoc.Default.GetInstance <ILogService>().GetLogger <App>(); logger.Fatal("Some crash occurred.", e.Exception); } catch (InvalidOperationException) { } var window = new ExceptionMessageBox(e.Exception, "Im Programm ist ein Fehler aufgetreten.", true); window.ShowDialog(); }
public static async Task <Device> GetCabinet(string serial) { try { Properties.Settings.Default.Reload(); string serverIP = Properties.Settings.Default.ServerIp; int serverPort = Properties.Settings.Default.ServerPort; string urlServer = "http://" + serverIP + ":" + serverPort; var client = new RestClient(urlServer); client.Authenticator = new HttpBasicAuthenticator(publicApiLogin, publicApiMdp); var request = new RestRequest("cabinets/" + serial, Method.GET); client.Timeout = timeout; client.ReadWriteTimeout = timeout; request.Timeout = timeout; request.ReadWriteTimeout = timeout; var response = await client.ExecuteTaskAsync(request); if (response.IsSuccessful) { var device = JsonDevice.DeserializedJsonAlone(response.Content); if (device != null) { Device newDev = new Device { DeviceName = device.name, DeviceSerial = device.serial_num, DeviceLocation = device.Location, IpAddress = device.IP_addr, }; return(newDev); } return(null); } else { return(null); } } catch (Exception error) { ExceptionMessageBox exp = new ExceptionMessageBox(error, "Error in Get Cabinet"); exp.ShowDialog(); return(null); } }
private void CreateStripButton_Click(object sender, EventArgs e) { if (this.ActiveEditObject != null) { try { this.ActiveEditObject.Configuration.Create(); this.outputTextBox.Text = this.ActiveEditObject.Configuration.SqlScript; this.SetStripButtonState(ObjectsSplitPanel.operations.Show); } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } } }
/// <summary> /// Crea el mensaje de error y lo muestra /// </summary> /// <param name="ex"></param> /// <param name="handlingInstanceId"></param> /// <returns></returns> private DialogResult ShowThreadExceptionDialog(Exception exception, Guid handlingInstanceId) { //Capturar las excepciones para las cuales no se quiere mostrar el dialogo de exception, sino un mensaje estandar if (exception is PPPNegocioException) { MessageHelper.MostrarMensajeAlerta(exception.Message); return DialogResult.OK; } //Capturar las excepciones para las cuales se muestra la innerException if (exception.InnerException != null) { if (exception.InnerException is SqlException) { exception = exception.InnerException; } } var form = new ExceptionMessageBox(exception.Message); return form.ShowDialog(); }
private IConfiguration NewObject(string classType, string caption, int height) { EditObject obj; IConfiguration config = null; try { ConfigurationPanel.EditObjectButton.Text = caption; Assembly a = Assembly.GetAssembly(this.GetType()); object[] args = new object[1]; args[0] = SqlConnectionControl.ServiceBroker; //Create a new instance of class type stored in classType. config = (IConfiguration)a.CreateInstance (classType, true, BindingFlags.CreateInstance, null, args, System.Globalization.CultureInfo.CurrentCulture, null); obj = ConfigurationPanel.AddObject("(New)", config); obj.Expand(height); obj.ButtonVisible = false; } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } return config; }
public void OnProjectChanged(string path, string[] filter) { this.treeViewExplorer.BeginUpdate(); this._model = new TreeModel(); BaseNode rootNode = new BaseNode("UDK"); this._model.Nodes.Add(rootNode); try { PopulateTree(path, rootNode, filter); } catch (Exception e) { ExceptionMessageBox msgBox = new ExceptionMessageBox(e); msgBox.ShowDialog(); } this.treeViewExplorer.Model = _model; this.treeViewExplorer.EndUpdate(); foreach (TreeNodeAdv node in this.treeViewExplorer.Root.Children) { node.Expand(); } }
private void RefreshService(Service svc) { // Update the service status field try { svc.Refresh(); ListViewItem ServiceListViewItem; ServiceListViewItem = ServicesListView.SelectedItems[0]; ServiceListViewItem.SubItems[2].Text = svc.ServiceState.ToString(); UpdateButtons(); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
private void GetServices() { Cursor csr = null; ManagedComputer mc; ListViewItem ServiceListViewItem; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear control ServicesListView.Items.Clear(); mc = new ManagedComputer(SqlServerSelection.Name); foreach (Service svc in mc.Services) { ServiceListViewItem = ServicesListView.Items.Add(svc.Name); ServiceListViewItem.SubItems.Add(svc.DisplayName); ServiceListViewItem.SubItems.Add(svc.ServiceState.ToString()); ServiceListViewItem.SubItems.Add(svc.StartMode.ToString()); ServiceListViewItem.SubItems.Add(svc.ServiceAccount); ServiceListViewItem.SubItems.Add(svc.State.ToString()); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void ResumeButton_Click(System.Object sender, System.EventArgs e) { // Resume a paused service Cursor csr = null; Service svc; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor svc = GetSelectedService(); if (svc != null) { if (svc.ServiceState == ServiceState.Paused) { sbrStatus.Text = Properties.Resources.Resuming; sbrStatus.Refresh(); svc.Resume(); } // Wait for service state to change WaitServiceStateChange(svc, ServiceState.Running); RefreshService(svc); sbrStatus.Text = Properties.Resources.Ready; } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void ListDatabaseSpace() { try { this.dataGridView1.Rows.Clear(); foreach (Database db in SqlServerSelection.Databases) { if (db.IsSystemObject == false) { if (db.LogFiles.Count > 0) { this.dataGridView1.Rows.Add(new object[] { db.Name, db.Size, db.SpaceAvailable / 1024.0, db.LogFiles[0].Size / 1024.0, db.LogFiles[0].UsedSpace / 1024.0 }); } else { this.dataGridView1.Rows.Add(new object[] { db.Name, db.Size, db.SpaceAvailable / 1024.0, 0.0, 0.0 }); } } } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
private void DisplayIndexSizes() { Database db; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor db = (Database)DatabasesComboBox.SelectedItem; this.dataGridView1.Rows.Clear(); foreach (Table tbl in db.Tables) { if (tbl.IsSystemObject == false) { foreach (Index idx in tbl.Indexes) { if (idx.IndexKeyType != IndexKeyType.None) { continue; // Only show indexes } this.dataGridView1.Rows.Add(new object[] { tbl.ToString(), idx.Name, idx.SpaceUsed }); } } } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void AlterStripButton_Click(object sender, EventArgs e) { if (this.ActiveEditObject != null) { try { this.ActiveEditObject.Configuration.Alter(); this.outputTextBox.Text = this.ActiveEditObject.Configuration.SqlScript; this.outputDataGridView.AutoGenerateColumns = true; } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } } }
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { if (this.ActiveEditObject != null) { try { Cursor.Current = Cursors.WaitCursor; this.outputTextBox.Text = this.ActiveEditObject.Configuration.Export(String.Empty); DataSet ds = this.ActiveEditObject.Configuration.Query(); if (ds != null) this.outputDataGridView.DataSource = ds.Tables[0]; } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { Cursor.Current = Cursors.Default; } } }
private void DropStripButton_Click(object sender, EventArgs e) { if (this.ActiveEditObject != null) { try { if (MessageBox.Show ("Drop this object?", "Drop Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { this.ActiveEditObject.Configuration.Drop(); this.SetStripButtonState(ObjectsSplitPanel.operations.Drop); this.RemoveAllObjects(); } } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } } }
private ConnectedState GetConnectionState() { SelectQuery wmiQuery; ManagementObjectSearcher searcher; bool isConnected; try { // Query the WMI provider to determine if we are connected. wmiQuery = new SelectQuery("SELECT * FROM Win32_NetworkAdapter"); searcher = new ManagementObjectSearcher(wmiQuery); // Assume that we are not connected. isConnected = false; // Check the results for a NetConnectionStatus of 2 (connected). foreach (ManagementObject result in searcher.Get()) { if (Convert.ToInt32(result["NetConnectionStatus"], System.Globalization.CultureInfo.InvariantCulture) == 2) { isConnected = true; } } if (isConnected) { return ConnectedState.Connected; } else { return ConnectedState.Disconnected; } } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); return ConnectedState.Disconnected; } }
private void AddTableButton_Click(object sender, System.EventArgs e) { Database db; Table tbl; Column col; Index idx; Default dflt; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Show the current tables for the selected database db = (Database)DatabasesComboBox.SelectedItem; if (db.Tables.Contains(TableNameTextBox.Text) == false) { // Create an empty string default dflt = db.Defaults["dfltEmptyString"]; if (dflt == null) { dflt = new Default(db, "dfltEmptyString"); dflt.TextHeader = "CREATE DEFAULT [dbo].[dfltEmptyString] AS "; dflt.TextBody = @"'';"; dflt.Create(); } // Create a new table object tbl = new Table(db, TableNameTextBox.Text, db.DefaultSchema); // Add the first column col = new Column(tbl, @"Column1", DataType.Int); tbl.Columns.Add(col); col.Nullable = false; col.Identity = true; col.IdentitySeed = 1; col.IdentityIncrement = 1; // Add the primary key index idx = new Index(tbl, @"PK_" + TableNameTextBox.Text); tbl.Indexes.Add(idx); idx.IndexedColumns.Add(new IndexedColumn(idx, col.Name)); idx.IsClustered = true; idx.IsUnique = true; idx.IndexKeyType = IndexKeyType.DriPrimaryKey; // Add the second column col = new Column(tbl, @"Column2", DataType.NVarChar(1024)); tbl.Columns.Add(col); col.DataType.MaximumLength = 1024; col.AddDefaultConstraint(null); // Use SQL Server default naming col.DefaultConstraint.Text = Properties.Resources.DefaultConstraintText; col.Nullable = false; // Add the third column col = new Column(tbl, @"Column3", DataType.DateTime); tbl.Columns.Add(col); col.Nullable = false; // Create the table tbl.Create(); // Refresh list and select the one we just created ShowTables(); // Clear selected items TablesComboBox.SelectedIndex = -1; // Find the table just created TablesComboBox.SelectedIndex = TablesComboBox.FindStringExact(tbl.ToString()); } else { ExceptionMessageBox emb = new ExceptionMessageBox(); emb.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.TableExists, TableNameTextBox.Text); emb.Show(this); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void 只上传数据ToolStripMenuItem_Click(object sender, EventArgs e) { try { Synchronize syncSub = new Synchronize(); // Disable the current form this.Enabled = false; syncSub.Show(this); syncSub.SynchronizeSubscriptionUploadOnly(); syncWhenConnectedStatus.Visible = false; } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex, ExceptionMessageBoxButtons.OK); emb.Show(this); } finally { // Enable the current form this.Enabled = true; } }
private void ShowDatabases(bool selectDefault) { // Show the current databases on the server Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear control DatabasesComboBox.Items.Clear(); // Limit the database properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Database), new String[] { "Name", "IsSystemObject", "IsAccessible" }); // Limit the table properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Name", "CreateDate", "IsSystemObject" }); // Limit the column properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Column), new String[] {"Name", "DataType", "SystemType", "Length", "NumericPrecision", "NumericScale", "XmlSchemaNamespace", "XmlSchemaNamespaceSchema", "DataTypeSchema", "Nullable", "InPrimaryKey" }); // Add database objects to combobox; the default ToString will display the database name foreach (Database db in SqlServerSelection.Databases) { if (db.IsSystemObject == false && db.IsAccessible == true) { DatabasesComboBox.Items.Add(db); } } if ((selectDefault == true) && (DatabasesComboBox.Items.Count > 0)) { DatabasesComboBox.SelectedIndex = 0; } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void mnuTellMeMore_Click(object sender, EventArgs e) { ExceptionMessageBox emb = new ExceptionMessageBox( Properties.Resources.TellMeMoreWebSync); emb.Symbol = ExceptionMessageBoxSymbol.Information; emb.Show(this); }
private void ShowColumns() { Cursor csr = null; ListViewItem ColumnListViewItem; Table tbl; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Delay rendering until after list filled ColumnsListView.BeginUpdate(); // Clear the columns list ColumnsListView.Items.Clear(); // Show the current columns for the selected table if (TablesComboBox.SelectedIndex >= 0) { // Get the selected table object tbl = (Table)TablesComboBox.SelectedItem; // Iterate through all the columns to fill list foreach (Column col in tbl.Columns) { ColumnListViewItem = ColumnsListView.Items.Add(col.Name); ColumnListViewItem.SubItems.Add(col.DataType.Name); ColumnListViewItem.SubItems.Add(col.DataType. MaximumLength.ToString( System.Globalization.CultureInfo.InvariantCulture)); ColumnListViewItem.SubItems.Add( col.Nullable.ToString()); ColumnListViewItem.SubItems.Add( col.InPrimaryKey.ToString()); } } // Now we render the listview ColumnsListView.EndUpdate(); UpdateButtons(); } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void okButton_Click(object sender, EventArgs e) { if (enableWebSyncChkBox.Checked == true && (string.IsNullOrEmpty(userNameTextBox.Text) == true || string.IsNullOrEmpty(passwordTextBox.Text) == true || string.IsNullOrEmpty(webSyncUrlTexBox.Text) == true)) { ExceptionMessageBox emb = new ExceptionMessageBox( Properties.Resources.ExceptionFormValidation); emb.Show(this); return; } else { if (enableWebSyncChkBox.Checked) { mergePullSub.UseWebSynchronization = true; mergePullSub.InternetLogin = userNameTextBox.Text; mergePullSub.InternetPassword = passwordTextBox.Text; mergePullSub.InternetUrl = webSyncUrlTexBox.Text; useWebSync = true; } else { mergePullSub.UseWebSynchronization = false; mergePullSub.InternetLogin = string.Empty; mergePullSub.InternetPassword = string.Empty; mergePullSub.InternetUrl = string.Empty; useWebSync = false; } mergePullSub.CommitPropertyChanges(); mergePullSub.Refresh(); subscriberConn.Disconnect(); this.Close(); } }
private void showSyncDialog() { try { Synchronize syncSub = new Synchronize(); // Disable the current form this.Enabled = false; syncSub.Show(this); // Check that the subscription exists. syncSub.CheckSubscription(); // Disable upload only if Web synchronization is enabled. if (syncSub.UseWebSynchronization) { mnuSynchronizeOnlyUploadData.Enabled = false; } } catch (SqlException ex) { ExceptionMessageBox emb = new ExceptionMessageBox( Properties.Resources.ExceptionVerifySqlServerRunning, Properties.Resources.ExceptionSqlServerError, ExceptionMessageBoxButtons.OK); emb.InnerException = ex; emb.Show(this); // Shutdown the application because we can't continue. Application.Exit(); } catch (ApplicationException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex, ExceptionMessageBoxButtons.OK); emb.Show(this); // Shutdown the application because we can't continue. Application.Exit(); } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex, ExceptionMessageBoxButtons.OK); emb.Show(this); // Shutdown the application because we can't continue. Application.Exit(); } catch { ExceptionMessageBox emb = new ExceptionMessageBox(@"CATASTROPHIC FAILURE!", @"CLOSING APPLICATION"); emb.Show(this); // Shutdown the application because we can't continue. Application.Exit(); } finally { // Enable the current form this.Enabled = true; } }
private void WebSyncOptions_Load(object sender, EventArgs e) { passwordTextBox.Text = string.Empty; try { subscriberConn = new ServerConnection(subscriberServer); subscriberConn.Connect(); mergePullSub = new MergePullSubscription(subscriptionDatabase, publisherServer, publicationDatabase, publicationName, subscriberConn); mergePullSub.Load(); if (mergePullSub.UseWebSynchronization) { enableWebSyncChkBox.Checked = true; useWebSync = true; } if (string.IsNullOrEmpty(mergePullSub.InternetUrl) == false) { webSyncUrlTexBox.Text = mergePullSub.InternetUrl; } else { webSyncUrlTexBox.Text = webSynchronizationUrl; } if (string.IsNullOrEmpty(mergePullSub.InternetLogin) == false) { userNameTextBox.Text = mergePullSub.InternetLogin; } else { if (Environment.UserDomainName.Length != 0) { userNameTextBox.Text = Environment.UserDomainName + @"\" + Environment.UserName; } else { userNameTextBox.Text = Environment.UserName; } } if (mergePullSub.UseWebSynchronization == false) { userNameTextBox.Enabled = false; passwordTextBox.Enabled = false; } } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); this.Close(); } }
private void 重新初始化数据RToolStripMenuItem_Click(object sender, EventArgs e) { try { Synchronize syncSub = new Synchronize(); // Disable the current form this.Enabled = false; syncSub.Show(this); syncSub.ReinitializeSubscription(); } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex, ExceptionMessageBoxButtons.OK); emb.Show(this); } finally { loadLastAgentSessionSummary(); // Enable the current form this.Enabled = true; } }
public void Draw(esriDrawPhase drawPhase, IDisplay display, ITrackCancel trackCancel) { switch (drawPhase) { case esriDrawPhase.esriDPGeography: if (Valid) { if (Visible) { try { var clipEnvelope = display.ClipEnvelope; // when loading from a file the active map doesn't exist yet // so just deal with it here. if (_map == null) { var mxdoc = (IMxDocument)_application.Document; _map = mxdoc.FocusMap; } Debug.WriteLine("Draw event"); var activeView = _map as IActiveView; Logger.Debug("Layer name: " + Name); if (activeView != null) { //_envelope = activeView.Extent; _envelope = clipEnvelope; Logger.Debug("Draw extent: xmin:" + _envelope.XMin + ", ymin:" + _envelope.YMin + ", xmax:" + _envelope.XMax + ", ymax:" + _envelope.YMax ); if (SpatialReference != null) { Logger.Debug("Layer spatial reference: " + SpatialReference.FactoryCode); } if (_map.SpatialReference != null) { Logger.Debug("Map spatial reference: " + _map.SpatialReference.FactoryCode); } var bruTileHelper = new BruTileHelper(_tileTimeOut); //_displayFilter.Transparency = (short)(255 - ((_transparency * 255) / 100)); //if (display.Filter == null) //{ // display.Filter = _displayFilter; //} var fileCache = CacheDirectory.GetFileCache(_cacheDir,_config,_enumBruTileLayer); bruTileHelper.Draw(_application.StatusBar.ProgressBar, activeView, fileCache, trackCancel, SpatialReference, ref _currentLevel, _tileSource, display); } } catch (Exception ex) { var mbox = new ExceptionMessageBox(ex); mbox.Show(null); } } // isVisible } // isValid break; case esriDrawPhase.esriDPAnnotation: break; } }