private async void Button_Click_4(object sender, RoutedEventArgs e)
        {
            var result1 = await restClient.MakeRequest("GET", "actor/allactors/getEmp/" + EmployeeUpdateTxt.Text);

            try
            {
                UpdateUserPopUp popUp = new UpdateUserPopUp();
                try
                {
                    object      scheduleSelected = ListUsersListBox.SelectedItem;
                    JObject     jSchedule        = scheduleSelected as JObject;
                    NewSchedule schedule         = jSchedule.ToObject <NewSchedule>();

                    popUp.UserNamerTxt.Text = schedule.departure;
                    popUp.UserSNameTxt.Text = schedule.arrival;
                    popUp.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Please select a Schedule");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a Schedule");
            }
        }
        public async Task OnNewMessage(NewSchedule newSchedule)
        {
            using (var scope = services.CreateScope())
            {
                var importScheduleService =
                    scope.ServiceProvider
                    .GetRequiredService <IImportPoolSchedule>();

                await importScheduleService.ImportSchedule(newSchedule.Pool.ToString(), newSchedule.StartDate, newSchedule.EndDate, newSchedule.Link);
            }
        }
        private async void DeleteScheduleS_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                object      scheduleSelected = ScheduleListBox.SelectedItem;
                JObject     jSchedule        = scheduleSelected as JObject;
                NewSchedule schedule         = jSchedule.ToObject <NewSchedule>();

                await restClient.MakeRequest("DELETE", "schedule/delete/" + schedule.trainNumber + "/" + schedule.departureDate + "/" + schedule.departure);

                Button_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a Schedule");
            }
        }
        private async Task SendNotification(string loggerInformation, PoolSchedule poolSchedule)
        {
            logger.LogInformation($"{loggerInformation}. Id: {poolSchedule.Id}");
            var message = new NewSchedule
            {
                Pool             = Pools.olimpijczyk,
                Id               = poolSchedule.Id,
                Link             = poolSchedule.Link,
                ModificationDate = poolSchedule.ModificationDate,
                DayFrom          = poolSchedule.DayFrom,
                DayTo            = poolSchedule.DayTo,
                MonthFrom        = poolSchedule.MonthFrom,
                MonthTo          = poolSchedule.MonthTo,
                YearFrom         = poolSchedule.YearFrom,
                YearTo           = poolSchedule.YearTo
            };

            await messageBus.SendAsync <NewSchedule>("swimmingpooltracker", message);
        }
Пример #5
0
        public void CreateSchedule(NewSchedule s)
        {
            if (!Directory.Exists(Path.Combine(CSVBasePath, ScheduledBookingsPath)))
            {
                Directory.CreateDirectory(Path.Combine(CSVBasePath, ScheduledBookingsPath));
            }

            var schTempFile = Path.Combine(CSVBasePath, "scheduled-parts-temp-" + s.ScheduleId + ".csv");
            var schFile     = Path.Combine(CSVBasePath, "scheduled-parts.csv");

            WriteScheduledParts(schTempFile, s.ScheduledParts);

            WriteScheduledBookings(s.ScheduleId, s.ScheduledTimeUTC, s.BookingIds);

            if (File.Exists(schFile))
            {
                File.Delete(schFile);
            }
            File.Move(schTempFile, schFile);
        }
        private async void UpdateScheduleBtn_Click(object sender, RoutedEventArgs e)
        {
            var depart      = DepartureTimeCbx.Text;
            var arrival     = ArrivalTimeCbx.Text;
            var depDate     = DepartureDate.Text;
            var trainNum    = int.Parse(TrainNumberTxt.Text);
            var seatsBooked = int.Parse(SeatsBookedTxt.Text);
            //var depLocation = DepartureLocationCbx.Text;
            //var arrivalLocation = ArrivalLocationCbx.Text;

            DateTime date             = (DateTime)DepartureDate.SelectedDate;
            string   departDateCreate = date.ToString("yyyy-MM-dd");


            NewSchedule schedule = new NewSchedule(trainNum, seatsBooked, departDateCreate, depart, arrival);

            await restClient.MakeRequest("UPDATE", "schedule/update", schedule);

            Close();
        }
Пример #7
0
        public void CreateSchedule(NewSchedule s)
        {
            using (var context = new BookingContext())
            {
                //Update the bookings and extra parts tables.

                foreach (var bookingId in s.BookingIds)
                {
                    var booking = context.Bookings.Single(b => b.BookingId == bookingId);
                    booking.ScheduleId = s.ScheduleId;
                }

                var oldParts = context.ExtraParts.ToDictionary(p => p.Part);
                var newParts = s.ScheduledParts.ToDictionary(p => p.Part);

                foreach (var p in newParts)
                {
                    if (oldParts.ContainsKey(p.Key))
                    {
                        oldParts[p.Key].Quantity = p.Value.Quantity;
                        oldParts.Remove(p.Key);
                    }
                    else
                    {
                        context.ExtraParts.Add(p.Value);
                    }
                }

                foreach (var p in oldParts)
                {
                    context.ExtraParts.Remove(p.Value);
                }

                //In addition to the above data, you could also store data about the schedule itself
                //in a schedule table, but keeping data about the schedule itself is not required for
                //implementing the booking plugin and would just be for your own internal use.

                context.SaveChanges();
            }
        }
Пример #8
0
        /// <summary>
        /// The ButtonAdd_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonAdd_Click(object sender, EventArgs args)
        {
            var newSchedule = new NewSchedule
            {
                Id   = tbxId.Text,
                Name = tbxName.Text,
                UseAllDataSources = ckbxUseAllDataSources.Checked,
                Action            = Schedule.Actions.Record
            };

            foreach (ListViewItem triggerItem in lvScheduleTriggers.Items)
            {
                newSchedule.ScheduleTriggers.Add((NewScheduleTrigger)triggerItem.Tag);
            }

            try
            {
                MainForm.CurrentSystem.AddSchedule(newSchedule);
            }
            catch (Exception ex)
            {
                MainForm.Instance.WriteToLog($"Error creating schedule: {ex.Message}");
            }
        }
        private void UpdateScheduleS_Click(object sender, RoutedEventArgs e)
        {
            UpdateSchedulePopUp popUp = new UpdateSchedulePopUp();

            try
            {
                object      scheduleSelected = ScheduleListBox.SelectedItem;
                JObject     jSchedule        = scheduleSelected as JObject;
                NewSchedule schedule         = jSchedule.ToObject <NewSchedule>();

                popUp.DepartureTimeCbx.Text = schedule.departure;
                popUp.ArrivalTimeCbx.Text   = schedule.arrival;
                popUp.DepartureDate.Text    = schedule.departureDate;
                popUp.TrainNumberTxt.Text   = schedule.trainNumber.ToString();
                popUp.SeatsBookedTxt.Text   = schedule.capacity.ToString();
                //popUp.DepartureLocationCbx.Text = schedule.departureLocation.ToString();
                //popUp.ArrivalLocationCbx.Text = schedule.arrivalLocation.ToString();
                popUp.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a Schedule");
            }
        }