| @@ -0,0 +1,396 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using Newtonsoft.Json; | |||||
| using System.IO; | |||||
| namespace importer | |||||
| { | |||||
| public class Global | |||||
| { | |||||
| private static Settings _settings; | |||||
| private static string _storageDir; | |||||
| public static string StorageDir { get { return _storageDir; } set { _storageDir = value; } } | |||||
| public static Settings Settings { get { return _settings; } set { _settings = value; } } | |||||
| public static string ServiceUrl | |||||
| { | |||||
| get | |||||
| { | |||||
| if (Program.Args[0] == "brandt") | |||||
| return JDISImport.ServiceUrl; | |||||
| else return string.Empty; | |||||
| } | |||||
| } | |||||
| public Global() { } | |||||
| public Global(string[] settingsFile) | |||||
| { | |||||
| if (IsWindows()) | |||||
| { | |||||
| Global.StorageDir = string.Format("C:/{0}/store/", settingsFile[0]).Replace("/", "\\"); | |||||
| } | |||||
| else if (IsMacOS()) | |||||
| { | |||||
| Global.StorageDir = string.Format("/Users/{0}/{1}/store/", settingsFile[1], settingsFile[0]); | |||||
| } | |||||
| else if (IsLinux()) | |||||
| { | |||||
| Global.StorageDir = string.Format("/home/{0}/{1}/store/", settingsFile[1], settingsFile[0]); | |||||
| } | |||||
| else | |||||
| { | |||||
| throw new Exception("OS cannot be detected."); | |||||
| } | |||||
| Global.Settings = new Settings(); | |||||
| string path = Path.Combine(Global.StorageDir, string.Format("{0}.json", settingsFile[0])); | |||||
| string text = File.ReadAllText(path); | |||||
| Global.Settings = JsonConvert.DeserializeObject<Settings>(text); | |||||
| } | |||||
| public static bool IsWindows() => | |||||
| System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); | |||||
| public static bool IsMacOS() => | |||||
| System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX); | |||||
| public static bool IsLinux() => | |||||
| System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux); | |||||
| public static DateTime DateFormatter(string d, bool hastime = true) | |||||
| { | |||||
| string month, day, year, time; | |||||
| DateTime dt = new DateTime(); | |||||
| if (d.IndexOf("JAN") != -1) | |||||
| { | |||||
| month = "01"; | |||||
| d = d.Replace("JAN", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("FEB") != -1) | |||||
| { | |||||
| month = "02"; | |||||
| d = d.Replace("FEB", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("MARCH") != -1) | |||||
| { | |||||
| month = "03"; | |||||
| d = d.Replace("MARCH", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("MAR") != -1) | |||||
| { | |||||
| month = "03"; | |||||
| d = d.Replace("MAR", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("APRIL") != -1) | |||||
| { | |||||
| month = "04"; | |||||
| d = d.Replace("APRIL", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("APR") != -1) | |||||
| { | |||||
| month = "04"; | |||||
| d = d.Replace("APR", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("MAY") != -1) | |||||
| { | |||||
| month = "05"; | |||||
| d = d.Replace("MAY", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("JUNE") != -1) | |||||
| { | |||||
| month = "06"; | |||||
| d = d.Replace("JUNE", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("JUN") != -1) | |||||
| { | |||||
| month = "06"; | |||||
| d = d.Replace("JUN", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("JULY") != -1) | |||||
| { | |||||
| month = "07"; | |||||
| d = d.Replace("JULY", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("JUL") != -1) | |||||
| { | |||||
| month = "07"; | |||||
| d = d.Replace("JUL", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("AUG") != -1) | |||||
| { | |||||
| month = "08"; | |||||
| d = d.Replace("AUG", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("SEPT") != -1) | |||||
| { | |||||
| month = "09"; | |||||
| d = d.Replace("SEPT", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("SEP") != -1) | |||||
| { | |||||
| month = "09"; | |||||
| d = d.Replace("SEP", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("OCT") != -1) | |||||
| { | |||||
| month = "10"; | |||||
| d = d.Replace("OCT", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("0CT") != -1) | |||||
| { | |||||
| month = "10"; | |||||
| d = d.Replace("0CT", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else if (d.IndexOf("NOV") != -1) | |||||
| { | |||||
| month = "11"; | |||||
| d = d.Replace("NOV", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| else | |||||
| { | |||||
| month = "12"; | |||||
| d = d.Replace("DEC", "|"); | |||||
| day = d.Substring(0, d.IndexOf("|")); | |||||
| year = d.Substring(d.IndexOf("|") + 1, 4); | |||||
| if (hastime) | |||||
| time = d.Substring(d.IndexOf(":") - 3 + 2); | |||||
| else time = "00:00:00.000"; | |||||
| string date = string.Format("{0}-{1}-{2} {3}", year, month, day, time); | |||||
| dt = DateTime.Parse(date); | |||||
| } | |||||
| return dt; | |||||
| } | |||||
| } | |||||
| public static class Deserialize | |||||
| { | |||||
| public static T FromJson<T>(string json) | |||||
| { | |||||
| //Console.WriteLine(json); | |||||
| return JsonConvert.DeserializeObject<T>(json, Converter.Settings); | |||||
| } | |||||
| } | |||||
| public static class Serialize | |||||
| { | |||||
| public static string ToJson<T>(this T self) | |||||
| { | |||||
| return JsonConvert.SerializeObject(self, Converter.Settings); | |||||
| } | |||||
| } | |||||
| internal static class Converter | |||||
| { | |||||
| public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | |||||
| { | |||||
| MetadataPropertyHandling = MetadataPropertyHandling.Ignore, | |||||
| DateParseHandling = DateParseHandling.None, | |||||
| DateFormatHandling = DateFormatHandling.MicrosoftDateFormat, | |||||
| }; | |||||
| } | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Settings | |||||
| { | |||||
| [JsonProperty(PropertyName = "Remote")] | |||||
| public bool Remote { get; set; } | |||||
| [JsonProperty(PropertyName = "LogFile")] | |||||
| public string LogFile { get; set; } | |||||
| [JsonProperty(PropertyName = "MailProperties")] | |||||
| public MailProperties MailProperties { get; set; } | |||||
| [JsonProperty(PropertyName = "Prelub")] | |||||
| public Prelub Prelub { get; set; } | |||||
| [JsonProperty(PropertyName = "Customer")] | |||||
| public string Customer { get; set; } | |||||
| } | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class MailProperties | |||||
| { | |||||
| [JsonProperty(PropertyName = "AppID")] | |||||
| public string AppID { get; set; } | |||||
| [JsonProperty(PropertyName = "TenentID")] | |||||
| public string TenentID { get; set; } | |||||
| [JsonProperty(PropertyName = "ObjectId")] | |||||
| public string ObjectId { get; set; } | |||||
| [JsonProperty(PropertyName = "SecretID")] | |||||
| public string SecretID { get; set; } | |||||
| [JsonProperty(PropertyName = "SecretV")] | |||||
| public string SecretV { get; set; } | |||||
| [JsonProperty(PropertyName = "Mailbox")] | |||||
| public string Mailbox { get; set; } | |||||
| [JsonProperty(PropertyName = "Url")] | |||||
| public string Url { get; set; } | |||||
| [JsonProperty(PropertyName = "Password")] | |||||
| public string Password { get; set; } | |||||
| [JsonProperty(PropertyName = "Username")] | |||||
| public string Username { get; set; } | |||||
| [JsonProperty(PropertyName = "Scope")] | |||||
| public string Scope { get; set; } | |||||
| [JsonProperty(PropertyName = "Filter")] | |||||
| public string Filter { get; set; } | |||||
| } | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Prelub | |||||
| { | |||||
| [JsonProperty(PropertyName = "LocalService")] | |||||
| public string LocalService { get; set; } | |||||
| [JsonProperty(PropertyName = "RemoteService")] | |||||
| public string RemoteService { get; set; } | |||||
| } | |||||
| } | |||||
| /* | |||||
| { | |||||
| "MailProperties": { | |||||
| "Username": "mcarman@prelub.com", | |||||
| "Password": "Gr@nt@cc3$$", | |||||
| "Mailbox": 4, | |||||
| "Url": "https://outlook.office365.com/ews/Exchange.asmx", | |||||
| "Filter": "Brandt Import, brandt import, Brandt import, brandt Import, BRANDT IMPORT", | |||||
| "AppID": "489776b1-ee79-4b14-bc44-9f6bf47332db", | |||||
| "TenentID": "1fd06c96-d3a4-45e9-9ed7-bcecb394d277", | |||||
| "ObjectId": "c7647074-edb6-4e8e-8a01-a1ed924fdae9", | |||||
| "SecretID": "cba04a6c-a233-4646-909b-b50921edbe1c", | |||||
| "SecretV": "up-8Q~y46~JyQZjJlsAJ-zpXpglpmuPIJ1Gx3a2O" | |||||
| }, | |||||
| "Remote": false, | |||||
| "LogFile": "jdis.log", | |||||
| "Prelub": { | |||||
| "LocalService": "http://servicesbrandt.rpmindustries.com:8081", | |||||
| "RemoteService": "https://servicesbrandt.rpmindustries.com" | |||||
| } | |||||
| } | |||||
| */ | |||||
| @@ -0,0 +1,18 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| namespace importer.ImportObjects | |||||
| { | |||||
| public class CustomerImport | |||||
| { | |||||
| public string Number { get; set; } | |||||
| public string Name { get; set; } | |||||
| public string Addr1 { get; set; } | |||||
| public string Addr2 { get; set; } | |||||
| public string City { get; set; } | |||||
| public string State { get; set; } | |||||
| public string Zip { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,28 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using importer.RestObjects; | |||||
| namespace importer.ImportObjects | |||||
| { | |||||
| public class EquipmentImport | |||||
| { | |||||
| public bool IsNew { get; set; } | |||||
| public int MID { get; set; } | |||||
| public string Make { get; set; } | |||||
| public string Model { get; set; } | |||||
| public string SerialNumber { get; set; } | |||||
| public string EquipmentNumber { get; set; } | |||||
| public string MeterReading { get; set; } | |||||
| public static int MachineExists(string serialNumber) | |||||
| { | |||||
| Dictionary<string, string> search = new Dictionary<string, string>(); | |||||
| search.Add("search", serialNumber); | |||||
| RESTService svc = new RESTService(); | |||||
| List<Equipment> machines = svc.RestGet<Equipment>("Equipments.svc", search); | |||||
| if (machines.Count > 0) return machines.LastOrDefault().ID; | |||||
| else return 0; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| namespace importer.ImportObjects | |||||
| { | |||||
| public class PartImport | |||||
| { | |||||
| public string Qty { get; set; } | |||||
| public string Number { get; set; } | |||||
| public string Description { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| namespace importer.ImportObjects | |||||
| { | |||||
| public class WorkOrderImport | |||||
| { | |||||
| public DateTime CreateDate { get; set; } | |||||
| public DateTime OpnDt { get; set; } | |||||
| public string Number { get; set; } | |||||
| public string Segment { get; set; } | |||||
| public string InspectionLevel { get; set; } | |||||
| public string TechnicianUserID { get; set; } | |||||
| public DateTime ScheduledStartDate { get; set; } | |||||
| public string InspectionInterval { get; set; } | |||||
| public string InspectionType { get; set; } | |||||
| public string CodeAndDescriptionOriginal { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,536 @@ | |||||
| using System.Security.Principal; | |||||
| using System; | |||||
| using System.Text; | |||||
| using System.Linq; | |||||
| using System.Collections.Generic; | |||||
| using importer.RestObjects; | |||||
| using importer.ImportObjects; | |||||
| using System.IO; | |||||
| namespace importer | |||||
| { | |||||
| public class JDISImport | |||||
| { | |||||
| private static string _serviceUrl; | |||||
| private static RESTService _rservice; | |||||
| private static List<Customer> _customers; | |||||
| private static List<Make> _makes; | |||||
| private static List<Product> _products; | |||||
| private static List<Model> _models; | |||||
| private static List<InspectionType> _inspectionTypes; | |||||
| private static List<Template> _templates; | |||||
| private static List<User> _users; | |||||
| private static Status _status; | |||||
| private static Priority _priority; | |||||
| private static Reason _reason; | |||||
| public static string ServiceUrl { get { return _serviceUrl; } set { _serviceUrl = value; } } | |||||
| public static Dictionary<string, int> InspectionType; | |||||
| private static List<string> WriteFileToText(string file) | |||||
| { | |||||
| List<string> list = new List<string>(); | |||||
| string txt = string.Empty; | |||||
| using (StreamReader sr = new StreamReader(file)) | |||||
| { | |||||
| txt = sr.ReadToEnd().Trim(); | |||||
| txt = txt.Replace("\r\r\r", ""); | |||||
| txt = txt.Replace("\r\r", ""); | |||||
| txt = txt.Replace("\r", ""); | |||||
| sr.Close(); | |||||
| } | |||||
| string[] array = txt.Trim().Split('\n'); | |||||
| list.AddRange(array); | |||||
| return list; | |||||
| } | |||||
| private static string[] RemoveWhiteSpace(ref List<string> filelines) | |||||
| { | |||||
| for (int i = filelines.Count - 1; i >= 0; i--) | |||||
| { | |||||
| if (string.IsNullOrEmpty(filelines[i])) filelines.RemoveAt(i); | |||||
| } | |||||
| return filelines.ToArray(); | |||||
| } | |||||
| private static void Line1(string currentline, ref ToDo todo) | |||||
| { | |||||
| string strDate = currentline.Substring(5, currentline.IndexOf("*") - 6); | |||||
| strDate = strDate.Trim(); | |||||
| strDate.Replace(" ", " "); | |||||
| todo.WorkOrder.CreateDate = Global.DateFormatter(strDate); | |||||
| } | |||||
| private static void Line2(string currentline, ref ToDo todo) | |||||
| { | |||||
| string strWONum = currentline.Substring(currentline.IndexOf("Work Order") + 10, 12); | |||||
| strWONum = strWONum.Trim(); | |||||
| todo.WorkOrder.Number = strWONum; | |||||
| todo.WorkOrderNumber = strWONum; | |||||
| string strSeg = currentline.Substring(currentline.IndexOf("Seg.") + 4, 25); | |||||
| strSeg = strSeg.Trim(); | |||||
| todo.WorkOrder.Segment = strSeg; | |||||
| string strODate = currentline.Substring(currentline.IndexOf("Opn Dt") + 6); | |||||
| strODate = strODate.Trim(); | |||||
| todo.WorkOrder.OpnDt = Global.DateFormatter(strODate, false); | |||||
| } | |||||
| private static void Line5678(string currentline, ref ToDo todo, int lineNumber) | |||||
| { | |||||
| if (lineNumber == 5) | |||||
| { | |||||
| todo.Customer.Name = currentline.Substring(3, 25); | |||||
| todo.Customer.Number = currentline.Substring(38, 10); | |||||
| } | |||||
| if (lineNumber == 6) | |||||
| { | |||||
| todo.Customer.Addr1 = currentline.Substring(3, 25); | |||||
| } | |||||
| if (lineNumber == 7) | |||||
| { | |||||
| todo.Customer.Addr2 = currentline.Substring(3, 25); | |||||
| } | |||||
| if (lineNumber == 8) | |||||
| { | |||||
| int comma = currentline.IndexOf(","); | |||||
| int length = currentline.Length - 3; | |||||
| todo.Customer.City = (comma == -1) ? "" : currentline.Substring(3, comma - 3); | |||||
| todo.Customer.State = currentline.Substring(currentline.IndexOf(",") + 2, 2); | |||||
| todo.Customer.Zip = currentline.Substring(comma + 5, 7); | |||||
| } | |||||
| } | |||||
| private static void Line11(string currentline, ref ToDo todo) | |||||
| { | |||||
| todo.Equipment.Make = currentline.Substring(0, 8).Trim(); | |||||
| todo.Equipment.Model = currentline.Substring(8, 14).Trim(); | |||||
| todo.Equipment.SerialNumber = currentline.Substring(22, 22).Trim(); | |||||
| todo.Equipment.EquipmentNumber = currentline.Substring(42, 16).Trim(); | |||||
| todo.Equipment.MeterReading = currentline.Substring(60, 7).Trim(); | |||||
| todo.Equipment.MID = EquipmentImport.MachineExists(todo.Equipment.SerialNumber); | |||||
| if (todo.Equipment.MID == 0) todo.Equipment.IsNew = true; | |||||
| else todo.Equipment.IsNew = false; | |||||
| } | |||||
| private static void CreateAPart(string currentline, ref ToDo todo) | |||||
| { | |||||
| PartImport pt = new PartImport(); | |||||
| string sline = currentline.Substring(19).Trim(); | |||||
| //pt.Description = currentline.Substring(34, 14); | |||||
| pt.Number = sline.Substring(0, sline.IndexOf(" ")); | |||||
| sline = sline.Substring(sline.IndexOf(" ")).Trim(); | |||||
| pt.Description = sline.Substring(0, sline.IndexOf(" ")).Trim(); | |||||
| pt.Qty = currentline.Substring(0, currentline.IndexOf(" ")).Trim(); | |||||
| todo.Parts.Add(pt); | |||||
| } | |||||
| private static void PMInterval(string currentline, ref ToDo todo, ref bool isSpecial) | |||||
| { | |||||
| isSpecial = false; | |||||
| string pminterval = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| pminterval = pminterval.Substring(0, pminterval.IndexOf(" ")).Trim(); | |||||
| if (XMLData.IntervalLookup.ContainsKey(pminterval)) todo.WorkOrder.InspectionLevel = XMLData.IntervalLookup[pminterval].ToString(); | |||||
| if (!string.IsNullOrEmpty(todo.WorkOrder.InspectionLevel)) todo.WorkOrder.InspectionInterval = pminterval; | |||||
| string strService = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| strService = strService.Substring(strService.IndexOf(" ") + 1).Trim(); | |||||
| strService = strService.Substring(0, strService.IndexOf(" ") + 1).Trim(); | |||||
| if (strService.IndexOf(" ") > 0) | |||||
| strService = strService.Substring(0, strService.IndexOf(" ")).Trim(); | |||||
| if (InspectionType.ContainsKey(strService)) | |||||
| todo.WorkOrder.InspectionType = InspectionType[strService].ToString(); | |||||
| else todo.WorkOrder.InspectionType = InspectionType["PM"].ToString(); | |||||
| string codeanddescriptionoriginal = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| codeanddescriptionoriginal = codeanddescriptionoriginal.Substring(0, codeanddescriptionoriginal.IndexOf(" T") - 3).Trim(); | |||||
| todo.WorkOrder.CodeAndDescriptionOriginal = codeanddescriptionoriginal; | |||||
| } | |||||
| private static void EmpID(string currentline, ref ToDo todo, ref bool isSpecial) | |||||
| { | |||||
| isSpecial = false; | |||||
| string empid = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| empid = empid.Substring(0, empid.IndexOf(" ")).Trim(); | |||||
| todo.WorkOrder.TechnicianUserID = empid; | |||||
| } | |||||
| private static void PromiseDate(string currentline, ref ToDo todo, ref bool isSpecial) | |||||
| { | |||||
| isSpecial = false; | |||||
| string promisedate = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| promisedate = promisedate.Substring(0, promisedate.IndexOf(" ")).Trim(); | |||||
| todo.WorkOrder.ScheduledStartDate = Global.DateFormatter(promisedate, false); | |||||
| } | |||||
| private static void SpecialInstructions(string currentline, ref ToDo todo, ref bool isSpecial, ref StringBuilder sb) | |||||
| { | |||||
| isSpecial = true; | |||||
| string special = currentline.Substring(currentline.IndexOf(":") + 2); | |||||
| special = special.Substring(0, special.IndexOf(" T") - 1).Trim(); | |||||
| sb.Append(special); | |||||
| } | |||||
| private static void Line14AndUp(string currentline, ref ToDo todo, ref bool isSpecial, ref StringBuilder sb) | |||||
| { | |||||
| if (currentline.EndsWith(" T")) | |||||
| { | |||||
| if (currentline.Contains("PM LEVEL")) isSpecial = false; | |||||
| else if (currentline.Contains("PM INTERVAL")) PMInterval(currentline, ref todo, ref isSpecial); | |||||
| else if (currentline.Contains("EMPID")) EmpID(currentline, ref todo, ref isSpecial); | |||||
| else if (currentline.Contains("PROMISE DATE")) PromiseDate(currentline, ref todo, ref isSpecial); | |||||
| else if (currentline.Contains("SPECIAL INSTRUCTIONS")) SpecialInstructions(currentline, ref todo, ref isSpecial, ref sb); | |||||
| else | |||||
| { | |||||
| if (isSpecial) | |||||
| { | |||||
| string addspecial = currentline.Substring(0, currentline.IndexOf(" T") - 1).Trim(); | |||||
| sb.Append(string.Format(" {0}", addspecial)); | |||||
| } | |||||
| } | |||||
| } | |||||
| else //Decide if it is a part | |||||
| { | |||||
| isSpecial = false; | |||||
| int qty = 0; | |||||
| if (currentline.Length > 0) | |||||
| { | |||||
| string input = currentline.Substring(0, (currentline.IndexOf(" ") == -1) ? 1 : currentline.IndexOf(" ")).Trim(); | |||||
| if (int.TryParse(input, out qty)) | |||||
| { | |||||
| if (qty < 100 && !currentline.Contains("HR")) | |||||
| { | |||||
| CreateAPart(currentline, ref todo); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| private static Customer IsNewCustomer(string name) | |||||
| { | |||||
| List<Customer> list = _customers.FindAll(x => x.Name.Trim() == name.Trim()); | |||||
| if (list.Count > 1) | |||||
| return list[list.Count - 1]; | |||||
| else if (list.Count == 1) | |||||
| return list[0]; | |||||
| else return null; | |||||
| } | |||||
| private static Customer CreateNewCustomer(ToDo todo) | |||||
| { | |||||
| Customer cust = new Customer(); | |||||
| cust.Name = todo.Customer.Name; | |||||
| cust.Address = todo.Customer.Addr1; | |||||
| cust.Address2 = todo.Customer.Addr2; | |||||
| cust.City = todo.Customer.City; | |||||
| cust.State = todo.Customer.State; | |||||
| cust.CreateDate = DateTime.Now; | |||||
| cust.CreateUserID = -1; | |||||
| cust.UpdateDate = DateTime.Now; | |||||
| cust.UpdateUserID = -1; | |||||
| cust.IsActive = true; | |||||
| cust.Number = todo.Customer.Number; | |||||
| cust.ZipCode = todo.Customer.Zip; | |||||
| string json = Serialize.ToJson<Customer>(cust); | |||||
| cust = _rservice.PostRest<Customer>(json, "customers.svc"); | |||||
| return cust; | |||||
| } | |||||
| private static Model CreateNewModel(Product defaultP, ToDo todo) | |||||
| { | |||||
| Model mdl = new Model(); | |||||
| //Find the Make and assign the default Product | |||||
| mdl.Name = todo.Equipment.Model.Trim(); | |||||
| mdl.IsActive = true; | |||||
| mdl.CreateDate = DateTime.Now; | |||||
| mdl.CreateUserID = -1; | |||||
| mdl.UpdateDate = DateTime.Now; ; | |||||
| mdl.UpdateUserID = -1; | |||||
| mdl.Product = defaultP; | |||||
| Make mk = (from x in _makes where x.Name.Trim() == todo.Equipment.Make.Trim() select x).FirstOrDefault(); | |||||
| if (mk == null) | |||||
| { | |||||
| //Create new Make | |||||
| mk.Name = todo.Equipment.Make.Trim(); | |||||
| mk.CreateDate = DateTime.Now; | |||||
| mk.CreateUserID = -1; | |||||
| mk.UpdateDate = DateTime.Now; | |||||
| mk.UpdateUserID = -1; | |||||
| mk.IsActive = true; | |||||
| mk.Description = todo.Equipment.Make.Trim(); | |||||
| string mkJson = Serialize.ToJson<Make>(mk); | |||||
| mk = _rservice.PostRest<Make>(mkJson, "makes.svc"); | |||||
| } | |||||
| mdl.Make = mk; | |||||
| string json = Serialize.ToJson<Model>(mdl); | |||||
| mdl = _rservice.PostRest<Model>(json, "models.svc"); | |||||
| return mdl; | |||||
| } | |||||
| private static Equipment CreateNewMachine(Model mdl, Customer cust, ToDo todo) | |||||
| { | |||||
| Equipment newMachine = new Equipment(); | |||||
| newMachine.Model = mdl; | |||||
| newMachine.Make = mdl.Make; | |||||
| newMachine.Product = mdl.Product; | |||||
| newMachine.BarcodeID = null; | |||||
| newMachine.CreateDate = DateTime.Now; | |||||
| newMachine.UpdateDate = DateTime.Now; | |||||
| newMachine.UpateUserID = -1; | |||||
| newMachine.CreateUserID = -1; | |||||
| newMachine.Description = todo.Equipment.SerialNumber; | |||||
| newMachine.IsActive = true; | |||||
| newMachine.LastServiceDate = null; | |||||
| newMachine.Location = null; | |||||
| newMachine.ManufacturerYear = "2000"; | |||||
| newMachine.MeterReading = todo.Equipment.MeterReading; | |||||
| newMachine.Number = todo.Equipment.EquipmentNumber; | |||||
| newMachine.Odometer = null; | |||||
| newMachine.SerialNumber = todo.Equipment.SerialNumber; | |||||
| newMachine.Customer = cust; | |||||
| string eqJson = Serialize.ToJson<Equipment>(newMachine); | |||||
| newMachine = _rservice.PostRest<Equipment>(eqJson, "Equipments.svc"); | |||||
| return newMachine; | |||||
| } | |||||
| private static List<Equipment> IsNewMachine(string serial) | |||||
| { | |||||
| Dictionary<string, string> ps = new Dictionary<string, string>(); | |||||
| ps.Add("search", serial); | |||||
| List<Equipment> machines = _rservice.RestGet<Equipment>("equipments.svc", ps); | |||||
| return machines; | |||||
| } | |||||
| private static void APIPush(ref ToDo todo) | |||||
| { | |||||
| Equipment machine = new Equipment(); | |||||
| string strModel = todo.Equipment.Model.Trim(); | |||||
| Model mdl = _models.Find(x => x.Name.Trim() == strModel); | |||||
| Product defaultP = _products.Find(x => x.ID == 14); | |||||
| //Customer cust = new Customer(); | |||||
| Customer cust = IsNewCustomer(todo.Customer.Name); | |||||
| if (cust == null) | |||||
| cust = CreateNewCustomer(todo); | |||||
| List<Equipment> equipment = IsNewMachine(todo.Equipment.SerialNumber); | |||||
| todo.Equipment.IsNew = equipment.Count == 0; | |||||
| if (todo.Equipment.IsNew) | |||||
| { | |||||
| bool isNewModel = mdl == null; | |||||
| if (isNewModel) | |||||
| { | |||||
| string sModel = todo.Equipment.Model.Trim().Substring(0, todo.Equipment.Model.Length - 1); | |||||
| mdl = (from x in _models where x.Name.Contains(sModel) orderby x.ID select x).LastOrDefault(); | |||||
| if (mdl == null) | |||||
| mdl = CreateNewModel(defaultP, todo); | |||||
| else | |||||
| machine = CreateNewMachine(mdl, cust, todo); | |||||
| } | |||||
| else | |||||
| { | |||||
| machine = CreateNewMachine(mdl, cust, todo); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| string eqSerial = todo.Equipment.SerialNumber.Trim(); | |||||
| List<Equipment> eqlist = equipment.FindAll(x => x.SerialNumber == eqSerial); | |||||
| machine = eqlist[eqlist.Count - 1]; | |||||
| machine.Customer = cust; | |||||
| } | |||||
| //Find the Template | |||||
| string il = todo.WorkOrder.InspectionLevel.Trim(); | |||||
| string it = todo.WorkOrder.InspectionType.Trim(); | |||||
| string eqmdl = todo.Equipment.Model.Trim(); | |||||
| Template template = _templates.Find(x => x.InspectionLevel.ID == Convert.ToInt32(il) && x.InspectionType.ID == Convert.ToInt32(it) && x.Name == eqmdl); | |||||
| if (template == null) | |||||
| { | |||||
| //Search by model prefix and get the last one | |||||
| string prefix = todo.Equipment.Model.Trim(); | |||||
| prefix = prefix.Substring(0, prefix.Length - 1); | |||||
| template = (from x in _templates where x.InspectionLevel.ID == Convert.ToInt32(il) && x.InspectionType.ID == Convert.ToInt32(it) && x.Name.Contains(prefix) orderby x.ID select x).LastOrDefault(); | |||||
| if (template == null || template.ID == 0) | |||||
| { | |||||
| todo.Success = false; | |||||
| todo.Validation = todo.Validation + " No template for this model."; | |||||
| } | |||||
| } | |||||
| string tuid = todo.WorkOrder.TechnicianUserID.Trim(); | |||||
| User user = _users.Find(x => x.Number == tuid); | |||||
| WorkOrder workorder = new WorkOrder(); | |||||
| workorder.Number = todo.WorkOrder.Number;// wo.Number; | |||||
| workorder.Technician = user; | |||||
| workorder.Reason = _reason; | |||||
| workorder.Priority = _priority; | |||||
| workorder.Status = _status; | |||||
| workorder.CreateDate = DateTime.Now; | |||||
| workorder.CreateUserID = -1; | |||||
| workorder.Equipment = machine; | |||||
| workorder.Customer = cust; | |||||
| string mtrReading = todo.Equipment.MeterReading; | |||||
| workorder.MeterReading = Convert.ToDecimal(mtrReading); | |||||
| workorder.ScheduledStartDate = todo.WorkOrder.OpnDt;// wo.OpnDt; | |||||
| workorder.ScheduledEndDate = todo.WorkOrder.OpnDt.AddDays(1d); | |||||
| workorder.UpdateDate = DateTime.Now; | |||||
| workorder.UpdateUserID = -1; | |||||
| string woJson = Serialize.ToJson<WorkOrder>(workorder); | |||||
| //Console.WriteLine("WorkOrder Object"); | |||||
| //Console.WriteLine(); | |||||
| //Console.WriteLine(woJson); | |||||
| //JDISLog.WriteToLog(_logFile, string.Format("Creating Work Order: {0}", workorder.Number)); | |||||
| workorder = _rservice.PostRest<WorkOrder>(woJson, "workorders.svc"); | |||||
| if (workorder.ID != 0) todo.Success = true; | |||||
| if (template == null || template.ID == 0) | |||||
| { | |||||
| todo.Validation = string.Format("Work Order {0} was created but there is no template matching model # {1}", workorder.Number, mdl.Name); | |||||
| todo.Success = false; | |||||
| } | |||||
| else | |||||
| { | |||||
| //JDISLog.WriteToLog(_logFile, String.Format("Creating Inspections for Workorder {0}", workorder.Number)); | |||||
| Dictionary<string, string> tps = new Dictionary<string, string>(); | |||||
| tps.Add("create", string.Format("{0}/{1}/{2}", template.ID, workorder.ID, -1)); | |||||
| Inspection i = _rservice.RestGet<Inspection>(true, "inspections.svc", tps); | |||||
| tps["create"] = string.Format("{0}/{1}/{2}", 1691, workorder.ID, -1); | |||||
| Inspection sta = _rservice.RestGet<Inspection>(true, "inspections.svc", tps); | |||||
| if (i != null && i.ID != 0) | |||||
| { | |||||
| todo.Success = true; | |||||
| } | |||||
| } | |||||
| } | |||||
| private static void ReadFile(ref ToDo todo) | |||||
| { | |||||
| todo.PathToFile = Path.Combine(Global.StorageDir, todo.FileName); | |||||
| todo.Customer = new CustomerImport(); | |||||
| todo.WorkOrder = new WorkOrderImport(); | |||||
| todo.Equipment = new EquipmentImport(); | |||||
| todo.Parts = new List<PartImport>(); | |||||
| string filemove = string.Empty; | |||||
| string filetxt = string.Empty; | |||||
| string inspectionLevel = string.Empty; | |||||
| bool isSpecial = false; | |||||
| StringBuilder specialInstructions = new StringBuilder(); | |||||
| int line = 1; | |||||
| try | |||||
| { | |||||
| List<string> filelines = WriteFileToText(todo.PathToFile); | |||||
| string[] lines = RemoveWhiteSpace(ref filelines); | |||||
| foreach (string s in lines) | |||||
| { | |||||
| string currentline = s.Trim().Replace("'", "''"); | |||||
| if (currentline.Contains("Page") && currentline.Substring(78).Trim() != "1") | |||||
| line = 18; | |||||
| if (currentline.Contains("Page") && currentline.Substring(78).Trim() == "1") | |||||
| line = 1; | |||||
| switch (line) | |||||
| { | |||||
| case 1: | |||||
| Line1(currentline, ref todo); | |||||
| break; | |||||
| case 2: | |||||
| Line2(currentline, ref todo); | |||||
| break; | |||||
| case 5: | |||||
| case 6: | |||||
| case 7: | |||||
| case 8: | |||||
| Line5678(currentline, ref todo, line); | |||||
| break; | |||||
| case 11: | |||||
| Line11(currentline, ref todo); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| if (line > 14) | |||||
| { | |||||
| Line14AndUp(currentline, ref todo, ref isSpecial, ref specialInstructions); | |||||
| } | |||||
| line++; | |||||
| } | |||||
| if (todo.WorkOrder.ScheduledStartDate == DateTime.MinValue) todo.WorkOrder.ScheduledStartDate = DateTime.Now; | |||||
| // List<CSVObject> list = new List<CSVObject>(); | |||||
| // List<CSVObject> exceptions = new List<CSVObject>(); | |||||
| if (todo.Parts.Count == 0) | |||||
| { | |||||
| PartImport p = new PartImport(); | |||||
| p.Description = string.Empty; | |||||
| p.Qty = string.Empty; | |||||
| p.Number = string.Empty; | |||||
| todo.Parts.Add(p); | |||||
| } | |||||
| APIPush(ref todo); | |||||
| } | |||||
| catch (Exception ex) | |||||
| { | |||||
| Console.WriteLine(ex.Message); | |||||
| } | |||||
| } | |||||
| public static void BeginImport(List<ToDo> todos) | |||||
| { | |||||
| for (int i = 0; i < todos.Count; i++) | |||||
| { | |||||
| ToDo todo = todos[i]; | |||||
| XMLData.BuildIntervalLookup(); | |||||
| GetInspectionTypes(); | |||||
| ReadFile(ref todo); | |||||
| todos[i] = todo; | |||||
| } | |||||
| } | |||||
| public static void GetInspectionTypes() | |||||
| { | |||||
| List<InspectionType> list = _rservice.RestGet<InspectionType>("inspectiontypes.svc"); | |||||
| InspectionType = new Dictionary<string, int>(); | |||||
| foreach (InspectionType t in list) | |||||
| { | |||||
| InspectionType.Add(t.Name, t.ID); | |||||
| } | |||||
| } | |||||
| public static void BuildDefaults() | |||||
| { | |||||
| if (Global.Settings.Remote) | |||||
| _serviceUrl = Global.Settings.Prelub.RemoteService; | |||||
| else _serviceUrl = Global.Settings.Prelub.LocalService; | |||||
| _rservice = new RESTService(); | |||||
| _customers = _rservice.RestGet<Customer>("customers.svc"); | |||||
| _makes = _rservice.RestGet<Make>("makes.svc"); | |||||
| _products = _rservice.RestGet<Product>("products.svc"); | |||||
| _models = _rservice.RestGet<Model>("models.svc"); | |||||
| _inspectionTypes = _rservice.RestGet<InspectionType>("inspectionTypes.svc"); | |||||
| _templates = _rservice.RestGet<Template>("templates.svc"); | |||||
| _users = _rservice.RestGet<User>("users.svc"); | |||||
| _status = new Status(); | |||||
| _status.ID = 1; | |||||
| _status.Name = "Open"; | |||||
| _priority = new Priority(); | |||||
| _priority.ID = 3; | |||||
| _priority.Name = "Medium"; | |||||
| _reason = new Reason(); | |||||
| _reason.ID = 9; | |||||
| _reason.Name = "Cust. Request"; | |||||
| _reason.IsActive = true; | |||||
| _reason.CreateDate = new DateTime(2013, 10, 1, 9, 23, 7); | |||||
| _reason.CreateUserID = -1; | |||||
| _reason.UpdateDate = new DateTime(2013, 10, 1, 9, 23, 7); | |||||
| _reason.UpdateUserID = -1; | |||||
| } | |||||
| } | |||||
| public class JDISLog | |||||
| { | |||||
| public static void WriteToLog(string logFile, string msg) | |||||
| { | |||||
| using (StreamWriter sw = File.AppendText(logFile)) | |||||
| { | |||||
| sw.WriteLine(msg); | |||||
| } | |||||
| } | |||||
| public static void Begin(string logFile) | |||||
| { | |||||
| using (StreamWriter sw = File.AppendText(logFile)) | |||||
| { | |||||
| sw.WriteLine(); | |||||
| sw.WriteLine("###########################################################################"); | |||||
| sw.WriteLine(string.Format("Service Started @ {0}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString())); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,194 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Threading.Tasks; | |||||
| using System.Timers; | |||||
| using Microsoft.Identity.Client; | |||||
| using Microsoft.Exchange.WebServices.Data; | |||||
| using System.IO; | |||||
| using importer.ImportObjects; | |||||
| namespace importer | |||||
| { | |||||
| class Program | |||||
| { | |||||
| private static List<ToDo> _todos; | |||||
| private static string _jdislog; | |||||
| private static string[] _args; | |||||
| public static string[] Args { get { return _args; } set { _args = value; } } | |||||
| private static int[] TimeParts(int t) | |||||
| { | |||||
| string st = t.ToString(); | |||||
| if (st.Length == 1) st = "0" + st; | |||||
| string st1 = st.Substring(0, 1); | |||||
| string st2 = st.Substring(1, 1); | |||||
| int[] ints = new int[2]; | |||||
| ints[0] = Convert.ToInt32(st1); | |||||
| ints[1] = Convert.ToInt32(st2); | |||||
| return ints; | |||||
| } | |||||
| static async System.Threading.Tasks.Task Main(string[] args) | |||||
| { | |||||
| bool hasRun = false; | |||||
| _args = args; | |||||
| Global global = new Global(args); | |||||
| if (_args[0] == "brandt") | |||||
| { | |||||
| _jdislog = Path.Combine(Global.StorageDir, "jdis.log"); | |||||
| JDISLog.Begin(_jdislog); | |||||
| JDISImport.BuildDefaults(); | |||||
| for (; ; ) | |||||
| { | |||||
| int minute = DateTime.Now.Minute; | |||||
| int[] timeParts = TimeParts(minute); | |||||
| if ( | |||||
| (timeParts[0] == 0 && timeParts[1] == 0) || | |||||
| (timeParts[0] == 1 && timeParts[1] == 5) || | |||||
| (timeParts[0] == 3 && timeParts[1] == 0) || | |||||
| (timeParts[0] == 4 && timeParts[1] == 5) || | |||||
| (timeParts[0] == 0 && timeParts[1] == 5) | |||||
| ) | |||||
| { | |||||
| if (!hasRun) | |||||
| { | |||||
| JDISLog.WriteToLog(_jdislog, string.Format("Beginning Import Procces @ {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString())); | |||||
| hasRun = true; | |||||
| await MailService(); | |||||
| } | |||||
| } | |||||
| else hasRun = false; | |||||
| } | |||||
| } | |||||
| //add more to the if statement to account for other imports | |||||
| } | |||||
| static async System.Threading.Tasks.Task MailService() | |||||
| { | |||||
| _todos = new List<ToDo>(); | |||||
| var cca = ConfidentialClientApplicationBuilder | |||||
| .Create(Global.Settings.MailProperties.AppID) | |||||
| .WithClientSecret(Global.Settings.MailProperties.SecretV) | |||||
| .WithTenantId(Global.Settings.MailProperties.TenentID) | |||||
| .Build(); | |||||
| var ewsScopes = new string[] { Global.Settings.MailProperties.Scope }; | |||||
| var authResult = await cca.AcquireTokenForClient(ewsScopes) | |||||
| .ExecuteAsync(); | |||||
| // Configure the ExchangeService with the access token | |||||
| var ewsClient = new ExchangeService(); | |||||
| ewsClient.Url = new Uri(Global.Settings.MailProperties.Url); | |||||
| ewsClient.Credentials = new OAuthCredentials(authResult.AccessToken); | |||||
| ewsClient.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, Global.Settings.MailProperties.Username); | |||||
| Mailbox mb = new Mailbox(Global.Settings.MailProperties.Mailbox); | |||||
| FolderId fid = new FolderId(WellKnownFolderName.Inbox, mb); | |||||
| List<SearchFilter> searchFilterCollection = new List<SearchFilter>(); | |||||
| string[] filters = Global.Settings.MailProperties.Filter.Split(';'); | |||||
| foreach (string s in filters) | |||||
| searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, s)); | |||||
| SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray()); | |||||
| ItemView view = new ItemView(100); | |||||
| view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived); | |||||
| view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending); | |||||
| view.Traversal = ItemTraversal.Shallow; | |||||
| //Console.WriteLine("Line 90: Finding emails."); | |||||
| try | |||||
| { | |||||
| FindItemsResults<Item> findResults = ewsClient.FindItems(fid, searchFilter, view); | |||||
| List<EmailMessage> messages = new List<EmailMessage>(); | |||||
| foreach (EmailMessage message in findResults.Items) | |||||
| { | |||||
| message.Load(); | |||||
| if (!message.IsRead) | |||||
| messages.Add(message); | |||||
| } | |||||
| foreach (EmailMessage msg in messages) | |||||
| { | |||||
| if (msg.HasAttachments) | |||||
| { | |||||
| foreach (Attachment attachment in msg.Attachments) | |||||
| { | |||||
| attachment.Load(); | |||||
| if (attachment is FileAttachment) | |||||
| { | |||||
| ToDo todo = new ToDo(); | |||||
| todo.Sender = msg.Sender.Address; | |||||
| todo.SenderName = msg.Sender.Name; | |||||
| todo.FileName = attachment.Name; | |||||
| _todos.Add(todo); | |||||
| //Download File | |||||
| FileAttachment fAttachment = attachment as FileAttachment; | |||||
| string fileAttachmentPath = Path.Combine(Global.StorageDir, fAttachment.Name); | |||||
| File.WriteAllBytes(fileAttachmentPath, fAttachment.Content); | |||||
| msg.IsRead = true; | |||||
| msg.Update(ConflictResolutionMode.AlwaysOverwrite); | |||||
| msg.Move(WellKnownFolderName.DeletedItems); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| JDISImport.BeginImport(_todos); | |||||
| foreach (ToDo sendMsg in _todos) | |||||
| { | |||||
| EmailMessage msgToSend = new EmailMessage(ewsClient); | |||||
| //JDISLog.WriteToLog(_logFile, string.Format("Sending Message to: {0}\r\nFor Work Order: {1}\r\nJDIS File: {2}", sendMsg.Sender, sendMsg.WorkOrderNumber, sendMsg.FileName.Substring(sendMsg.FileName.LastIndexOf("/") + 1).Trim())); | |||||
| string body = "JDIS File: {0} Work Order:{1} {2}"; | |||||
| if (sendMsg.Success) | |||||
| { | |||||
| body = string.Format(body, sendMsg.FileName.Substring(sendMsg.FileName.LastIndexOf("/") + 1).Trim(), sendMsg.WorkOrderNumber, "Was Imported Successfully"); | |||||
| } | |||||
| else | |||||
| { | |||||
| body = string.Format(body, sendMsg.FileName.Substring(sendMsg.FileName.LastIndexOf("/") + 1).Trim(), sendMsg.WorkOrderNumber, string.Format("Had Errors while importing: {0}", sendMsg.Validation)); | |||||
| msgToSend.Attachments.AddFileAttachment(Path.Combine(Global.StorageDir, sendMsg.FileName)); | |||||
| } | |||||
| string fileNameOnly = sendMsg.FileName.Substring(sendMsg.FileName.LastIndexOf("/") + 1); | |||||
| msgToSend.Subject = fileNameOnly; | |||||
| msgToSend.ToRecipients.Add(new EmailAddress(sendMsg.Sender)); | |||||
| msgToSend.CcRecipients.Add(new EmailAddress("mcarman@rpmindustries.com")); | |||||
| msgToSend.Body = body; | |||||
| msgToSend.SendAndSaveCopy(); | |||||
| string pathToFile = Path.Combine(Global.StorageDir, sendMsg.FileName); | |||||
| if (sendMsg.Success) | |||||
| { | |||||
| File.Move(pathToFile, Path.Combine(Global.StorageDir, "success", sendMsg.FileName), true); | |||||
| JDISLog.WriteToLog(_jdislog, string.Format("Work Order: {0} Successfully Imported from {1} on {2} {3}", sendMsg.WorkOrderNumber, sendMsg.FileName, DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongTimeString())); | |||||
| } | |||||
| else | |||||
| { | |||||
| File.Move(sendMsg.FileName, Path.Combine(Global.StorageDir, "failure", sendMsg.FileName), true); | |||||
| JDISLog.WriteToLog(_jdislog, string.Format("Work Order: {0} Failed to Import from {1} on {2} {3}", sendMsg.WorkOrderNumber, sendMsg.FileName, DateTime.Now.ToShortTimeString(), DateTime.Now.ToLongTimeString())); | |||||
| } | |||||
| } | |||||
| } | |||||
| catch (Exception ex) | |||||
| { | |||||
| Console.WriteLine(ex.Message); | |||||
| } | |||||
| } | |||||
| } | |||||
| public class ToDo | |||||
| { | |||||
| public string Sender { get; set; } | |||||
| public string SenderName { get; set; } | |||||
| public string FileName { get; set; } | |||||
| public string PathToFile { get; set; } | |||||
| public string WorkOrderNumber { get; set; } | |||||
| public bool Success { get; set; } | |||||
| public string Validation { get; set; } | |||||
| public WorkOrderImport WorkOrder { get; set; } | |||||
| public CustomerImport Customer { get; set; } | |||||
| public EquipmentImport Equipment { get; set; } | |||||
| public List<PartImport> Parts { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace importer | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class RESTMeta | |||||
| { | |||||
| #region Fields | |||||
| private int _numResults; | |||||
| private bool _success = true; | |||||
| private string _type; | |||||
| private string _errorMessage; | |||||
| #endregion | |||||
| #region Properties | |||||
| [JsonProperty(PropertyName = "numResults")] | |||||
| public int numResults | |||||
| { | |||||
| get { return _numResults; } | |||||
| set { _numResults = value; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "success")] | |||||
| public bool success | |||||
| { | |||||
| get { return _success; } | |||||
| set { _success = value; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "errorMessage")] | |||||
| public string errorMessage | |||||
| { | |||||
| get { return _errorMessage; } | |||||
| set { _errorMessage = value; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "type")] | |||||
| public string type | |||||
| { | |||||
| get { return _type; } | |||||
| set { _type = value; } | |||||
| } | |||||
| #endregion | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| using System.Globalization; | |||||
| using Newtonsoft.Json; | |||||
| using Newtonsoft.Json.Converters; | |||||
| using System; | |||||
| namespace importer | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class RESTResponse<T> | |||||
| { | |||||
| #region Fields | |||||
| private RESTMeta _meta = null; | |||||
| private T _data; | |||||
| #endregion | |||||
| #region Properties | |||||
| [JsonProperty(PropertyName = "meta")] | |||||
| public RESTMeta meta | |||||
| { | |||||
| get | |||||
| { | |||||
| if (_meta == null) | |||||
| { | |||||
| _meta = new RESTMeta(); | |||||
| } | |||||
| return _meta; | |||||
| } | |||||
| set { _meta = value; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "data")] | |||||
| public T data | |||||
| { | |||||
| get { return _data; } | |||||
| set { _data = value; } | |||||
| } | |||||
| #endregion | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,137 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using System.Net.Http; | |||||
| using System.Net.Http.Headers; | |||||
| using RestSharp; | |||||
| namespace importer | |||||
| { | |||||
| public class RESTService | |||||
| { | |||||
| private string _baseUrl = Global.ServiceUrl; | |||||
| private HttpClient _httpClient; | |||||
| public string BaseUrl { get { return _baseUrl; } set { _baseUrl = value; } } | |||||
| public RESTService() | |||||
| { | |||||
| } | |||||
| public RESTService(string endPoint, Dictionary<string, string> parameters) | |||||
| { | |||||
| _baseUrl = _baseUrl + "/" + endPoint; | |||||
| foreach (KeyValuePair<string, string> kvp in parameters) | |||||
| { | |||||
| _baseUrl = _baseUrl + "/" + kvp.Key; | |||||
| if (!string.IsNullOrEmpty(kvp.Value)) | |||||
| _baseUrl = _baseUrl + "/" + kvp.Value; | |||||
| } | |||||
| _httpClient = new HttpClient(new HttpClientHandler | |||||
| { | |||||
| UseCookies = true, | |||||
| CookieContainer = new System.Net.CookieContainer() | |||||
| }) | |||||
| { | |||||
| BaseAddress = new Uri(_baseUrl), | |||||
| DefaultRequestHeaders = { Accept = { MediaTypeWithQualityHeaderValue.Parse("application/json") } } | |||||
| }; | |||||
| } | |||||
| public string RestGet(string endpoint, Dictionary<string, string> parameters = null) | |||||
| { | |||||
| string url = _baseUrl + "/" + endpoint + '/'; | |||||
| RestClient client = new RestClient(url); | |||||
| RestRequest request = new RestRequest(endpoint, Method.Get); | |||||
| request.AddHeader("Accept", "application/json"); | |||||
| request.Method = Method.Get; | |||||
| RestResponse response = client.Execute(request); | |||||
| return response.Content; | |||||
| } | |||||
| public T RestGet<T>(bool single, string endpoint, Dictionary<string, string> parameters = null) | |||||
| { | |||||
| RESTResponse<T> rest = new RESTResponse<T>(); | |||||
| string url = _baseUrl + "/" + endpoint + "/"; | |||||
| if (parameters != null) | |||||
| { | |||||
| foreach (KeyValuePair<string, string> kvp in parameters) | |||||
| { | |||||
| url = url + kvp.Key + "/" + kvp.Value; | |||||
| } | |||||
| } | |||||
| RestClient client = new RestClient(url); | |||||
| RestRequest request = new RestRequest(); | |||||
| request.AddHeader("Accept", "application/json"); | |||||
| request.Method = Method.Get; | |||||
| RestResponse response = client.Execute(request); | |||||
| rest = Deserialize.FromJson<RESTResponse<T>>(response.Content); | |||||
| return rest.data; | |||||
| } | |||||
| public T PostRest<T>(string json, string endpoint) | |||||
| { | |||||
| RESTResponse<T> rest = new RESTResponse<T>(); | |||||
| string url = _baseUrl + "/" + endpoint + "/"; | |||||
| RestClient client = new RestClient(url); | |||||
| Console.WriteLine(); | |||||
| Console.WriteLine(); | |||||
| Console.WriteLine(); | |||||
| Console.WriteLine(json); | |||||
| RestRequest request = new RestRequest(); | |||||
| request.Method = Method.Post; | |||||
| request.RequestFormat = DataFormat.Json; | |||||
| request.AddBody(json); | |||||
| request.AddHeader("Accept", "application/json"); | |||||
| RestResponse response = client.Execute(request); | |||||
| Console.WriteLine(); | |||||
| Console.WriteLine(); | |||||
| Console.WriteLine(response.Content); | |||||
| rest = Deserialize.FromJson<RESTResponse<T>>(response.Content); | |||||
| return rest.data; | |||||
| } | |||||
| public T PostRest<T>(string json, string endpoint, Dictionary<string, string> parameters) | |||||
| { | |||||
| RESTResponse<T> rest = new RESTResponse<T>(); | |||||
| string url = _baseUrl + "/" + endpoint + "/"; | |||||
| foreach (KeyValuePair<string, string> kvp in parameters) | |||||
| { | |||||
| url = url + kvp.Key + "/" + kvp.Value; | |||||
| } | |||||
| RestClient client = new RestClient(url); | |||||
| RestRequest request = new RestRequest(url, Method.Post); | |||||
| request.AddBody(json); | |||||
| request.AddHeader("Accept", "application/json"); | |||||
| RestResponse response = client.Execute(request); | |||||
| rest = Deserialize.FromJson<RESTResponse<T>>(response.Content); | |||||
| return rest.data; | |||||
| } | |||||
| public List<T> RestGet<T>(string endpoint, Dictionary<string, string> parameters = null) | |||||
| { | |||||
| RESTResponse<List<T>> rest = new RESTResponse<List<T>>(); | |||||
| string url = _baseUrl + "/" + endpoint + "/"; | |||||
| if (parameters != null) | |||||
| { | |||||
| foreach (KeyValuePair<string, string> kvp in parameters) | |||||
| { | |||||
| url = url + kvp.Key + "/" + kvp.Value; | |||||
| } | |||||
| } | |||||
| RestClient client = new RestClient(url); | |||||
| RestRequest request = new RestRequest(); | |||||
| request.Method = Method.Get; | |||||
| request.AddHeader("Accept", "application/json"); | |||||
| request.Method = Method.Get; | |||||
| RestResponse response = client.Execute(request); | |||||
| rest = Deserialize.FromJson<RESTResponse<List<T>>>(response.Content); | |||||
| List<T> list = new List<T>(); | |||||
| list.AddRange(rest.data); | |||||
| return list; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,46 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Customer | |||||
| { | |||||
| [JsonProperty(PropertyName = "Address")] | |||||
| public string Address { get; set; } | |||||
| [JsonProperty(PropertyName = "Address2")] | |||||
| public string Address2 { get; set; } | |||||
| [JsonProperty(PropertyName = "City")] | |||||
| public string City { get; set; } | |||||
| [JsonProperty(PropertyName = "State")] | |||||
| public string State { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "Number")] | |||||
| public string Number { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "Phone1")] | |||||
| public string Phone1 { get; set; } | |||||
| [JsonProperty(PropertyName = "Phone2")] | |||||
| public string Phone2 { get; set; } | |||||
| [JsonProperty(PropertyName = "Fax")] | |||||
| public string Fax { get; set; } | |||||
| [JsonProperty(PropertyName = "ZipCode")] | |||||
| public string ZipCode { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,59 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Equipment | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "BarcodeID")] | |||||
| public int? BarcodeID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "LastServiceDate")] | |||||
| public DateTime? LastServiceDate { get; set; } | |||||
| [JsonProperty(PropertyName = "Location")] | |||||
| public string Location { get; set; } | |||||
| [JsonProperty(PropertyName = "ManufacturerYear")] | |||||
| public string ManufacturerYear { get; set; } | |||||
| [JsonProperty(PropertyName = "MeterReading")] | |||||
| public string MeterReading { get; set; } | |||||
| [JsonProperty(PropertyName = "Number")] | |||||
| public string Number { get; set; } | |||||
| [JsonProperty(PropertyName = "Odometer")] | |||||
| public string Odometer { get; set; } | |||||
| [JsonProperty(PropertyName = "SerialNumber")] | |||||
| public string SerialNumber { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Make")] | |||||
| public Make Make { get; set; } | |||||
| [JsonProperty(PropertyName = "MakeID")] | |||||
| public int MakeID { get { return this.Make != null ? this.Make.ID : 0; } set { value = this.Make != null ? this.Make.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "Product")] | |||||
| public Product Product { get; set; } | |||||
| [JsonProperty(PropertyName = "ProductID")] | |||||
| public int ProductID { get { return this.Product != null ? this.Product.ID : 0; } set { value = this.Product != null ? this.Product.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "Model")] | |||||
| public Model Model { get; set; } | |||||
| [JsonProperty(PropertyName = "ModelID")] | |||||
| public int ModelID { get { return this.Model != null ? this.Model.ID : 0; } set { value = this.Model != null ? this.Model.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "Customer")] | |||||
| public Customer Customer { get; set; } | |||||
| [JsonProperty(PropertyName = "CustomerID")] | |||||
| public int CustomerID { get { return this.Customer != null ? this.Customer.ID : 0; } set { value = this.Customer != null ? this.Customer.ID : 0; } } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Inspection | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,34 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class InspectionLevel | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionType")] | |||||
| public InspectionType InspectionType { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionTypeID")] | |||||
| public int InspectionTypeID { get { return this.InspectionType != null ? this.InspectionType.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class InspectionType | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionLevels")] | |||||
| public List<InspectionLevel> InspectionLevels { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| /* | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "InspectionLevels":[{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "InspectionTypeID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }], | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| */ | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Make | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,37 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Model | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "Make")] | |||||
| public Make Make { get; set; } | |||||
| [JsonProperty(PropertyName = "MakeID")] | |||||
| public int MakeID { get { return this.Make != null ? this.Make.ID : 0; } set { value = this.Make != null ? this.Make.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "Product")] | |||||
| public Product Product { get; set; } | |||||
| [JsonProperty(PropertyName = "ProductID")] | |||||
| public int ProductID { get { return this.Product != null ? this.Product.ID : 0; } set { value = this.Product != null ? this.Product.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Priority | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,30 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Product | |||||
| { | |||||
| [JsonProperty(PropertyName = "Code")] | |||||
| public string Code { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Reason | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int UpdateUserID { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Status | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,265 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class Template | |||||
| { | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Description")] | |||||
| public string Description { get; set; } | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "Name")] | |||||
| public string Name { get; set; } | |||||
| [JsonProperty(PropertyName = "IsActive")] | |||||
| public bool IsActive { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime? UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int? UpdateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionLevel")] | |||||
| public InspectionLevel InspectionLevel { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionLevelID")] | |||||
| public int InspectionLevelID | |||||
| { | |||||
| get | |||||
| { | |||||
| return this.InspectionLevel != null ? this.InspectionLevel.ID : 0; | |||||
| } | |||||
| set | |||||
| { | |||||
| value = this.InspectionLevel != null ? this.InspectionLevel.ID : 0; | |||||
| } | |||||
| } | |||||
| [JsonProperty(PropertyName = "InspectionType")] | |||||
| public InspectionType InspectionType { get; set; } | |||||
| [JsonProperty(PropertyName = "InspectionTypeID")] | |||||
| public int InspectionTypeID | |||||
| { | |||||
| get | |||||
| { | |||||
| return this.InspectionType != null ? this.InspectionType.ID : 0; | |||||
| } | |||||
| set | |||||
| { | |||||
| value = this.InspectionType != null ? this.InspectionType.ID : 0; | |||||
| } | |||||
| } | |||||
| [JsonProperty(PropertyName = "Model")] | |||||
| public Model Model { get; set; } | |||||
| [JsonProperty(PropertyName = "ModelID")] | |||||
| public int? ModelID { get { return this.Model != null ? Model.ID : null; } set { value = this.Model != null ? Model.ID : null; } } | |||||
| [JsonProperty(PropertyName = "Product")] | |||||
| public Product Product { get; set; } | |||||
| [JsonProperty(PropertyName = "ProductID")] | |||||
| public int? ProductID { get { return this.Product != null ? Product.ID : null; } set { value = this.Product != null ? Product.ID : null; } } | |||||
| /* | |||||
| "TemplateCategories":[{ | |||||
| "Category":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "CategoryID":2147483647, | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "ID":2147483647, | |||||
| "SortOrder":2147483647, | |||||
| "TemplateID":2147483647, | |||||
| "TemplateItemSpecs":[{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "ID":2147483647, | |||||
| "Item":{ | |||||
| "Category":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "CategoryID":2147483647, | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "InputType":{ | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "InputTypeID":2147483647, | |||||
| "IsActive":true, | |||||
| "ItemResponseTypes":[{ | |||||
| "ID":2147483647, | |||||
| "ItemID":2147483647, | |||||
| "ResponseType":{ | |||||
| "Color":"String content", | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "RepairType":{ | |||||
| "Color":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "ResponseTypeID":2147483647, | |||||
| "SortOrder":2147483647 | |||||
| }], | |||||
| "Name":"String content", | |||||
| "SMSCCode":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "SMSCCodeID":2147483647, | |||||
| "Specs":[{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "ItemID":2147483647, | |||||
| "Name":"String content", | |||||
| "NumberOfTests":2147483647, | |||||
| "SpecItems":[{ | |||||
| "ComparisonType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "ComparisonTypeID":2147483647, | |||||
| "ID":2147483647, | |||||
| "Name":"String content", | |||||
| "Qualifier":"String content", | |||||
| "SortOrder":2147483647, | |||||
| "SpecID":2147483647, | |||||
| "SpecItemValues":[{ | |||||
| "ID":2147483647, | |||||
| "SortOrder":2147483647, | |||||
| "SpecItemID":2147483647, | |||||
| "Value":"String content", | |||||
| "ValueType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "ValueTypeID":2147483647 | |||||
| }], | |||||
| "Unit":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "DataType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "DataTypeID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "UnitID":2147483647 | |||||
| }], | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }], | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "ItemID":2147483647, | |||||
| "SortOrder":2147483647, | |||||
| "Spec":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "ItemID":2147483647, | |||||
| "Name":"String content", | |||||
| "NumberOfTests":2147483647, | |||||
| "SpecItems":[{ | |||||
| "ComparisonType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "ComparisonTypeID":2147483647, | |||||
| "ID":2147483647, | |||||
| "Name":"String content", | |||||
| "Qualifier":"String content", | |||||
| "SortOrder":2147483647, | |||||
| "SpecID":2147483647, | |||||
| "SpecItemValues":[{ | |||||
| "ID":2147483647, | |||||
| "SortOrder":2147483647, | |||||
| "SpecItemID":2147483647, | |||||
| "Value":"String content", | |||||
| "ValueType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "ValueTypeID":2147483647 | |||||
| }], | |||||
| "Unit":{ | |||||
| "CreateDate":"\/Date(928164000000-0400)\/", | |||||
| "CreateUserID":2147483647, | |||||
| "DataType":{ | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "Name":"String content" | |||||
| }, | |||||
| "DataTypeID":2147483647, | |||||
| "Description":"String content", | |||||
| "ID":2147483647, | |||||
| "IsActive":true, | |||||
| "Name":"String content", | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "UnitID":2147483647 | |||||
| }], | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }, | |||||
| "SpecID":2147483647, | |||||
| "TemplateCategoryID":2147483647, | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }], | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| }], | |||||
| "UpdateDate":"\/Date(928164000000-0400)\/", | |||||
| "UpdateUserID":2147483647 | |||||
| */ | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class User | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "Number")] | |||||
| public string Number { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,112 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using Newtonsoft.Json; | |||||
| namespace importer.RestObjects | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class WorkOrder | |||||
| { | |||||
| [JsonProperty(PropertyName = "ID")] | |||||
| public int ID { get; set; } | |||||
| [JsonProperty(PropertyName = "CustomerID")] | |||||
| public int CustomerID { get { return this.Customer != null ? this.Customer.ID : 0; } set { value = this.Customer != null ? this.Customer.ID : 0; } } | |||||
| [JsonProperty(PropertyName = "PriorityID")] | |||||
| public int PriorityID | |||||
| { | |||||
| get { return this.Priority != null ? this.Priority.ID : 0; } | |||||
| set { value = this.Priority != null ? this.Priority.ID : 0; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "StatusID")] | |||||
| public int StatusID | |||||
| { | |||||
| get { return this.Status != null ? this.Status.ID : 0; } | |||||
| set { value = this.Status != null ? this.Status.ID : 0; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "EquipmentID")] | |||||
| public int EquipmentID | |||||
| { | |||||
| get { return this.Equipment != null ? this.Equipment.ID : 0; } | |||||
| set { value = this.Equipment != null ? this.Equipment.ID : 0; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "ReasonID")] | |||||
| public int? ReasonID | |||||
| { | |||||
| get { return this.Reason != null ? this.Reason.ID : null; } | |||||
| set { value = this.Reason != null ? this.Reason.ID : null; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "IncompleteReasonID")] | |||||
| public int? IncompleteReasonID { get; set; } | |||||
| [JsonProperty(PropertyName = "TechnicianUserID")] | |||||
| public int TechnicianUserID | |||||
| { | |||||
| get { return this.Technician != null ? this.Technician.ID : 0; } | |||||
| set { value = this.Technician != null ? this.Technician.ID : 0; } | |||||
| } | |||||
| [JsonProperty(PropertyName = "Number")] | |||||
| public string Number { get; set; } | |||||
| [JsonProperty(PropertyName = "MeterReading")] | |||||
| public decimal? MeterReading { get; set; } | |||||
| [JsonProperty(PropertyName = "Odometer")] | |||||
| public decimal? Odometer { get; set; } | |||||
| [JsonProperty(PropertyName = "SpecialInstructions")] | |||||
| public string SpecialInstructions { get; set; } | |||||
| [JsonProperty(PropertyName = "ScheduledStartDate")] | |||||
| public DateTime ScheduledStartDate { get; set; } | |||||
| [JsonProperty(PropertyName = "ScheduledEndDate")] | |||||
| public DateTime ScheduledEndDate { get; set; } | |||||
| [JsonProperty(PropertyName = "StartDate")] | |||||
| public DateTime? StartDate { get; set; } | |||||
| [JsonProperty(PropertyName = "EndDate")] | |||||
| public DateTime? EndDate { get; set; } | |||||
| [JsonProperty(PropertyName = "ApprovedDate")] | |||||
| public DateTime? ApprovedDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateDate")] | |||||
| public DateTime CreateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "CreateUserID")] | |||||
| public int CreateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateDate")] | |||||
| public DateTime UpdateDate { get; set; } | |||||
| [JsonProperty(PropertyName = "UpdateUserID")] | |||||
| public int UpdateUserID { get; set; } | |||||
| [JsonProperty(PropertyName = "Customer")] | |||||
| public Customer Customer { get; set; } | |||||
| [JsonProperty(PropertyName = "Priority")] | |||||
| public Priority Priority { get; set; } | |||||
| [JsonProperty(PropertyName = "Status")] | |||||
| public Status Status { get; set; } | |||||
| [JsonProperty(PropertyName = "Equipment")] | |||||
| public Equipment Equipment { get; set; } | |||||
| [JsonProperty(PropertyName = "Reason")] | |||||
| public Reason Reason { get; set; } | |||||
| [JsonProperty(PropertyName = "Technician")] | |||||
| public User Technician { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Xml.Linq; | |||||
| using System.Threading.Tasks; | |||||
| using System.IO; | |||||
| namespace importer | |||||
| { | |||||
| public class XMLData | |||||
| { | |||||
| private static Dictionary<string, string> _cclookup; | |||||
| public static Dictionary<string, string> CCLookup { get { return _cclookup; } set { _cclookup = value; } } | |||||
| private static Dictionary<string, int> _intervalLookup; | |||||
| public static Dictionary<string, int> IntervalLookup { get { return _intervalLookup; } set { _intervalLookup = value; } } | |||||
| public static void BuildIntervalLookup() | |||||
| { | |||||
| string dir = Global.StorageDir; | |||||
| _intervalLookup = new Dictionary<string, int>(); | |||||
| string intervalLookupPath = Path.Combine(dir, "IntervalData.xml"); | |||||
| var doc = XDocument.Load(intervalLookupPath); | |||||
| var rootNodes = doc.Root.DescendantNodes().OfType<XElement>(); | |||||
| Dictionary<string, string> dic = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); | |||||
| foreach (KeyValuePair<string, string> kvp in dic) | |||||
| { | |||||
| _intervalLookup.Add(kvp.Key.Replace("ZZ", ""), int.Parse(kvp.Value)); | |||||
| } | |||||
| } | |||||
| public static void BuildCCLookup(string os) | |||||
| { | |||||
| string dir = Global.StorageDir; | |||||
| string ccLookupPath = Path.Combine(dir, "CCAddresses.xml"); | |||||
| _cclookup = new Dictionary<string, string>(); | |||||
| var doc = XDocument.Load(ccLookupPath); | |||||
| var rootNodes = doc.Root.DescendantNodes().OfType<XElement>(); | |||||
| _cclookup = rootNodes.ToDictionary(n => n.Name.ToString(), n => n.Value); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| { | |||||
| "MailProperties": { | |||||
| "Username": "cmobile@prelub.com", | |||||
| "Password": "Gr@nt@cc3$$", | |||||
| "Mailbox": "connexionmobile@rpmindustries.org", | |||||
| "Url": "https://outlook.office365.com/ews/Exchange.asmx", | |||||
| "Filter": "Brandt Import; brandt import; Brandt import; brandt Import; BRANDT IMPORT", | |||||
| "AppID": "489776b1-ee79-4b14-bc44-9f6bf47332db", | |||||
| "TenentID": "1fd06c96-d3a4-45e9-9ed7-bcecb394d277", | |||||
| "ObjectId": "c7647074-edb6-4e8e-8a01-a1ed924fdae9", | |||||
| "SecretID": "cba04a6c-a233-4646-909b-b50921edbe1c", | |||||
| "SecretV": "up-8Q~y46~JyQZjJlsAJ-zpXpglpmuPIJ1Gx3a2O", | |||||
| "Scope": "https://outlook.office365.com/.default" | |||||
| }, | |||||
| "Remote": false, | |||||
| "LogFile": "jdis.log", | |||||
| "Prelub": { | |||||
| "LocalService": "http://servicesbrandt.rpmindustries.com:8081", | |||||
| "RemoteService": "https://servicesbrandt.rpmindustries.com" | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| { | |||||
| "runtimeOptions": { | |||||
| "tfm": "net6.0", | |||||
| "framework": { | |||||
| "name": "Microsoft.NETCore.App", | |||||
| "version": "6.0.0" | |||||
| } | |||||
| } | |||||
| } | |||||