private void btnThrow_Click(object sender, EventArgs e) { try { // To use general catch, uncomment the next line // throw new System.OutOfMemoryException(); if (rbDivideBy0.Checked == true) { throw new System.DivideByZeroException(); } else { if (rbFileNotFound.Checked == true) { throw new System.IO.FileNotFoundException(); } else { throw new System.OverflowException(); } } } catch (DivideByZeroException ex) { MessageBox.Show("DivideByZeroException thrown.", "Exception Error"); err = "DivideByZeroException: " + ex.StackTrace; } catch (FileNotFoundException ex) { MessageBox.Show("FileNotFoundException thrown.", "Exception Error"); err = "FileNotFoundException" + ex.StackTrace; } catch (OverflowException ex) { MessageBox.Show("OverflowException thrown.", "Exception Error"); err = "OverflowException" + ex.StackTrace; } catch (Exception ex) { MessageBox.Show(ex.StackTrace + "", "Exception Error"); err = ex.Message + " " + ex.StackTrace; } finally { clsErrorLog myErrLog = new clsErrorLog(err); myErrLog.PathName = Application.StartupPath; myErrLog.WriteErrorLog(); txtErrorMsgs.Text = myErrLog.ReadErrorLog(); } }
public static Boolean InsertUpdateErrorLog(clsErrorLog objErrorLog) { bool isAdded = false; string SpName = "usp_InsertUpdateErrorLog"; try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { db.Execute(SpName, objErrorLog, commandType: CommandType.StoredProcedure); } isAdded = true; } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } return(isAdded); }
private void CalculateBPM() { double totalTime = 0; int index = signals.Count - 1; if (counter > 1 && counter < 5) { if (counter == 2) { totalTime = signals[index].timeStamp - signals[index - 1].timeStamp; } BPM = (int)(60000 / totalTime); if (counter == 3) { totalTime = signals[index].timeStamp - signals[index - 2].timeStamp; } BPM = (int)(120000 / totalTime); if (counter == 4) { totalTime = signals[index].timeStamp - signals[index - 3].timeStamp; } BPM = (int)(180000 / totalTime); } if (counter > 4) { totalTime = signals[index].timeStamp - signals[index - 4].timeStamp; BPM = (int)(240000 / totalTime); int teller = counter - 4; err = teller.ToString() + "," + BPM.ToString() + ","; clsErrorLog txtWrite = new clsErrorLog(err); txtWrite.PathName = @"C:\TekstMappe\"; txtWrite.WriteErrorLog(); } }
public static clsErrorLog SelectErrorLogById(int?errorId) { clsErrorLog objErrorLog = new clsErrorLog(); bool isnull = true; string SpName = "usp_SelectErrorLog"; var objPar = new DynamicParameters(); if (String.IsNullOrEmpty(errorId.ToString())) { throw new ArgumentException("Function parameters cannot be blank!"); } else { try { objPar.Add("@errorId", errorId, dbType: DbType.Int32); using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { objErrorLog = db.Query <clsErrorLog>(SpName, objPar, commandType: CommandType.StoredProcedure).SingleOrDefault(); isnull = false; } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } } if (isnull) { return(null); } else { return(objErrorLog); } }