private void process_package_tag(XmlNodeReader nodeReader, SobekCM_Item thisPackage) { // Get the value of whether this is a new package if (nodeReader.HasAttributes) { // Move to what should be the bib id attribute nodeReader.MoveToAttribute(0); if (nodeReader.Name == "new") { thisPackage.METS_Header.RecordStatus_Enum = METS_Record_Status.COMPLETE; } } }
private void process_entity_tag_and_project(XmlNodeReader nodeReader, SobekCM_Item thisPackage) { // Process the attributes on the entityDesc int attributes = nodeReader.AttributeCount; for (int i = 0; i < attributes; i++) { // Go to this attribute nodeReader.MoveToAttribute(i); // If this is type, save it if (nodeReader.Name.Trim().ToUpper() == "TYPE") { thisPackage.Bib_Info.Type.Add_Uncontrolled_Type(nodeReader.Value.Trim()); } // If this is the source code, save that if (nodeReader.Name.Trim().ToUpper() == "SOURCE") { thisPackage.Bib_Info.Source.Code = nodeReader.Value.Trim(); thisPackage.Bib_Info.Source.Statement = nodeReader.Value.Trim(); } } // Read the project code.. first being the primary move_to_node(nodeReader, "projects"); // Get the text from this node nodeReader.Read(); string projectText = nodeReader.Value.Trim(); thisPackage.Behaviors.Add_Aggregation(projectText); }
private void process_packageDesc(XmlNodeReader nodeReader, SobekCM_Item thisPackage) { // Get the bib id first if (nodeReader.HasAttributes) { // Move to what should be the bib id attribute nodeReader.MoveToAttribute(0); if (nodeReader.Name == "id") thisPackage.BibID = nodeReader.Value.Trim(); } // Read in the rest of the data until the closing packageDesc tag while ((nodeReader.Read()) && (nodeReader.Name.Trim() != "packageDesc")) { // Is this the opening tag for contrib? if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.Trim() == "contrib")) { // Get the attribute if (nodeReader.HasAttributes) { nodeReader.MoveToAttribute(0); if (nodeReader.Name.Trim() == "creator") { // Get the value string creatorValue = nodeReader.Value; // If there is a comma, parse it if (creatorValue.IndexOf(",") > 0) { string[] split = creatorValue.Split(",".ToCharArray()); thisPackage.METS_Header.Creator_Software = split[0].Trim(); thisPackage.METS_Header.Creator_Individual = split[1].Trim(); } else { thisPackage.METS_Header.Creator_Individual = creatorValue.Trim(); } } } // Get the text of this... this is the institution that made the MXF if ((nodeReader.Read()) && (nodeReader.NodeType == XmlNodeType.Text)) { thisPackage.METS_Header.Creator_Organization = nodeReader.Value.Trim(); } } // Is this the opening tag for the timestamp? if ((nodeReader.NodeType == XmlNodeType.Element) && (nodeReader.Name.Trim() == "timestamp")) { // Get the text of this... this is the timestamp if ((nodeReader.Read()) && (nodeReader.NodeType == XmlNodeType.Text)) { string mxf_dateString = nodeReader.Value.Trim(); string dateString = mxf_dateString.Substring(0, 4) + "/" + mxf_dateString.Substring(4, 2) + "/" + mxf_dateString.Substring(6, 2) + " " + mxf_dateString.Substring(9, 2) + ":" + mxf_dateString.Substring(11, 2) + ":" + mxf_dateString.Substring(13, 2); thisPackage.METS_Header.Create_Date = Convert.ToDateTime(dateString); } } } }
private static void read_banners(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:SOURCE": // Check for any attributes to this banner node string lang = String.Empty; bool special = false; Item_Aggregation_Front_Banner_Type_Enum type = Item_Aggregation_Front_Banner_Type_Enum.Left; ushort width = 550; ushort height = 230; if (NodeReader.HasAttributes) { if (NodeReader.MoveToAttribute("lang")) { lang = NodeReader.Value.Trim().ToUpper(); } if (NodeReader.MoveToAttribute("type")) { if ((NodeReader.Value.Trim().ToUpper() == "HIGHLIGHT") || ( NodeReader.Value.Trim().ToUpper() == "FRONT")) special = true; } if (NodeReader.MoveToAttribute("side")) { switch (NodeReader.Value.Trim().ToUpper()) { case "RIGHT": type = Item_Aggregation_Front_Banner_Type_Enum.Right; break; case "LEFT": type = Item_Aggregation_Front_Banner_Type_Enum.Left; break; case "FULL": type = Item_Aggregation_Front_Banner_Type_Enum.Full; break; } } if (NodeReader.MoveToAttribute("width")) { ushort.TryParse(NodeReader.Value, out width); } if (NodeReader.MoveToAttribute("height")) { ushort.TryParse(NodeReader.Value, out height); } } // Now read the banner information and add to the aggregation object NodeReader.Read(); if (special) { Item_Aggregation_Front_Banner bannerObj = HierarchyObject.Add_Front_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum( lang)); bannerObj.Width = width; bannerObj.Height = height; bannerObj.Type = type; } else { HierarchyObject.Add_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang)); } break; } } if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:BANNER")) { return; } } }
private void process_bib_desc(XmlNodeReader nodeReader, SobekCM_Item thisPackage) { // Set some counters for the creator role/date and contributor role/date int creatorRole = 0; int creatorDate = 0; //int contribRole = 0; //int contribDate = 0; // Read all the nodes while (nodeReader.Read()) { // If this is the end tag for bibDesc, return if ((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeReader.Name.Trim().ToUpper() == "BIBDESC")) { return; } // If this is the beginning tag for an element, assign the next values accordingly if (nodeReader.NodeType == XmlNodeType.Element) { // Switch based on the element name switch (nodeReader.Name.Trim().ToUpper()) { case "DC.TITLE": thisPackage.Bib_Info.Main_Title.Title = read_text_node(nodeReader); break; case "DC.RIGHTS": thisPackage.Bib_Info.Access_Condition.Text = read_text_node(nodeReader); break; case "DC.IDENTIFIER": thisPackage.Bib_Info.Add_Identifier(read_text_node(nodeReader)); break; case "DC.DATE": thisPackage.Bib_Info.Origin_Info.Date_Issued = read_text_node(nodeReader); break; case "DC.CREATOR": thisPackage.Bib_Info.Add_Named_Entity(read_text_node(nodeReader), "creator"); break; case "PALMM.CREATORROLE": if (thisPackage.Bib_Info.Names_Count > creatorRole) { if (thisPackage.Bib_Info.Names[creatorRole].Roles.Count == 0) { thisPackage.Bib_Info.Names[creatorRole].Roles.Add(new Name_Info_Role(read_text_node(nodeReader), Name_Info_Role_Type_Enum.text)); } else { thisPackage.Bib_Info.Names[creatorRole].Roles[0].Role = read_text_node(nodeReader); } creatorRole++; } break; case "PALMM.CREATORDATES": if (thisPackage.Bib_Info.Names_Count > creatorDate) { thisPackage.Bib_Info.Names[creatorDate++].Dates = read_text_node(nodeReader); } break; case "DC.CONTRIBUTOR": thisPackage.Bib_Info.Add_Named_Entity(new Name_Info(read_text_node(nodeReader), "contributor")); break; case "DC.DESCRIPTION": thisPackage.Bib_Info.Add_Note(new Note_Info(read_text_node(nodeReader))); break; case "DC.SUBJECT": if (nodeReader.HasAttributes) { nodeReader.MoveToAttribute(0); string scheme = nodeReader.Value.Trim(); thisPackage.Bib_Info.Add_Subject(new Subject_Info_Standard(read_text_node(nodeReader), scheme)); } else { thisPackage.Bib_Info.Add_Subject(new Subject_Info_Standard(read_text_node(nodeReader), String.Empty)); } break; case "PALMM.SPATIALNAME": if (nodeReader.HasAttributes) { nodeReader.MoveToAttribute(0); string scheme = nodeReader.Value.Trim(); Subject_Info_HierarchicalGeographic thisSpatial = new Subject_Info_HierarchicalGeographic(); thisSpatial.Authority = scheme; thisSpatial.Area = read_text_node(nodeReader); thisPackage.Bib_Info.Add_Subject(thisSpatial); } else { Subject_Info_HierarchicalGeographic thisSpatial = new Subject_Info_HierarchicalGeographic(); thisSpatial.Area = read_text_node(nodeReader); thisPackage.Bib_Info.Add_Subject(thisSpatial); } break; case "DC.FORMAT.EXTENT": thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader); break; case "DC.TYPE": if (thisPackage.Bib_Info.Original_Description.Extent.Length > 0) { thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader) + " ( " + thisPackage.Bib_Info.Original_Description.Extent + " )"; } else { thisPackage.Bib_Info.Original_Description.Extent = read_text_node(nodeReader); } break; case "PALMM.LOCATION": thisPackage.Bib_Info.Location.Holding_Name = read_text_node(nodeReader); break; case "PALMM.NOTES": thisPackage.Bib_Info.Add_Note(read_text_node(nodeReader)); break; } } } }
private static void read_results_specs(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { bool inViews = false; while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly string nodeName; if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper nodeName = NodeReader.Name.Trim().ToUpper(); switch (nodeName) { case "HI:VIEWS": inViews = true; break; case "HI:ADD": if ( inViews ) { bool isDefault = false; string type = String.Empty; if (NodeReader.MoveToAttribute("default")) { isDefault = true; } if (NodeReader.MoveToAttribute("type")) { type = NodeReader.Value.ToUpper(); } if (type.Length > 0) { Result_Display_Type_Enum displayType = Result_Display_Type_Enum.Default; switch (type) { case "BRIEF": displayType = Result_Display_Type_Enum.Brief; break; case "FULL": displayType = Result_Display_Type_Enum.Full_Citation; break; case "THUMBNAIL": displayType = Result_Display_Type_Enum.Thumbnails; break; case "TABLE": displayType = Result_Display_Type_Enum.Table; break; case "MAP": displayType = Result_Display_Type_Enum.Map; break; } if (displayType != Result_Display_Type_Enum.Default) { if (!HierarchyObject.Result_Views.Contains(displayType)) { HierarchyObject.Result_Views.Add(displayType); } if (isDefault) { HierarchyObject.Default_Result_View = displayType; } } } } break; case "HI:REMOVE": if (inViews) { string type = String.Empty; if (NodeReader.MoveToAttribute("type")) { type = NodeReader.Value.ToUpper(); } if (type.Length > 0) { Result_Display_Type_Enum displayType = Result_Display_Type_Enum.Default; switch (type) { case "BRIEF": displayType = Result_Display_Type_Enum.Brief; break; case "FULL": displayType = Result_Display_Type_Enum.Full_Citation; break; case "THUMBNAIL": displayType = Result_Display_Type_Enum.Thumbnails; break; case "TABLE": displayType = Result_Display_Type_Enum.Table; break; case "MAP": displayType = Result_Display_Type_Enum.Map; break; } if (displayType != Result_Display_Type_Enum.Default) { if (HierarchyObject.Result_Views.Contains(displayType)) { HierarchyObject.Result_Views.Remove(displayType); } } } } break; } } // If this is not an end element, continue if (NodeReader.NodeType != XmlNodeType.EndElement) continue; // Get the node name, trimmed and to upper nodeName = NodeReader.Name.Trim().ToUpper(); switch ( nodeName ) { case "HI:VIEWS": inViews = false; break; case "HI:RESULTS": return; } } }
private static void read_settings(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:WEBSKINS": NodeReader.Read(); string webskins = NodeReader.Value; string[] splitter = webskins.Split(",".ToCharArray()); foreach (string thisSplitter in splitter) { if ( thisSplitter.Length > 0 ) HierarchyObject.Add_Web_Skin(thisSplitter.ToLower()); } break; case "HI:CSS": NodeReader.Read(); HierarchyObject.CSS_File = NodeReader.Value.Trim(); break; case "HI:CUSTOMHOME": NodeReader.Read(); // No longer do anything with this tag // HierarchyObject.Custom_Home_Page_Source_File = NodeReader.Value.Trim(); break; case "HI:FACETS": NodeReader.Read(); string facets = NodeReader.Value; string[] splitter2 = facets.Split(",".ToCharArray()); HierarchyObject.Clear_Facets(); foreach (string thisSplitter2 in splitter2) { HierarchyObject.Add_Facet(Convert.ToInt16(thisSplitter2)); } break; case "HI:MAPSEARCH": if (NodeReader.MoveToAttribute("type")) { switch (NodeReader.GetAttribute("type").ToLower()) { case "extent": case "computed": // This should already be set, assuming there were values to be added if (HierarchyObject.Map_Search_Display == null) { HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED); } break; case "fixed": decimal latitude = 999; decimal longitude = 999; int zoom = 999; if (NodeReader.MoveToAttribute("latitude")) { Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude); } if (NodeReader.MoveToAttribute("longitude")) { Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude); } if (NodeReader.MoveToAttribute("zoom")) { Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom); } if ((latitude != 999) && (longitude != 999)) { HierarchyObject.Map_Search_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude ); } break; } } break; case "HI:MAPBROWSE": if (NodeReader.MoveToAttribute("type")) { switch (NodeReader.GetAttribute("type").ToLower()) { case "extent": HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.EXTENT); break; case "computed": HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.COMPUTED); break; case "fixed": decimal latitude = 999; decimal longitude = 999; int zoom = 999; if (NodeReader.MoveToAttribute("latitude")) { Decimal.TryParse(NodeReader.GetAttribute("latitude"), out latitude); } if (NodeReader.MoveToAttribute("longitude")) { Decimal.TryParse(NodeReader.GetAttribute("longitude"), out longitude); } if (NodeReader.MoveToAttribute("zoom")) { Int32.TryParse(NodeReader.GetAttribute("zoom"), out zoom); } if ((latitude != 999) && (longitude != 999)) { HierarchyObject.Map_Browse_Display = new Item_Aggregation_Map_Coverage_Info(Item_Aggregation_Map_Coverage_Type_Enum.FIXED, zoom, longitude, latitude); } break; } } break; } } if (NodeReader.NodeType == XmlNodeType.EndElement) { if (NodeReader.Name.Trim().ToUpper() == "HI:SETTINGS") { return; } } } }
private static void read_highlights(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { Complete_Item_Aggregation_Highlights highlight = new Complete_Item_Aggregation_Highlights(); // Determine if this is a rotating type of highlight or not if (NodeReader.HasAttributes) { if (NodeReader.MoveToAttribute("type")) { if (NodeReader.Value == "ROTATING") HierarchyObject.Rotating_Highlights = true; } if (HierarchyObject.Front_Banner_Dictionary != null) { // The following three values are for reading legacy XML files. These // data fields have been moved to be attached to the actual banner if (NodeReader.MoveToAttribute("bannerSide")) { if (NodeReader.Value.Trim().ToUpper() == "RIGHT") { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Right; } else { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Left; } } if (NodeReader.MoveToAttribute("bannerHeight")) { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Height = Convert.ToUInt16(NodeReader.Value); } if (NodeReader.MoveToAttribute("bannerWidth")) { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Width = Convert.ToUInt16(NodeReader.Value); } } } while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name string languageText; switch (nodeName) { case "HI:SOURCE": NodeReader.Read(); highlight.Image = NodeReader.Value.ToLower(); break; case "HI:LINK": NodeReader.Read(); highlight.Link = NodeReader.Value.ToLower(); break; case "HI:TOOLTIP": languageText = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) languageText = NodeReader.Value.ToUpper(); NodeReader.Read(); highlight.Add_Tooltip( Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value ); break; case "HI:TEXT": languageText = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) languageText = NodeReader.Value.ToUpper(); NodeReader.Read(); highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value); break; } } if (NodeReader.NodeType == XmlNodeType.EndElement) { if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT" ) { if (HierarchyObject.Highlights == null) HierarchyObject.Highlights = new List<Complete_Item_Aggregation_Highlights>(); HierarchyObject.Highlights.Add(highlight); highlight = new Complete_Item_Aggregation_Highlights(); } if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS") { // Done with all the highlights so return return; } } } }
private static void read_home(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:BODY": Web_Language_Enum langEnum = Web_Language_Enum.DEFAULT; bool isCustom = false; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) { string bodyLanguage = NodeReader.GetAttribute("lang"); langEnum = Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage); } if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("isCustom"))) { string attribute = NodeReader.GetAttribute("isCustom"); if (attribute != null && attribute.ToLower() == "true") isCustom = true; } NodeReader.Read(); HierarchyObject.Add_Home_Page_File(NodeReader.Value, langEnum, isCustom ); break; } } if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME")) { return; } } }
private static void read_home(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject) { while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:BODY": if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) { string bodyLanguage = NodeReader.GetAttribute("lang"); NodeReader.Read(); HierarchyObject.Add_Home_Page_File( NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage)); } else { NodeReader.Read(); HierarchyObject.Add_Home_Page_File( NodeReader.Value, Web_Language_Enum.DEFAULT); } break; } } if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:HOME")) { return; } } }
private static void read_browse(bool Browse, XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { // Create a new browse/info object Complete_Item_Aggregation_Child_Page newBrowse = new Complete_Item_Aggregation_Child_Page { Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu, Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML }; bool isDefault = false; // Determine which XML node name to look for and set browse v. info string lastName = "HI:BROWSE"; if (!Browse) { lastName = "HI:INFO"; newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None; } // Check for the attributes if (NodeReader.HasAttributes) { if (NodeReader.MoveToAttribute("location")) { if (NodeReader.Value == "BROWSEBY") newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By; } if (NodeReader.MoveToAttribute("default")) { if (NodeReader.Value == "DEFAULT") isDefault = true; } if (NodeReader.MoveToAttribute("visibility")) { switch (NodeReader.Value) { case "NONE": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None; break; case "MAIN_MENU": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu; break; case "BROWSEBY": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By; break; } } if (NodeReader.MoveToAttribute("parent")) { newBrowse.Parent_Code = NodeReader.Value; } } // Step through the XML and build this browse/info object while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:METADATA": NodeReader.Read(); newBrowse.Code = NodeReader.Value.ToLower(); newBrowse.Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Database_Table; break; case "HI:CODE": NodeReader.Read(); newBrowse.Code = NodeReader.Value.ToLower(); break; case "HI:TITLE": // Look for a language attached to this title string titleLanguage = String.Empty; if ((NodeReader.HasAttributes) && ( NodeReader.MoveToAttribute("lang"))) { titleLanguage = NodeReader.GetAttribute("lang"); } // read and save the title NodeReader.Read(); newBrowse.Add_Label( NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage)); break; case "HI:BODY": // Look for a language attached to this title string bodyLanguage = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) { bodyLanguage = NodeReader.GetAttribute("lang"); } // read and save the title NodeReader.Read(); string bodySource = NodeReader.Value; newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage)); break; } } if (NodeReader.NodeType == XmlNodeType.EndElement) { if (NodeReader.Name.Trim().ToUpper() == lastName ) { // Don't add ALL or NEW here if ((String.Compare(newBrowse.Code, "all", StringComparison.InvariantCultureIgnoreCase) != 0) && (String.Compare(newBrowse.Code, "new", StringComparison.InvariantCultureIgnoreCase) != 0)) { HierarchyObject.Add_Child_Page(newBrowse); //HierarchyObject.Add // If this set the default browse by save that information if ((newBrowse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By) && (isDefault)) { HierarchyObject.Default_BrowseBy = newBrowse.Code; } } return; } } } }
private static void read_banners(XmlNodeReader nodeReader, Item_Aggregation hierarchyObject ) { while (nodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (nodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = nodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:SOURCE": // Check for any attributes to this banner node string lang = String.Empty; bool special = false; if (nodeReader.HasAttributes) { if (nodeReader.MoveToAttribute("lang")) { lang = nodeReader.Value.Trim().ToUpper(); } if (nodeReader.MoveToAttribute("type")) { if (nodeReader.Value.Trim().ToUpper() == "HIGHLIGHT") special = true; } } // Now read the banner information and add to the aggregation object nodeReader.Read(); if (special) { hierarchyObject.Add_Front_Banner_Image(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum( lang)); } else { hierarchyObject.Add_Banner_Image(nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang)); } break; } } if ((nodeReader.NodeType == XmlNodeType.EndElement) && (nodeReader.Name.Trim().ToUpper() == "HI:BANNER")) { return; } } }
private static void read_highlights( XmlNodeReader nodeReader, Item_Aggregation hierarchyObject ) { Item_Aggregation_Highlights highlight = new Item_Aggregation_Highlights(); // Determine if this is a rotating type of highlight or not if (nodeReader.HasAttributes) { if (nodeReader.MoveToAttribute("type")) { if (nodeReader.Value == "ROTATING") hierarchyObject.Rotating_Highlights = true; } if (nodeReader.MoveToAttribute("bannerSide")) { if (nodeReader.Value.Trim().ToUpper() == "RIGHT") hierarchyObject.Front_Banner_Left_Side = false; } if (nodeReader.MoveToAttribute("bannerHeight")) { hierarchyObject.Front_Banner_Height = Convert.ToUInt16(nodeReader.Value); } if (nodeReader.MoveToAttribute("bannerWidth")) { hierarchyObject.Front_Banner_Width = Convert.ToUInt16(nodeReader.Value); } } while (nodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (nodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = nodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name string languageText; switch (nodeName) { case "HI:SOURCE": nodeReader.Read(); highlight.Image = nodeReader.Value.ToLower(); break; case "HI:LINK": nodeReader.Read(); highlight.Link = nodeReader.Value.ToLower(); break; case "HI:TOOLTIP": languageText = String.Empty; if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang"))) languageText = nodeReader.Value.ToUpper(); nodeReader.Read(); highlight.Add_Tooltip( Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value ); break; case "HI:TEXT": languageText = String.Empty; if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang"))) languageText = nodeReader.Value.ToUpper(); nodeReader.Read(); highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), nodeReader.Value); break; } } if (nodeReader.NodeType == XmlNodeType.EndElement) { if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT" ) { hierarchyObject.Highlights.Add(highlight); highlight = new Item_Aggregation_Highlights(); } if (nodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS") { // Done with all the highlights so return return; } } } }
private static void read_browse(bool browse, XmlNodeReader nodeReader, Item_Aggregation hierarchyObject ) { // Create a new browse/info object Item_Aggregation_Browse_Info newBrowse = new Item_Aggregation_Browse_Info { Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_Home, Source = Item_Aggregation_Browse_Info.Source_Type.Static_HTML, Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Text }; bool isDefault = false; string code = String.Empty; // Determine which XML node name to look for and set browse v. info string lastName = "HI:BROWSE"; if (!browse) { lastName = "HI:INFO"; newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Info; } // Check for the attributes if (nodeReader.HasAttributes) { if (nodeReader.MoveToAttribute("location")) { if (nodeReader.Value == "BROWSEBY") newBrowse.Browse_Type = Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By; } if (nodeReader.MoveToAttribute("default")) { if (nodeReader.Value == "DEFAULT") isDefault = true; } } // Step through the XML and build this browse/info object while (nodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (nodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = nodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name switch (nodeName) { case "HI:METADATA": nodeReader.Read(); newBrowse.Code = nodeReader.Value.ToLower(); newBrowse.Source = Item_Aggregation_Browse_Info.Source_Type.Database; newBrowse.Data_Type = Item_Aggregation_Browse_Info.Result_Data_Type.Table; break; case "HI:CODE": nodeReader.Read(); newBrowse.Code = nodeReader.Value.ToLower(); break; case "HI:TITLE": // Look for a language attached to this title string titleLanguage = String.Empty; if ((nodeReader.HasAttributes) && ( nodeReader.MoveToAttribute("lang"))) { titleLanguage = nodeReader.GetAttribute("lang"); } // read and save the title nodeReader.Read(); newBrowse.Add_Label( nodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage)); break; case "HI:BODY": // Look for a language attached to this title string bodyLanguage = String.Empty; if ((nodeReader.HasAttributes) && (nodeReader.MoveToAttribute("lang"))) { bodyLanguage = nodeReader.GetAttribute("lang"); } // read and save the title nodeReader.Read(); string bodySource = nodeReader.Value; newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage)); break; } } if (nodeReader.NodeType == XmlNodeType.EndElement) { if (nodeReader.Name.Trim().ToUpper() == lastName ) { hierarchyObject.Add_Browse_Info(newBrowse); // If this set the default browse by save that information if ((newBrowse.Browse_Type == Item_Aggregation_Browse_Info.Browse_Info_Type.Browse_By) && (isDefault)) { hierarchyObject.Default_BrowseBy = newBrowse.Code; } return; } } } }
/// <summary> /// Captures MSN conversations /// </summary> /// <param name="xmlMessage">xml string containing an IM message data</param> /// <returns>an MSNMessageData struct containing the parsed data</returns> private MSNMessageData ParseMessageData(string xmlMessage) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlMessage); XmlNodeReader reader = new XmlNodeReader(doc); MSNMessageData messageData = new MSNMessageData(); // Moves the reader to the root element. reader.MoveToContent(); // get the date reader.MoveToAttribute("DateTime"); messageData.date = DateTime.Parse(reader.Value); // get the session id reader.MoveToAttribute("SessionID"); messageData.sessionId = Convert.ToInt32(reader.Value); // get the rest of the attributes while (reader.Read()) { // advance to the inner node we're interested in if (reader.NodeType == XmlNodeType.Element) { string parentNodeName = reader.LocalName; reader.Read(); switch(parentNodeName) { case "From": // get the from user reader.MoveToAttribute("FriendlyName"); messageData.fromFriendlyName = reader.Value; break; case "To": // get the to user reader.MoveToAttribute("FriendlyName"); messageData.toFriendlyName = reader.Value; break; // get the actual IM message case "Text": messageData.message = reader.Value; break; default: break; } } } // set user and buddy names if not already set if (userName == null) userName = messageData.fromFriendlyName; if (buddyName == null) buddyName = messageData.toFriendlyName; return messageData; }
/// <summary> /// Parses an IM log file and sends the information to GDS /// </summary> /// <param name="logFile">The IM conversations log file</param> /// <param name="lastIndexed">messages older than this will not be sent to GDS</param> private void ParseAndSendMessages(string logFile, DateTime lastIndexed) { XmlDocument doc = new XmlDocument(); doc.Load(logFile); XmlNodeReader reader = new XmlNodeReader(doc); // reset user and buddy name userName = null; buddyName = null; // Moves the reader to the root element. reader.MoveToContent(); // move to the first message reader.Read(); while(reader.LocalName == "Message") { // check the date of the message - if older skip reader.MoveToAttribute("DateTime"); DateTime messageDateTime = DateTime.Parse(reader.Value); reader.MoveToElement(); // if older than the last indexing time, skip the message if (messageDateTime.CompareTo(lastIndexed) <= 0) { reader.Skip(); continue; } // get message data MSNMessageData messageData = ParseMessageData(reader.ReadOuterXml()); // send this message to GDS for indexing SendMessageData(messageData); } }