Skip to content

Commit bb1327b

Browse files
authored
Merge pull request #19 from I-RzR-I/feature/AddMessageDetails
Modify current message (string) into object, fix SOAP/XML serialization
2 parents 128b7a7 + ec2c2e2 commit bb1327b

41 files changed

Lines changed: 1294 additions & 159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/pack-repo.ps1

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
$assemblyPath = "..\src\shared\GeneralAssemblyInfo.cs";
2+
$defaultVersion = "1.0.0.0";
3+
$nugetPath = "../nuget";
4+
$data = ("..\src\AggregatedGenericResultMessage\AggregatedGenericResultMessage.csproj");
5+
$forceCustomPackVersion = $args[0];
6+
7+
<#
8+
.SYNOPSIS
9+
A brief description of the Get-CurrentAssemblyVersion function.
10+
11+
.DESCRIPTION
12+
Get current assembly version
13+
14+
.EXAMPLE
15+
PS C:\> Get-CurrentAssemblyVersion
16+
17+
.NOTES
18+
Additional information about the function.
19+
#>
20+
function Get-CurrentAssemblyVersion
21+
{
22+
[OutputType([string])]
23+
param ()
24+
25+
$assemblyInfo = (Get-Content $assemblyPath);
26+
$asVersion = ($assemblyInfo -match 'AssemblyVersion\(".*"\)');
27+
$asVersion = $asVersion -split ('"');
28+
$asVersion = $asVersion[1];
29+
30+
return $asVersion;
31+
}
32+
33+
<#
34+
.SYNOPSIS
35+
A brief description of the Build-And-Pack-BuildPack function.
36+
37+
.DESCRIPTION
38+
Build project and pack as package (u pkg)
39+
40+
.PARAMETER packVersion
41+
Package/Build version
42+
43+
.PARAMETER currentVersion
44+
A description of the currentVersion parameter.
45+
46+
.EXAMPLE
47+
PS C:\> Build-And-Pack-BuildPack -packVersion 'Value1'
48+
49+
.NOTES
50+
Additional information about the function.
51+
#>
52+
function Set-BuildAndPack
53+
{
54+
[CmdletBinding()]
55+
[OutputType([bool])]
56+
param
57+
(
58+
[Parameter(Mandatory = $true)]
59+
[string]$packVersion,
60+
[string]$currentVersion
61+
)
62+
63+
try
64+
{
65+
Write-Host "Project restore '$($_)'!" -ForegroundColor Green;
66+
dotnet restore $($_);
67+
68+
Write-Host "Build in Release '$($_)'!" -ForegroundColor Green;
69+
$buildResult = dotnet build $($_) --source https://api.nuget.org/v3/index.json -c Release /p:AssemblyVersion=$packVersion /p:AssemblyFileVersion=$packVersion /p:AssemblyInformationalVersion=$packVersion;
70+
if ($LASTEXITCODE -ne 0)
71+
{
72+
Set-VersionAssembly -packVersion $currentVersion;
73+
Write-Host $buildResult;
74+
75+
return $false;
76+
}
77+
78+
Write-Host "Pack in Release '$($_)'!" -ForegroundColor Green;
79+
dotnet pack $($_) -p:PackageVersion=$packVersion --no-build -c Release --output $nugetPath;
80+
81+
return $true;
82+
}
83+
catch
84+
{
85+
Write-Host -foregroundcolor Red "An error occurred: $_"
86+
87+
return $false;
88+
}
89+
}
90+
91+
<#
92+
.SYNOPSIS
93+
A brief description of the Get-TimeStamp function.
94+
95+
.DESCRIPTION
96+
Get time stamp version
97+
98+
.EXAMPLE
99+
PS C:\> Get-TimeStamp
100+
101+
.NOTES
102+
Additional information about the function.
103+
#>
104+
function Get-TimeStamp
105+
{
106+
[CmdletBinding()]
107+
[OutputType([int])]
108+
param ()
109+
110+
$current = [System.DateTime]::Now;
111+
$end = [System.DateTime]::Now.Date;
112+
$diff = (New-TimeSpan -Start $current -End $end).TotalSeconds / 10;
113+
$timeSec = If ($diff -le 0) { $diff * -1 }
114+
Else { $diff };
115+
116+
return [int]$timeSec;
117+
}
118+
119+
<#
120+
.SYNOPSIS
121+
A brief description of the Set-VersionAssembly function.
122+
123+
.DESCRIPTION
124+
Set current version in assembly file
125+
126+
.PARAMETER packVersion
127+
A description of the packVersion parameter.
128+
129+
.EXAMPLE
130+
PS C:\> Set-VersionAssembly -packVersion 'Value1'
131+
132+
.NOTES
133+
Additional information about the function.
134+
#>
135+
function Set-VersionAssembly
136+
{
137+
[CmdletBinding()]
138+
[OutputType([void])]
139+
param
140+
(
141+
[Parameter(Mandatory = $true)]
142+
[string]$packVersion
143+
)
144+
$NewVersion = 'AssemblyVersion("' + $packVersion + '")';
145+
$NewFileVersion = 'AssemblyFileVersion("' + $packVersion + '")';
146+
$NewAssemblyInformationalVersion = 'AssemblyInformationalVersion("' + $packVersion + '")';
147+
148+
(Get-Content $assemblyPath -encoding utf8) |
149+
%{ $_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
150+
%{ $_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } |
151+
%{ $_ -replace 'AssemblyInformationalVersion\("[0-9x]+(\.([0-9x]+|\*)){1,3}"\)', $NewAssemblyInformationalVersion } |
152+
Set-Content $assemblyPath -encoding utf8
153+
}
154+
155+
<#
156+
.SYNOPSIS
157+
A brief description of the Exec-TestSolution function.
158+
159+
.DESCRIPTION
160+
Execute solution test
161+
162+
.EXAMPLE
163+
PS C:\> Exec-TestSolution
164+
165+
.NOTES
166+
Additional information about the function.
167+
#>
168+
function Exec-TestSolution
169+
{
170+
[CmdletBinding()]
171+
[OutputType([bool])]
172+
param ()
173+
174+
# Merge all streams into stdout
175+
$result = dotnet test "..\src\tests\InfoResultTests\InfoResultTests.csproj" *>&1
176+
177+
# Evaluate success/failure
178+
if ($LASTEXITCODE -eq 0)
179+
{
180+
return $true;
181+
}
182+
else
183+
{
184+
$errorString = $result -join [System.Environment]::NewLine;
185+
Write-Host -foregroundcolor Red "An error occurred: $errorString";
186+
187+
return $false;
188+
}
189+
}
190+
191+
Write-Host "Init test solution...`n" -ForegroundColor Green;
192+
$testExec = Exec-TestSolution;
193+
If ($testExec -eq $true)
194+
{
195+
Write-Host "Path to pack: '$nugetPath'`n" -ForegroundColor Green;
196+
197+
$currentVersion = "";
198+
If ($forceCustomPackVersion -eq $null -or $forceCustomPackVersion -eq "") { $currentVersion = Get-CurrentAssemblyVersion; }
199+
Else { $currentVersion = $forceCustomPackVersion; }
200+
201+
$directoryInfo = Get-ChildItem $nugetPath | Where-Object { $_.Name -match '[a-z]*.1.0.0.nupkg$' } | Measure-Object;
202+
If ($defaultVersion -eq $currentVersion -and $directoryInfo.count -eq 0)
203+
{
204+
Set-VersionAssembly -packVersion $currentVersion;
205+
206+
$data | ForEach-Object {
207+
$buildResult = Set-BuildAndPack -packVersion $currentVersion;
208+
If ($buildResult -eq $false -or $buildResult -ccontains $false)
209+
{
210+
exit;
211+
}
212+
}
213+
214+
Write-Host "`nPack executed with success with version: $currentVersion!" -ForegroundColor Green;
215+
216+
exit;
217+
}
218+
Else
219+
{
220+
$finalVersion = "";
221+
If ($forceCustomPackVersion -eq $null -or $forceCustomPackVersion -eq "")
222+
{
223+
$versArray = $currentVersion.Split('.');
224+
$finalVersion = $versArray[0].ToString() + "." + $versArray[1].ToString() + "." + (([int]$versArray[2]) + 1).ToString() + "." + (Get-TimeStamp).ToString();
225+
}
226+
Else { $finalVersion = $forceCustomPackVersion; }
227+
228+
Set-VersionAssembly -packVersion $finalVersion;
229+
230+
$data | ForEach-Object {
231+
$buildResult = Set-BuildAndPack -packVersion $finalVersion -currentVersion $currentVersion;
232+
If ($buildResult -eq $false -or $buildResult -ccontains $false)
233+
{
234+
exit;
235+
}
236+
}
237+
238+
Write-Host "`nPack executed with success with version: $finalVersion!" -ForegroundColor Green;
239+
240+
exit;
241+
}
242+
}
243+
Else { exit; }

src/AggregatedGenericResultMessage/Abstractions/IResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public interface IResult
4040
/// <summary>
4141
/// This property will contain messages keys if any.
4242
/// </summary>
43-
[XmlArray]
43+
[XmlArray("Messages")]
44+
[XmlArrayItem("Message")]
4445
ICollection<IMessageModel> Messages { get; set; }
4546

4647
/// <summary>

src/AggregatedGenericResultMessage/Abstractions/IResultOfT.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#region U S A G E S
1818

1919
using System.Xml.Serialization;
20-
using AggregatedGenericResultMessage.Enums;
20+
using AggregatedGenericResultMessage.Models;
2121

2222
#endregion
2323

@@ -38,5 +38,12 @@ public interface IResult<T> : IResult
3838
/// <returns></returns>
3939
/// <remarks></remarks>
4040
string GetFirstMessage();
41+
42+
/// <summary>
43+
/// Get first message from response
44+
/// </summary>
45+
/// <returns></returns>
46+
/// <remarks></remarks>
47+
MessageDataModel GetFirstMessageWithDetails();
4148
}
4249
}

