protected override void ProcessMessages() { while (true) { try { ServiceMessage msg = bq.deQ(); Console.Write("\n {0} Recieved Message:\n", msg.TargetCommunicator); msg.ShowMessage(); Dictionary<string, List<string>> child_dictionary = new Dictionary<string, List<string>>(); Dictionary<string, List<string>> parent_dictionary = new Dictionary<string, List<string>>(); ParentChildMap PCM = new ParentChildMap(); string xmlfilename = Path.GetFileNameWithoutExtension(msg.Contents) + ".xml"; string[] temp = Directory.GetFiles(@"..\..\DocumentVault\", "*.Xml"); foreach (string str in temp) PCM.UpdateMap(child_dictionary, parent_dictionary, str); XDocument doc = XDocument.Load(@"..\..\DocumentVault\" + xmlfilename); var categorynames = from x in doc.Elements(Path.GetFileNameWithoutExtension(msg.Contents)).Elements("Categories").Descendants() select x; List<string> parent_categories = new List<string>(); foreach (string category in categorynames) { parent_categories.Add(category); } //Dictionary<string, List<string>> new_parent_dictionary = new Dictionary<string, List<string>>(parent_dictionary); // new_parent_dictionary = parent_dictionary; bool flag = false; foreach (KeyValuePair<string, List<string>> str in parent_dictionary) { if (str.Key == msg.Contents) flag = true; } if (flag == false) { parent_dictionary.Add(msg.Contents, parent_categories); } //PCM.UpdateMap(child_dictionary, parent_dictionary, "../../Demo1.xml"); List<string> child_files = new List<string>(); foreach (var str in child_dictionary) { if (str.Key == msg.Contents) child_files = str.Value; } string childs = ""; foreach (string str in child_files) { childs = childs + str + ","; } List<string> parent_files = new List<string>(); foreach (var str in parent_dictionary) { if (str.Key == msg.Contents) parent_files = str.Value; } childs = childs + ";"; foreach (string str in parent_files) { childs = childs + str + ","; } ServiceMessage reply = ServiceMessage.MakeMessage("client-echo", "echo", childs, "update_infoview"); reply.TargetUrl = msg.SourceUrl; reply.SourceUrl = msg.TargetUrl; AbstractMessageDispatcher dispatcher = AbstractMessageDispatcher.GetInstance(); dispatcher.PostMessage(reply); Console.Write("\n {0} Resource data:\n", msg.ResourceName); //string[] str = msg.ResourceName.Split(','); } catch (Exception msg) { Console.WriteLine("Exception occured {0}",msg); } } }
public static void Main(string[] args) { Dictionary<string, List<string>> child_dictionary, Dictionary<string, List<string>> parent_dictionary; child_dictionary.Add(File1.txt,File2.txt); parent_dictionary.Add(File1.txt,File2.txt); string filename="file1.txt"; ParentChildMap PCB = new ParentChildMap(); Console.Write("\nI m testing Metadata Search"); PCB.UpdateMap(child_dictionary,parent_dictionary,filename) //Console.Write("n path = {0}\n file pattern = {1}\n query string = {2}", path, pattern, queryString); }