Skip to content

Commit 5fc50fa

Browse files
committed
Removed entity framework dependency and made a start on the full stack audit example.
1 parent e3e989b commit 5fc50fa

File tree

12 files changed

+1365
-1308
lines changed

12 files changed

+1365
-1308
lines changed

.vs/config/applicationhost.config

Lines changed: 1038 additions & 1038 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
using Castle.MicroKernel.Registration;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Web;
6-
using System.Web.Http.Controllers;
7-
using System.Web.Mvc;
8-
9-
namespace eCommerce.WebService.App_Start.Installers
10-
{
11-
public class DistributedInterfaceLayerInstall : Castle.MicroKernel.Registration.IWindsorInstaller
12-
{
13-
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
14-
{
15-
container.Register(Classes.FromThisAssembly()
16-
.BasedOn<IHttpController>()
17-
.Configure(c => c.LifestyleTransient()));
18-
}
19-
}
1+
using Castle.MicroKernel.Registration;
2+
using eCommerce.Helpers.Logging;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Web;
7+
using System.Web.Http.Controllers;
8+
using System.Web.Mvc;
9+
10+
namespace eCommerce.WebService.App_Start.Installers
11+
{
12+
public class DistributedInterfaceLayerInstall : Castle.MicroKernel.Registration.IWindsorInstaller
13+
{
14+
public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
15+
{
16+
container.Register(Classes.FromThisAssembly()
17+
.BasedOn<IHttpController>()
18+
.Configure(c => c.LifestyleTransient()));
19+
20+
container.Register(Component.For<IRequestCorrelationIdentifier>().ImplementedBy<WebRequestCorrelationIdentifier>().LifeStyle.PerWebRequest);
21+
}
22+
}
2023
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using eCommerce.Helpers.Logging;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Net;
6+
using System.Net.Http;
7+
using System.Security.Cryptography;
8+
using System.Text;
9+
using System.Web;
10+
11+
namespace eCommerce.WebService.App_Start
12+
{
13+
public class WebRequestCorrelationIdentifier : IRequestCorrelationIdentifier
14+
{
15+
public string CorrelationID { get; private set; }
16+
17+
public WebRequestCorrelationIdentifier()
18+
{
19+
string ipAddress = getIPAddress();
20+
string userName = HttpContext.Current.Request.Params["LOGON_USER"];
21+
string userAgent = HttpContext.Current.Request.UserAgent.ToString();
22+
string time = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
23+
24+
string rawId = time + "|" + ipAddress + "|" + userName + "|" + userAgent;
25+
26+
this.CorrelationID = md5Hash(rawId);
27+
}
28+
29+
private static string getIPAddress()
30+
{
31+
string ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
32+
33+
if (string.IsNullOrEmpty(ip))
34+
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
35+
else
36+
ip = ip.Split(',')[0];
37+
38+
return ip;
39+
}
40+
41+
private static string md5Hash(string input)
42+
{
43+
MD5 md5 = System.Security.Cryptography.MD5.Create();
44+
45+
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
46+
byte[] hash = md5.ComputeHash(inputBytes);
47+
48+
StringBuilder sb = new StringBuilder();
49+
for (int i = 0; i < hash.Length; i++)
50+
{
51+
sb.Append(hash[i].ToString("X2"));
52+
}
53+
54+
return sb.ToString();
55+
}
56+
}
57+
}

eCommerce.WebService/Web.config

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
http://go.microsoft.com/fwlink/?LinkId=169433
55
-->
66
<configuration>
7-
<configSections>
8-
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
9-
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
10-
</configSections>
11-
<connectionStrings>
12-
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-eCommerce.WebService-20140503185601;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-eCommerce.WebService-20140503185601.mdf" />
13-
</connectionStrings>
147
<appSettings>
158
<add key="webpages:Version" value="2.0.0.0" />
169
<add key="webpages:Enabled" value="false" />
@@ -95,11 +88,4 @@
9588
</dependentAssembly>
9689
</assemblyBinding>
9790
</runtime>
98-
<entityFramework>
99-
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
100-
<parameters>
101-
<parameter value="v11.0" />
102-
</parameters>
103-
</defaultConnectionFactory>
104-
</entityFramework>
10591
</configuration>

0 commit comments

Comments
 (0)