src/AggregatedGenericResultMessage/Abstractions/MessageResults/IAccessDeniedMessageResult.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// </summary>
1515
// ***********************************************************************
1616

17+
using AggregatedGenericResultMessage.Models;
18+
1719
namespace AggregatedGenericResultMessage.Abstractions.MessageResults
1820
{
1921
/// <summary>
@@ -35,12 +37,27 @@ public interface IAccessDeniedMessageResult<T>
3537
/// <returns></returns>
3638
IResult<T> AddAccessDenied(string message);
3739

40+
/// <summary>
41+
/// Add access denied message
42+
/// </summary>
43+
/// <param name="message">Message</param>
44+
/// <returns></returns>
45+
IResult<T> AddAccessDenied(MessageDataModel message);
46+
3847
/// <summary>
3948
/// Add access denied message
4049
/// </summary>
4150
/// <param name="key">Key</param>
4251
/// <param name="message">Message</param>
4352
/// <returns></returns>
4453
IResult<T> AddAccessDenied(string key, string message);
54+
55+
/// <summary>
56+
/// Add access denied message
57+
/// </summary>
58+
/// <param name="key">Key</param>
59+
/// <param name="message">Message</param>
60+
/// <returns></returns>
61+
IResult<T> AddAccessDenied(string key, MessageDataModel message);
4562
}
4663
}

