/// <summary>語の補足情報を取得します。XmlTextReader xtr の位置をElementからEndElementまで移動させます。</summary> /// <param name="refWord">この変数に参照する他の語の配列を渡します</param> /// <param name="example">この変数に例文の配列を渡します</param> private void readSubData(out string p, out string conj, out System.Collections.ArrayList refWordList, ref string[] example, out int shutsu, out int seikai) { //ref -> out についても考慮 refWordList = new System.Collections.ArrayList(); System.Collections.ArrayList exampleList = new System.Collections.ArrayList(); p = conj = ""; shutsu = seikai = 0; while (xtr.Read()) { if (xtr.NodeType == System.Xml.XmlNodeType.Element) { switch (xtr.Name) //Elementならその名前で場合分け { case "part": p = this.unescape(xtr.GetAttribute("value")); conj = this.unescape(xtr.GetAttribute("conjugate")); break; case "ref": string vName = this.unescape(xtr.GetAttribute("name")); string vType = xtr.GetAttribute("type"); if (vType == null) { vType = "Reference"; } string vMean = this.unescape(xtr.GetAttribute("mean")); string vPart = xtr.GetAttribute("part"); if (vPart == null) { vPart = "noun"; } refWordList.Add(new refWord(vName, vType, vPart, vMean)); break; case "xmp": //例文 exampleList.Add(this.unescape(xtr.ReadInnerXml())); break; case "exam": shutsu = System.Int32.Parse(xtr.GetAttribute("shutsudai")); seikai = System.Int32.Parse(xtr.GetAttribute("seikai")); break; } } else if (xtr.NodeType == System.Xml.XmlNodeType.EndElement) { example = (string[])exampleList.ToArray("s".GetType()); return; } } example = (string[])exampleList.ToArray("s".GetType()); } //public void readSubData() -->
internal static BroadCastReply ParseAndGet_BroadCastReply_FromXMLDataString(string XMLString) { System.IO.StringReader sr = null; System.Xml.XmlTextReader m_xmlr = null; BroadCastReply parsedBroadCartReplyfromXMLString = default(BroadCastReply); try { sr = new System.IO.StringReader(XMLString); m_xmlr = new System.Xml.XmlTextReader(sr); m_xmlr.WhitespaceHandling = System.Xml.WhitespaceHandling.None; } catch (System.Xml.XmlException) { string msg; msg = "Error trying to get XML format from Broad Cast Reply data string [" + XMLString + "]"; } catch (Exception ex) { string msg = ""; msg = "Error trying to parse Broad Cast Reply XML string : " + ex.Message; throw (new Exception(msg)); } m_xmlr.Read(); string HeaderIdentifier = m_xmlr.Name; if (HeaderIdentifier != "BROADCAST_REPLY") { throw (new System.Xml.XmlException("Invalid data socket header " + HeaderIdentifier + ". Must be \'BROADCAST_REPLY\'")); } else { string replyIDName = ""; replyIDName = m_xmlr.GetAttribute("replyIDName"); if (replyIDName == null) { throw (new Exception("Invalid XML string for a BroadCastReply, the attribute replyIDName is missing. Can´t parse the string")); } string dataXMLString = ""; dataXMLString = m_xmlr.ReadInnerXml(); DataVariable var = default(DataVariable); var = XMLDataFormatting.RetrieveDataVariableFromXMLString(dataXMLString); parsedBroadCartReplyfromXMLString = new BroadCastReply(replyIDName, System.Convert.ToString(var.Name), var.Data); } return(parsedBroadCartReplyfromXMLString); }
public void ProcessRequest(HttpContext context) { if (!SiteSecurity.IsValidContributor()) { context.Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html"); } SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string entryId = ""; string author = ""; string title = ""; string textToSave = ""; string redirectUrl = SiteUtilities.GetStartPageUrl(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(context.Request.InputStream); try { while (!xtr.EOF) { xtr.Read(); if (xtr.Name == "entryid") { entryId = xtr.ReadInnerXml(); } if (xtr.Name == "author") { author = xtr.ReadInnerXml(); } if (xtr.Name == "title" && xtr.NodeType == System.Xml.XmlNodeType.Element) { // Ensure this is the start element before moving forward to the CDATA. xtr.Read(); // Brings us to the CDATA inside "title" title = xtr.Value; } if (xtr.Name == "posttext" && xtr.NodeType == System.Xml.XmlNodeType.Element) { xtr.Read(); textToSave = xtr.Value; } } } finally { xtr.Close(); } // make sure the entry param is there if (entryId == null || entryId.Length == 0) { context.Response.Redirect(SiteUtilities.GetStartPageUrl(siteConfig)); return; } else { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); // First, attempt to get the entry. If the entry exists, then get it for editing // and save. If not, create a brand new entry and save it instead. Entry entry = dataService.GetEntry(entryId); if (entry != null) { entry = dataService.GetEntryForEdit(entryId); Entry modifiedEntry = entry.Clone(); modifiedEntry.Content = textToSave; modifiedEntry.Title = title; modifiedEntry.Author = author; modifiedEntry.Syndicated = false; modifiedEntry.IsPublic = false; modifiedEntry.ModifiedUtc = DateTime.Now.ToUniversalTime(); modifiedEntry.Categories = ""; dataService.SaveEntry(modifiedEntry, null); //context.Request.Form["textbox1"]; logService.AddEvent( new EventDataItem( EventCodes.EntryChanged, entryId, context.Request.RawUrl)); } else { // This is a brand new entry. Create the entry and save it. entry = new Entry(); entry.EntryId = entryId; entry.CreatedUtc = DateTime.Now.ToUniversalTime(); entry.ModifiedUtc = DateTime.Now.ToUniversalTime(); entry.Title = title; entry.Author = author; entry.Content = textToSave; entry.Syndicated = false; entry.IsPublic = false; dataService.SaveEntry(entry, null); //context.Request.Form["textbox1"]; logService.AddEvent( new EventDataItem( EventCodes.EntryAdded, entryId, context.Request.RawUrl)); } } }
public OAI_LIST(string sXML, ref Object objHandler) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null); while (reader.Read()) { if (reader.Name == "setSpec") { setSpec = reader.ReadString(); } else if (reader.Name == "setName") { setName = reader.ReadString(); } else if (reader.Name == "setDescription") { Type theHandlerType = Type.GetType(objHandler.ToString()); Object[] tobject = new object[1]; tobject[0] = reader.ReadInnerXml(); description = theHandlerType.InvokeMember("", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, tobject); } } }
public OAI_DC(string sXML) { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sXML, System.Xml.XmlNodeType.Element, null); while (reader.Read() && reader.Name != "oai_dc:dc" && reader.Name != "oaidc:dc") ; // Keep reading until finding oia_dc string oiaDCxml = reader.ReadInnerXml(); reader = new System.Xml.XmlTextReader(oiaDCxml, System.Xml.XmlNodeType.Element, null); while (reader.Read()) { string metadata = reader.Name.Replace("dc:", ""); // Remove optional dc: switch (metadata) { case "title": title.Add(reader.ReadString()); break; case "creator": creator.Add(reader.ReadString()); break; case "subject": subject.Add(reader.ReadString()); break; case "description": description.Add(reader.ReadString()); break; case "publisher": publisher.Add(reader.ReadString()); break; case "contributor": contributor.Add(reader.ReadString()); break; case "date": date.Add(reader.ReadString()); break; case "type": type.Add(reader.ReadString()); break; case "format": format.Add(reader.ReadString()); break; case "identifier": identifier.Add(reader.ReadString()); break; case "source": source.Add(reader.ReadString()); break; case "language": language.Add(reader.ReadString()); break; case "relation": relation.Add(reader.ReadString()); break; case "coverage": coverage.Add(reader.ReadString()); break; case "rights": rights.Add(reader.ReadString()); break; default: break; } } // end while }
public ListSet ListSets(ResumptionToken objToken, ref Object objHandler) { System.IO.Stream objStream; OAI_LIST objRecord; ListSet objList = new ListSet(); ResumptionToken myToken; string tmp = ""; System.Net.HttpWebRequest wr; System.Xml.XmlTextReader rd; if (objToken == null) { prequestURL = baseURL + "?verb=ListSets"; } else { prequestURL = baseURL + "?verb=ListSets&resumptionToken=" + objToken.resumptionToken; //This is where we handle the resumptionToken } //====================================================== // If you wanted to support additional metadata formats, // you would just need to have additional handlers. //====================================================== try { wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(prequestURL); wr.UserAgent = cUserAgent; System.Net.WebResponse response = wr.GetResponse(); objStream = response.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(objStream); prawXML = reader.ReadToEnd(); reader.Close(); rd = new System.Xml.XmlTextReader(prawXML, System.Xml.XmlNodeType.Document, null); } catch (Exception e) { error.errorName = e.ToString(); error.errorDescription = e.Message + "\n<br>Unable to connect to " + baseURL; return null; } while (rd.Read()) { if (rd.NodeType == System.Xml.XmlNodeType.Element) { if (rd.Name == "responseDate") { presponseDate = rd.ReadString(); } else if (rd.Name == "ListSets") { //while (rd.Read()) do { if (rd.Name == "set") { objRecord = new OAI_LIST(rd.ReadInnerXml(), ref objHandler); objList.listset.Add(objRecord); //return objRecord; } else if (rd.Name == "resumptionToken") { tmp = rd.ReadOuterXml(); myToken = new ResumptionToken(tmp); objList.token = myToken; } else rd.Read(); // Added the Read() and will never occur with the ReadInnerXml() } while (rd.Name != "ListSets"); // loop } else if (rd.Name == "error") { error.errorName = rd.GetAttribute("code"); error.errorDescription = rd.ReadString(); return null; } } } rd.Close(); return objList; }
/// <summary> /// Checks for new updates for the application /// </summary> public UpdateInfo CheckForUpdates(Uri relativeURL) { UpdateInfo info = new UpdateInfo(); info.Update = false; string[] CurrentVersion = new string[4]; // To see if the user is connected to the internet... if (!CheckInternetConnection()) { // return they have no internet connection return info; } try { System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(relativeURL.ToString()); wr.UserAgent = "PARTY BUFFALO\r\n"; System.Net.WebResponse response = wr.GetResponse(); Stream responseStream = response.GetResponseStream(); System.Xml.XmlTextReader r = new System.Xml.XmlTextReader(responseStream); while (r.Read()) { if (r.NodeType == System.Xml.XmlNodeType.Element) { // If we're getting the current version that's available if (r.Name == "CurrentVersion") { // Set the update version to the inner text info.UpdateVersion = r.ReadInnerXml(); // Split it at every instance of a period so that // we can compare each number individually CurrentVersion = info.UpdateVersion.Split('.'); // Get our current version, split that as well string[] AppVersion = System.Windows.Forms.Application.ProductVersion.Split('.'); // Create new int arrays that contain the current & // updated versions int[] Current = new int[4]; int[] App = new int[4]; // Set their indexes accordingly for (int i = 0; i < Current.Length; i++) { Current[i] = Convert.ToInt32(CurrentVersion[i]); App[i] = Convert.ToInt32(AppVersion[i]); } // If the major is larger than current, there's an update if (Current[0] > App[0]) { info.Update = true; return info; } else if (Current[0] < App[0]) { return info; } // If the minor is larger than the current, there's an update :O if (Current[1] > App[1]) { info.Update = true; return info; } else if (Current[1] < App[1]) { return info; } // Same for build if (Current[2] > App[2]) { info.Update = true; return info; } else if (Current[2] < App[2]) { return info; } // Same for revision if (Current[3] > App[3]) { info.Update = true; return info; } else if (Current[3] < App[3]) { return info; } // None of those guys returned anything -- they must have // the current version, return our info return info; } if (r.Name == "UpdateFixes") { info.UpdateText = r.ReadInnerXml(); } if (r.Name == "UpdatePath") { info.UpdatePath = r.ReadInnerXml(); } if (r.Name == "UpdateDLLPath") { info.UpdateDLLPath = r.ReadInnerXml(); } if (r.Name == "DLLNeeded") { if (r.ReadInnerXml() == "true") { info.DLLNeeded = true; } else { info.DLLNeeded = false; } } if (r.Name == "QuickMessage") { info.QuickMessage = r.ReadInnerXml(); } } } } catch { return info; } return info; }
internal static P2PDataRequest ParseAndGet_P2PDataRequest_FromXMLDataString(string XMLString) { System.IO.StringReader sr = null; System.Xml.XmlTextReader m_xmlr = null; try { sr = new System.IO.StringReader(XMLString); m_xmlr = new System.Xml.XmlTextReader(sr); m_xmlr.WhitespaceHandling = System.Xml.WhitespaceHandling.None; } catch (System.Xml.XmlException) { string msg; msg = "Error trying to get XML format from P2PDataRequest Data string [" + XMLString + "]"; } catch (Exception ex) { string msg = ""; msg = "Error trying to parse P2PDataRequest XML string : " + ex.Message; throw (new Exception(msg)); } m_xmlr.Read(); string HeaderIdentifier = m_xmlr.Name; if (HeaderIdentifier != "P2P_DATAREQUEST") { throw (new System.Xml.XmlException("Invalid P2PDataRequest header " + HeaderIdentifier + ". Must be \'P2P_DATAREQUEST\'")); } else { string datanameToRequest = m_xmlr.GetAttribute("datanameToRequest"); if (datanameToRequest == null) { throw (new Exception("No dataname to retrieve attribute found in the P2PDataRequest XML String")); } m_xmlr.Read(); string AttributesSectionName = m_xmlr.Name; if (AttributesSectionName != "DATA_REQUEST_PARAMETERS") { throw (new Exception("Invalid section name \'" + AttributesSectionName + "\'")); } string parametersCountStr = m_xmlr.GetAttribute("ParametersCount"); int numOfParameters = 0; CustomHashTable parametersTable = null; if (!(parametersCountStr == null)) { numOfParameters = System.Convert.ToInt32(parametersCountStr); if (numOfParameters > 0) { string attrTableXMLString = m_xmlr.ReadInnerXml(); DataVariable tableVar = default(DataVariable); tableVar = XMLDataFormatting.RetrieveDataVariableFromXMLString(attrTableXMLString); parametersTable = (CustomHashTable)tableVar.Data; } } else { throw (new Exception("The parameter \'AttrCount\' is missing on the XML string of the section \'REQUEST_ATTRIBUTES\'")); } P2PDataRequest dataRq = default(P2PDataRequest); if (numOfParameters > 0) { if (!(parametersTable == null)) { dataRq = new P2PDataRequest(datanameToRequest, parametersTable); } else { dataRq = new P2PDataRequest(datanameToRequest); } } else { dataRq = new P2PDataRequest(datanameToRequest); } return(dataRq); } }
private System.Collections.ArrayList Process_SRU(string xml) { System.Xml.XmlTextReader rd; System.Collections.ArrayList tp = new System.Collections.ArrayList(); System.Xml.XmlDocument objDoc = new System.Xml.XmlDocument(); objDoc.XmlResolver = null; System.Xml.XmlNamespaceManager Manager = new System.Xml.XmlNamespaceManager(objDoc.NameTable); System.Xml.XmlNodeList objNodes; string RetrievedRecords = "0"; System.Collections.ArrayList RecordSet = new System.Collections.ArrayList(); rd = new System.Xml.XmlTextReader(xml, System.Xml.XmlNodeType.Document, null); string RecordPosition = "1"; while (rd.Read()) { if (rd.NodeType == System.Xml.XmlNodeType.Element) { if (rd.Name.IndexOf("numberOfRecords") > -1) { RetrievedRecords = rd.ReadString(); } if (rd.Name.IndexOf("recordData") > -1) { RecordSet.Add(rd.ReadInnerXml()); //this needs to go somewhere } if (rd.Name.IndexOf("recordPosition") > -1) { RecordPosition = rd.ReadString(); } } } rd.Close(); for (int x = 0; x < RecordSet.Count; x++) { struct_Records st_recs = new struct_Records(); st_recs.xml = (string)RecordSet[x]; Manager.AddNamespace("marc", "http://www.loc.gov/MARC21/slim"); //try //{ objDoc.LoadXml((string)RecordSet[x]); objNodes = objDoc.SelectNodes("marc:record/marc:datafield[@tag='150']", Manager); if (objNodes == null) { objNodes = objDoc.SelectNodes("record/datafield[@tag='150']", Manager); } foreach (System.Xml.XmlNode objNode in objNodes) { st_recs.xml = objNode.InnerXml; System.Xml.XmlNodeList codes = objNode.SelectNodes("marc:subfield", Manager); if (codes == null) { codes = objNode.SelectNodes("subfield", Manager); } foreach (System.Xml.XmlNode objN in codes) { st_recs.display += objN.InnerText + " -- "; st_recs.main += "$" + objN.Attributes["code"].InnerText + objN.InnerText; } if (st_recs.display != null) { st_recs.display = st_recs.display.TrimEnd(" -".ToCharArray()); } else { st_recs.display = ""; } } if (objNodes.Count <= 0) { st_recs.main = "Undefined"; st_recs.xml = "<undefined>undefined</undefined>"; } //} //catch //{ // return null; //} tp.Add(st_recs); } RecordCount = System.Convert.ToInt32(RetrievedRecords); return tp; }
public void ProcessRequest( HttpContext context ) { if (!SiteSecurity.IsValidContributor()) { context.Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html"); } SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string entryId = ""; string author = ""; string title = ""; string textToSave = ""; string redirectUrl = SiteUtilities.GetStartPageUrl(); System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(context.Request.InputStream); try { while (!xtr.EOF) { xtr.Read(); if (xtr.Name=="entryid") { entryId = xtr.ReadInnerXml(); } if (xtr.Name=="author") { author = xtr.ReadInnerXml(); } if (xtr.Name=="title" && xtr.NodeType == System.Xml.XmlNodeType.Element) { // Ensure this is the start element before moving forward to the CDATA. xtr.Read(); // Brings us to the CDATA inside "title" title = xtr.Value; } if (xtr.Name=="posttext" && xtr.NodeType == System.Xml.XmlNodeType.Element) { xtr.Read(); textToSave = xtr.Value; } } } finally { xtr.Close(); } // make sure the entry param is there if (entryId == null || entryId.Length == 0) { context.Response.Redirect(SiteUtilities.GetStartPageUrl(siteConfig)); return; } else { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService ); // First, attempt to get the entry. If the entry exists, then get it for editing // and save. If not, create a brand new entry and save it instead. Entry entry = dataService.GetEntry(entryId); if ( entry != null ) { entry = dataService.GetEntryForEdit( entryId ); Entry modifiedEntry = entry.Clone(); modifiedEntry.Content = textToSave; modifiedEntry.Title = title; modifiedEntry.Author = author; modifiedEntry.Syndicated = false; modifiedEntry.IsPublic = false; modifiedEntry.ModifiedUtc = DateTime.Now.ToUniversalTime(); modifiedEntry.Categories = ""; dataService.SaveEntry(modifiedEntry, null); //context.Request.Form["textbox1"]; logService.AddEvent( new EventDataItem( EventCodes.EntryChanged, entryId, context.Request.RawUrl)); } else { // This is a brand new entry. Create the entry and save it. entry = new Entry(); entry.EntryId = entryId; entry.CreatedUtc = DateTime.Now.ToUniversalTime(); entry.ModifiedUtc = DateTime.Now.ToUniversalTime(); entry.Title = title; entry.Author = author; entry.Content = textToSave; entry.Syndicated = false; entry.IsPublic = false; dataService.SaveEntry(entry, null); //context.Request.Form["textbox1"]; logService.AddEvent( new EventDataItem( EventCodes.EntryAdded, entryId, context.Request.RawUrl)); } } }
internal static P2PData ParseAndGet_P2PData_FromXMLDataString(string XMLString) { System.IO.StringReader sr = null; System.Xml.XmlTextReader m_xmlr = null; try { sr = new System.IO.StringReader(XMLString); m_xmlr = new System.Xml.XmlTextReader(sr); m_xmlr.WhitespaceHandling = System.Xml.WhitespaceHandling.None; } catch (System.Xml.XmlException) { string msg; msg = "Error trying to get XML format from P2P Data string [" + XMLString + "]"; } catch (Exception ex) { string msg = ""; msg = "Error trying to parse P2P socket XML string : " + ex.Message; throw (new Exception(msg)); } m_xmlr.Read(); string HeaderIdentifier = m_xmlr.Name; if (HeaderIdentifier != "P2P_DATA") { throw (new System.Xml.XmlException("Invalid P2P data header " + HeaderIdentifier + ". Must be \'P2P_DATA\'")); } else { //********************************************************** //retrieves the data operation type //********************************************************** string operationID = ""; operationID = m_xmlr.GetAttribute("P2PDataOperationID"); if (operationID == null) { operationID = Guid.NewGuid().ToString(); } //********************************************************** //retrieves the data itself //********************************************************** m_xmlr.Read(); string dataSectionName = m_xmlr.Name; DataVariable variable = default(DataVariable); if (dataSectionName == "DATA") { string variableXMLstring = m_xmlr.ReadOuterXml(); variable = XMLDataFormatting.RetrieveDataVariableFromXMLString(variableXMLstring); } else { throw (new Exception("Invalid data XML section name \'" + dataSectionName + "\'. Is expected to be \'DATA\'")); } //********************************************************** //retrieves the attributes table and its XML attributes //********************************************************** string dataAttributesSectionName = m_xmlr.Name; P2PDataAttributesTable attrTAble = null; int AttrCount = 0; if (dataAttributesSectionName == "DATA_ATTRIBUTES") { string attributesCount = m_xmlr.GetAttribute("DataAttrCount"); if (!(attributesCount == null)) { AttrCount = System.Convert.ToInt32(attributesCount); if (AttrCount > 0) { string attrTableXMLString = m_xmlr.ReadInnerXml(); DataVariable tableVar = default(DataVariable); tableVar = XMLDataFormatting.RetrieveDataVariableFromXMLString(attrTableXMLString); attrTAble = new P2PDataAttributesTable((CustomHashTable)tableVar.Data); } } else { throw (new Exception("The parameter \'AttrCount\' is missing on the XML string in te section \'DATA_ATTRIBUTES\'")); } } else { throw (new Exception("Invalid data attributes XML section name \'" + dataSectionName + "\'. Is expected to be \'DATA_ATTRIBUTES\'")); } P2PData data = default(P2PData); data = new P2PData(operationID, System.Convert.ToString(variable.Name), variable.Data); if (AttrCount > 0) { data.AttachAttributesTable(attrTAble); } return(data); } }
public static SocketData ParseAndGet_SocketData_FromXMLDataString(string XMLString) { System.IO.StringReader sr = null; System.Xml.XmlTextReader m_xmlr = null; try { sr = new System.IO.StringReader(XMLString); m_xmlr = new System.Xml.XmlTextReader(sr); m_xmlr.WhitespaceHandling = System.Xml.WhitespaceHandling.None; } catch (System.Xml.XmlException) { string msg; msg = "Error trying to get XML format from data socket data string [" + XMLString + "]"; } catch (Exception ex) { string msg = ""; msg = "Error trying to parse data socket XML string : " + ex.Message; throw (new Exception(msg)); } m_xmlr.Read(); string HeaderIdentifier = m_xmlr.Name; if (HeaderIdentifier != "SD") { throw (new System.Xml.XmlException("Invalid data socket header " + HeaderIdentifier + ". Must be \'SD\'")); } else { //********************************************************** //retrieves the data transported on the XML //********************************************************** m_xmlr.Read(); string dataSectionName = m_xmlr.Name; DataVariable variable = default(DataVariable); if (dataSectionName == "DATA") { string variableXMLstring = m_xmlr.ReadOuterXml(); variable = XMLDataFormatting.RetrieveDataVariableFromXMLString(variableXMLstring); } else { throw (new Exception("Invalid data XML section name \'" + dataSectionName + "\'. Is expected to be \'DATA\'")); } //********************************************************** //retrieves the attributes table and its XML attributes //********************************************************** string dataAttributesSectionName = m_xmlr.Name; AttributesTable attributesTable = null; int AttrCount = 0; if (dataAttributesSectionName == "SDAS") { string attributesCount = m_xmlr.GetAttribute("cn"); if (!(attributesCount == null)) { AttrCount = System.Convert.ToInt32(attributesCount); if (AttrCount > 0) { string attrTableXMLString = m_xmlr.ReadInnerXml(); DataVariable tableVar = default(DataVariable); tableVar = XMLDataFormatting.RetrieveDataVariableFromXMLString(attrTableXMLString); CustomHashTable table = default(CustomHashTable); table = (CustomHashTable)tableVar.Data; attributesTable = new AttributesTable(table); } } else { throw (new Exception("The parameter \'cn\' is missing on the XML string in te section \'SDAS\'")); } } else { throw (new Exception("Invalid data attributes XML section name \'" + dataSectionName + "\'. Is expected to be \'SD_ATTRS\'")); } SocketData data = default(SocketData); data = new SocketData(System.Convert.ToString(variable.Name), variable.Data); if (AttrCount > 0) { data.AttachAttributesTable(attributesTable); } return(data); } }
/// <summary> /// Checks for new updates for the application /// </summary> public UpdateInfo CheckForUpdates(Uri relativeURL) { UpdateInfo info = new UpdateInfo(); info.Update = false; string[] CurrentVersion = new string[4]; // To see if the user is connected to the internet... if (!CheckInternetConnection()) { // return they have no internet connection return(info); } try { System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(relativeURL.ToString()); wr.UserAgent = "PARTY BUFFALO\r\n"; System.Net.WebResponse response = wr.GetResponse(); Stream responseStream = response.GetResponseStream(); System.Xml.XmlTextReader r = new System.Xml.XmlTextReader(responseStream); while (r.Read()) { if (r.NodeType == System.Xml.XmlNodeType.Element) { // If we're getting the current version that's available if (r.Name == "CurrentVersion") { // Set the update version to the inner text info.UpdateVersion = r.ReadInnerXml(); // Split it at every instance of a period so that // we can compare each number individually CurrentVersion = info.UpdateVersion.Split('.'); // Get our current version, split that as well string[] AppVersion = System.Windows.Forms.Application.ProductVersion.Split('.'); // Create new int arrays that contain the current & // updated versions int[] Current = new int[4]; int[] App = new int[4]; // Set their indexes accordingly for (int i = 0; i < Current.Length; i++) { Current[i] = Convert.ToInt32(CurrentVersion[i]); App[i] = Convert.ToInt32(AppVersion[i]); } // If the major is larger than current, there's an update if (Current[0] > App[0]) { info.Update = true; return(info); } else if (Current[0] < App[0]) { return(info); } // If the minor is larger than the current, there's an update :O if (Current[1] > App[1]) { info.Update = true; return(info); } else if (Current[1] < App[1]) { return(info); } // Same for build if (Current[2] > App[2]) { info.Update = true; return(info); } else if (Current[2] < App[2]) { return(info); } // Same for revision if (Current[3] > App[3]) { info.Update = true; return(info); } else if (Current[3] < App[3]) { return(info); } // None of those guys returned anything -- they must have // the current version, return our info return(info); } if (r.Name == "UpdateFixes") { info.UpdateText = r.ReadInnerXml(); } if (r.Name == "UpdatePath") { info.UpdatePath = r.ReadInnerXml(); } if (r.Name == "UpdateDLLPath") { info.UpdateDLLPath = r.ReadInnerXml(); } if (r.Name == "DLLNeeded") { if (r.ReadInnerXml() == "true") { info.DLLNeeded = true; } else { info.DLLNeeded = false; } } if (r.Name == "QuickMessage") { info.QuickMessage = r.ReadInnerXml(); } } } } catch { return(info); } return(info); }