示例#1
0
        public static void SerializeEventType(Event t, string fileName)
        {
            // Create an instance of the type and serialize it.
    
            IFormatter formatter = new BinaryFormatter();
            //SerializeEvent.SerializeEventType(eventOne, "EventOne", formatter);
            FileStream s = new FileStream(fileName, FileMode.Create);
            formatter.Serialize(s, t);
            s.Close();

        }
示例#2
0
        public void CarDistribution(Event eventToOrganize)
        {

            var participantsInCars = new Dictionary<string, string>();

           var participantsToDistribute = participantsList.Where(x=>x.IsDriver==false);

            var participantsDrivers = participantsList.Where(x=>x.IsDriver==true);
           
            foreach (var driver in participantsDrivers)
            {
                for (int j = 0; j < participantsToDistribute.Count(); j++)
			        {
			        for (int i = 0; i < driver.SeatsAvailable; i++)
                        {
                            participantsInCars.Add(driver.GSM, participantsToDistribute.ElementAt(j).GSM);
                        }
			        }
            }
        }
示例#3
0
 public void ChangeStatus(Event organizedEvent)
 {
     throw new NotImplementedException();
 }
 private void ButtonNewEvent_Click(object sender, RoutedEventArgs e)
 {
     DateTime date = Convert.ToDateTime(MyDaTePicker.SelectedDate);
     var money = Convert.ToDecimal(NewMoneyNeed.Text);
     var x = Convert.ToDecimal(NewLocationX.Text);
     var y = Convert.ToDecimal(NewLocationY.Text);
     Location loc = new Location(new Coordinates(x, y));
     Event currentEv = new Event() { Title = NewTitle.Text, Budget = money, Location = loc, MeetingPoint = NewMeetingPoint.Text, DateTime = date};
     if (!string.IsNullOrEmpty(NewCommentBox.Text))
     {
         currentEv.Comment = NewCommentBox.Text;
     }
     foreach (Window item in Application.Current.Windows)
     {
         if (item.GetType() == typeof(MainWindow))
         {
             (item as MainWindow).eventsList.Add(currentEv);
             SerializeEvent.SerializeEventList((item as MainWindow).eventsList, "AllEvents.bin");
             (item as MainWindow).MyComboBox.ItemsSource = null;
             
            
         }
        
     }            /////
     MessageBox.Show("EventAdded");
     winAdEv.Close();
 }
