/// <summary> /// Save the configuration data. /// </summary> /// <param name="fileName">file name</param> /// <param name="configData">configuration data</param> /// <returns>success flag</returns> public bool SaveSeriesConfigData( string fileName, SeriesConfigType configData) { bool success = true; try { XDocument writer = new XDocument( new XDeclaration("1.0", "uft-8", "yes"), new XComment("Series Configuration XML")); XElement root = new XElement(rootElement); XElement racePoints = new XElement( numberElement, new XAttribute( prefixAttribute, configData.NumberPrefix), new XAttribute( allPositionsAttribute, configData.AllPositionsShown)); root.Add(racePoints); writer.Add(root); writer.Save(fileName); } catch (Exception ex) { this.logger.WriteLog("Error writing Series Configuration data " + ex.ToString()); } return(success); }
/// <summary> /// Initialises a new instance of the <see cref="SeriesConfigViewModel"/> class. /// </summary> /// <param name="seriesConfigurationManager">series configuration manager</param> /// <param name="logger">application logger</param> public SeriesConfigViewModel( ISeriesConfigMngr seriesConfigurationManager, IJHcLogger logger) { this.logger = logger; this.seriesConfigManager = seriesConfigurationManager; SeriesConfigType config = this.seriesConfigManager.ReadSeriesConfiguration(); if (config == null) { this.logger.WriteLog( "Series Config VM not initialised, Config reader has failed."); return; } numberPrefix = config.NumberPrefix; numberPrefixOrig = this.NumberPrefix; this.SaveCommand = new SeriesConfigSaveCmd(this); this.jointSecondThird = !config.AllPositionsShown; this.allPositions = config.AllPositionsShown; }
/// <summary> /// Determine whether the input number is unique, and doesn't start with the banned string. /// </summary> /// <param name="testNumber">number to test</param> /// <returns>valid flag</returns> private bool RunningNumberValid(string testNumber) { if (string.IsNullOrEmpty(testNumber)) { return(false); } return(!this.AllocatedNumbers.Exists(s => s.Equals(testNumber)) && SeriesConfigType.ValidNumber(testNumber)); }
/// <summary> /// Initialises a new instance of the <see cref="CalculateResultsMngr"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigurationManager"> /// normalisation configuration manager /// </param> /// <param name="resultsConfigurationManager"> /// results configuration manager /// </param> /// <param name="seriesConfigurationManager"> /// series configuration manager /// </param> /// <param name="logger">application logger</param> public CalculateResultsMngr( IModel model, INormalisationConfigMngr normalisationConfigurationManager, IResultsConfigMngr resultsConfigurationManager, ISeriesConfigMngr seriesConfigurationManager, IJHcLogger logger) : base(model) { this.logger = logger; this.resultsConfiguration = resultsConfigurationManager; this.hcConfiguration = normalisationConfigurationManager.ReadNormalisationConfiguration(); this.seriesConfiguration = seriesConfigurationManager.ReadSeriesConfiguration(); }
/// <summary> /// Creates a set of images containing spare barcodes on a crib sheet. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="seriesConfigurationManager">series configuration manager</param> /// <param name="savePath">path to save the images to</param> /// <param name="numberOfSpareSheets">number of spare sheets to create</param> /// <param name="numberOfLabelColumns">number of columns of labels</param> /// <param name="numberOfLabelRow">number of rows of labels</param> public static void CreateSpareLabelsCribSheet( IModel model, ISeriesConfigMngr seriesConfigurationManager, string savePath, int numberOfSpareSheets, int numberOfLabelColumns, int numberOfLabelRow) { SeriesConfigType config = seriesConfigurationManager.ReadSeriesConfiguration(); int summarySheetNumber = 1; int raceNumber = model.Athletes.NextAvailableRaceNumber; int numberOfSpareLabels = numberOfLabelColumns * numberOfLabelRow * numberOfSpareSheets; int numberOfCribPerSheet = numberOfCribSheetColumns * numberOfCribSheetRows; ObservableCollection <AthleteLabel> labels = new ObservableCollection <AthleteLabel>(); for (int labelIndex = 0; labelIndex < numberOfSpareLabels; ++labelIndex) { labels.Add(new AthleteLabel("________________________________________________________________________", string.Empty, GetRaceNumber(config?.NumberPrefix, raceNumber), null, false)); if (labels.Count == numberOfCribPerSheet) { CreateSingleCribSheet( new LabelsSheetViewModel(labels), savePath + Path.DirectorySeparatorChar + spareLabelsCribName + summarySheetNumber.ToString() + ".png"); ++summarySheetNumber; labels = new ObservableCollection <AthleteLabel>(); } // TODO UpdateString ++raceNumber; } if (labels.Count > 0) { CreateSingleCribSheet(new LabelsSheetViewModel(labels), savePath + Path.DirectorySeparatorChar + spareLabelsCribName + summarySheetNumber.ToString() + ".png"); } }
/// <summary> /// Gets the series configuration data /// </summary> /// <param name="fileName">file name</param> /// <returns>configuration data</returns> public SeriesConfigType LoadSeriesConfigData(string fileName) { try { if (!File.Exists(fileName)) { string error = string.Format("Athlete Data file missing, one created - {0}", fileName); this.logger.WriteLog(error); SeriesConfigType newConfiguration = new SeriesConfigType( "TMP", true); this.SaveSeriesConfigData( fileName, newConfiguration); } XDocument reader = XDocument.Load(fileName); XElement root = reader.Root; XElement number = root.Element(numberElement); bool allPositions = this.ReadBoolAttribute( number, allPositionsAttribute, false, fileName); return(new SeriesConfigType( (string)number.Attribute(prefixAttribute), allPositions)); } catch (Exception ex) { this.logger.WriteLog("Error reading Series Configuration data " + ex.ToString()); return(null); } }
/// <summary> /// Write the next runner to a file. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="folder">output model</param> /// <param name="seriesConfigMngr">series configuraton manager</param> /// <param name="logger">application logger</param> /// <returns>success flag</returns> public static bool WriteNextRunnerTable( IModel model, string folder, ISeriesConfigMngr seriesConfigMngr, IJHcLogger logger) { bool success = true; Messenger.Default.Send( new HandicapProgressMessage( "Printing next runner.")); SeriesConfigType config = seriesConfigMngr.ReadSeriesConfiguration(); try { using (StreamWriter writer = new StreamWriter(Path.GetFullPath(folder) + Path.DirectorySeparatorChar + model.CurrentSeason.Name + model.CurrentEvent.Name + ResultsPaths.nextNewRunner + ResultsPaths.csvExtension)) { writer.WriteLine(config?.NumberPrefix + model.Athletes.NextAvailableRaceNumber.ToString("000000")); } } catch (Exception ex) { logger.WriteLog("Error, failed to print next runner: " + ex.ToString()); Messenger.Default.Send( new HandicapErrorMessage( "Failed to print next runner")); success = false; } return(success); }
/// <summary> /// Creates a set of image files, each containing a spare barcodes. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="seriesConfigManager">series configuration manager</param> /// <param name="savePath">path to save the images to</param> /// <param name="numberOfSpareSheets">number of spare sheets to create</param> /// <param name="numberOfColumns">number of columns of labels</param> /// <param name="numberOfRow">number of rows of labels</param> /// <param name="eventDetails">details of the event, name and date</param> public static void CreateSpareLabels( IModel model, ISeriesConfigMngr seriesConfigManager, string savePath, int numberOfSpareSheets, int numberOfColumns, int numberOfRow, string eventDetails) { int raceNumber = model.Athletes.NextAvailableRaceNumber; SeriesConfigType config = seriesConfigManager.ReadSeriesConfiguration(); for (int sheetNumber = 0; sheetNumber < numberOfSpareSheets; ++sheetNumber) { ObservableCollection <AthleteLabel> sheet = new ObservableCollection <AthleteLabel>(); for (int labelIndex = 0; labelIndex < numberOfColumns * numberOfRow; ++labelIndex) { AthleteLabel newLabel = new AthleteLabel( string.Empty, string.Empty, GetRaceNumber(config?.NumberPrefix, raceNumber), null, false); newLabel.EventDetails = eventDetails; newLabel.AthleteLabelWidth = A4Details.GetLabelWidth96DPI(numberOfColumns); newLabel.AthleteLabelHeight = A4Details.GetLabelHeight96DPI(numberOfRow); sheet.Add(newLabel); // TODO UpdateString ++raceNumber; } CreateSingleSheet(new LabelsSheetViewModel(sheet), savePath + Path.DirectorySeparatorChar + spareLabelsName + sheetNumber.ToString() + ".png"); } }
public bool CanSaveConfig() { return(SeriesConfigType.ValidNumber(this.NumberPrefix)); }