Skip to content

Commit

Permalink
Merge pull request #1 from RudolfJan/PrepareRelease
Browse files Browse the repository at this point in the history
Prepare release
  • Loading branch information
RudolfJan authored Apr 29, 2020
2 parents 7a189b5 + 171f350 commit b9d1910
Show file tree
Hide file tree
Showing 17 changed files with 322 additions and 286 deletions.
2 changes: 1 addition & 1 deletion DataAccess.Library/Logic/ServiceInstanceDataAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static void InsertServiceInstance(ServiceInstanceModel serviceInstance)

public static void UpdateServiceInstance(ServiceInstanceModel serviceInstance)
{
string sql = "UPDATE OR IGNORE ServiceInstances SET ServiceInstanceName=@ServiceInstanceName, ServiceInstanceAbbreviation=@ServiceInstanceAbbreviation, StartTime=@StartTime, EndTime=@EndTime, ServiceId=@ServiceId) WHERE Id=@Id";
string sql = "UPDATE OR IGNORE ServiceInstances SET ServiceInstanceName=@ServiceInstanceName, ServiceInstanceAbbreviation=@ServiceInstanceAbbreviation, StartTime=@StartTime, EndTime=@EndTime, ServiceId=@ServiceId WHERE Id=@Id";
SQLiteData.SaveData<dynamic>(sql,
new {serviceInstance.ServiceInstanceName, serviceInstance.ServiceInstanceAbbreviation,
serviceInstance.StartTime, serviceInstance.EndTime, serviceInstance.ServiceId, serviceInstance.Id},
Expand Down
6 changes: 3 additions & 3 deletions TimeTableTool.Desktop/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ public Bootstrapper()
protected override void Configure()
{
_container
.Singleton<IWindowManager, WindowManager>()
.Singleton<IEventAggregator, EventAggregator>()
.Singleton<ILogCollectionManager, LogCollectionManager>();
.Singleton<IWindowManager, WindowManager>()
.Singleton<IEventAggregator, EventAggregator>();

GetType().Assembly.GetTypes()
.Where(type => type.IsClass)
Expand All @@ -45,6 +44,7 @@ private void OnLogEvent(Object Sender, LogEventArgs args)
{
if (args.EntryClass.EventType == LogEventType.Error || args.EntryClass.EventType == LogEventType.Event)
{
LogCollectionManager.LogEvents.Add(args.EntryClass);
var message = args.EntryClass.LogEntry;
var form = new NotificationView(message);
form.Show();
Expand Down
1 change: 1 addition & 0 deletions TimeTableTool.Desktop/TimeTableTool.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<AssemblyName>TimetableTool</AssemblyName>
</PropertyGroup>

<ItemGroup>
Expand Down
48 changes: 24 additions & 24 deletions TimeTableTool.Desktop/ViewModels/ServiceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public ServiceModel SelectedService
ServiceSelectedEvent serviceSelectedEvent = new ServiceSelectedEvent();
serviceSelectedEvent.SelectedService = _selectedService;
_events.PublishOnUIThreadAsync(serviceSelectedEvent);
if(SelectedService!=null)
if (SelectedService != null)
{
FullTimeEventsList= new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
FullTimeEventsList = new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
}
else
{
FullTimeEventsList=null;
FullTimeEventsList = null;
}
NotifyOfPropertyChange(() => CanLoadTimeEvents);
NotifyOfPropertyChange(() => SelectedService);
Expand Down Expand Up @@ -221,7 +221,7 @@ public void EditService()
SelectedServiceDirection = ServiceDirectionDataAccess.GetServiceDirectionById(ServiceDirectionId);
ServiceDirectionName = SelectedServiceDirection.ServiceDirectionName;
ServiceId = SelectedService.Id;
FullTimeEventsList= new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
FullTimeEventsList = new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
NotifyOfPropertyChange(() => CanLoadTimeEvents);
NotifyOfPropertyChange(() => CanEditService);
NotifyOfPropertyChange(() => CanDeleteService);
Expand Down Expand Up @@ -295,15 +295,15 @@ public void ClearService()
ServiceDirectionName = "";
ServiceId = 0;
NotifyOfPropertyChange(() => ServicesUI);
NotifyOfPropertyChange(()=>CanLoadTimeEvents);
NotifyOfPropertyChange(() => CanLoadTimeEvents);
NotifyOfPropertyChange(() => CanEditService);
}

public bool CanLoadTimeEvents
{
get
{
return SelectedService != null && (FullTimeEventsList==null ||
return SelectedService != null && (FullTimeEventsList == null ||
FullTimeEventsList.Count == 0);
}
}
Expand All @@ -317,34 +317,34 @@ public void LoadTimeEvents()

public void SaveTimeEvents()
{
foreach (var item in FullTimeEventsList)
foreach (var item in FullTimeEventsList)
{
if (item.EventType?.Length > 0)
{
if (item.EventType?.Length > 0)
var timeEvent = new TimeEventModel();
timeEvent.Id = item.Id;
timeEvent.EventType = item.EventType;
timeEvent.ArrivalTime = item.ArrivalTime;
timeEvent.WaitTime = item.WaitTime;
timeEvent.LocationId = item.LocationId;
timeEvent.ServiceId = item.ServiceId;
timeEvent.Order = item.Order;
if (item.Id > 0)
{
var timeEvent = new TimeEventModel();
timeEvent.Id = item.Id;
timeEvent.EventType = item.EventType;
timeEvent.ArrivalTime = item.ArrivalTime;
timeEvent.WaitTime = item.WaitTime;
timeEvent.LocationId = item.LocationId;
timeEvent.ServiceId = item.ServiceId;
timeEvent.Order = item.Order;
if(item.Id>0)
{
timeEvent.Id=item.Id;
TimeEventDataAccess.UpdateTimeEvent(timeEvent);
}
else
{
{
TimeEventDataAccess.InsertTimeEventForService(timeEvent);
}
}
}
int duration = FullTimeEventsList.Sum(x => x.ArrivalTime+x.WaitTime);
SelectedService.CalculatedDuration= duration;
ServiceDataAccess.UpdateServiceCalculatedDuration(duration,SelectedService.Id);
NotifyOfPropertyChange(()=>ServicesUI.ServiceList);
FullTimeEventsList= new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
int duration = FullTimeEventsList.Sum(x => x.ArrivalTime + x.WaitTime);
SelectedService.CalculatedDuration = duration;
ServiceDataAccess.UpdateServiceCalculatedDuration(duration, SelectedService.Id);
ServicesUI.ServiceList.Refresh();
FullTimeEventsList = new BindableCollection<FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerService(SelectedService.Id));
Log.Trace($"Time events for service {SelectedService.ServiceAbbreviation} saved", LogEventType.Event);
}
}
Expand Down
6 changes: 4 additions & 2 deletions TimeTableTool.Desktop/ViewModels/TimeTableViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ protected override async void OnViewLoaded(object view)
RouteId = rm.Id;
TimetablesUI.TimetableList = new BindableCollection<TimetableModel>(TimetableDataAccess.GetAllTimetablesPerRoute(RouteId));
ServiceDirectionList = new BindableCollection<ServiceDirectionModel>(ServiceDirectionDataAccess.GetAllServiceDirectionsPerRoute(RouteId));


NotifyOfPropertyChange(() => TimetablesUI);
}
#endregion
Expand Down Expand Up @@ -384,6 +382,7 @@ public void AddServiceInstance()
ServiceInstancesDestinationList.Add(SelectedServiceInstanceSource);
ConnectTtSiDataAccess.InsertConnection(SelectedServiceInstanceSource.Id, SelectedTimetable.Id);
NotifyOfPropertyChange(() => ServiceInstancesDestinationList);
NotifyOfPropertyChange(()=>CopyStatus);
}

public bool CanRemoveServiceInstance
Expand All @@ -398,6 +397,8 @@ public void RemoveServiceInstance()
{
ConnectTtSiDataAccess.DeleteConnection(SelectedServiceInstanceDestination.Id, SelectedTimetable.Id);
ServiceInstancesDestinationList.Remove(SelectedServiceInstanceDestination);
NotifyOfPropertyChange(() => ServiceInstancesDestinationList);
NotifyOfPropertyChange(()=>CopyStatus);
}


Expand All @@ -415,6 +416,7 @@ public void CopyAllServiceInstances()
ServiceInstancesDestinationList.Add(item);
ConnectTtSiDataAccess.InsertConnection(item.Id, SelectedTimetable.Id);
NotifyOfPropertyChange(() => ServiceInstancesDestinationList);
NotifyOfPropertyChange(()=>CopyStatus);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion TimeTableTool.Desktop/Views/LocationView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
Height="400" MinWidth="400"
CanUserAddRows="False"
CanUserDeleteRows="False"
AutoGenerateColumns="False"
AutoGenerateColumns="False" LoadingRow="OnLoadingRow"

>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id, NotifyOnSourceUpdated=True}">
Expand Down
36 changes: 24 additions & 12 deletions TimeTableTool.Desktop/Views/LocationView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@
using System.Windows.Shapes;

namespace TimetableTool.Desktop.Views
{
/// <summary>
/// Interaction logic for LocationView.xaml
/// </summary>
public partial class LocationView : UserControl
{
public LocationView()
{
InitializeComponent();
}
}
}
{
/// <summary>
/// Interaction logic for LocationView.xaml
/// </summary>
public partial class LocationView : UserControl
{
private int rowCount;
public LocationView()
{
InitializeComponent();
}

//Scroll to last row if a row is added
private void OnLoadingRow(object sender, DataGridRowEventArgs e)
{
if (LocationList.Items.Count > rowCount)
{
var lastRow = LocationList.Items[^1];
LocationList.ScrollIntoView(lastRow);
rowCount = LocationList.Items.Count;
}
}
}
}
4 changes: 2 additions & 2 deletions TimeTableTool.Desktop/Views/ServiceInstanceView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
Height="400" MinWidth="400"
CanUserAddRows="False"
CanUserDeleteRows="False"
AutoGenerateColumns="False"
>
AutoGenerateColumns="False"
LoadingRow="OnLoadingRow">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id, NotifyOnSourceUpdated=True}">
<DataGridTextColumn.HeaderTemplate>
Expand Down
36 changes: 24 additions & 12 deletions TimeTableTool.Desktop/Views/ServiceInstanceView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@
using System.Windows.Shapes;

namespace TimetableTool.Desktop.Views
{
/// <summary>
/// Interaction logic for ServiceInstanceView.xaml
/// </summary>
public partial class ServiceInstanceView : UserControl
{
public ServiceInstanceView()
{
InitializeComponent();
}
}
}
{
/// <summary>
/// Interaction logic for ServiceInstanceView.xaml
/// </summary>

public partial class ServiceInstanceView : UserControl
{
private int rowCount;
public ServiceInstanceView()
{
InitializeComponent();
}

private void OnLoadingRow(object sender, DataGridRowEventArgs e)
{
if (ServiceInstanceListDataGrid.Items.Count > rowCount)
{
var lastRow = ServiceInstanceListDataGrid.Items[^1];
ServiceInstanceListDataGrid.ScrollIntoView(lastRow);
rowCount = ServiceInstanceListDataGrid.Items.Count;
}
}
}
}
3 changes: 2 additions & 1 deletion TimeTableTool.Desktop/Views/TimeEventView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
<DataGrid x:Name="EventTimeEventDataGrid" Style="{StaticResource DefaultDataGrid}"
AutoGenerateColumns="False" Height="400"
ItemsSource="{Binding TimeEvents.FilteredFullTimeEventList}"
SelectedItem="{Binding SelectedTimeEvent}">
SelectedItem="{Binding SelectedTimeEvent}" LoadingRow="OnLoadingRow"
>
<DataGrid.Columns>
<DataGridTextColumn Header="Location" Width="150"
Binding="{Binding LocationName}" />
Expand Down
38 changes: 26 additions & 12 deletions TimeTableTool.Desktop/Views/TimeEventView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Printing;
using System.Text;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -12,15 +13,28 @@
using System.Windows.Shapes;

namespace TimetableTool.Desktop.Views
{
/// <summary>
/// Interaction logic for TimeEventView.xaml
/// </summary>
public partial class TimeEventView : UserControl
{
public TimeEventView()
{
InitializeComponent();
}
}
}
{
/// <summary>
/// Interaction logic for TimeEventView.xaml
/// </summary>
public partial class TimeEventView : UserControl
{
private int rowCount;
public TimeEventView()
{
InitializeComponent();
}

//Scroll to last row if a row is added
private void OnLoadingRow(object sender, DataGridRowEventArgs e)
{
if (EventTimeEventDataGrid.Items.Count > rowCount)
{
var lastRow = EventTimeEventDataGrid.Items[^1];
EventTimeEventDataGrid.ScrollIntoView(lastRow);
rowCount = EventTimeEventDataGrid.Items.Count;
}

}
}
}
Binary file not shown.
File renamed without changes.
Loading

0 comments on commit b9d1910

Please sign in to comment.