Example #1
0
 /// <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();
 }
Example #2
0
        /// <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");
            }
        }
Example #3
0
        /// <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);
        }
Example #4
0
        /// <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");
            }
        }