Skip to content

Commit a5e5e54

Browse files
committed
Hisar upgrade, NetCoreStack upgrade, tests, UI, packages
1 parent c1b4a5f commit a5e5e54

File tree

43 files changed

+370
-138
lines changed

Some content is hidden

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

43 files changed

+370
-138
lines changed

Component.Common.Props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project>
2-
<!--<PropertyGroup>
2+
<PropertyGroup>
33
<SolutionDir Condition="$(Solutiondir) == '' Or $(SolutionDir) == '*Undefined*'">$(MsBuildProjectDirectory)\..\..\</SolutionDir>
4-
</PropertyGroup>
4+
</PropertyGroup>
55

66
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
7-
<Exec Command="cd $(ProjectDir) &amp; dotnet hisar build &quot;$(ProjectDir)&quot;" />
7+
<Exec Command="cd $(ProjectDir) &amp; dotnet hisar --build &quot;$(ProjectDir)&quot;" />
88
</Target>
99

1010
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
@@ -13,5 +13,5 @@
1313
<Exec Condition=" '$(OS)' == 'Windows_NT'" Command="xcopy /y $(ProjectDir)$(OutDir)*.dll $(SolutionDir)test\components\Hisar.Component.CoreManagement\ExternalComponents" />
1414
<Exec Condition=" '$(OS)' != 'Windows_NT'" Command="cp $(ProjectDir)$(OutDir)*.dll $(SolutionDir)test/Landing.Hosting/ExternalComponents" />
1515
<Exec Condition=" '$(OS)' != 'Windows_NT'" Command="cp $(ProjectDir)$(OutDir)*.dll $(SolutionDir)test/Admin.Hosting/ExternalComponents" />
16-
</Target>-->
16+
</Target>
1717
</Project>

NetCoreStack.Hisar.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
1111
Component.Common.Props = Component.Common.Props
12-
NuGet.config = NuGet.config
12+
NuGet.Config = NuGet.Config
1313
README.md = README.md
1414
EndProjectSection
1515
EndProject

NuGet.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
4-
<clear />
54
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
5+
<add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
66
</packageSources>
77
</configuration>

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ When you start develop the component you can fallow these steps;
5959
- Add Hisar WebCli tool to the project manually
6060
```xml
6161
<ItemGroup>
62-
<DotNetCliToolReference Include="NetCoreStack.Hisar.WebCli.Tools" Version="1.1.7" />
62+
<DotNetCliToolReference Include="NetCoreStack.Hisar.WebCli.Tools" Version="2.1.0" />
6363
</ItemGroup>
6464
```
6565
- Add PreBuild event to generate component helper classes.
@@ -105,9 +105,27 @@ When you start develop the component you can fallow these steps;
105105
106106
dotnet hisar --appdir <the-path-of-your-hosting-app-relative-or-absolute>
107107

108+
## Database
109+
### MongoDb Database
110+
111+
docker volume create --name=mongodata
112+
113+
docker run -it -v mongodata:/data/db -p 27017:27017 -d mongo
114+
108115
## Tools
109116
[Hisar Web Cli](https://github.com/NetCoreStack/Tools) tool provides manage extensibility and templating of components. You don't need extra gulp or grunt tooling and scripting behaviors. .NET Core Cli tools extensibility model has various tooling features. **Hisar Web Cli** is built on top of it.
110117
118+
## Components.json (Sample Nuget package reference)
119+
120+
{
121+
"components": {
122+
"Hisar.Component.CoreManagement": {
123+
targetFramework": "netcoreapp1.1",
124+
"version": "2.1.0"
125+
}
126+
}
127+
}
128+
111129
## TODO
112130
- Hisar Package Repository
113131
- Component Marketplace (Upload, search, download and enable the component)

src/NetCoreStack.Hisar.Server/NetCoreStack.Hisar.Server.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="NetCoreStack.Data" Version="2.0.0" />
10-
<PackageReference Include="NetCoreStack.Mvc" Version="2.0.0" />
9+
<PackageReference Include="NetCoreStack.Data" Version="2.0.15" />
10+
<PackageReference Include="NetCoreStack.Mvc" Version="2.0.15" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/NetCoreStack.Hisar/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal static RunningComponentHelperOfT<TStartup> CreateComponentHelper<TStart
4646
}
4747

