Example #1
0
        /// <summary>
        /// Konstruktor, naplneni atributu z dat
        /// </summary>
        /// <param name="d"></param>
        public JsonExport(MeetingsData d)
        {
            foreach (MeetingCenter mc in d.meetingCenters)
            {
                foreach (MeetingRoom mr in mc.MeetingRooms)
                {
                    if (mr.Meetings.Count() > 0)
                    {
                        // tento meeting room se zaradi do exportu
                        // ulozeni meetin roomu
                        Hashtable record = new Hashtable();
                        record["meetingCentre"] = mc.Code;
                        record["meetingRoom"]   = mr.Code;
                        // pomocny hash pro dny
                        Hashtable days = new Hashtable();
                        // projit vsechny meetingy
                        // pro jednotliva data
                        foreach (string den in IndividualDates(mr))
                        {
                            // kazdy den samostatna polozka
                            // v reservations
                            List <Hashtable> meets = new List <Hashtable>();
                            foreach (Meeting mm in mr.Meetings)
                            {
                                if (mm.Date.Equals(den))
                                {
                                    Hashtable m = new Hashtable();
                                    m.Add("from", mm.HoursFrom.ToString() + ":" + mm.MinutesFrom.ToString());
                                    m.Add("to", mm.HoursTo.ToString() + ":" + mm.MinutesTo.ToString());
                                    m.Add("expectedPersonsCount", mm.ExpectedPersons.ToString());
                                    m.Add("customer", mm.Customer);
                                    m.Add("videoConference", mm.VideoConference);
                                    m.Add("note", mm.Note);
                                    meets.Add(m);
                                }
                            }
                            if (meets.Count() > 0)
                            {
                                days.Add(den, meets);
                            }
                        }
                        // ulozit hashtable do reservations
                        record.Add("reservations", days);

                        data.Add(record);
                    }
                    else
                    {
                        // tento meeting room nema meetingy, takze se nebude davat do exportu
                        continue;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Konstruktor, uvodni inicializace seznamu meeting center pro oba taby, takze do ListBox a do ComboBox
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            data = new MeetingsData();

            // nacteni ulozenych dat
            XmlSerializer serializer = new XmlSerializer(typeof(MeetingsData));
            FileStream    stream     = new FileStream(data.dataPath, FileMode.Open);

            data = (MeetingsData)serializer.Deserialize(stream);

            listMeetingCenters.ItemsSource       = data.meetingCenters;
            listMeetingCenters.DisplayMemberPath = "Name";
            listMeetingCenters.SelectedValuePath = "Code";

            selectMC.ItemsSource       = data.meetingCenters;
            selectMC.DisplayMemberPath = "Name";
        }