Skip to content

Commit

Permalink
Introducing several services
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Mar 9, 2019
1 parent 645cf64 commit 83b9de1
Show file tree
Hide file tree
Showing 49 changed files with 1,032 additions and 737 deletions.
2 changes: 2 additions & 0 deletions src/BuildVision.Contracts/BuildVision.Contracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
<Compile Include="Enums\ErrorLevel.cs" />
<Compile Include="ErrorsBox.cs" />
<Compile Include="Enums\ProjectState.cs" />
<Compile Include="Models\IBuildInformationModel.cs" />
<Compile Include="Models\ISolutionModel.cs" />
<Compile Include="ProjectNotFoundException.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyNotFoundException.cs" />
Expand Down
3 changes: 2 additions & 1 deletion src/BuildVision.Contracts/Enums/BuildActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum BuildActions
BuildActionBuild = 1,
BuildActionRebuildAll = 2,
BuildActionClean = 3,
BuildActionDeploy = 4
BuildActionDeploy = 4,
Unknown = 5
}
}
3 changes: 2 additions & 1 deletion src/BuildVision.Contracts/Enums/BuildScopes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum BuildScopes
{
BuildScopeSolution = 1,
BuildScopeBatch = 2,
BuildScopeProject = 3
BuildScopeProject = 3,
Unknown = 4
}
}
3 changes: 2 additions & 1 deletion src/BuildVision.Contracts/Enums/BuildState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public enum BuildState
NotStarted = 0,
InProgress = 1,
Done = 2,
Cancelled = 3
Cancelled = 3,
Failed = 4
}
}
24 changes: 24 additions & 0 deletions src/BuildVision.Contracts/Models/IBuildInformationModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace BuildVision.Contracts.Models
{
public interface IBuildInformationModel
{
BuildActions BuildAction { get; set; }
DateTime? BuildFinishTime { get; set; }
BuildScopes BuildScope { get; set; }
DateTime? BuildStartTime { get; set; }
BuildState CurrentBuildState { get; set; }
int ErrorCount { get; set; }
int FailedProjectsCount { get; set; }
int MessagesCount { get; set; }
BuildResultState ResultState { get; }
string StateMessage { get; set; }
int SucceededProjectsCount { get; set; }
int UpToDateProjectsCount { get; set; }
int WarnedProjectsCount { get; set; }
int WarningsCount { get; set; }

BuildResultState GetBuildState();
}
}
10 changes: 10 additions & 0 deletions src/BuildVision.Contracts/Models/ISolutionModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace BuildVision.Contracts.Models
{
public interface ISolutionModel
{
string FileName { get; set; }
string FullName { get; set; }
bool IsEmpty { get; set; }
string Name { get; set; }
}
}
4 changes: 4 additions & 0 deletions src/BuildVision.Exports/BuildVision.Exports.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BuildVision.Contracts\BuildVision.Contracts.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions src/BuildVision.Exports/Providers/IBuildInformationProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using BuildVision.Contracts.Models;

