public List <string> ReadFile(string filepath) { try { if (!File.Exists(filepath)) { return(null); } string jsonString = File.ReadAllText(filepath); Recipents result = JsonSerializer.Deserialize <Recipents>(jsonString); ParseObject parse = new ParseObject(); return(parse.Handle(result)); } catch (Exception ex) { throw ex; } }
public List <string> Handle(Recipents result) { List <Recipent> listMoreThanOne = result.recipients.Where(x => x.tags.Count > 1).ToList(); List <string> listMatchedUser = new List <string>(); if (listMoreThanOne.Count == 0) { return(listMatchedUser); } int row = listMoreThanOne.Count; int count = 0; while (count < row) { for (int i = count + 1; i < row; i++) { var list1 = listMoreThanOne[count].tags; var list2 = listMoreThanOne[i].tags; var match = list1.Where(x => list2.Any(z => z.Equals(x))); if (match.Count() > 1) { string matchUsersName = string.Format("{0},{1}", listMoreThanOne[count].name, listMoreThanOne[i].name); string repeatedUsersName = string.Format("{0},{1}", listMoreThanOne[i].name, result.recipients[count].name); if (!listMatchedUser.Contains(matchUsersName) && !listMatchedUser.Contains(repeatedUsersName)) { listMatchedUser.Add(matchUsersName); } } } count++; } return(listMatchedUser); }
public Automation(Recipents recipents, Settings settings, TriggerSettings triggerSettings) { this.Recipents = recipents; this.Settings = settings; this.TriggerSettings = triggerSettings; }