public void Chmod(ProcessException e) { // When recording the exit code, use 0 for success, process exit code for execution // errors, or -1 for all other errors. RecordData(new CopyBinaryData { SshChmodExitCode = ExitCodeFromError(e) }); }
public void CustomDeploy(double latencyMs, ProcessException e) { RecordCustomCommandData(new CustomCommandData { CustomCommandSucceeded = e == null, CustomCommandLatencyMs = latencyMs }); }
/// <summary> /// /// </summary> /// <param name="cmdStr"></param> /// <returns></returns> internal static ICmd ParseSqlCmdString(string cmdStr, CoreEA.ICoreEAHander dbe) { ICmd curCmd = null; if (string.IsNullOrEmpty(cmdStr)) { ProcessException.DisplayErrors(new Exception("Empty Command")); return(null); } try { cmdStr = cmdStr.TrimStart(); cmdStr = cmdStr.TrimEnd(); //Can't to lower , otherwise the insert data will never 大写 //cmdText = cmdText.ToLower(); string tempCmdText = cmdStr.ToLower(); if (tempCmdText.StartsWith("select")) { curCmd = new SelectCmd(dbe); } else if (tempCmdText.StartsWith("insert")) { curCmd = new InsertCmd(dbe); } else if (tempCmdText.StartsWith("update")) { curCmd = new UpdateCmd(dbe); } else if (tempCmdText.StartsWith("delete")) { curCmd = new DeleteCmd(dbe); } else if (tempCmdText.StartsWith("alter") || (tempCmdText.StartsWith("drop"))) { curCmd = new SpecialCmd(dbe); } else if (tempCmdText.StartsWith("create")) { curCmd = new CreateCmd(dbe); } else if (tempCmdText.StartsWith("sp_rename")) { curCmd = new SpecialCmd(dbe); } else { curCmd = null; //throw new Exception("ErrorMsg_CannotParseSqlCmd".GetFromResourece()); } } catch (Exception ee) { ProcessException.DisplayErrors(ee); } return(curCmd); }
/// <summary> /// Creates a new instance of the <see cref="AsyncDoubleBufferedQueue{T}"/> class. /// </summary> public AsyncDoubleBufferedQueue() { m_asyncQueue = new AsyncQueue <IEnumerable <T> >(); m_doubleBufferedQueue = new DoubleBufferedQueue <T>(); m_asyncQueue.ProcessItemFunction = item => m_doubleBufferedQueue.Enqueue(item); m_asyncQueue.ProcessException += (sender, args) => ProcessException?.SafeInvoke(sender ?? this, args); m_doubleBufferedQueue.ProcessException += (sender, args) => ProcessException?.SafeInvoke(sender ?? this, args); }
public WhenThrowingCircularDependencyException() { try { _process.Execute(_data); } catch (ProcessException ex) { _ex = ex; } }
void dataGridControl1_CellEndEdit(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { object celValue = dataGridViewForCreateTable.CurrentCell.Value; if (celValue == null) { return; } try { if ((e.ColumnIndex == 1) && (dataGridViewForCreateTable.CurrentRow.Cells[2].Value == null)) { string ttt = celValue.ToString(); if (ttt == "nvarchar") { dataGridViewForCreateTable.CurrentRow.Cells[1].Value = "nvarchar"; dataGridViewForCreateTable.CurrentRow.Cells[2].Value = "100"; } if (ttt == "int") { dataGridViewForCreateTable.CurrentRow.Cells[1].Value = "int"; dataGridViewForCreateTable.CurrentRow.Cells[2].Value = "8"; } if (ttt == "integer") { dataGridViewForCreateTable.CurrentRow.Cells[1].Value = "integer"; dataGridViewForCreateTable.CurrentRow.Cells[2].Value = "8"; } if (ttt == "smallint") { dataGridViewForCreateTable.CurrentRow.Cells[1].Value = "smallint"; dataGridViewForCreateTable.CurrentRow.Cells[2].Value = "4"; } if (dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_Unique].Value == null) { dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_Unique].Value = "No"; } if (dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_PrimaryKey] == null) { dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_PrimaryKey].Value = "No"; } if (dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_AllowNull].Value == null) { dataGridViewForCreateTable.CurrentRow.Cells[ColumnName_AllowNull].Value = "No"; } } } catch (Exception ee) { ProcessException.DisplayErrors(ee); } }
/// <summary> /// Raises the <see cref="ProcessException"/> event. /// </summary> /// <param name="level">The <see cref="MessageLevel"/> to assign to this message</param> /// <param name="exception">Processing <see cref="Exception"/>.</param> /// <param name="eventName">A fixed string to classify this event; defaults to <c>null</c>.</param> /// <param name="flags"><see cref="MessageFlags"/> to use, if any; defaults to <see cref="MessageFlags.None"/>.</param> /// <remarks> /// <see pref="eventName"/> should be a constant string value associated with what type of message is being /// generated. In general, there should only be a few dozen distinct event names per class. Exceeding this /// threshold will cause the EventName to be replaced with a general warning that a usage issue has occurred. /// </remarks> protected virtual void OnProcessException(MessageLevel level, Exception exception, string eventName = null, MessageFlags flags = MessageFlags.None) { try { Log.Publish(level, flags, eventName ?? "DataGapRecovery", exception?.Message, null, exception); using (Logger.SuppressLogMessages()) ProcessException?.Invoke(this, new EventArgs <Exception>(exception)); } catch (Exception ex) { // We protect our code from consumer thrown exceptions Log.Publish(MessageLevel.Info, "ConsumerEventException", $"Exception in consumer handler for ProcessException event: {ex.Message}", null, ex); } }
private void butOK_Click(object sender, RoutedEventArgs e) { try { Properties.Settings.Default["AutoBackupOldVersionFileBeforeUpgrade"] = (bool)checkBox1.IsChecked; Properties.Settings.Default.Save(); Properties.Settings.Default.UseSpeakInsteadOfMsgBox = (bool)chkIsUseSpeakInsteadOfMsg.IsChecked; Properties.Settings.Default.CmdTextFontSize = (int)txtFontSize.Value; Properties.Settings.Default.Save(); Close(); } catch (Exception ee) { ProcessException.DisplayErrors(ee); } }
public void Exception() { if (IsAlive()) { Process.WaitForExit(); if (Process.ExitCode != 0) { var except = new ProcessException(Process.ExitCode, "ops", string.Format("Execution of {0} with arguments {1} failed with exit code {2}", ProcessStartInfo.FileName, ProcessStartInfo.Arguments, Process.ExitCode)); Process = null; throw except; } } else { Process = null; } }
static DeveloperLogEvent RecordProcessException(ProcessException e) { var logEvent = new DeveloperLogEvent(); if (e is ProcessExecutionException) { logEvent.StatusCode = DeveloperEventStatus.Types.Code.ExternalToolFailure; var externalError = new DeveloperLogEvent.Types.ExternalToolError { ExitCode = ((ProcessExecutionException)e).ExitCode }; logEvent.ExternalToolError = externalError; } else { logEvent.StatusCode = DeveloperEventStatus.Types.Code.ExternalToolUnavailable; } return(logEvent); }
public void GetStartElementId_ProcessWithTwoStartEvents_IdentifyInitialTask_ThrowsProcessException() { // Arrange string definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn"); BpmnReader target = BpmnReader.Create(definitions); ProcessException actual = null; // Act try { _ = target.GetStartElementId(); } catch (ProcessException pe) { actual = pe; } // Assert Assert.NotNull(actual); Assert.IsType <ProcessException>(actual); }
public void NextElements_AskForNextStepWithANonexistingId_ThrowsProcessException() { // Arrange string definitions = LoadResourceAsString("Altinn.Process.UnitTest.TestData.multiple_events.bpmn"); BpmnReader target = BpmnReader.Create(definitions); ProcessException actual = null; // Act try { _ = target.NextElements("donotexist"); } catch (ProcessException pe) { actual = pe; } // Assert Assert.NotNull(actual); Assert.IsType <ProcessException>(actual); }
public static SplitResult FromException(ProcessException exception, int cnt = 1) { return(new SplitResult(null, exception, cnt)); }
private void processGenerate(string item) { try { CodeCompileUnit targetUnit = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(Properties.Settings.Default.MM_NamespaceName); ns.Imports.Add(new CodeNamespaceImport("System")); ns.Imports.Add(new CodeNamespaceImport("System.Text")); targetUnit.Namespaces.Add(ns); CodeTypeDeclaration ct = new CodeTypeDeclaration("Table_" + item); ct.IsClass = true; ct.Attributes = MemberAttributes.Public | MemberAttributes.Static | MemberAttributes.Final; //ct.IsPartial = true; ns.Types.Add(ct); List <string> ColumnLists = App.MainEngineer.GetColumnNameListFromTable(item); if (ColumnLists.Count < 1) { return; } foreach (string columnName in ColumnLists) { CodeMemberField member = new CodeMemberField(); member.Name = "_" + columnName; member.Type = new CodeTypeReference(typeof(string)); member.Attributes = MemberAttributes.Private | MemberAttributes.Static; member.InitExpression = new CodePrimitiveExpression(columnName); ct.Members.Add(member); CodeMemberProperty p = new CodeMemberProperty(); p.Name = columnName; p.Attributes = MemberAttributes.Public | MemberAttributes.Final | MemberAttributes.Static; p.HasGet = true; p.HasSet = false; p.Type = new CodeTypeReference(typeof(string)); //p.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "_"+columnName))); p.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression("_" + columnName))); ct.Members.Add(p); } CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"); CodeGeneratorOptions options = new CodeGeneratorOptions(); options.BracingStyle = "C"; using (StreamWriter sm = new StreamWriter(String.Format("{0}\\{1}.cs", this.textBox1.Text, item))) { provider.GenerateCodeFromCompileUnit(targetUnit, sm, options); } } catch (Exception ee) { errorTableList.Add(item); ProcessException.DisplayErrors(ee); } }
private void button1_Click(object sender, RoutedEventArgs e) { int recordCount = 10000; using (PopupForm p = new PopupForm()) { p.X_NotifyStr = "Record Count"; if (p.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int outValue; if (!int.TryParse(p.X_Result, out outValue)) { return; } recordCount = outValue; } else { return; } } string testDb = DateTime.Now.Second.ToString() + "test.sdf"; string testTable = "testTable"; if (!App.MainEngineer.CreateDatabase(new LoginInfo_SSCE() { DbName = testDb })) { return; } App.MainEngineer.Open(new CoreEA.LoginInfo.LoginInfo_SSCE() { DbName = testDb, Pwd = "", IsEncrypted = false }); if (!App.MainEngineer.IsOpened) { throw new Exception("Can't Open"); } //List<CreateTableArgs> argsList=new List<CreateTableArgs>(); //CreateTableArgs args=new CreateTableArgs(); //args.allowNulls = false; //args.dataLength = 0; //args.dataType="int"; //args.fieldName="id"; //args.isUnique = false; //args.isPrimaryKey = false; //argsList.Add(args); BaseTableSchema tableSchame = new BaseTableSchema(); tableSchame.Columns.Add(new BaseColumnSchema() { ColumnName = "id", ColumnType = "int" }); try { App.MainEngineer.CreateTable(tableSchame); string sqlCmd = string.Empty; SqlCeConnection conn = new SqlCeConnection(string.Format("Data source={0}", testDb)); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = conn; conn.Open(); Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < recordCount; i++) { sqlCmd = string.Format("insert into {0} values ({1})", testTable, i); cmd.CommandText = sqlCmd; cmd.ExecuteNonQuery(); } watch.Stop(); long sqlDirectTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); cmd.CommandText = string.Format("INSERT INTO {0} VALUES (?)", testTable); cmd.Parameters.Add("@id", SqlDbType.Int); cmd.Prepare(); for (int i = 0; i < recordCount; i++) { cmd.Parameters[0].Value = i; cmd.ExecuteNonQuery(); } watch.Stop(); long sqlParaTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); cmd.CommandText = testTable; cmd.CommandType = CommandType.TableDirect; SqlCeResultSet st = cmd.ExecuteResultSet(ResultSetOptions.Updatable); SqlCeUpdatableRecord rec = st.CreateRecord(); for (int i = 0; i < recordCount; i++) { rec.SetInt32(0, i); st.Insert(rec); } watch.Stop(); long sqlceResultSetTime = watch.ElapsedMilliseconds; //watch.Start(); //cmd.CommandText = testTable; //cmd.CommandType = CommandType.TableDirect; //SqlCeResultSet st = cmd.ExecuteResultSet(ResultSetOptions.Updatable); //SqlCeUpdatableRecord rec = //for (int i = 0; i < recordCount; i++) //{ // rec.SetInt32(0, i); // st.Insert(rec); //} //watch.Stop(); long sqlceUpdateResultSetTime = 100;// watch.ElapsedMilliseconds; cmd.Dispose(); conn.Close(); MessageBox.Show(string.Format("Test Result is \r\nDirect sql command used {0} \r\nUse parameters used{1}\r\nUse SqlceResultSet used{2}\r\nUpdate Sqlce ResultSet{3}\r\n", sqlDirectTime, sqlParaTime, sqlceResultSetTime, sqlceUpdateResultSetTime)); } catch (Exception ee) { ProcessException.DisplayErrors(ee); } }
private void DoOKWhenCreateTable() { if (string.IsNullOrEmpty(textBox1.Text)) { "CreatTableSchema_NeedTableName".GetFromResourece().Notify(); return; } string tableName = textBox1.Text; if (dataGridViewForCreateTable.Rows.Count > 0) { List <CreateTableArgs> createTableArgsList = new List <CreateTableArgs>(); foreach (System.Windows.Forms.DataGridViewRow row in this.dataGridViewForCreateTable.Rows) { CreateTableArgs args = new CreateTableArgs(); if (row.Cells[ColumnName_AllowNull].Value != null) { try { args.allowNulls = CommonUtil.SwitchToBool(row.Cells[ColumnName_AllowNull].Value); args.isPrimaryKey = CommonUtil.SwitchToBool(row.Cells[ColumnName_PrimaryKey].Value); args.isUnique = CommonUtil.SwitchToBool(row.Cells[ColumnName_Unique].Value); if (row.Cells[ColumnName_DataType].Value == null) { "Data Type Can not be empty".Notify(); return; } args.dataType = row.Cells[ColumnName_DataType].Value.ToString(); if (row.Cells[ColumnName_Length].Value == null) { "Column Length Can not be empty".Notify(); return; } args.dataLength = int.Parse(row.Cells[ColumnName_Length].Value.ToString()); if (row.Cells[ColumnName_ColumName].Value == null) { "Column Name Can not be empty".Notify(); return; } args.fieldName = row.Cells[ColumnName_ColumName].Value.ToString(); //Some type no need length properties ,so set empty //These types include int,interge, if (GlobalDefine.NoLenghtType.Collections.Contains(args.dataType)) { args.dataLength = 0; } createTableArgsList.Add(args); } catch (Exception ee) { ProcessException.DisplayErrors(ee); } } } if (App.MainEngineer.CreateTableWithSchemaInfo(createTableArgsList, tableName)) { if (RaiseAddNewTable != null) { RaiseAddNewTable(); } "CreateTableSchmea_CreateTableOkMsg".GetFromResourece().Notify(); Close(); } } }
private static void OnProcessException(Exception ex) { ProcessException?.Invoke(typeof(SessionHandler), new EventArgs <Exception>(ex)); }
public static AccumulationResult FromException(ProcessException exception, int cnt = 1) { return(new AccumulationResult(null, exception, cnt)); }