Example #1
0
        private static void AddCollectionLabel(GenericBarcode_20150909 barcodeInfo, DocumentClass doc, int index)
        {
            string collectionType = string.Empty;
            string collectionName = string.Empty;

            if (barcodeInfo.ParticipationTypeToCollectionName.Count > index)
            {
                collectionType = barcodeInfo.ParticipationTypeToCollectionName[index].Item1;
                collectionName = barcodeInfo.ParticipationTypeToCollectionName[index].Item2;
            }

            IObject cType = doc.GetObject(string.Format("CollectionType{0}", index));

            cType.Text = Convert.ToString(collectionType);

            IObject cName = doc.GetObject(string.Format("CollectionName{0}", index));

            cName.Text = Convert.ToString(collectionName);
        }
Example #2
0
        public void Print(GenericBarcode_20150909 barcodeInfo)
        {
            DocumentClass doc      = new DocumentClass();
            const string  path     = @".\Templates\Generic_20150909.lbx";
            string        fullPath = Path.GetFullPath(path);

            if (doc.Open(fullPath))
            {
                IObject barcode = doc.GetObject("barcode");
                barcode.Text = Convert.ToString(barcodeInfo.Barcode);

                IObject shooterName = doc.GetObject("shooterName");
                shooterName.Text = Convert.ToString(barcodeInfo.FirstName + " " + barcodeInfo.LastName);

                IObject dateOfBirth = doc.GetObject("dateOfBirth");
                dateOfBirth.Text = Convert.ToString(barcodeInfo.DateOfBirth != null ? ((DateTime)barcodeInfo.DateOfBirth).ToString("dd.MM.yyyy") : string.Empty);

                AddCollectionLabel(barcodeInfo, doc, 0);
                AddCollectionLabel(barcodeInfo, doc, 1);

                AddStichLabel(barcodeInfo, doc, 1);
                AddStichLabel(barcodeInfo, doc, 2);
                AddStichLabel(barcodeInfo, doc, 3);
                AddStichLabel(barcodeInfo, doc, 4);
                AddStichLabel(barcodeInfo, doc, 5);

                doc.StartPrint("", PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            else
            {
                throw new InvalidOperationException(string.Format("Can not open template file '{0}'", fullPath));
            }
        }
        private void PrintBarcode()
        {
            if (SelectedShooter != null)
            {
                var personShooter = (from shooter in _shooterDataStore.GetAll()
                                     join person in _personDataStore.GetAll() on shooter.PersonId equals person.PersonId
                                     where shooter.ShooterId == SelectedShooter.Shooter.ShooterId
                                     select new
                {
                    person.FirstName,
                    person.LastName,
                    person.DateOfBirth,
                    shooter.ShooterNumber
                }).Single();

                IBarcodeBuilderService barcodeBuilderService = ServiceLocator.Current.GetInstance <IBarcodeBuilderService>();
                string barcode = barcodeBuilderService.BuildBarcode(personShooter.ShooterNumber, 0);


                var shooterCollections = from sc in _shooterCollectionDataStore.GetAll()
                                         join cs in _collectionShooterDataStore.GetAll() on
                                         sc.ShooterCollectionId equals cs.ShooterCollectionId
                                         join p in _serviceDeskConfiguration.ParticipationDescriptions.GetAll() on
                                         sc.ProgramNumber.ToString() equals p.ProgramNumber
                                             where p.AllowShooterCollectionParticipation && cs.ShooterId == SelectedShooter.Shooter.ShooterId
                                         select new
                {
                    sc.CollectionName,
                    p.ProgramName,
                    p.ProgramNumber
                };

                Dictionary <string, Tuple <string, string> > grouped = (from sc in shooterCollections
                                                                        group sc by sc.ProgramNumber
                                                                        into g
                                                                        select new
                {
                    ProgramNumber = g.Key,
                    CollectionName = g.Single().CollectionName,
                    ProgramName = g.Single().ProgramName
                }).ToDictionary(x => x.ProgramNumber,
                                x => new Tuple <string, string>(x.ProgramName, x.CollectionName));

                IBarcodePrintService barcodeService = ServiceLocator.Current.GetInstance <IBarcodePrintService>();

                GenericBarcode_20150909 genericBarcode = new GenericBarcode_20150909
                {
                    FirstName   = personShooter.FirstName,
                    LastName    = personShooter.LastName,
                    DateOfBirth = personShooter.DateOfBirth,
                    Barcode     = barcode,
                    ParticipationTypeToCollectionName = grouped.Values.Take(2).ToList(),
                    Participations = _serviceDeskConfiguration.ParticipationDescriptions.GetAll().Select(x => x.ProgramName).Take(5).ToList()
                };

                try
                {
                    barcodeService.Print(genericBarcode);
                }
                catch (Exception e)
                {
                    MessengerInstance.Send(new DialogMessage("Barcode Print Error",
                                                             "Fehler beim Drucken des Barcodes.\r\n\r\n" + e.ToString(),
                                                             MessageIcon.Error));
                }
            }
        }