public bool Execute(InitializationStep step) { step.Executed = true; var success = false; // check whether the Mgr is expected as first argument var args = step.GetArgs(this); var start = DateTime.Now; // If the invoke method returns a bool, we assume it is referring to whether or not // it actually completed. try { // Invoke the method and capture its return value var result = step.InitMethod.Invoke(null, args); if ((result is bool) && !(bool)result) { // Step failed. Check if it was required and and log the initial failure. s_log.Error(Resources.InitStepFailed, step.InitStepName, step.InitMethod.Name, "."); } else { success = true; } } catch (Exception ex) { // Step failed. Check if it was required and and log the initial failure. LogUtil.ErrorException(ex, Resources.InitStepFailed, step.InitStepName, step.InitMethod.Name, ""); } if (success) { // Step succeeded totalSuccess++; if (!string.IsNullOrEmpty(step.InitStepName)) { var span = DateTime.Now - start; if (m_MeasureSteps) { // save stats for later use } var timeStr = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0') + "." + span.Milliseconds.ToString().PadLeft(2, '0'); s_log.Info(string.Format(Resources.InitStepSucceeded, step.InitStepName, timeStr)); } } else { if (!failHandler(this, step)) { // Step failed if (step.IsRequired) { // It was required. Log this, and cease any further initialization. s_log.Fatal(string.Format(Resources.InitStepWasRequired, step.InitStepName, step.InitMethod.Name)); return false; } else { totalFails++; } } } return true; }
public bool Execute(InitializationStep step) { step.Executed = true; bool flag = false; object[] args = step.GetArgs(this); DateTime now = DateTime.Now; try { object obj = step.InitMethod.Invoke(null, args); if (obj is bool && !(bool)obj) { s_log.Error(WCell_Core.InitStepFailed, step.InitStepName, step.InitMethod.Name, "."); } else { flag = true; } } catch (Exception ex) { LogUtil.ErrorException(ex, WCell_Core.InitStepFailed, (object)step.InitStepName, (object)step.InitMethod.Name, (object)""); } if (flag) { ++totalSuccess; if (!string.IsNullOrEmpty(step.InitStepName)) { TimeSpan timeSpan = DateTime.Now - now; if (!m_MeasureSteps) { ; } string[] strArray1 = new string[5] { timeSpan.Minutes.ToString().PadLeft(2, '0'), ":", null, null, null }; string[] strArray2 = strArray1; int index1 = 2; int num = timeSpan.Seconds; string str1 = num.ToString().PadLeft(2, '0'); strArray2[index1] = str1; strArray1[3] = "."; string[] strArray3 = strArray1; int index2 = 4; num = timeSpan.Milliseconds; string str2 = num.ToString().PadLeft(2, '0'); strArray3[index2] = str2; string str3 = string.Concat(strArray1); s_log.Info(string.Format(WCell_Core.InitStepSucceeded, step.InitStepName, str3)); } } else if (!failHandler(this, step)) { if (step.IsRequired) { s_log.Fatal(string.Format(WCell_Core.InitStepWasRequired, step.InitStepName, step.InitMethod.Name)); return(false); } ++totalFails; } return(true); }
public bool Execute(InitializationStep step) { step.Executed = true; var success = false; // check whether the Mgr is expected as first argument var args = step.GetArgs(this); var start = DateTime.Now; // If the invoke method returns a bool, we assume it is referring to whether or not // it actually completed. try { // Invoke the method and capture its return value var result = step.InitMethod.Invoke(null, args); if ((result is bool) && !(bool)result) { // Step failed. Check if it was required and and log the initial failure. s_log.Error(Resources.InitStepFailed, step.InitStepName, step.InitMethod.Name, "."); } else { success = true; } } catch (Exception ex) { // Step failed. Check if it was required and and log the initial failure. LogUtil.ErrorException(ex, Resources.InitStepFailed, step.InitStepName, step.InitMethod.Name, ""); } if (success) { // Step succeeded totalSuccess++; if (!string.IsNullOrEmpty(step.InitStepName)) { var span = DateTime.Now - start; if (m_MeasureSteps) { // save stats for later use } var timeStr = span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0') + "." + span.Milliseconds.ToString().PadLeft(2, '0'); s_log.Info(string.Format(Resources.InitStepSucceeded, step.InitStepName, timeStr)); } } else { if (!failHandler(this, step)) { // Step failed if (step.IsRequired) { // It was required. Log this, and cease any further initialization. s_log.Fatal(string.Format(Resources.InitStepWasRequired, step.InitStepName, step.InitMethod.Name)); return(false); } else { totalFails++; } } } return(true); }