|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.IO;
|
| 4 | +using Microsoft.SqlServer.Management.Smo; |
4 | 5 | using Newtonsoft.Json;
|
| 6 | +using TEAM_Library; |
| 7 | +using static System.Net.Mime.MediaTypeNames; |
| 8 | +using static System.Runtime.InteropServices.JavaScript.JSType; |
5 | 9 |
|
6 | 10 | namespace Virtual_Data_Warehouse
|
7 | 11 | {
|
@@ -77,17 +81,24 @@ internal static string SaveTemplateCollection(string templateFilePath, string fi
|
77 | 81 | return returnMessage;
|
78 | 82 | }
|
79 | 83 |
|
80 |
| - internal static List<TemplateHandling> LoadTemplateCollection() |
| 84 | + internal static List<TemplateHandling> LoadTemplateCollection(EventLog eventLog) |
81 | 85 | {
|
82 | 86 | List<TemplateHandling> templateList = new List<TemplateHandling>();
|
83 | 87 |
|
84 |
| - // Retrieve the file contents and store in a string. |
85 |
| - if (File.Exists(FormBase.VdwConfigurationSettings.TemplatePath + FormBase.GlobalParameters.TemplateCollectionFileName)) |
| 88 | + try |
86 | 89 | {
|
87 |
| - var jsonInput = File.ReadAllText(FormBase.VdwConfigurationSettings.TemplatePath + FormBase.GlobalParameters.TemplateCollectionFileName); |
| 90 | + // Retrieve the file contents and store in a string. |
| 91 | + if (File.Exists(FormBase.VdwConfigurationSettings.TemplatePath + FormBase.GlobalParameters.TemplateCollectionFileName)) |
| 92 | + { |
| 93 | + var jsonInput = File.ReadAllText(FormBase.VdwConfigurationSettings.TemplatePath + FormBase.GlobalParameters.TemplateCollectionFileName); |
88 | 94 |
|
89 |
| - //Move the (json) string into a List object (a list of the type Template). |
90 |
| - templateList = JsonConvert.DeserializeObject<List<TemplateHandling>>(jsonInput); |
| 95 | + //Move the (json) string into a List object (a list of the type Template). |
| 96 | + templateList = JsonConvert.DeserializeObject<List<TemplateHandling>>(jsonInput); |
| 97 | + } |
| 98 | + } |
| 99 | + catch (Exception exception) |
| 100 | + { |
| 101 | + eventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An error was encountered loading the template collection from '{FormBase.VdwConfigurationSettings.TemplatePath + FormBase.GlobalParameters.TemplateCollectionFileName}. The error encountered was '{exception.Message}'.")); |
91 | 102 | }
|
92 | 103 |
|
93 | 104 | // Return the list to the instance
|
|
0 commit comments