public static List<BrowserScriptPocketQueriesPQSetting> Load(string filename) { List<BrowserScriptPocketQueriesPQSetting> result = new List<BrowserScriptPocketQueriesPQSetting>(); if (System.IO.File.Exists(filename)) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlElement root = doc.DocumentElement; XmlNodeList bmNodes = root.SelectNodes("Setting"); if (bmNodes != null) { foreach (XmlNode n in bmNodes) { BrowserScriptPocketQueriesPQSetting pq = new BrowserScriptPocketQueriesPQSetting(); pq.ID = n.SelectSingleNode("ID").InnerText; pq.Name = n.SelectSingleNode("Name").InnerText; pq.GenerateOnDays = new List<int>(); XmlNode subn = n.SelectSingleNode("GenerateOnDays"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Day"); if (subs != null) { foreach (XmlNode sn in subs) { pq.GenerateOnDays.Add(int.Parse(sn.InnerText)); } } } pq.ExecutionScheme = int.Parse(n.SelectSingleNode("ExecutionScheme").InnerText); pq.MaximumCaches = n.SelectSingleNode("MaximumCaches").InnerText; pq.GeocacheTypes = new List<int>(); subn = n.SelectSingleNode("GeocacheTypes"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Type"); if (subs != null) { foreach (XmlNode sn in subs) { pq.GeocacheTypes.Add(int.Parse(sn.InnerText)); } } } pq.GeocacheContainer = new List<int>(); subn = n.SelectSingleNode("GeocacheContainer"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Container"); if (subs != null) { foreach (XmlNode sn in subs) { pq.GeocacheContainer.Add(int.Parse(sn.InnerText)); } } } pq.WhichOptions = new List<int>(); subn = n.SelectSingleNode("WhichOptions"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Option"); if (subs != null) { foreach (XmlNode sn in subs) { pq.WhichOptions.Add(int.Parse(sn.InnerText)); } } } pq.DifficultyCondition = n.SelectSingleNode("DifficultyCondition").InnerText; pq.DifficultyValue = n.SelectSingleNode("DifficultyValue").InnerText; pq.TerrainCondition = n.SelectSingleNode("TerrainCondition").InnerText; pq.TerrainValue = n.SelectSingleNode("TerrainValue").InnerText; pq.WithinSelection = n.SelectSingleNode("WithinSelection").InnerText; pq.Countries = new List<string>(); subn = n.SelectSingleNode("Countries"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Country"); if (subs != null) { foreach (XmlNode sn in subs) { pq.Countries.Add(sn.InnerText); } } } pq.States = new List<string>(); subn = n.SelectSingleNode("States"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("State"); if (subs != null) { foreach (XmlNode sn in subs) { pq.States.Add(sn.InnerText); } } } pq.FromPointSelection = n.SelectSingleNode("FromPointSelection").InnerText; pq.FromPointGCCode = n.SelectSingleNode("FromPointGCCode").InnerText; pq.FromPointPostalCode = n.SelectSingleNode("FromPointPostalCode").InnerText; pq.LatLonFormatValue = n.SelectSingleNode("LatLonFormatValue").InnerText; pq.NorthSouthValues = new List<string>(); subn = n.SelectSingleNode("NorthSouthValues"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Value"); if (subs != null) { foreach (XmlNode sn in subs) { pq.NorthSouthValues.Add(sn.InnerText); } } } pq.EastWestValues = new List<string>(); subn = n.SelectSingleNode("EastWestValues"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Value"); if (subs != null) { foreach (XmlNode sn in subs) { pq.EastWestValues.Add(sn.InnerText); } } } pq.WithinRadius = n.SelectSingleNode("WithinRadius").InnerText; pq.WithinRadiusUnitType = n.SelectSingleNode("WithinRadiusUnitType").InnerText; pq.PlacedDuring = n.SelectSingleNode("PlacedDuring").InnerText; pq.PlacedDuringFixedInterval = n.SelectSingleNode("PlacedDuringFixedInterval").InnerText; pq.PlacedDuringFromDate = DateTime.Parse(n.SelectSingleNode("PlacedDuringFromDate").InnerText); pq.PlacedDuringToDate = DateTime.Parse(n.SelectSingleNode("PlacedDuringToDate").InnerText); pq.IncludeAttributes = new List<AttributeState>(); subn = n.SelectSingleNode("IncludeAttributes"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Attr"); if (subs != null) { foreach (XmlNode sn in subs) { AttributeState attr = new AttributeState(); attr.ID = sn.SelectSingleNode("ID").InnerText; attr.Value = sn.SelectSingleNode("Value").InnerText; pq.IncludeAttributes.Add(attr); } } } pq.ExcludeAttributes = new List<AttributeState>(); subn = n.SelectSingleNode("ExcludeAttributes"); if (subn != null) { XmlNodeList subs = subn.SelectNodes("Attr"); if (subs != null) { foreach (XmlNode sn in subs) { AttributeState attr = new AttributeState(); attr.ID = sn.SelectSingleNode("ID").InnerText; attr.Value = sn.SelectSingleNode("Value").InnerText; pq.ExcludeAttributes.Add(attr); } } } pq.EMail = n.SelectSingleNode("EMail").InnerText; pq.FileFormat = n.SelectSingleNode("FileFormat").InnerText; pq.CompressFile = bool.Parse(n.SelectSingleNode("CompressFile").InnerText); pq.PQNameInFileName = bool.Parse(n.SelectSingleNode("PQNameInFileName").InnerText); result.Add(pq); } } } return result; }
public static BrowserScriptPocketQueriesPQSetting FromPQPage(Framework.Interfaces.ICore core, Framework.Interfaces.IPlugin plugin, WebBrowser wb) { BrowserScriptPocketQueriesPQSetting result = new BrowserScriptPocketQueriesPQSetting(); try { result.ID = Guid.NewGuid().ToString("N"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_tbName"); result.Name = wb.Document.GetElementById("ctl00_ContentBody_tbName").GetAttribute("value"); result.GenerateOnDays = new List<int>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbDays_"); for (int i = 0; i < 7; i++) { if (checkBoxChecked(wb, string.Format("ctl00_ContentBody_cbDays_{0}", i))) { result.GenerateOnDays.Add(i); } } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbRunOption_"); for (int i = 0; i < 3; i++) { if (checkBoxChecked(wb, string.Format("ctl00_ContentBody_rbRunOption_{0}", i))) { result.ExecutionScheme = i; break; } } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_tbResults"); result.MaximumCaches = wb.Document.GetElementById("ctl00_ContentBody_tbResults").GetAttribute("value"); result.GeocacheTypes = new List<int>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbTypeAny"); if (!radioButtonChecked(wb, "ctl00_ContentBody_rbTypeAny")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbTaxonomy_"); for (int i = 0; i < 11; i++) { if (checkBoxChecked(wb, string.Format("ctl00_ContentBody_cbTaxonomy_{0}", i))) { result.GeocacheTypes.Add(i); } } } result.GeocacheContainer = new List<int>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbContainerAny"); if (!radioButtonChecked(wb, "ctl00_ContentBody_rbContainerAny")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbContainers_"); for (int i = 0; i < 7; i++) { if (checkBoxChecked(wb, string.Format("ctl00_ContentBody_cbContainers_{0}", i))) { result.GeocacheContainer.Add(i); } } } result.WhichOptions = new List<int>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbOptions_"); for (int i = 0; i < 14; i++) { if (checkBoxChecked(wb, string.Format("ctl00_ContentBody_cbOptions_{0}", i))) { result.WhichOptions.Add(i); } } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbDifficulty"); if (checkBoxChecked(wb, "ctl00_ContentBody_cbDifficulty")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddDifficulty"); result.DifficultyCondition = wb.Document.GetElementById("ctl00_ContentBody_ddDifficulty").GetAttribute("value"); } else { result.DifficultyCondition = ""; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddDifficultyScore"); result.DifficultyValue = wb.Document.GetElementById("ctl00_ContentBody_ddDifficultyScore").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbTerrain"); if (checkBoxChecked(wb, "ctl00_ContentBody_cbTerrain")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddTerrain"); result.TerrainCondition = wb.Document.GetElementById("ctl00_ContentBody_ddTerrain").GetAttribute("value"); } else { result.TerrainCondition = ""; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddTerrainScore"); result.TerrainValue = wb.Document.GetElementById("ctl00_ContentBody_ddTerrainScore").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbNone"); if (radioButtonChecked(wb, "ctl00_ContentBody_rbNone")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbNone"); result.WithinSelection = "ctl00_ContentBody_rbNone"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbCountries")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbCountries"); result.WithinSelection = "ctl00_ContentBody_rbCountries"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbStates")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbStates"); result.WithinSelection = "ctl00_ContentBody_rbStates"; } else { result.WithinSelection = ""; } result.Countries = new List<string>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_lbCountries"); HtmlElement listel = wb.Document.GetElementById("ctl00_ContentBody_lbCountries"); foreach (HtmlElement el in listel.Children) { if (el.GetAttribute("selected") != null && (el.GetAttribute("selected").ToLower() == "selected" || el.GetAttribute("selected").ToLower() == "true")) { result.Countries.Add(el.GetAttribute("value")); } } result.States = new List<string>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_lbStates"); listel = wb.Document.GetElementById("ctl00_ContentBody_lbStates"); foreach (HtmlElement el in listel.Children) { if (el.GetAttribute("selected") != null && (el.GetAttribute("selected").ToLower() == "selected" || el.GetAttribute("selected").ToLower() == "true")) { result.States.Add(el.GetAttribute("value")); } } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbOriginNone"); if (radioButtonChecked(wb, "ctl00_ContentBody_rbOriginNone")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbOriginNone"); result.FromPointSelection = "ctl00_ContentBody_rbOriginNone"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbOriginHome")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbOriginHome"); result.FromPointSelection = "ctl00_ContentBody_rbOriginHome"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbOriginGC")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbOriginGC"); result.FromPointSelection = "ctl00_ContentBody_rbOriginGC"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbPostalCode")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbPostalCode"); result.FromPointSelection = "ctl00_ContentBody_rbPostalCode"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbOriginWpt")) { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbOriginWpt"); result.FromPointSelection = "ctl00_ContentBody_rbOriginWpt"; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_tbGC"); result.FromPointGCCode = wb.Document.GetElementById("ctl00_ContentBody_tbGC").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_tbPostalCode"); result.FromPointPostalCode = wb.Document.GetElementById("ctl00_ContentBody_tbPostalCode").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00$ContentBody$LatLong"); result.LatLonFormatValue = GetElementByName(wb.Document.Body, "ctl00$ContentBody$LatLong").GetAttribute("value"); result.NorthSouthValues = new List<string>(); result.EastWestValues = new List<string>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong:_selectNorthSouth"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong:_selectNorthSouth").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong:_selectEastWest"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong:_selectEastWest").GetAttribute("value")); if (result.LatLonFormatValue == "0") { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatDegs"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatDegs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongDegs"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongDegs").GetAttribute("value")); } else if (result.LatLonFormatValue == "1") { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatDegs"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatDegs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatMins"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatMins").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongDegs"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongDegs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongMins"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongMins").GetAttribute("value")); } else if (result.LatLonFormatValue == "2") { core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatDegs"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatDegs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatMins"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatMins").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLatSecs"); result.NorthSouthValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLatSecs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongDegs"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongDegs").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongMins"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongMins").GetAttribute("value")); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_LatLong__inputLongSecs"); result.EastWestValues.Add(wb.Document.GetElementById("ctl00_ContentBody_LatLong__inputLongSecs").GetAttribute("value")); } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_tbRadius"); result.WithinRadius = wb.Document.GetElementById("ctl00_ContentBody_tbRadius").GetAttribute("value"); if (radioButtonChecked(wb, "ctl00_ContentBody_rbUnitType_0")) { result.WithinRadiusUnitType = "ctl00_ContentBody_rbUnitType_0"; } else { result.WithinRadiusUnitType = "ctl00_ContentBody_rbUnitType_1"; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_rbPlacedNone"); if (radioButtonChecked(wb, "ctl00_ContentBody_rbPlacedNone")) { result.PlacedDuring = "ctl00_ContentBody_rbPlacedNone"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbPlacedLast")) { result.PlacedDuring = "ctl00_ContentBody_rbPlacedLast"; } else if (radioButtonChecked(wb, "ctl00_ContentBody_rbPlacedBetween")) { result.PlacedDuring = "ctl00_ContentBody_rbPlacedBetween"; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddLastPlaced"); result.PlacedDuringFixedInterval = wb.Document.GetElementById("ctl00_ContentBody_ddLastPlaced").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_DateTimeBegin_Year"); result.PlacedDuringFromDate = new DateTime( int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeBegin_Year").GetAttribute("value")), int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeBegin_Month").GetAttribute("value")), int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeBegin_Day").GetAttribute("value")) ); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_DateTimeEnd_Year"); result.PlacedDuringToDate = new DateTime( int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeEnd_Year").GetAttribute("value")), int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeEnd_Month").GetAttribute("value")), int.Parse(wb.Document.GetElementById("ctl00_ContentBody_DateTimeEnd_Day").GetAttribute("value")) ); result.IncludeAttributes = new List<AttributeState>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ctlAttrInclude_dtlAttributeIcons_ctl{0}_hidInput"); for (int i = 0; i < 70; i++) { HtmlElement el = wb.Document.GetElementById(string.Format("ctl00_ContentBody_ctlAttrInclude_dtlAttributeIcons_ctl{0}_hidInput", i.ToString("00"))); if (el != null) { AttributeState ats = new AttributeState(); ats.ID = el.GetAttribute("AttID"); ats.Value = el.GetAttribute("value"); result.IncludeAttributes.Add(ats); } } result.ExcludeAttributes = new List<AttributeState>(); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ctlAttrExclude_dtlAttributeIcons_ctl{0}_hidInput"); for (int i = 0; i < 70; i++) { HtmlElement el = wb.Document.GetElementById(string.Format("ctl00_ContentBody_ctlAttrExclude_dtlAttributeIcons_ctl{0}_hidInput", i.ToString("00"))); if (el != null) { AttributeState ats = new AttributeState(); ats.ID = el.GetAttribute("AttID"); ats.Value = el.GetAttribute("value"); result.ExcludeAttributes.Add(ats); } } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddlAltEmails"); try { result.EMail = wb.Document.GetElementById("ctl00_ContentBody_ddlAltEmails").GetAttribute("value"); } catch { result.EMail = ""; } core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbZip"); result.CompressFile = checkBoxChecked(wb, "ctl00_ContentBody_cbZip"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_ddFormats"); result.FileFormat = wb.Document.GetElementById("ctl00_ContentBody_ddFormats").GetAttribute("value"); core.DebugLog(Framework.Data.DebugLogLevel.Info, plugin, null, "ctl00_ContentBody_cbIncludePQNameInFileName"); result.PQNameInFileName = checkBoxChecked(wb, "ctl00_ContentBody_cbIncludePQNameInFileName"); } catch { result = null; } return result; }
private void button3_Click(object sender, EventArgs e) { SelectedSetting = listBox1.SelectedItem as BrowserScriptPocketQueriesPQSetting; DialogResult = System.Windows.Forms.DialogResult.OK; }