BF2Statistics.ASP.StatsProcessor.BackendAwardData.BuildAwardData C# (CSharp) Method

BuildAwardData() public static method

Builds the Backend award data for the snapshot processor to use
public static BuildAwardData ( ) : void
return void
        public static void BuildAwardData()
        {
            // Clear out old data
            BackendAwards.Clear();

            // Enumerate through each .XML file in the data directory
            string xmlFile = Path.Combine(Paths.DocumentsFolder, "BackendAwards.xml");
            XmlDocument Doc = new XmlDocument();

            // Load Army Data, Creating file if it doesnt exist already
            using (FileStream file = new FileStream(xmlFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
            {
                if (file.Length == 0)
                {
                    using (StreamWriter writer = new StreamWriter(file, Encoding.UTF8, 1024, true))
                        writer.Write(Program.GetResourceAsString("BF2Statistics.ASP.BackendAwards.xml"));

                    file.Flush();
                    file.Seek(0, SeekOrigin.Begin);
                }

                // Load the xml data
                Doc.Load(file);
                foreach (XmlNode Node in Doc.GetElementsByTagName("award"))
                {
                    // Never know what the user is capable of!
                    if (!Node.HasChildNodes) continue;

                    // Fetch child nodes into a list of conditions
                    List<AwardCriteria> criterias = new List<AwardCriteria>();
                    foreach(XmlNode cNode in Node.ChildNodes)
                    {
                        // Make sure its a valid tag
                        if (cNode.Name != "query") continue;

                        // Add the criteria query
                        criterias.Add(new AwardCriteria(
                            cNode.Attributes["table"].Value,
                            cNode.Attributes["select"].Value,
                            Int32.Parse(cNode.Attributes["result"].Value, NumberFormatInfo.InvariantInfo),
                            cNode.Attributes["where"].Value
                        ));
                    }

                    // Add award
                    BackendAwards.Add(new BackendAward(
                        Int32.Parse(Node.Attributes["id"].Value, NumberFormatInfo.InvariantInfo),
                        criterias.ToArray()
                    ));
                }
            }
        }
BackendAwardData