Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
add some code for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
clement128 committed Aug 20, 2020
1 parent 826e8be commit ad714cd
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 6 deletions.
15 changes: 15 additions & 0 deletions SimplCommerce.sln
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimplCommerce.Module.Paymen
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimplCommerce.Module.PaymentCashfree", "src\Modules\SimplCommerce.Module.PaymentCashfree\SimplCommerce.Module.PaymentCashfree.csproj", "{E30CF10F-FABF-4917-8BEB-CB81E4CE2C92}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecurityTest", "src\Modules\SecurityTest\SecurityTest.csproj", "{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -696,6 +698,18 @@ Global
{E30CF10F-FABF-4917-8BEB-CB81E4CE2C92}.Release|x64.Build.0 = Release|Any CPU
{E30CF10F-FABF-4917-8BEB-CB81E4CE2C92}.Release|x86.ActiveCfg = Release|Any CPU
{E30CF10F-FABF-4917-8BEB-CB81E4CE2C92}.Release|x86.Build.0 = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|x64.ActiveCfg = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|x64.Build.0 = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|x86.ActiveCfg = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Debug|x86.Build.0 = Debug|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|Any CPU.Build.0 = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|x64.ActiveCfg = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|x64.Build.0 = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|x86.ActiveCfg = Release|Any CPU
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -750,6 +764,7 @@ Global
{1A8B6FA0-8341-4D27-9B71-57F70AB37571} = {0A27C140-4CCB-40DD-BE48-F5DE16D1177B}
{14586564-62CC-4117-AC1B-858ED53C2D6C} = {7EFA2FA7-32DD-4047-B021-50E77A83D714}
{E30CF10F-FABF-4917-8BEB-CB81E4CE2C92} = {7EFA2FA7-32DD-4047-B021-50E77A83D714}
{D71E11B8-ED5B-4BE5-9663-26CF2AB6E7AB} = {7EFA2FA7-32DD-4047-B021-50E77A83D714}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B9D0D8F0-1AB9-44DD-839F-ED8CEE7DDB10}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.100",
"version": "3.1.401",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
68 changes: 68 additions & 0 deletions src/Modules/SecurityTest/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Data;
using System.Text;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace SecurityTest
{
public class Class1Options
{
public string ConnectionString { get; set; }
}

public class Class1
{
private readonly ILogger<Class1> logger;
private readonly IOptions<Class1Options> options;

public Class1(ILogger<Class1> logger, IOptions<Class1Options> options)
{
this.logger = logger;
this.options = options;
}

public void Method1(string title, string contents, string user)
{
var connection = new SqlConnection();
var sb = new StringBuilder();
try
{
connection.ConnectionString = options.Value.ConnectionString;
connection.Open();
var insertSql =
string.Format("insert into BlogEntries (Title, Contents, Author, PostedDate) values ('{0}','{1}','{2}',{3:yyyy-MM-dd}); select top 1 * from blogentries order by Id desc;",
title,
contents,
user,
DateTime.Now);

var insertCommand = new SqlCommand(insertSql, connection);

var dataReader = insertCommand.ExecuteReader();

while (dataReader.Read()) {
var x = string.Format("Id:<br />{0}<br />Title:<br />{1}<br />Contents:<br />{2}<br />Author:<br />{3}<br />Posted date:<br />{4}<br />",
dataReader[0],
dataReader[1],
dataReader[2],
dataReader[3],
dataReader[4]);
sb.AppendLine(x);
}
}
catch (Exception ex)
{
logger.LogError(string.Format("A problem has occured. Please try again. Error={0}", ex.Message));
}
finally
{
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
}
}
}
11 changes: 11 additions & 0 deletions src/Modules/SecurityTest/SecurityTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.7" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
</ItemGroup>

<Target Name="CopyModule" AfterTargets="Build">
<Copy
SourceFiles="@(SampleContent)"
DestinationFiles="@(SampleContent->'..\..\SimplCommerce.WebHost\Modules\SimplCommerce.Module.SampleData\SampleContent\%(RecursiveDir)%(Filename)%(Extension)')"
/>
<Copy SourceFiles="@(SampleContent)" DestinationFiles="@(SampleContent-&gt;'..\..\SimplCommerce.WebHost\Modules\SimplCommerce.Module.SampleData\SampleContent\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" version="9.3.3" />
<PackageReference Include="WindowsAzure.Storage" version="9.3.3" Version="9.3.3" />
<ProjectReference Include="..\..\SimplCommerce.Infrastructure\SimplCommerce.Infrastructure.csproj" />
<ProjectReference Include="..\SimplCommerce.Module.Core\SimplCommerce.Module.Core.csproj" />
</ItemGroup>
Expand Down

0 comments on commit ad714cd

Please sign in to comment.