4848
internal static void AddHisar<TStartup>(this IServiceCollection services,
49-
IConfigurationRoot configuration,
49+
IConfiguration configuration,
5050
IHostingEnvironment env) where TStartup : class
5151
{
5252
services.AddNetCoreStackMvc();

src/NetCoreStack.Hisar/Filters/HisarExceptionFilter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Microsoft.Extensions.Logging;
1010
using NetCoreStack.Contracts;
1111
using NetCoreStack.Mvc;
12-
using NetCoreStack.Mvc.Exceptions;
1312
using NetCoreStack.Mvc.Extensions;
1413
using NetCoreStack.Mvc.Types;
1514
using System;
@@ -63,8 +62,6 @@ private void CreateErrorViewResult(ExceptionContext context, string contentBody,
6362
else
6463
exceptionContextModel.Message = context.Exception.Message;
6564

66-
// Workaround for https://github.com/aspnet/Home/issues/1820
67-
context.HttpContext.Items.Add(nameof(BasicExceptionContext), exceptionContextModel);
6865
context.Result = result;
6966
}
7067

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Globalization;
5+
using System.Reflection;
6+
using System.Runtime.Versioning;
7+
using System.Security;
8+
using System.Security.Principal;
9+
using System.Text;
10+
11+
namespace NetCoreStack.Hisar
12+
{
13+
public static class ExceptionFormatter
14+
{
15+
private static string LineSeparator = "======================================";
16+
17+
private static NameValueCollection CollectAdditionalInfo()
18+
{
19+
NameValueCollection nameValueCollection = null;
20+
NameValueCollection additionalInfo = new NameValueCollection();
21+
if (additionalInfo["MachineName:"] == null)
22+
{
23+
additionalInfo.Add("MachineName:", string.Concat("MachineName: ", GetMachineName()));
24+
DateTime utcNow = DateTime.UtcNow;
25+
additionalInfo.Add("TimeStamp:", string.Concat("TimeStamp: ", utcNow.ToString(CultureInfo.CurrentCulture)));
26+
additionalInfo.Add("FullName:", string.Concat("FullName: ", Assembly.GetEntryAssembly().GetCustomAttribute<TargetFrameworkAttribute>().FrameworkName));
27+
additionalInfo.Add("ApplicationName:", string.Concat("ApplicationName: ", Assembly.GetEntryAssembly().GetName().Name));
28+
additionalInfo.Add("WindowsIdentity:", string.Concat("WindowsIdentity: ", GetWindowsIdentity()));
29+
nameValueCollection = additionalInfo;
30+
}
31+
else
32+
{
33+
nameValueCollection = null;
34+
}
35+
return nameValueCollection;
36+
}
37+
38+
private static string GetMachineName()
39+
{
40+
string machineName = null;
41+
try
42+
{
43+
machineName = Environment.GetEnvironmentVariable("COMPUTERNAME");
44+
}
45+
catch (SecurityException)
46+
{
47+
machineName = "Permission Denied";
48+
}
49+
return machineName;
50+
}
51+
52+
private static string GetWindowsIdentity()
53+
{
54+
string name = null;
55+
try
56+
{
57+
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
58+
if (windowsIdentity == null)
59+
{
60+
name = null;
61+
}
62+
else
63+
{
64+
name = windowsIdentity.Name;
65+
}
66+
}
67+
catch (SecurityException)
68+
{
69+
name = "Permission Denied";
70+
}
71+
return name;
72+
}
73+
74+
private static void ProcessAdditionalInfo(PropertyInfo propinfo, object propValue, StringBuilder stringBuilder)
75+
{
76+
if (!(propinfo.Name == "AdditionalInformation"))
77+
{
78+
stringBuilder.AppendFormat("" + Environment.NewLine + "{0}: {1}", propinfo.Name, propValue);
79+
}
80+
else if (propValue != null)
81+
{
82+
NameValueCollection currAdditionalInfo = (NameValueCollection)propValue;
83+
if (currAdditionalInfo.Count > 0)
84+
{
85+
stringBuilder.AppendFormat("" + Environment.NewLine + "AdditionalInformation:", new object[1]);
86+
int i = 0;
87+
while (i < currAdditionalInfo.Count)
88+
{
89+
stringBuilder.AppendFormat("" + Environment.NewLine + "{0}: {1}", currAdditionalInfo.GetKey(i), currAdditionalInfo[i]);
90+
i = i + 1;
91+
}
92+
}
93+
}
94+
}
95+
96+
private static void ReflectException(Exception currException, StringBuilder strEventInfo)
97+
{
98+
object propValue = null;
99+
PropertyInfo[] properties = currException.GetType().GetProperties();
100+
int ınt32 = 0;
101+
while (ınt32 < Convert.ToInt32(properties.Length))
102+
{
103+
PropertyInfo propinfo = properties[ınt32];
104+
if (propinfo.Name == "InnerException" ? false : propinfo.Name != "StackTrace")
105+
{
106+
if (!propinfo.CanRead ? false : Convert.ToInt32(propinfo.GetIndexParameters().Length) == 0)
107+
{
108+
try
109+
{
110+
propValue = propinfo.GetValue(currException, null);
111+
}
112+
catch (TargetInvocationException)
113+
{
114+
propValue = "Access failed";
115+
}
116+
if (propValue != null)
117+
{
118+
ProcessAdditionalInfo(propinfo, propValue, strEventInfo);
119+
}
120+
else
121+
{
122+
strEventInfo.AppendFormat("" + Environment.NewLine + "{0}: NULL", propinfo.Name);
123+
}
124+
}
125+
}
126+
ınt32 = ınt32 + 1;
127+
}
128+
}
129+
130+
private static string InternalGetMessage(Exception exception)
131+
{
132+
StringBuilder eventInformation = new StringBuilder();
133+
NameValueCollection additionalInfo = CollectAdditionalInfo();
134+
foreach (string info in additionalInfo)
135+
{
136+
eventInformation.AppendFormat("" + Environment.NewLine + "--> {0}", additionalInfo.Get(info));
137+
}
138+
if (exception != null)
139+
{
140+
Exception currException = exception;
141+
do
142+
{
143+
eventInformation.AppendFormat("" + Environment.NewLine + "" + Environment.NewLine + "{0}" + Environment.NewLine + "{1}", "Exception Information Details:", LineSeparator);
144+
eventInformation.AppendFormat("" + Environment.NewLine + "{0}: {1}", "Exception Type", currException.GetType().FullName);
145+
ReflectException(currException, eventInformation);
146+
if (currException.StackTrace != null)
147+
{
148+
eventInformation.AppendFormat("" + Environment.NewLine + "" + Environment.NewLine + "{0} " + Environment.NewLine + "{1}", "StackTrace Information Details:", LineSeparator);
149+
eventInformation.AppendFormat("" + Environment.NewLine + "{0}", currException.StackTrace);
150+
}
151+
currException = currException.InnerException;
152+
} while (currException != null);
153+
}
154+
return eventInformation.ToString();
155+
}
156+
157+
/// <summary>
158+
///
159+
/// </summary>
160+
/// <param name="exception"></param>
161+
/// <param name="values">Dictionary values</param>
162+
/// <returns></returns>
163+
public static string CreateMessage(Exception exception, IDictionary<string, object> values = null)
164+
{
165+
var resultString = new StringBuilder();
166+
if (values != null)
167+
{
168+
resultString.AppendFormat("AdditionalInfo:");
169+
foreach (KeyValuePair<string, object> item in values)
170+
{
171+
resultString.AppendFormat("" + Environment.NewLine + "--> {0}: {1}", item.Key, item.Value);
172+
}
173+
resultString.AppendLine(Environment.NewLine + LineSeparator);
174+
}
175+
176+
resultString.AppendLine(InternalGetMessage(exception));
177+
return resultString.ToString();
178+
}
179+
}
180+
}

src/NetCoreStack.Hisar/Infrastructure/DataStreamingInvocator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace NetCoreStack.Hisar
1111
{
1212
internal class DataStreamingInvocator : IClientWebSocketCommandInvocator
1313
{
14-
private readonly IWebSocketConnector _connector;
14+
private readonly IWebSocketConnector<DataStreamingInvocator> _connector;
1515
private readonly IDefaultProxyFileLocator _cliFileProvider;
16-
public DataStreamingInvocator(IWebSocketConnector connector, IDefaultProxyFileLocator layoutFileProvider)
16+
public DataStreamingInvocator(IWebSocketConnector<DataStreamingInvocator> connector, IDefaultProxyFileLocator layoutFileProvider)
1717
{
1818
_connector = connector;
1919
_cliFileProvider = layoutFileProvider;

src/NetCoreStack.Hisar/Infrastructure/DefaultHisarStartup.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,22 @@ public class DefaultHisarStartup<TStartup> : IStartup where TStartup : class
1212
{
1313
private readonly Assembly _componentAssembly = typeof(TStartup).GetTypeInfo().Assembly;
1414
private readonly HisarConventionBasedStartup _componentStartup;
15-
private readonly IHostingEnvironment _env;
15+
private readonly IHostingEnvironment _hostingEnvironment;
1616
private readonly ILoggerFactory _loggerFactory;
17-
public IConfigurationRoot Configuration { get; }
17+
public IConfiguration Configuration { get; }
1818

19-
public DefaultHisarStartup(IServiceProvider sp, IHostingEnvironment env, ILoggerFactory loggerFactory)
19+
public DefaultHisarStartup(IServiceProvider serviceProvider,
20+
IHostingEnvironment hostingEnvironment,
21+
IConfiguration configuration)
2022
{
21-
var builder = new ConfigurationBuilder()
22-
.SetBasePath(env.ContentRootPath)
23-
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
24-
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
25-
.AddEnvironmentVariables();
26-
27-
Configuration = builder.Build();
28-
_env = env;
29-
_loggerFactory = loggerFactory;
30-
_componentStartup = StartupTypeLoader.CreateHisarConventionBasedStartup(typeof(TStartup), sp, _env);
23+
_hostingEnvironment = hostingEnvironment;
24+
Configuration = Configuration;
25+
_componentStartup = StartupTypeLoader.CreateHisarConventionBasedStartup(typeof(TStartup), serviceProvider, _hostingEnvironment);
3126
}
3227

3328
public IServiceProvider ConfigureServices(IServiceCollection services)
3429
{
35-
services.AddHisar<TStartup>(Configuration, _env);
30+
services.AddHisar<TStartup>(Configuration, _hostingEnvironment);
3631
_componentStartup.ConfigureServices(services);
3732
return services.BuildServiceProvider();
3833
}

0 commit comments

Comments
 (0)