Пример #1
0
        private static string DrawBadge(BadgeType obj, Person person)
        {
            String filename;
            // Create a temporary file

            var s_document = new PdfDocument();
            if (person != null)
            {
                 filename = String.Format("{0}_{1}_{2}.pdf", person.Id, person.FullName, DefaultManager.Instance.CurrentDateTimeShortString);
                 s_document.Info.Title = person.FullName;
            } else
            {
                 filename = String.Format("{0}.pdf",  DefaultManager.Instance.CurrentDateTimeShortString);
                 s_document.Info.Title = "IACMAC";
            }
            filename = DefaultManager.Instance.AbstractFilePath + @"\" + filename;
            s_document.Info.Author = "IACMAC";
            s_document.Info.Subject = "IACMAC Conference Badge";

            // Create  pages
            var page = s_document.AddPage();

            PageSize[] pageSizes = (PageSize[])Enum.GetValues(typeof(PageSize));
            foreach (PageSize pageSize in pageSizes)
            {
                if (pageSize == PageSize.Undefined)
                    continue;
                page.Width = obj.Width;
                page.Height = obj.Height;
                page.Orientation = PageOrientation.Portrait;
            }

            XGraphics gfx = XGraphics.FromPdfPage(page);

            foreach (var badge in obj.Badges.ToList())
            {
                if (person != null)
                {
                       badge.Value = badge.Value.Replace("$F$", person.FirstName);
                       badge.Value = badge.Value.Replace("$FI$", person.FirstName + " " + person.SecondName);
                       badge.Value = badge.Value.Replace("$FIO$", person.FirstName + " " + person.SecondName + " " + person.ThirdName);
                       badge.Value = badge.Value.Replace("$POST$", person.Post);
                       badge.Value = badge.Value.Replace("$CITY$", person.Addresses.Select(o => o.CityName).FirstOrDefault());
                       badge.Value = badge.Value.Replace("$COUNTRY$", person.Addresses.Select(o => o.CountryName).FirstOrDefault());
                    //badge.Value.Replace("$COMPANY$", person);
                }
                DrawBadgeElement(badge, gfx);
            }

            //   DrawRoundedRectangle(gfx, 2);
            //  DrawEllipse(gfx, 3);

            // Save the s_document...
            s_document.Save(filename);
            // ...and start a viewer
            return filename;
        }
