private PressAnnouncement ParsePressAnnouncementNode(XmlNode pressAnnouncementNode) { try { PressAnnouncement pressAnnouncement = new PressAnnouncement(); foreach (XmlNode xmlNode in pressAnnouncementNode.ChildNodes) { switch (xmlNode.Name) { case Tags.Subject: pressAnnouncement.subjectField = xmlNode.InnerText; break; case Tags.Body: pressAnnouncement.bodyField = xmlNode.InnerText; break; case Tags.SendDate: pressAnnouncement.sendDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; } } return(pressAnnouncement); } catch (Exception ex) { throw ex; } }
private CurrentCapacity ParseCurrentCapacityNode(XmlNode xmlNodeCurrentCapacity) { try { CurrentCapacity currentCapacity = new CurrentCapacity(); if (xmlNodeCurrentCapacity.ChildNodes != null) { foreach (XmlNode xmlNode in xmlNodeCurrentCapacity.ChildNodes) { switch (xmlNode.Name) { case Tags.RebuiltDate: if (xmlNode.Attributes[Tags.Available] != null) { currentCapacity.availableField = GenericFunctions.ConvertStringToBool(xmlNode.Attributes[Tags.Available].Value); if (currentCapacity.availableField) { currentCapacity.rebuiltDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); } } break; case Tags.Basic: currentCapacity.basicField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.Terraces: currentCapacity.terracesField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.Roof: currentCapacity.roofField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.VIP: currentCapacity.vipField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.Total: currentCapacity.totalField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } } } return(currentCapacity); } catch (Exception ex) { throw ex; } }
private Match ParseMatchNode(XmlNode matchNode) { try { Match match = new Match(); foreach (XmlNode xmlNode in matchNode.ChildNodes) { switch (xmlNode.Name) { case Tags.MatchId: match.matchIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.HomeTeam: if (xmlNode.ChildNodes != null) { match.homeTeamField = ParseHomeTeamNode(xmlNode); } break; case Tags.AwayTeam: if (xmlNode.ChildNodes != null) { match.awayTeamField = ParseAwayTeamNode(xmlNode); } break; case Tags.MatchDate: match.matchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.MatchType: match.matchTypeField = (MatchType)Convert.ToInt32(xmlNode.InnerText); break; case Tags.HomeGoals: match.homeGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; case Tags.AwayGoals: match.awayGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; } } return(match); } catch (Exception ex) { throw ex; } }
private Transfer ParseTransferNode(XmlNode transferNode) { try { Transfer transfer = new Transfer(); foreach (XmlNode xmlNode in transferNode.ChildNodes) { switch (xmlNode.Name) { case Tags.TransferID: transfer.transferIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.Deadline: transfer.deadlineField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.Buyer: if (xmlNode.ChildNodes != null) { transfer.buyerField = ParseBuyerNode(xmlNode); } break; case Tags.Seller: if (xmlNode.ChildNodes != null) { transfer.sellerField = ParseSellerNode(xmlNode); } break; case Tags.Price: transfer.priceField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.TSI: transfer.tsiField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } } return(transfer); } catch (Exception ex) { throw ex; } }
private ExpandedCapacity ParseExpandedCapacityNode(XmlNode xmlNodeExpandedCapacity) { try { ExpandedCapacity expandedCapacity = new ExpandedCapacity(); if (xmlNodeExpandedCapacity.ChildNodes != null) { if (xmlNodeExpandedCapacity.Attributes[Tags.Available] != null) { expandedCapacity.availableField = GenericFunctions.ConvertStringToBool(xmlNodeExpandedCapacity.Attributes[Tags.Available].Value); } if (expandedCapacity.availableField) { foreach (XmlNode xmlNode in xmlNodeExpandedCapacity.ChildNodes) { switch (xmlNode.Name) { case Tags.ExpansionDate: expandedCapacity.expansionDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.Basic: expandedCapacity.basicField = Convert.ToInt32(xmlNode.InnerText); break; case Tags.Terraces: expandedCapacity.terracesField = Convert.ToInt32(xmlNode.InnerText); break; case Tags.Roof: expandedCapacity.roofField = Convert.ToInt32(xmlNode.InnerText); break; case Tags.VIP: expandedCapacity.vipField = Convert.ToInt32(xmlNode.InnerText); break; } } } } return(expandedCapacity); } catch (Exception ex) { throw ex; } }
protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity) { try { TransfersPlayer transfersPlayer = (TransfersPlayer)entity; switch (xmlNode.Name) { case Tags.Transfers: if (xmlNode.ChildNodes != null) { foreach (XmlNode xmlNodeTransfers in xmlNode.ChildNodes) { switch (xmlNodeTransfers.Name) { case Tags.StartDate: transfersPlayer.transfersField.startDateField = GenericFunctions.ConvertStringToDateTime(xmlNodeTransfers.InnerText); break; case Tags.EndDate: transfersPlayer.transfersField.endDateField = GenericFunctions.ConvertStringToDateTime(xmlNodeTransfers.InnerText); break; case Tags.Player: if (xmlNodeTransfers.ChildNodes != null) { transfersPlayer.transfersField.playerField = ParsePlayerNode(xmlNodeTransfers); } break; case Tags.Transfer: if (xmlNodeTransfers.ChildNodes != null) { transfersPlayer.transfersField.transferField.Add(ParseTransferNode(xmlNodeTransfers)); } break; } } } break; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Reads the xml document and populates internal state with its data. /// </summary> /// <param name="xmlDocument">Xml document</param> public void ReadXml(XmlDocument xmlDocument) { if (xmlDocument.DocumentElement.ChildNodes != null) { //Iterates thru each node in HattrickData node foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { bool generalNode = false; switch (xmlNode.Name) { case Tags.FileName: { this.fileNameField = xmlNode.InnerText; generalNode = true; break; } case Tags.Version: { this.versionField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText); generalNode = true; break; } case Tags.UserID: { this.userIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); generalNode = true; break; } case Tags.FetchedDate: { this.fetchedDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); generalNode = true; break; } } if (!generalNode) { // Not one of the general nodes, // try reading it as a specific node //ReadSpecificNode(xmlNode); } } } }
protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity) { MatchLineup matchLineup = (MatchLineup)entity; switch (xmlNode.Name) { case Tags.MatchId: matchLineup.matchIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.IsYouth: matchLineup.isYouthField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText); break; case Tags.MatchType: matchLineup.matchTypeField = (MatchType)Convert.ToInt32(xmlNode.InnerText); break; case Tags.MatchDate: matchLineup.matchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.HomeTeam: matchLineup.homeTeamField = ParseHomeTeamNode(xmlNode); break; case Tags.AwayTeam: matchLineup.awayTeamField = ParseAwayTeamNode(xmlNode); break; case Tags.Arena: matchLineup.arenaField = ParseArenaNode(xmlNode); break; case Tags.Team: matchLineup.teamField = ParseTeamNode(xmlNode); break; } }
private Achievement ParseAchievementNode(XmlNode achievementListNode) { Achievement achievement = new Achievement(); foreach (XmlNode achievementNode in achievementListNode.ChildNodes) { switch (achievementNode.Name) { case Tags.AchievementTypeID: achievement.achievementTypeIdField = GenericFunctions.ConvertStringToUInt(achievementNode.InnerText); break; case Tags.AchievementText: achievement.achievementTextField = achievementNode.InnerText; break; case Tags.CategoryID: achievement.categoryIdField = (AchievementCategory)Convert.ToInt32(achievementNode.InnerText); break; case Tags.EventDate: achievement.eventDateField = GenericFunctions.ConvertStringToDateTime(achievementNode.InnerText); break; case Tags.Points: achievement.pointsField = Convert.ToInt32(achievementNode.InnerText); break; case Tags.MultiLevel: achievement.multilevelField = GenericFunctions.ConvertStringToBool(achievementNode.InnerText); break; case Tags.NumberOfEvents: achievement.numberOfEventsField = GenericFunctions.ConvertStringToUInt(achievementNode.InnerText); break; } } return(achievement); }
/// <summary> /// Parses given XmlDocument and populates a HattrickBase object with data from it. /// </summary> /// <param name="xmlDocument">XmlDocument to parse</param> /// <returns>Populated entity, a HattrickBase (or derived) object</returns> public HattrickBase ParseXmlDocument(XmlDocument xmlDocument) { HattrickBase entity = CreateEntity(); if (xmlDocument.DocumentElement.ChildNodes != null) { // Iterates through each node in HattrickData node foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { switch (xmlNode.Name) { case Tags.FileName: entity.fileNameField = xmlNode.InnerText; break; case Tags.Version: entity.versionField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText); break; case Tags.UserID: entity.userIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.FetchedDate: entity.fetchedDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; default: ParseSpecificNode(xmlNode, entity); break; } } } return(entity); }
private Match ParseMatchNode(XmlNode matchNode) { Match match = new Match(); foreach (XmlNode xmlNode in matchNode.ChildNodes) { switch (xmlNode.Name) { case Tags.MatchId: match.matchIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.HomeTeam: if (xmlNode.ChildNodes != null) { match.homeTeamField = ParseHomeTeamNode(xmlNode); } break; case Tags.AwayTeam: if (xmlNode.ChildNodes != null) { match.awayTeamField = ParseAwayTeamNode(xmlNode); } break; case Tags.MatchDate: match.matchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.MatchType: match.matchTypeField = (MatchType)Convert.ToInt32(xmlNode.InnerText); break; case Tags.HomeGoals: match.homeGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; case Tags.AwayGoals: match.awayGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; case Tags.Status: string statusString = xmlNode.InnerText; MatchStatus status = MatchStatus.Finished; switch (statusString) { case General.StatusFinished: status = MatchStatus.Finished; break; case General.StatusUpcoming: status = MatchStatus.Upcoming; break; } match.statusField = status; break; case Tags.OrdersGiven: match.ordersGivenField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText); break; } } return(match); }
private League ParseLeagueNode(XmlNode leagueNode) { try { League league = new League(); foreach (XmlNode xmlNode in leagueNode.ChildNodes) { switch (xmlNode.Name) { case (Tags.LeagueID): { league.leagueIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } case (Tags.LeagueName): { league.leagueNameField = xmlNode.InnerText; break; } case (Tags.Season): { league.seasonField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } case (Tags.MatchRound): { league.matchRoundField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; } case (Tags.ShortName): { league.shortNameField = xmlNode.InnerText; break; } case (Tags.Continent): { league.continentField = xmlNode.InnerText; break; } case (Tags.ZoneName): { league.zoneNameField = xmlNode.InnerText; break; } case (Tags.EnglishName): { league.englishNameField = xmlNode.InnerText; break; } case (Tags.Country): { if (xmlNode.ChildNodes != null) { league.countryField = ParseCountryNode(xmlNode); } break; } case (Tags.Cup): { if (xmlNode.ChildNodes != null) { league.cupField = ParseCupNode(xmlNode); } break; } case (Tags.ActiveUsers): { league.activeUsersField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } case (Tags.WaitingUsers): { league.waitingUsersField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; } case (Tags.TrainingDate): { league.trainingDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; } case (Tags.EconomyDate): { league.economyDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; } case (Tags.CupMatchDate): { league.cupMatchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; } case (Tags.SeriesMatchDate): { league.seriesMatchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; } case (Tags.NumberOfLevels): { league.numberOfLevelsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText); break; } } } return(league); } catch (Exception ex) { throw ex; } }
/// <summary> /// Reads UserProfile xml file /// </summary> /// <param name="xmlStream">Xml file content</param> /// <returns>UserProfiles object loaded with readed data</returns> public HMEntities.UserProfiles.UserProfiles ReadUserProfilesFile(Stream xmlStream) { try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlStream); HMEntities.UserProfiles.UserProfiles hattrickManagerData = new HM.Entities.HattrickManager.UserProfiles.UserProfiles(); if (xmlDocument.DocumentElement.ChildNodes != null) { foreach (XmlNode xmlNodeRoot in xmlDocument.DocumentElement.ChildNodes) { switch (xmlNodeRoot.Name) { case Tags.SavedDate: { hattrickManagerData.savedDateField = GenericFunctions.ConvertStringToDateTime(xmlNodeRoot.InnerText); break; } case Tags.UserList: { if (xmlNodeRoot.ChildNodes != null) { foreach (XmlNode xmlNodeUserList in xmlNodeRoot.ChildNodes) { if (xmlNodeUserList.ChildNodes != null) { HMEntities.UserProfiles.User hattrickManagerDataUser = new HM.Entities.HattrickManager.UserProfiles.User(); foreach (XmlNode xmlNodeUser in xmlNodeUserList) { switch (xmlNodeUser.Name) { case Tags.TeamID: { hattrickManagerDataUser.teamIdField = GenericFunctions.ConvertStringToUInt(xmlNodeUser.InnerText); break; } case Tags.YouthTeamID: { hattrickManagerDataUser.youthTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNodeUser.InnerText); break; } case Tags.Loginname: { hattrickManagerDataUser.username = xmlNodeUser.InnerText; break; } case Tags.UserToken: { hattrickManagerDataUser.accessToken = xmlNodeUser.InnerText; break; } case Tags.UserTokenSecret: { hattrickManagerDataUser.accessTokenSecret = xmlNodeUser.InnerText; break; } case Tags.ActivationDate: { hattrickManagerDataUser.activationDateField = GenericFunctions.ConvertStringToDateTime(xmlNodeUser.InnerText); break; } case Tags.DataFolder: { hattrickManagerDataUser.dataFolderField = xmlNodeUser.InnerText; break; } } } hattrickManagerData.userListField.Add(hattrickManagerDataUser); } } } break; } } } } xmlStream.Close(); return(hattrickManagerData); } catch (Exception ex) { throw ex; } }
private Match ParseMatchNode(XmlNode xmlNode) { try { Match match = new Match(); foreach (XmlNode matchNode in xmlNode.ChildNodes) { switch (matchNode.Name) { case Tags.MatchId: match.matchIdField = GenericFunctions.ConvertStringToUInt(matchNode.InnerText); break; case Tags.MatchType: match.matchTypeField = (MatchType)Convert.ToInt32(matchNode.InnerText); break; case Tags.MatchDate: match.matchDateField = GenericFunctions.ConvertStringToDateTime(matchNode.InnerText); break; case Tags.FinishedDate: match.finishedDateField = GenericFunctions.ConvertStringToDateTime(matchNode.InnerText); break; case Tags.HomeTeam: match.homeTeamField = ParseHomeTeamNode(matchNode); break; case Tags.AwayTeam: match.awayTeamField = ParseAwayTeamNode(matchNode); break; case Tags.Arena: match.arenaField = ParseArenaNode(matchNode); break; case Tags.Scorers: match.scorersField = ParseScorersNode(matchNode); break; case Tags.Bookings: match.bookingsField = ParseBookingsNode(matchNode); break; case Tags.PossessionFirstHalfHome: match.possesionFirstHalfHomeField = GenericFunctions.ConvertStringToByte(matchNode.InnerText); break; case Tags.PossessionFirstHalfAway: match.possesionFirstHalfAwayField = GenericFunctions.ConvertStringToByte(matchNode.InnerText); break; case Tags.PossessionSecondHalfHome: match.possesionSecondHalfHomeField = GenericFunctions.ConvertStringToByte(matchNode.InnerText); break; case Tags.PossessionSecondHalfAway: match.possesionSecondHalfAwayField = GenericFunctions.ConvertStringToByte(matchNode.InnerText); break; case Tags.EventList: match.eventListField = ParseEventListNode(matchNode); break; } } return(match); } catch (Exception ex) { throw ex; } }
private User ParseUserNode(XmlNode userNode) { try { User user = new User(); foreach (XmlNode xmlNode in userNode.ChildNodes) { switch (xmlNode.Name) { case Tags.UserID: user.userIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText); break; case Tags.Language: if (xmlNode.ChildNodes != null) { user.languageField = ParseLanguageNode(xmlNode); } break; case Tags.HasSupporter: user.hasSupporterField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText); break; case Tags.Loginname: user.loginnameField = xmlNode.InnerText; break; case Tags.Name: user.nameField = xmlNode.InnerText; break; case Tags.ICQ: user.icqField = xmlNode.InnerText; break; case Tags.SignupDate: user.signupDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.ActivationDate: user.activationDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.LastLoginDate: user.lastLoginDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText); break; case Tags.NationalTeamCoach: if (xmlNode.ChildNodes != null) { user.nationalTeamCoachField = ParseNationalTeamCoachNode(xmlNode); } break; } } return(user); } catch (Exception ex) { throw ex; } }