public static QueryObject readDownloadedXml(string path, QueryObject downloadedFile, string option) { XmlDocument doc = new XmlDocument(); QueryObject newFile = (QueryObject)Activator.CreateInstance(downloadedFile.GetType()); List <string> queryKeys = newFile.getKeys(); bool readFile = false; while (!readFile) { Thread.Sleep(50); try { doc.Load(path); foreach (string dicomTagName in queryKeys) { string result = findTag(doc, dicomTagName, option); result = result.Replace("/", "-").Replace(' ', '_').Replace("\"", "-"); newFile.SetField(dicomTagName, result); } readFile = true; } catch (Exception) { MessageBox.Show("Impossibile accedere al file " + path + ", ancora in scrittura"); } } return(newFile); }
// wrapper for Dicom Toolkit services string[] queryString(QueryObject queryData, string dir) { string query = ""; foreach (string dicomTag in queryData.getKeys()) { query = " -k " + dicomTag + "=\"" + queryData.GetField(dicomTag) + "\" " + query; } if (dir != "") { DirectoryInfo di = Directory.CreateDirectory(dir); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } } return(specificQuery(query, dir)); }