Пример #1
0
        private void collectData()
        {
            var customers    = service.GetAllCustomers();
            var reservations = service.GetAllReservations();
            var loans        = service.GetAllLoans();

            AllCustomer.Clear();
            foreach (Customer c in customers)
            {
                List <Loan> cLoans = getLoans(c, loans);
                AllCustomer.Add(new AllOfCustomer(c.Studentnumber, c.Name, getReservations(c, reservations), cLoans, getToBackInformations(cLoans)));
            }


            foreach (Reservation r in reservations)
            {
                AllReservations.Add(new ReserveByUser(r.Customer.Name, r.Gadget.Name, r.WaitingPosition, r.IsReady));
            }

            foreach (Loan l in loans)
            {
                DateTime?date = l.ReturnDate;
                if (l.ReturnDate == null)
                {
                    date = l.OverDueDate;
                }
                AllLoans.Add(new LoansByUser(l.Gadget.Name, l.Customer.Name, date, l.IsOverdue, getResByGadget(l, reservations)));
            }
        }
Пример #2
0
 private void AsyncGetReservations()
 {
     foreach (var reservation in _service.GetAllReservations())
     {
         Application.Current.Dispatcher.Invoke(() => { AllReservations.Add(reservation); });
     }
     IsLoading = false;
 }
Пример #3
0
        public Ausleihe()
        {
            InitializeComponent();
            var service = new LibraryAdminService("http://mge5.dev.ifs.hsr.ch/");


            var gadgets      = service.GetAllGadgets();
            var customers    = service.GetAllCustomers();
            var reservations = service.GetAllReservations();
            var loans        = service.GetAllLoans();



            List <AllOfCustomer> allCustomer = new List <AllOfCustomer>();

            foreach (Customer c in customers)
            {
                List <Loan> cLoans = getLoans(c, loans);
                allCustomer.Add(new AllOfCustomer(c.Studentnumber, c.Name, getReservations(c, reservations), cLoans, getToBackInformations(cLoans)));
            }
            GadgetsByUser.ItemsSource = allCustomer;
            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(GadgetsByUser.ItemsSource);

            view.Filter = UserFilter1;


            List <ReserveByUser> allReservations = new List <ReserveByUser>();

            foreach (Reservation r in reservations)
            {
                allReservations.Add(new ReserveByUser(r.Customer.Name, r.Gadget.Name, r.WaitingPosition, r.IsReady));
            }
            ReservationsByUsers.ItemsSource = allReservations;
            CollectionView view2 = (CollectionView)CollectionViewSource.GetDefaultView(ReservationsByUsers.ItemsSource);

            view2.Filter = UserFilter2;


            List <LoansByUser> allLoans = new List <LoansByUser>();

            foreach (Loan l in loans)
            {
                if (l.Gadget != null)
                {
                    allLoans.Add(new LoansByUser(l.Gadget.Name, l.Customer.Name, l.ReturnDate, l.IsOverdue, getResByGadget(l, reservations)));
                }
            }
            LeansByGadget.ItemsSource = allLoans;
            CollectionView view3 = (CollectionView)CollectionViewSource.GetDefaultView(LeansByGadget.ItemsSource);

            view3.Filter = UserFilter3;
        }
Пример #4
0
 public MainViewModel(String server)
 {
     ServerAddress = server;
     Gadgets       = new ObservableCollection <Gadget>(Service.GetAllGadgets());
     Loans         = new ObservableCollection <Loan>(Service.GetAllLoans());
     Reservations  = new ObservableCollection <Reservation>(Service.GetAllReservations());
     Task.Run(() =>
     {
         while (true)
         {
             Console.WriteLine("Update Loans");
             Thread.Sleep(3000);
             List <Loan> list = Service.GetAllLoans();
             Application.Current.Dispatcher.BeginInvoke(
                 DispatcherPriority.Background,
                 new Action(() => {
                 Loans.Clear();
                 list.ForEach(Loans.Add);
             }));
         }
     });
     Task.Run(() =>
     {
         while (true)
         {
             Console.WriteLine("Update Reservations");
             Thread.Sleep(3000);
             List <Reservation> list = Service.GetAllReservations();
             Application.Current.Dispatcher.BeginInvoke(
                 DispatcherPriority.Background,
                 new Action(() => {
                 Reservations.Clear();
                 list.ForEach(Reservations.Add);
             }));
         }
     });
 }
Пример #5
0
        /// <summary>
        /// demonstrates how to get the full inventory from the gadgeothek
        /// </summary>
        public void ShowInventory()
        {
            var service = new LibraryAdminService(ServerUrl);

            // no need to login as admin, woohoo :-)

            var gadgets = service.GetAllGadgets();

            PrintAll(gadgets);

            var customers = service.GetAllCustomers();

            PrintAll(customers);

            var reservations = service.GetAllReservations();

            PrintAll(reservations);

            var loans = service.GetAllLoans();

            PrintAll(loans);
        }
Пример #6
0
        public MainWindow()
        {
            InitializeComponent();
            service = new LibraryAdminService(ConfigurationSettings.AppSettings.Get("server"));
            var client = new websocket.WebSocketClient(ConfigurationSettings.AppSettings.Get("server"));

            this.DataContext = this;
            Gadgets          = new ObservableCollection <Gadget>(service.GetAllGadgets());
            Loans            = new ObservableCollection <Loan>(service.GetAllLoans());
            List <domain.Customer>    customers    = service.GetAllCustomers();
            List <domain.Reservation> reservations = service.GetAllReservations();

            //gadgetGrid.ItemsSource = gadgets;
            //loanGrid.ItemsSource = loans;
            reservationGrid.ItemsSource = reservations;
            customerGrid.ItemsSource    = customers;


            client.NotificationReceived += (o, e) =>
            {
                Console.WriteLine("WebSocket::Notification: " + e.Notification.Target + " > " + e.Notification.Type);

                // demonstrate how these updates could be further used
                if (e.Notification.Target == typeof(Loan).Name.ToLower())
                {
                    // deserialize the json representation of the data object to an object of type Gadget
                    var loan = e.Notification.DataAs <Loan>();
                    // now you can use it as usual...
                    //Console.WriteLine("Details: " + gadget);
                    Loans.Add(loan);
                }
            };

            // spawn a new background thread in which the websocket client listens to notifications from the server
            var bgTask = client.ListenAsync();
        }