src/AggregatedGenericResultMessage/Abstractions/MessageResults/IErrorMessageResult.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#region U S A G E S
1818

19+
using AggregatedGenericResultMessage.Models;
1920
using System;
2021

2122
#endregion
@@ -42,6 +43,13 @@ public interface IErrorMessageResult<T>
4243
/// <returns></returns>
4344
IResult<T> AddError(string error);
4445

46+
/// <summary>
47+
/// Add error
48+
/// </summary>
49+
/// <param name="error"></param>
50+
/// <returns></returns>
51+
IResult<T> AddError(MessageDataModel error);
52+
4553
/// <summary>
4654
/// Add error
4755
/// </summary>
@@ -50,13 +58,28 @@ public interface IErrorMessageResult<T>
5058
/// <returns></returns>
5159
IResult<T> AddError(string key, string error);
5260

61+
/// <summary>
62+
/// Add error
63+
/// </summary>
64+
/// <param name="key"></param>
65+
/// <param name="error"></param>
66+
/// <returns></returns>
67+
IResult<T> AddError(string key, MessageDataModel error);
68+
5369
/// <summary>
5470
/// Add error for confirmation result
5571
/// </summary>
5672
/// <param name="error"></param>
5773
/// <returns></returns>
5874
IResult<T> AddErrorConfirm(string error);
5975

76+
/// <summary>
77+
/// Add error for confirmation result
78+
/// </summary>
79+
/// <param name="error"></param>
80+
/// <returns></returns>
81+
IResult<T> AddErrorConfirm(MessageDataModel error);
82+
6083
/// <summary>
6184
/// Add error for confirmation result
6285
/// </summary>
@@ -65,6 +88,14 @@ public interface IErrorMessageResult<T>
6588
/// <returns></returns>
6689
IResult<T> AddErrorConfirm(string key, string error);
6790

91+
/// <summary>
92+
/// Add error for confirmation result
93+
/// </summary>
94+
/// <param name="key"></param>
95+
/// <param name="error"></param>
96+
/// <returns></returns>
97+
IResult<T> AddErrorConfirm(string key, MessageDataModel error);
98+
6899
/// <summary>
69100
/// Add exception error
70101
/// </summary>

0 commit comments

Comments
 (0)