Пример #2
0
 public CurrentPersonViewModel(Person person)
 {
     this.Model = person;
     ActualConference = Model.PersonConferences.Where(p => p.ConferenceId == DefaultManager.Instance.DefaultConference.Id).FirstOrDefault();
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Persons EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPersons(Person person)
 {
     base.AddObject("Persons", person);
 }
Пример #4
0
        public PersonViewModel(Person person)
        {
            Model = person;

            ScienceDegreeLookup = new ObservableCollection<ScienceDegree>(DataManager.Instance.GetAllScienceDegrees());
            ScienceStatusLookup = new ObservableCollection<ScienceStatus>(DataManager.Instance.GetAllScienceStatuses());
            SexLookup = new ObservableCollection<Sex>(DataManager.Instance.GetAllSexes());
            SpecialityLookup = new ObservableCollection<Speciality>(DataManager.Instance.GetAllSpecialities());
            OrderStatusLookup = new ObservableCollection<OrderStatus>(DataManager.Instance.GetAllOrderStatuses());
            PaymentTypeLookup = new ObservableCollection<PaymentType>(DataManager.Instance.GetAllPaymentTypes());
            CompanyLookup = new ObservableCollection<Company>(DataManager.Instance.GetAllCompanies());
            RankLookup = new ObservableCollection<Rank>(DataManager.Instance.GetAllRanks());

            PersonEmails = new ObservableCollection<EmailViewModel>();
            PersonAddresses = new ObservableCollection<AddressViewModel>();
            PersonPhones = new ObservableCollection<PhoneViewModel>();
            if (Model.Emails.Count > 0)
            {
                foreach (var email in Model.Emails)
                {
                    PersonEmails.Add(new EmailViewModel(email));
                }
            }
            PersonEmails.CollectionChanged += (sender, e) =>
            {
                CurrentEmail = PersonEmails.FirstOrDefault();
            };
            if (Model.Addresses.Count > 0)
            {
                foreach (var adr in Model.Addresses)
                {
                    PersonAddresses.Add(new AddressViewModel(adr));
                }
            }
            PersonAddresses.CollectionChanged += (sender, e) =>
            {
                CurrentAddress = PersonAddresses.FirstOrDefault();
            };
            if (Model.Phones.Count > 0)
            {
                foreach (var phone in Model.Phones)
                {
                    PersonPhones.Add(new PhoneViewModel(phone));
                }
            }
            PersonPhones.CollectionChanged += (sender, e) =>
            {
                CurrentPhone = PersonPhones.FirstOrDefault();
            };

            AllConferences = new ObservableCollection<ConferenceViewModel>();
            foreach (var c in DataManager.Instance.GetAllConferences())
            {
                AllConferences.Add(new ConferenceViewModel(c));
            }
            AllConferences.CollectionChanged += AllConferences_CollectionChanged;

            // Проверяем режим работы конференция
            if (DefaultManager.Instance.ConferenceMode)
            {
                var defConf = DefaultManager.Instance.DefaultConference;
                var persConf = DataManager.Instance.GetPersonConference(Model, defConf);
                if (persConf == null)
                {
                    var newPersConf = DataManager.Instance.CreateObject<PersonConference>();
                    newPersConf.PersonConferenceId = GuidComb.Generate();
                    newPersConf.PersonId = Model.Id;
                    newPersConf.ConferenceId = defConf.Id;
                    newPersConf.PersonConferences_Detail =
                        DefaultManager.Instance.DefaultPersonConferenceDetail(newPersConf.PersonConferenceId);
                    newPersConf.PersonConferences_Payment =
                        DefaultManager.Instance.DefaultPersonConferencePayment(newPersConf.PersonConferenceId);
                    DataManager.Instance.AddPersonConference(newPersConf);
                }
            }
            // Проверяем режим работы регистрация
            if (DefaultManager.Instance.RegistrationMode)
            {
                var defConf = DefaultManager.Instance.DefaultConference;
                var persConf = DataManager.Instance.GetPersonConference(Model, defConf);
                if (persConf == null)
                {
                    var newPersConf = DataManager.Instance.CreateObject<PersonConference>();
                    newPersConf.PersonConferenceId = GuidComb.Generate();
                    newPersConf.PersonId = Model.Id;
                    newPersConf.ConferenceId = defConf.Id;
                    newPersConf.PersonConferences_Detail =
                        DefaultManager.Instance.DefaultPersonConferenceDetail(newPersConf.PersonConferenceId);
                    newPersConf.PersonConferences_Detail.IsArrive = true;
                    newPersConf.PersonConferences_Detail.RankId = DefaultManager.Instance.DefaultRank.Id;
                    newPersConf.PersonConferences_Detail.DateArrive = DateTime.Now;
                    newPersConf.PersonConferences_Payment =
                        DefaultManager.Instance.DefaultPersonConferencePayment(newPersConf.PersonConferenceId);
                    DataManager.Instance.AddPersonConference(newPersConf);
                }
                else
                {
                    persConf.PersonConferences_Detail.IsArrive = true;
                    persConf.PersonConferences_Detail.DateArrive = DateTime.Now;
                    DataManager.Instance.Save();
                }
            }

            AllPersonConferences = new ObservableCollection<PersonConference>(DataManager.Instance.GetPersonConferencesForPerson(Model));
            CurrentPersonConference = AllPersonConferences.Count > 0 ? AllPersonConferences[0] : null;
            if (DefaultManager.Instance.ConferenceMode || DefaultManager.Instance.RegistrationMode)
            {
                CurrentPersonConference =
                    AllPersonConferences.SingleOrDefault(o => o.Conference == DefaultManager.Instance.DefaultConference);
            }

            AllAbstracts = new ObservableCollection<Abstract>(DataManager.Instance.GetAbstractsByPersonConferenceID(CurrentPersonConference.PersonConferenceId));

            CurrentAbstract = AllAbstracts.FirstOrDefault();

            PrintBadgeCommand = new DelegateCommand(o => PrintBadge());
            PrintOrderCommand = new DelegateCommand(o => PrintOrder());
            AddPersonConferenceCommand = new DelegateCommand(o => AddPersonConference());
            RemovePersonConferenceCommand = new DelegateCommand(o => RemoveCurrentPersonConference(), (o) => CurrentPersonConference != null);

            SaveCommand = new DelegateCommand(o => Save());
            CancelCommand = new DelegateCommand(o => Cancel());

            AddEmailCommand = new DelegateCommand(o => AddEmail());
            AddAddressCommand = new DelegateCommand(o => AddAddress());
            AddPhoneCommand = new DelegateCommand(o => AddPhone());
            DeleteEmailCommand = new DelegateCommand(o => DeleteEmail(), (o) => CurrentEmail != null);
            DeleteAddressCommand = new DelegateCommand(o => DeleteAddress(), (o) => CurrentAddress != null);
            DeletePhoneCommand = new DelegateCommand(o => DeletePhone(), (o) => CurrentPhone != null);

            AddAbstractCommand = new DelegateCommand(o => AddAbstract());
            RemoveAbstractCommand = new DelegateCommand(o => DeleteAbstract(), o => CurrentAbstract != null);
        }
Пример #5
0
 /// <summary>
 /// Create a new Person object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="secondName">Initial value of the SecondName property.</param>
 /// <param name="thirdName">Initial value of the ThirdName property.</param>
 /// <param name="sexId">Initial value of the SexId property.</param>
 /// <param name="specialityId">Initial value of the SpecialityId property.</param>
 /// <param name="scienceDegreeId">Initial value of the ScienceDegreeId property.</param>
 /// <param name="scienceStatusId">Initial value of the ScienceStatusId property.</param>
 /// <param name="sourceId">Initial value of the SourceId property.</param>
 public static Person CreatePerson(global::System.Guid id, global::System.String firstName, global::System.String secondName, global::System.String thirdName, global::System.Guid sexId, global::System.Guid specialityId, global::System.Guid scienceDegreeId, global::System.Guid scienceStatusId, global::System.Int32 sourceId)
 {
     Person person = new Person();
     person.Id = id;
     person.FirstName = firstName;
     person.SecondName = secondName;
     person.ThirdName = thirdName;
     person.SexId = sexId;
     person.SpecialityId = specialityId;
     person.ScienceDegreeId = scienceDegreeId;
     person.ScienceStatusId = scienceStatusId;
     person.SourceId = sourceId;
     return person;
 }