namespace BuildVision.Exports.Providers
{
public interface IBuildInformationProvider
{
void BuildFinished(bool success, bool modified, bool canceled);
void BuildStarted(uint dwAction);
void BuildUpdate();
IBuildInformationModel GetBuildInformationModel();
}
}
41 changes: 20 additions & 21 deletions src/BuildVision.UI/BuildVision.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Helpers\ResetTaskBarItemInfoCondition.cs" />
<Compile Include="Enums\ResetTaskBarItemInfoCondition.cs" />
<Compile Include="Helpers\SortDescription.cs" />
<Compile Include="Helpers\SortOrder.cs" />
<Compile Include="Helpers\WindowState.cs" />
<Compile Include="Enums\SortOrder.cs" />
<Compile Include="Enums\WindowState.cs" />
<Compile Include="Helpers\WindowStateAction.cs" />
<Compile Include="IPackageSettingsProvider.cs" />
<Compile Include="Models\BaseGridColumnSettings.cs" />
<Compile Include="Models\BuildMessagesSettings.cs" />
<Compile Include="Models\BuildProgressSettings.cs" />
<Compile Include="Settings\Models\BaseGridColumnSettings.cs" />
<Compile Include="Settings\Models\BuildMessagesSettings.cs" />
<Compile Include="Settings\Models\BuildProgressSettings.cs" />
<Compile Include="Common\Logging\BindingErrorListener.cs" />
<Compile Include="Common\Logging\TraceManager.cs" />
<Compile Include="Components\ControlHeader.xaml.cs">
Expand All @@ -92,13 +92,13 @@
</Compile>
<Compile Include="Contracts\BuildedProjectsCollection.cs" />
<Compile Include="Contracts\BuildProjectContextEntry.cs" />
<Compile Include="Models\ControlSettings.cs" />
<Compile Include="Models\GeneralSettings.cs" />
<Compile Include="Models\GridColumnSettings.cs" />
<Compile Include="Settings\Models\ControlSettings.cs" />
<Compile Include="Settings\Models\GeneralSettings.cs" />
<Compile Include="Settings\Models\GridColumnSettings.cs" />
<Compile Include="Models\GridColumnSettingsCollection.cs" />
<Compile Include="Models\GridSettings.cs" />
<Compile Include="Settings\Models\GridSettings.cs" />
<Compile Include="Helpers\BindingProxy.cs" />
<Compile Include="Helpers\BuildMessages.cs" />
<Compile Include="Helpers\BuildMessagesFactory.cs" />
<Compile Include="Contracts\BuildProjectEventArgs.cs" />
<Compile Include="Components\ControlView.xaml.cs">
<DependentUpon>ControlView.xaml</DependentUpon>
Expand All @@ -115,21 +115,20 @@
<Compile Include="Extensions\TextBlockUtils.cs" />
<Compile Include="Extensions\VectorResources.cs" />
<Compile Include="Extensions\VisualHelper.cs" />
<Compile Include="Helpers\DisplayStringAttribute.cs" />
<Compile Include="Attributes\DisplayStringAttribute.cs" />
<Compile Include="Helpers\EnumExtensions.cs" />
<Compile Include="Helpers\StyleConverting.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Models\ProjectItem.cs" />
<Compile Include="Extensions\ProjectStateExtensions.cs" />
<Compile Include="Models\BuildExtraMessageFormat.cs" />
<Compile Include="Models\BuildMajorMessageFormat.cs" />
<Compile Include="Models\NavigateToBuildFailureReasonCondition.cs" />
<Compile Include="Models\GridColumnAttribute.cs" />
<Compile Include="Enums\BuildExtraMessageFormat.cs" />
<Compile Include="Enums\BuildMajorMessageFormat.cs" />
<Compile Include="Enums\NavigateToBuildFailureReasonCondition.cs" />
<Compile Include="Attributes\GridColumnAttribute.cs" />
<Compile Include="Helpers\ProjectItemColumnSorter.cs" />
<Compile Include="Models\SolutionItem.cs" />
<Compile Include="Models\ProjectItemSettings.cs" />
<Compile Include="Settings\Models\ProjectItemSettings.cs" />
<Compile Include="Resources.Designer.cs">
<DependentUpon>Resources.resx</DependentUpon>
<AutoGen>True</AutoGen>
Expand All @@ -153,11 +152,11 @@
<Compile Include="Settings\WindowSettingsControl.xaml.cs">
<DependentUpon>WindowSettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\SolutionModel.cs" />
<Compile Include="Models\BuildInformationModel.cs" />
<Compile Include="Models\SolutionModel.cs" />
<Compile Include="ViewModels\BuildProgressViewModel.cs" />
<Compile Include="ViewModels\BuildVisionPaneViewModel.cs" />
<Compile Include="ViewModels\VisualStudioSolution.cs" />
<Compile Include="Models\WindowSettings.cs" />
<Compile Include="Settings\Models\WindowSettings.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\AlternatingRowBackgroundConverter.cs" />
Expand Down
4 changes: 2 additions & 2 deletions src/BuildVision.UI/Components/ControlHeader.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:dvm="clr-namespace:BuildVision.UI.ViewModels"
d:DataContext ="{d:DesignInstance {x:Type dvm:BuildMetaInformationsViewModel}, IsDesignTimeCreatable=True}"
xmlns:dvm="clr-namespace:BuildVision.Contracts.Models"
d:DataContext ="{d:DesignInstance {x:Type dvm:IBuildInformationModel}, IsDesignTimeCreatable=True}"
d:DesignWidth="697"
xmlns:res="clr-namespace:BuildVision.UI"
xmlns:extensions1="clr-namespace:BuildVision.UI.Extensions"
Expand Down
4 changes: 2 additions & 2 deletions src/BuildVision.UI/Components/ControlView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<components:ControlHeader DataContext="{Binding}"
<components:ControlHeader DataContext="{Binding BuildInformationModel}"
Grid.Row="0"
Height="auto" />

