public void Go(String file) { string url = "file:///" + file.Replace("\\", "/"); //Add block parameters if needed url += "?"; //TODO - get metadata from file into url. if (Plugin.WantMetaData) { // Read meta-data string md = ""; OmApiNet.OmReader reader = null; try { reader = OmApiNet.OmReader.Open(CWAFilenames[0]); md = reader.MetaData; } catch (Exception e) { Console.Error.WriteLine("ERROR: Problem reading metadata: " + e.Message); } finally { if (reader != null) { try { reader.Close(); } catch (Exception e) { Console.Error.WriteLine("ERROR: Problem closing reader: " + e.Message); } reader = null; } } Dictionary <string, string> parsed = (Dictionary <string, string>)MetaDataTools.ParseMetaData(md, MetaDataTools.mdStringList); Dictionary <string, string> metadataBuiltReadable = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> kvp in parsed) { metadataBuiltReadable.Add(MetaDataTools.metaDataMappingDictionary[kvp.Key], kvp.Value); } bool notFirst = false; foreach (KeyValuePair <string, string> kvp in metadataBuiltReadable) { if (!notFirst) { notFirst = true; } else { url += "&"; } url += kvp.Key + "=" + kvp.Value; } } Console.WriteLine("URL: " + url); if (Plugin.SelectionBlockStart > -1 && Plugin.SelectionBlockCount > -1) { if (url.Length > 1) { url += "&"; } url += "startBlock=" + Plugin.SelectionBlockStart; url += "&blockCount=" + Plugin.SelectionBlockCount; } if (Plugin.SelectionDateTimeStart != "" && Plugin.SelectionDateTimeEnd != "") { if (url.Length > 1) { url += "&"; } url += "startTime=" + Plugin.SelectionDateTimeStart; url += "&endTime=" + Plugin.SelectionDateTimeEnd; } if (Plugin.RequiresCWANames) { if (url.Length > 1) { url += "&"; } url += "input1=" + CWAFilenames[0]; for (int i = 1; i < CWAFilenames.Length; i++) { url += "&input" + (i + 1) + "=" + CWAFilenames[i]; } } string profileString = loadXmlProfile(); if (profileString != null) { url += profileString; } Console.WriteLine("url:\n" + url); this.webBrowser1.Url = new System.Uri(url, System.UriKind.RelativeOrAbsolute); }
public static Dictionary <string, string> MetadataFromReader(string filename) { // Read meta-data ushort? deviceId = null; uint? sessionId = null; DateTime?startTime = null; DateTime?endTime = null; string md = ""; OmApiNet.OmReader reader = null; try { reader = OmApiNet.OmReader.Open(filename); deviceId = reader.DeviceId; sessionId = reader.SessionId; startTime = reader.StartTime; endTime = reader.EndTime; md = reader.MetaData; } catch (Exception e) { Console.Error.WriteLine("ERROR: Problem reading metadata: " + e.Message); } finally { if (reader != null) { try { reader.Close(); } catch (Exception e) { Console.Error.WriteLine("ERROR: Problem closing reader: " + e.Message); } reader = null; } } Dictionary <string, string> metadataMap = new Dictionary <string, string>(); Dictionary <string, string> parsed = (Dictionary <string, string>)MetaDataTools.ParseMetaData(md, MetaDataTools.mdStringList); if (parsed != null) { foreach (KeyValuePair <string, string> kvp in parsed) { metadataMap.Add(MetaDataTools.metaDataMappingDictionary[kvp.Key], kvp.Value); } } if (deviceId.HasValue) { metadataMap.Add("DeviceId", string.Format("{0:00000}", deviceId.Value)); } if (sessionId.HasValue) { metadataMap.Add("SessionId", string.Format("{0:0000000000}", sessionId.Value)); } if (startTime.HasValue) { metadataMap.Add("StartTime", string.Format("{0:yyyy-MM-dd HH:mm:ss}", startTime.Value)); metadataMap.Add("StartTimeNumeric", string.Format("{0:yyyyMMddHHmmss}", startTime.Value)); } if (endTime.HasValue) { metadataMap.Add("EndTime", string.Format("{0:yyyy-MM-dd HH:mm:ss}", endTime.Value)); metadataMap.Add("EndTimeNumeric", string.Format("{0:yyyyMMddHHmmss}", endTime.Value)); } return(metadataMap); // Dictionary<string, string> metadataMap = MetaDataTools.MetadataFromFile(filename); // foreach (KeyValuePair<string, string> kvp in metadataMap) { kvp.Key + "=" + kvp.Value; }; }