public string Transform(ModelMap mapToProcess, ModelProcess action, string input) { if (input == string.Empty) input = DateTime.Now.ToShortDateString(); string result = string.Empty; try { DateTime date = DateTime.Parse(input); int quarter = ((((date.Month - 1) / 3) + 3) % 4) + 1; switch (quarter) { case 2: result = string.Format("01/04/{0}", date.Year); break; case 3: result = string.Format("01/07/{0}", date.Year); break; case 4: result = string.Format("01/10/{0}", date.Year - 1); break; case 1: result = string.Format("01/01/{0}", date.Year); break; } } catch (Exception ex) { LoggerSingleton.Instance.LogMessage(ex); } return result; }
public string Transform(ModelMap mapToProcess, ModelProcess actionProcess, string input) { string result = string.Empty; try { CsvFileDescription outputFileDescription = new CsvFileDescription { SeparatorChar = ',', // tab delimited FirstLineHasColumnNames = false, // no column names in first record FileCultureName = "en-GB" // use formats used in The Netherlands }; CsvContext csvContext = new CsvContext(); string fileLocation = Path.Combine( new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName, actionProcess.Where); var theList = csvContext.Read<Data.DataRow>(fileLocation, outputFileDescription); var thePairs = theList.ToDictionary( d=>d[0].Value.ToString(), d =>d[1].Value.ToString()); if (thePairs.ContainsKey(input)) result = input != null ? thePairs[input] : "No Code Found"; } catch (Exception ex) { LoggerSingleton.Instance.LogMessage(ex); } return result; }
public void LoadCsvFileAndConvertToDictionaryThenReplaceInputWithValue() { ModelMap map = new ModelMap { ConnectTo = 0, DataType = "String", Destination = "GP_CODE", Id = 1, Processes = (IEnumerable<ModelProcess>)new List<ModelProcess> { new ModelProcess { Where = "GPCodes.csv", Make = string.Empty, ProcessAction = "Load" } }, Source = "Usual GP's Full Name" }; string input = "TOOSY, Raza (Dr)"; var factory = new AutoFactory(); IActionable process = factory.CreateInstance(map.Processes.First().ProcessAction.ToLower()); string result = process.Transform(map, map.Processes.First(), input); Assert.AreNotEqual(result, "No Code Found"); }
public void TestInitialise() { _map = new ModelMap { ConnectTo = 0, DataType = "String", Destination = "NHS_Number", Id = 1, Processes = (IEnumerable<ModelProcess>)new List<ModelProcess> { new ModelProcess { Where = string.Empty, Make = string.Empty, ProcessAction = "Removespaces" } }, Source = "NHS Number" }; }
public void TestInitialise() { _map = new ModelMap { ConnectTo = 0, DataType = "DateTime", Destination = "LIST_DATE", Id = 1, Processes = (IEnumerable<ModelProcess>)new List<ModelProcess> { new ModelProcess { Where = string.Empty, Make = string.Empty, ProcessAction = "QuarterStart" } }, Source = string.Empty }; }
public void TestInitialise() { _map = new ModelMap { ConnectTo = 0, DataType = "String", Destination = "MMR_UNDER_GMS", Id = 1, Processes = (IEnumerable<ModelProcess>)new List<ModelProcess> { new ModelProcess { Where = "^True$", //^.*True.*$ Make = "Y", ProcessAction = "RegexAction" }, new ModelProcess { Where = "^False$", //^.*False.*$ Make = "N", ProcessAction = "RegexAction" } }, Source = string.Empty }; }
public string Transform(ModelMap mapToProcess, ModelProcess action, string input) { return string.Empty; }
public string Transform(ModelMap mapToProcess, ModelProcess action, string input) { return input.Replace(" ", ""); }
public string Transform(ModelMap mapToProcess, ModelProcess action, string input) { var regex = new Regex(action.Where); return regex.IsMatch(input) ? action.Make : input; }