Expand Down Expand Up @@ -345,4 +345,4 @@
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Grid>
</UserControl>
</UserControl>
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/BuildVision.UI/Helpers/BindingProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override Freezable CreateInstanceCore()

public object Data
{
get { return (object)GetValue(DataProperty); }
get { return (object) GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ public BuildMessagesFactory(BuildMessagesSettings labelsSettings)
_labelSettings = labelsSettings;
}

public string GetBuildBeginMajorMessage(VisualStudioSolution solutionItem)
public string GetBuildBeginMajorMessage(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
var mainString = GetMainString(solutionItem);
var mainString = GetMainString(solutionItem, buildInformationModel);
return string.Format(_labelSettings.BuildBeginMajorMessageStringFormat, mainString);
}

private string GetMainString(VisualStudioSolution solutionItem)
private string GetMainString(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
var buildAction = BuildActions.BuildActionBuild; //TOdo replace

var unitName = GetUnitName(solutionItem);
var actionName = GetActionName(solutionItem.BuildAction);
var beginAtString = GetBeginAtString(solutionItem.BuildAction);
var timeString = GetTimeString(solutionItem);
var unitName = GetUnitName(solutionItem, buildInformationModel);
var actionName = GetActionName(buildInformationModel.BuildAction);
var beginAtString = GetBeginAtString(buildInformationModel.BuildAction);
var timeString = GetTimeString(solutionItem, buildInformationModel);
string mainString;
switch (_labelSettings.MajorMessageFormat)
{
Expand All @@ -48,12 +48,12 @@ private string GetMainString(VisualStudioSolution solutionItem)
return mainString;
}

private string GetTimeString(VisualStudioSolution solution)
private string GetTimeString(SolutionModel solution, BuildInformationModel buildInformationModel)
{
string timeString = "";
try
{
timeString = solution.BuildStartTime.Value.ToString(_labelSettings.DateTimeFormat);
timeString = buildInformationModel.BuildStartTime.Value.ToString(_labelSettings.DateTimeFormat);
}
catch (FormatException)
{
Expand Down Expand Up @@ -97,10 +97,10 @@ private string GetActionName(BuildActions buildAction)
}
}

private string GetUnitName(VisualStudioSolution solutionItem)
private string GetUnitName(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
string unitName = "";
switch (solutionItem.BuildScope)
switch (buildInformationModel.BuildScope)
{
case BuildScopes.BuildScopeSolution:
unitName = Resources.BuildScopeSolution_UnitName;
Expand All @@ -118,20 +118,20 @@ private string GetUnitName(VisualStudioSolution solutionItem)
break;

default:
throw new ArgumentOutOfRangeException(nameof(solutionItem.BuildScope));
throw new ArgumentOutOfRangeException(nameof(buildInformationModel.BuildScope));
}

return unitName;
}

public string GetBuildBeginExtraMessage(VisualStudioSolution solutionItem)
public string GetBuildBeginExtraMessage(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
if (solutionItem.BuildStartTime == null || !_labelSettings.ShowExtraMessage || _labelSettings.ExtraMessageDelay < 0)
if (buildInformationModel.BuildStartTime == null || !_labelSettings.ShowExtraMessage || _labelSettings.ExtraMessageDelay < 0)
{
return string.Empty;
}

TimeSpan timeSpan = DateTime.Now.Subtract(solutionItem.BuildStartTime.Value);
TimeSpan timeSpan = DateTime.Now.Subtract(buildInformationModel.BuildStartTime.Value);
if (timeSpan.TotalSeconds > _labelSettings.ExtraMessageDelay)
{
return GetExtraTimePartString( timeSpan);
Expand All @@ -140,23 +140,23 @@ public string GetBuildBeginExtraMessage(VisualStudioSolution solutionItem)
return string.Empty;
}

public string GetBuildDoneMessage(VisualStudioSolution solutionItem)
public string GetBuildDoneMessage(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
return GetBuildDoneMajorMessage(solutionItem) + GetBuildDoneExtraMessage(solutionItem);
return GetBuildDoneMajorMessage(solutionItem, buildInformationModel) + GetBuildDoneExtraMessage(solutionItem, buildInformationModel);
}

private string GetBuildDoneMajorMessage(VisualStudioSolution solutionItem)
private string GetBuildDoneMajorMessage(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
var buildAction = solutionItem.BuildAction;
var buildScope = solutionItem.BuildScope;
var buildAction = buildInformationModel.BuildAction;
var buildScope = buildInformationModel.BuildScope;

if (solutionItem.BuildFinishTime == null)
if (buildInformationModel.BuildFinishTime == null)
throw new InvalidOperationException();

string timeString;
try
{
timeString = solutionItem.BuildFinishTime.Value.ToString(_labelSettings.DateTimeFormat);
timeString = buildInformationModel.BuildFinishTime.Value.ToString(_labelSettings.DateTimeFormat);
}
catch (FormatException)
{
Expand All @@ -181,18 +181,18 @@ private string GetBuildDoneMajorMessage(VisualStudioSolution solutionItem)
if (_labelSettings.ShowProjectName)
{
// Todo this is probably wrong. maybe we should go the extra mile and check which projects are selected?
var uniqProjName = solutionItem.Projects.LastOrDefault(x => x.State == ProjectState.BuildDone)?.UniqueName;
var projItem = solutionItem.Projects.FirstOrDefault(item => item.UniqueName == uniqProjName);
unitName += string.Format(Resources.BuildScopeProject_ProjectNameTemplate, projItem.Name);
//var uniqProjName = solutionItem.Projects.LastOrDefault(x => x.State == ProjectState.BuildDone)?.UniqueName;
//var projItem = solutionItem.Projects.FirstOrDefault(item => item.UniqueName == uniqProjName);
//unitName += string.Format(Resources.BuildScopeProject_ProjectNameTemplate, projItem.Name);
}
break;

default:
throw new ArgumentOutOfRangeException(nameof(buildScope));
}

var actionName = GetActionName(solutionItem.BuildAction);
var resultName = GetResultName(solutionItem.ResultState);
var actionName = GetActionName(buildInformationModel.BuildAction);
var resultName = GetResultName(buildInformationModel.ResultState);

string mainString;
switch (_labelSettings.MajorMessageFormat)
Expand Down Expand Up @@ -239,12 +239,12 @@ private string GetResultName(BuildResultState resultState)
}
}

private string GetBuildDoneExtraMessage(VisualStudioSolution solutionItem)
private string GetBuildDoneExtraMessage(SolutionModel solutionItem, BuildInformationModel buildInformationModel)
{
if (solutionItem.BuildStartTime == null || solutionItem.BuildFinishTime == null || !_labelSettings.ShowExtraMessage)
if (buildInformationModel.BuildStartTime == null || buildInformationModel.BuildFinishTime == null || !_labelSettings.ShowExtraMessage)
return string.Empty;

TimeSpan timeSpan = solutionItem.BuildFinishTime.Value.Subtract(solutionItem.BuildStartTime.Value);
TimeSpan timeSpan = buildInformationModel.BuildFinishTime.Value.Subtract(buildInformationModel.BuildStartTime.Value);
string extraTimePartString = GetExtraTimePartString(timeSpan);
return string.Format(_labelSettings.ExtraMessageStringFormat, extraTimePartString);
}
Expand Down
31 changes: 0 additions & 31 deletions src/BuildVision.UI/Models/BaseGridColumnSettings.cs

This file was deleted.

Loading

0 comments on commit 83b9de1

Please sign in to comment.