示例#1
0
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>SaveEventData</name>
        /// <date>04/03/15</date>
        /// <summary>
        /// Save the event data.
        /// </summary>
        /// <param name="fileName">file name</param>
        /// <param name="date">event date</param>
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public bool SaveEventData(
            string fileName,
            EventMiscData eventData)
        {
            bool success = true;

            try
            {
                XDocument writer = new XDocument(
                    new XDeclaration("1.0", "uft-8", "yes"),
                    new XComment("Athlete's season XML"));
                XElement rootElement = new XElement(c_rootElement);
                XElement dateElement = new XElement(c_dateElement, eventData.EventDate.ToString());

                rootElement.Add(dateElement);
                writer.Add(rootElement);
                writer.Save(fileName);
            }
            catch (Exception ex)
            {
                this.logger.WriteLog("Error saving event file: " + ex.ToString());
                success = false;
            }

            return(success);
        }
示例#2
0
 /// <summary>
 /// Saves the event misc details
 /// </summary>
 /// <param name="seasonName">season name</param>
 /// <param name="eventName">event name</param>
 /// <param name="summaryDetails">details to save</param>
 /// <returns>success flag</returns>
 public bool SaveEventData(
     string seasonName,
     string eventName,
     EventMiscData eventData)
 {
     return(this.eventDataReader.SaveEventData(
                RootPath.DataPath + seasonName + Path.DirectorySeparatorChar + eventName + Path.DirectorySeparatorChar + IOPaths.eventMiscFile,
                eventData));
 }
示例#3
0
        /// <summary>
        /// Loads a  new event into the model.
        /// </summary>
        /// <param name="message">load new event message</param>
        private void LoadNewEvent(
            LoadNewEventMessage message)
        {
            bool success = true;

            this.Name = message.Name;

            try
            {
                if (string.IsNullOrEmpty(this.Name))
                {
                    this.ResultsTable = new EventResults();
                    this.Summary      = new Summary();
                    this.Date         = new DateType();
                }
                else
                {
                    EventMiscData misc =
                        this.eventData.LoadEventData(
                            this.seasonName,
                            this.Name);
                    this.Date = misc.EventDate;

                    this.ResultsTable =
                        this.resultsTableReader.LoadResultsTable(
                            this.seasonName,
                            this.Name,
                            misc.EventDate);

                    this.Summary =
                        this.summaryData.LoadSummaryData(
                            this.seasonName,
                            this.Name);
                }
            }
            catch (Exception ex)
            {
                this.logger.WriteLog($"Failed to load new event ({this.Name}): {ex}");
            }

            if (success)
            {
                Messenger.Default.Send(
                    new HandicapProgressMessage(
                        $"New Event Loaded - {this.Name}"));

                this.logger.WriteLog($"Event, loaded {this.Name}");
            }
        }
示例#4
0
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>LoadResultsTable</name>
        /// <date>04/03/15</date>
        /// <summary>
        /// Reads the event details xml from file and decodes it.
        /// </summary>
        /// <param name="fileName">name of xml file</param>
        /// <returns>decoded event data</returns>
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public EventMiscData LoadEventData(string fileName)
        {
            EventMiscData eventData = new EventMiscData();

            try
            {
                XDocument reader      = XDocument.Load(fileName);
                XElement  rootElement = reader.Root;
                XElement  dateElement = rootElement.Element(c_dateElement);

                eventData.EventDate = new DateType(dateElement.Value);
            }
            catch (Exception ex)
            {
                this.logger.WriteLog("Error reading event data: " + ex.ToString());

                eventData = new EventMiscData();
            }

            return(eventData);
        }