示例#5
0
        public MainWindow()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            InitializeComponent();
            /*var colllect = new List<Admin>
                {
                        
                        new Admin { Event = 1, Name = "Nomer1"},
                        new Admin { Event = 2, Name = "Nomer2"},
                        new Admin { Event = 3, Name = "Nomer3"},
                        new Admin { Event = 4, Name = "Nomer4"},
                        new Admin { Event = 5, Name = "Nomer5"},
                        new Admin { Event = 6, Name = "Nomer6"},
                };

            
            MyDataGrid.ItemsSource = colllect;*/

            var rnd = new Random();
            var eventOne = new Event();
            var eventTwo = new Event();
            var eventThree = new Event();
            var eventFour = new Event();
            var eventFive = new Event();


            #region ParticipantsMaking
            var pesho = new Participant("Petar", "Petrov", Gender.Male, "*****@*****.**", "02/02020202", 13, 25);
            var hasan = new Participant("Hasan", "Asenov", Gender.Male, "*****@*****.**", "0888888888", 0.20m, 26);
            var aishe = new Participant("Aishe", "AsAnova", Gender.Female, "*****@*****.**", "080808888", 10, 27);
            var moni = new Participant("Simeon", "Vtori", Gender.NotSpecified, "*****@*****.**", "08888813564", 15, 28);
            var ciganIN = new Participant("Ivan", "Mostov", Gender.Male, "*****@*****.**", "0034/606666666", 15, 29);
            var siuleiman = new Participant("Siuleiman", "Pasi", Gender.NotSpecified, "*****@*****.**", "02/87087078", 134, 30);
            var analiq = new Participant("Analiq", "Bezfamiliq", Gender.Female, "*****@*****.**", "08callme", 5500, 31);
            var tazi = new Participant("TaziBe", "KakIBesheImeto", Gender.Female, "*****@*****.**", "ZvaniMiINeMiVdiga", 10, 33);
            var krisko = new Participant("Krisko", "Drisko", Gender.NotSpecified, "*****@*****.**", "0887 777 777", 0.01m, 32);
            var mariq = new Participant("Iliq", "Marieva", Gender.Female, "*****@*****.**", "0888 889 999", 1200, 34);

            #endregion


            #region enventMakeing



            eventOne.Budget = 1205.00m;
            eventOne.DateTime = DateTime.Parse("01.12.2015 20:00:00");
            eventOne.EventStaff = new List<EventStaff>() { new DJ("MC Grozen", eventOne, 200), new Cook("Bai Ivan", eventOne, 50, true) };
            eventOne.Location = new Location(new Coordinates(40.25m, 10.12m), "Limoncheto");
            eventOne.MeetingPoint = "Pazara";
            eventOne.Organizer = new Organizer("Ivailo", "Kenov", EventScheduler.Data.Enumerations.Gender.Male, "*****@*****.**", "+359 888 888 888", 1300, 25);
            eventOne.ParticipantsList = new List<Participant>();

            eventOne.Title = "Naj ludoto party ever";
            //for (int i = 0; i < 20; i++)
            //{
            //    var gender = rnd.Next(0, 3);
            //    eventOne.ParticipantsList.Add(
            //        new Participant("Participant" + (i + 1).ToString(), "LastName" + (i + 1).ToString(),(Gender)gender, eventOne,
            //            "p" + (i + 1).ToString() + "@gmail.com", "0888 888 8" + (i + 1).ToString(), 25));
            //}
            eventOne.ParticipantsList.Add(pesho);
            eventOne.ParticipantsList.Add(moni);
            eventOne.ParticipantsList.Add(aishe);
            eventOne.ParticipantsList.Add(ciganIN);
            eventOne.ParticipantsList.Add(mariq);



            eventTwo.Budget = 6500.00m;
            eventTwo.DateTime = new DateTime(2015, 12, 08, 22, 00, 00);
            eventTwo.EventStaff = new List<EventStaff>() { new DJ("MC Typ", eventTwo, 200), new Singer("Analiq", eventTwo, 5000, true), new Cook("Bai Ivan", eventTwo, 50, true) };
            eventTwo.Location = new Location(new Coordinates(80.25m, 120.12m), "Riblja Corba");
            eventTwo.MeetingPoint = "NDK";
            eventTwo.Organizer = new Organizer("Doncho", "Minkov", EventScheduler.Data.Enumerations.Gender.Male, "*****@*****.**", "+359 888 888 666", 6500, 25);
            eventTwo.ParticipantsList = new List<Participant>();
            //for (int i = 0; i < 20; i++)
            //{
            //    var gender = rnd.Next(0, 3);
            //    eventTwo.ParticipantsList.Add(
            //        new Participant("Participant" + (i + 21).ToString(), "LastName" + (i + 21).ToString(), (Gender)gender, eventTwo,
            //            "p" + (i + 21).ToString() + "@gmail.com", "0888 888 8" + (i + 21).ToString(), 25));
            //}
            eventTwo.ParticipantsList.Add(hasan);
            eventTwo.ParticipantsList.Add(analiq);
            eventTwo.ParticipantsList.Add(krisko);
            eventTwo.ParticipantsList.Add(tazi);

            eventTwo.Title = "Narko party";

            eventThree.Budget = 26500.00m;
            eventThree.DateTime = new DateTime(2015, 12, 31, 22, 00, 00);
            eventThree.EventStaff = new List<EventStaff>() { new Singer("Jochan Strauss JR", eventThree, 25000, true) };
            eventThree.Location = new Location(new Coordinates(54.25m, 50.12m), "NDK");
            eventThree.MeetingPoint = "NDK";
            eventThree.Organizer = new Organizer("Evlogi", "Georgiev", EventScheduler.Data.Enumerations.Gender.Male, "*****@*****.**", "+359 888 888 686", 26500, 25);
            eventThree.ParticipantsList = new List<Participant>();
            //for (int i = 0; i < 20; i++)
            //{
            //    var gender = rnd.Next(0, 3);
            //    eventThree.ParticipantsList.Add(
            //        new Participant("Participant" + (i + 321).ToString(), "LastName" + (i + 321).ToString(), (Gender)gender, eventThree,
            //            "p" + (i + 321).ToString() + "@gmail.com", "0888 888 8" + (i + 321).ToString(), 125));
            //}
            eventThree.ParticipantsList.Add(hasan);
            eventThree.ParticipantsList.Add(analiq);
            eventThree.ParticipantsList.Add(krisko);
            eventThree.ParticipantsList.Add(tazi);
            eventThree.ParticipantsList.Add(mariq);
            eventThree.ParticipantsList.Add(ciganIN);
            eventThree.ParticipantsList.Add(moni);
            eventThree.ParticipantsList.Add(pesho);

            eventThree.Title = "Forever Classics";

            eventFour.Budget = 0.00m;
            eventFour.DateTime = DateTime.Now.AddDays(1);
            eventFour.Location = new Location(new Coordinates(4.25m, 0.12m), "U vas");
            eventFour.MeetingPoint = "Mr. Popa";
            eventFour.Organizer = new Organizer("Nikolai", "Kostov", EventScheduler.Data.Enumerations.Gender.Male, "*****@*****.**", "+359 888 888 000", 2.5m, 25);
            eventFour.ParticipantsList = new List<Participant>();
            //for (int i = 0; i < 20; i++)
            //{
            //    var gender = rnd.Next(0, 3);
            //    eventFour.ParticipantsList.Add(
            //        new Participant("Participant" + (i + 4321).ToString(), "LastName" + (i + 4321).ToString(), (Gender)gender, eventFour,
            //            "p" + (i + 4321).ToString() + "@gmail.com", "0888 888 8" + (i + 4321).ToString(), 0));
            //}
            eventFour.ParticipantsList.Add(hasan);
            eventFour.ParticipantsList.Add(analiq);
            eventFour.ParticipantsList.Add(krisko);
            eventFour.ParticipantsList.Add(tazi);
            eventFour.ParticipantsList.Add(mariq);
            eventFour.ParticipantsList.Add(ciganIN);
            eventFour.ParticipantsList.Add(moni);
            eventFour.ParticipantsList.Add(pesho);
            eventFour.ParticipantsList.Add(siuleiman);
            eventFour.ParticipantsList.Add(aishe);
            eventFour.Title = "Pijama party";
            #endregion


            //IFormatter formatter = new BinaryFormatter();
            ////SerializeEvent.SerializeEventType(eventOne, "EventOne", formatter);
            //FileStream s = new FileStream("EventName", FileMode.Create);
            //formatter.Serialize(s, eventFour);
            //s.Close();

            SerializeEvent.SerializeEventType(eventFour, "Event.txt");
            Event Deserialized = SerializeEvent.DeserializeEvent("Event.txt");


            //eventsList = new List<Event> { eventOne, eventTwo, eventThree, eventFour, eventFive,Deserialized };
            // eventsList.Add(eventOne);
            // eventsList.Add(eventTwo);
            // eventsList.Add(eventThree);
            // eventsList.Add(eventFour);
            // eventsList.Add(eventFive);
            //SerializeEvent.SerializeEventList(eventsList, "AllEvents.bin");

            List<Event> returnedList = SerializeEvent.DeserializeEventList("AllEvents.bin");
            eventsList = returnedList;
            MyComboBox.ItemsSource = returnedList;


        }