static void Main(string[] args) { var log = new CrmLog(true, LogLevel.Debug); log.InitOfflineLog("log.csv", false, new FileConfiguration { FileSplitMode = SplitMode.Size, MaxFileSize = 1024, FileDateFormat = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss-fff}" }); try { var settings = GetConfigurationParams(args); var service = ConnectToCrm(settings.ConnectionString, log); if (service == null) { return; } foreach (var solutionConfig in settings.SolutionConfigs) { try { var(solutionVersion, exportXml) = RetrieveSolution(solutionConfig.SolutionName, log, service); var outputPath = string.IsNullOrWhiteSpace(solutionConfig.OutputPath) ? settings.DefaultOutputPath : solutionConfig.OutputPath; var fullPath = BuildOutputPath(outputPath, solutionConfig.OutputFilename, solutionConfig.SolutionName, solutionVersion); Directory.CreateDirectory(outputPath); log.Log($"Writing solution to '{fullPath}'..."); File.WriteAllBytes($"{fullPath}", exportXml); log.Log($"Solution file written."); } catch (Exception e) { log.Log(e); } } } catch (Exception e) { log.Log(e); log.ExecutionFailed(); } finally { log.LogExecutionEnd(); } }
static int Main(string[] args) { args.RequireCountAtLeast(2, "Command Line Arguments", "A JSON file name must be passed to the program as argument."); var logLevel = ConfigurationManager.AppSettings["LogLevel"]; log = new CrmLog(true, (LogLevel)int.Parse(logLevel)); log.InitOfflineLog("log.csv", false, new FileConfiguration { FileSplitMode = SplitMode.Size, MaxFileSize = 1024, FileDateFormat = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss-fff}" }); try { ParseCmdArgs(args); foreach (var config in configs) { log.Log($"Parsing config file {config} ..."); var settings = GetConfigurationParams(config); var result = ProcessConfiguration(settings); log.Log($"Finished parsing config file {config}."); if (result > 0) { return(result); } } return(0); } catch (Exception e) { log.Log(e); log.ExecutionFailed(); return(1); } finally { log.LogExecutionEnd(); if (isPauseOnExit) { Console.WriteLine(); Console.WriteLine("Press any key to exit ..."); Console.ReadKey(); } } }