public static void DebugException(Exception ex) { CLILogs.Debug("InnerException : " + ex?.InnerException?.ToString()); CLILogs.Debug("StackTrace : " + ex?.StackTrace); CLILogs.Debug("Source : " + ex?.Source); CLILogs.Debug("Data : " + ex?.Data.ToString()); CLILogs.Debug("TargetSite : " + ex?.TargetSite?.ToString()); CLILogs.Error(ex?.Message); }
public CreateConfiguration ConvertGenericCreationOption(ConfigType type, Options.ICreateOptions option) { ConfigGetGlobalOptions(option); CreateConfiguration config = new CreateConfiguration(type, CommandApi.Create); if (!string.IsNullOrEmpty(option.FileConf)) { try { config = this.ReadConfigurationFile <CreateConfiguration>(option.FileConf, type, CommandApi.Create); } catch (System.IO.FileNotFoundException ex) { CLILogs.Error(ex.Message); } } GetDefaultOptions(config, option); ConfigPrintInformation(option, type, "create"); config.Name = option.Name ?? config.Name; config.Shortname = option.Shortname ?? config.Shortname; config.Range = option.Range ?? config.Range; config.Profile = option.Profile ?? config.Profile; config.Tags = option.Tags?.ToList().Count > 0 ? option.Tags?.ToList() : config.Tags; config.Constants = option.Constants?.ToList().Count > 0 ? option.Constants?.ToList() : config.Constants; config.Constraints = option.Constraints?.ToList().Count > 0 ? option.Constraints?.ToList() : config.Constraints; config.Labels = (option.Labels?.Any() ?? false) ? option.Labels.ToList() : config.Labels; config.Resources = option.Resources?.ToList().Count > 0 ? option.Resources?.ToList() : config.Resources; config.InstanceCount = option.InstanceCount > 0 ? option.InstanceCount : config.InstanceCount; config.JobUuid = option.Job ?? config.JobUuid; config.PoolUuid = option.Pool ?? config.PoolUuid; config.IsElastic = option.IsElastic ? option.IsElastic : config.IsElastic; config.IsDependents = option.IsDependents ? option.IsDependents : config.IsDependents; config.Result = option.Result ?? config.Result; config.Dependents = option.Dependents?.ToList().Count > 0 ? option.Dependents?.ToList() : config.Dependents; Options.IElasticityOptions elasticOption = option as Options.IElasticityOptions; var MaximumWallTime = string.IsNullOrEmpty(option.MaximumWallTime) ? config.MaximumWallTime : (TimeSpan?)ParseTimeSpanString(option.MaximumWallTime); config.MaximumWallTime = MaximumWallTime == default(TimeSpan) ? null : MaximumWallTime; config.TasksDefaultWaitForPoolResourcesSynchronization = option.TasksDefaultWaitForPoolResourcesSynchronization ?? config.TasksDefaultWaitForPoolResourcesSynchronization; config.WaitForPoolResourcesSynchronization = option.WaitForPoolResourcesSynchronization ?? config.WaitForPoolResourcesSynchronization; if (elasticOption != null) { config.ElasticMinimumTotalNodes = elasticOption.ElasticMinimumTotalNodes; config.ElasticMaximumTotalNodes = elasticOption.ElasticMaximumTotalNodes; config.ElasticMinimumIdlingNodes = elasticOption.ElasticMinimumIdlingNodes; config.ElasticResizePeriod = elasticOption.ElasticResizePeriod; config.ElasticResizeFactor = elasticOption.ElasticResizeFactor; config.ElasticMinimumIdlingTime = elasticOption.ElasticMinimumIdlingTime; } return(config); }
protected string CreateJson(object obj) { try { return(JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented)); } catch (Newtonsoft.Json.JsonSerializationException ex) { CLILogs.Error(ex.Message); return("Value not found"); } }
private string CreateXML(object obj) { string jsonSerialize = JsonConvert.SerializeObject(obj); CLILogs.Debug(jsonSerialize); try { return(JsonConvert.DeserializeXNode(jsonSerialize, "Information", false).ToString()); } catch (Newtonsoft.Json.JsonSerializationException ex) { CLILogs.Error(ex.Message); return("Value not found"); } }
/// <summary> /// Main function, launch the program and return. /// </summary> /// <param name="args">Command-line arguments passed to the program.</param> /// <returns>0 if success or exit if fail.</returns> public static async Task <int> Main(string[] args) { int returnValue = 0; try { await CLI.StartCliAsync(args); } catch (NotImplementedException ex) { CLILogs.Error("NotImplementedException found"); CLILogs.Error(ex.ToString()); returnValue = 1; } catch (ParseVersionException) { CLILogs.Debug("version ask"); } catch (ParseHelpException) { CLILogs.Debug("help ask"); } catch (ParseException) { CLILogs.Debug("Parse error found"); returnValue = 1; } catch (System.IO.FileNotFoundException ex) { CLILogs.Error(ex.Message); returnValue = 1; } catch (CommandManager.ErrorPrintException) { CLILogs.Debug("Error catch in the launcher"); returnValue = 1; } return(returnValue); }