add ssl 1.2
authorv.shishlov <vladimir.shishlov@sophicsystems.com>
Sun, 29 Aug 2021 15:28:47 +0000 (18:28 +0300)
committerv.shishlov <vladimir.shishlov@sophicsystems.com>
Sun, 29 Aug 2021 15:28:47 +0000 (18:28 +0300)
14 files changed:
CPE.sln
CPE/CPE.App/CPE.App.Api.Test/CPE.App.Api.Test.csproj [new file with mode: 0644]
CPE/CPE.App/CPE.App.Api.Test/Properties/AssemblyInfo.cs [new file with mode: 0644]
CPE/CPE.App/CPE.App.Api.Test/StatementControllerTest.cs [new file with mode: 0644]
CPE/CPE.App/CPE.App.Api.Test/app.config [new file with mode: 0644]
CPE/CPE.App/CPE.App.Api.Test/packages.config [new file with mode: 0644]
CPE/CPE.App/CPE.App.Api/CPE.App.Api.csproj
CPE/CPE.App/CPE.App.Api/Helpers/SendEmailHelper.cs
CPE/CPE.App/CPE.App.Api/Helpers/TinCanHelper.cs
CPE/CPE.App/CPE.App.Api/Web.config
CPE/CPE.App/CPE.App.Api/log4net.config
CPE/CPE.App/CPE.App.Web/CPE.App.Web.csproj
CPE/CPE.App/CPE.App.Web/Controllers/IndexController.cs
CPE/CPE.App/CPE.App.Web/Helpers/SendEmailHelper.cs [new file with mode: 0644]

diff --git a/CPE.sln b/CPE.sln
index eeffbfe..7009806 100644 (file)
--- a/CPE.sln
+++ b/CPE.sln
@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31624.102
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.Api", "CPE\CPE.App\CPE.App.Api\CPE.App.Api.csproj", "{6E4AE2DF-5EA5-431B-BB49-193F11171206}"
 EndProject
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.Api", "CPE\CPE.App\CPE.App.Api\CPE.App.Api.csproj", "{6E4AE2DF-5EA5-431B-BB49-193F11171206}"
 EndProject
@@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.NotifyService", "CP
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.NotifyConsole", "CPE\CPE.App\CPE.App.NotifyConsole\CPE.App.NotifyConsole.csproj", "{A71359A1-3731-436D-83E9-5EF779E4BF47}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.NotifyConsole", "CPE\CPE.App\CPE.App.NotifyConsole\CPE.App.NotifyConsole.csproj", "{A71359A1-3731-436D-83E9-5EF779E4BF47}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPE.App.Api.Test", "CPE\CPE.App\CPE.App.Api.Test\CPE.App.Api.Test.csproj", "{097E31AB-E16C-4D32-839A-539F93973D35}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -59,6 +61,10 @@ Global
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Release|Any CPU.Build.0 = Release|Any CPU
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {A71359A1-3731-436D-83E9-5EF779E4BF47}.Release|Any CPU.Build.0 = Release|Any CPU
+               {097E31AB-E16C-4D32-839A-539F93973D35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {097E31AB-E16C-4D32-839A-539F93973D35}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {097E31AB-E16C-4D32-839A-539F93973D35}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {097E31AB-E16C-4D32-839A-539F93973D35}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
@@ -70,5 +76,9 @@ Global
                {3161F348-B6C7-4B00-BC03-74B67A7949A1} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
                {165A20D7-30C3-4CAB-8BC1-D4C23219B633} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
                {A71359A1-3731-436D-83E9-5EF779E4BF47} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
                {3161F348-B6C7-4B00-BC03-74B67A7949A1} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
                {165A20D7-30C3-4CAB-8BC1-D4C23219B633} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
                {A71359A1-3731-436D-83E9-5EF779E4BF47} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
+               {097E31AB-E16C-4D32-839A-539F93973D35} = {76CEA54F-65A1-413F-A08C-CF3A029897B6}
+       EndGlobalSection
+       GlobalSection(ExtensibilityGlobals) = postSolution
+               SolutionGuid = {FBF87F62-852B-4BEF-AB03-1E1602B43317}
        EndGlobalSection
 EndGlobal
        EndGlobalSection
 EndGlobal
diff --git a/CPE/CPE.App/CPE.App.Api.Test/CPE.App.Api.Test.csproj b/CPE/CPE.App/CPE.App.Api.Test/CPE.App.Api.Test.csproj
new file mode 100644 (file)
index 0000000..82101b5
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{097E31AB-E16C-4D32-839A-539F93973D35}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CPE.App.Api.Test</RootNamespace>
+    <AssemblyName>CPE.App.Api.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="Shouldly, Version=2.8.2.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
+      <HintPath>..\..\..\packages\Shouldly.2.8.2\lib\net451\Shouldly.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="StatementControllerTest.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\CPE.App.Api\CPE.App.Api.csproj">
+      <Project>{6E4AE2DF-5EA5-431B-BB49-193F11171206}</Project>
+      <Name>CPE.App.Api</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
+    <Error Condition="!Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
+  </Target>
+  <Import Project="..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\..\..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
+</Project>
\ No newline at end of file
diff --git a/CPE/CPE.App/CPE.App.Api.Test/Properties/AssemblyInfo.cs b/CPE/CPE.App/CPE.App.Api.Test/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..2938e77
--- /dev/null
@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("CPE.App.Api.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CPE.App.Api.Test")]
+[assembly: AssemblyCopyright("Copyright ©  2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("097e31ab-e16c-4d32-839a-539f93973d35")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CPE/CPE.App/CPE.App.Api.Test/StatementControllerTest.cs b/CPE/CPE.App/CPE.App.Api.Test/StatementControllerTest.cs
new file mode 100644 (file)
index 0000000..26d04c8
--- /dev/null
@@ -0,0 +1,23 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using CPE.App.Api.Helpers;
+using CPE.App.Api.Models;
+using Newtonsoft.Json;
+using Shouldly;
+
+namespace CPE.App.Api.Test
+{
+    [TestClass]
+    public class StatementControllerTest
+    {
+        [TestMethod]
+        public void HandleStatementTest()
+        {
+            var tincanObject =
+                "{\"id\":null,\"actor\":{\"name\":\"Patricia Berry\",\"mbox\":\"mailto:pberry@cpeincmail.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/passed\"},\"result\":{\"score\":{\"scaled\":1,\"raw\":0,\"min\":0,\"max\":0},\"success\":true,\"completion\":false},\"timestamp\":\"08/28/2021 16:38:19\",\"version\":null,\"object\":{\"id\":\"https://learning.elucidat.com/course/611ecf21dbbae-611fca09461e2\",\"definition\":{\"name\":{\"en-US\":\"Ethics for Hawaii CPAs  \"}}}}";
+            TinCanStatementModel statement = JsonConvert.DeserializeObject<TinCanStatementModel>(tincanObject);
+            var done = TinCanHelper.HandleStatement(statement);
+            done.ShouldBe(true);
+        }
+    }
+}
diff --git a/CPE/CPE.App/CPE.App.Api.Test/app.config b/CPE/CPE.App/CPE.App.Api.Test/app.config
new file mode 100644 (file)
index 0000000..08545f7
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>
\ No newline at end of file
diff --git a/CPE/CPE.App/CPE.App.Api.Test/packages.config b/CPE/CPE.App/CPE.App.Api.Test/packages.config
new file mode 100644 (file)
index 0000000..eab5efc
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net452" />
+  <package id="MSTest.TestFramework" version="2.1.2" targetFramework="net452" />
+  <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
+  <package id="Shouldly" version="2.8.2" targetFramework="net452" />
+</packages>
\ No newline at end of file
index 37c6913..77179e4 100644 (file)
     <Content Include="fonts\glyphicons-halflings-regular.woff" />
     <Content Include="fonts\glyphicons-halflings-regular.ttf" />
     <Content Include="fonts\glyphicons-halflings-regular.eot" />
     <Content Include="fonts\glyphicons-halflings-regular.woff" />
     <Content Include="fonts\glyphicons-halflings-regular.ttf" />
     <Content Include="fonts\glyphicons-halflings-regular.eot" />
+    <Content Include="log4net.config" />
     <None Include="Scripts\jquery-1.10.2.intellisense.js" />
     <Content Include="Scripts\jquery-1.10.2.js" />
     <Content Include="Scripts\jquery-1.10.2.min.js" />
     <None Include="Scripts\jquery-1.10.2.intellisense.js" />
     <Content Include="Scripts\jquery-1.10.2.js" />
     <Content Include="Scripts\jquery-1.10.2.min.js" />
index ee506b2..ec69d3f 100644 (file)
@@ -1,9 +1,5 @@
 using System;
 using System;
-using System.Collections.Generic;
 using System.Configuration;
 using System.Configuration;
-using System.Linq;
-using System.Web;
-using System.IO;
 using CPE.App.Web.Models;
 using System.Net.Mail;
 using CPE.App.Api.Models;
 using CPE.App.Web.Models;
 using System.Net.Mail;
 using CPE.App.Api.Models;
@@ -15,9 +11,16 @@ namespace CPE.App.Api.Helpers
     {
         public static bool SendCertificateEmail(PurchasedCourse course)
         {
     {
         public static bool SendCertificateEmail(PurchasedCourse course)
         {
+            var courseEmail = course.Email;
+            var emailTest = ConfigurationManager.AppSettings["EmailTest"];
+            if (!string.IsNullOrWhiteSpace(emailTest))
+            {
+                courseEmail = emailTest;
+            }
+
             //elucidat cert email
             var cDate = course.CertificateDate.Value.ToString("yyyyMMdd");
             //elucidat cert email
             var cDate = course.CertificateDate.Value.ToString("yyyyMMdd");
-            MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailSender"], course.Email); 
+            MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailSender"], courseEmail); 
             SmtpClient client = new SmtpClient();
             client.Port = 25;
             client.DeliveryMethod = SmtpDeliveryMethod.Network;
             SmtpClient client = new SmtpClient();
             client.Port = 25;
             client.DeliveryMethod = SmtpDeliveryMethod.Network;
index 7e7a0e7..9629fc7 100644 (file)
@@ -4,6 +4,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
+using Newtonsoft.Json;
 
 namespace CPE.App.Api.Helpers
 {
 
 namespace CPE.App.Api.Helpers
 {
@@ -13,10 +14,10 @@ namespace CPE.App.Api.Helpers
         {
             // statement.Verb.Id=http://adlnet.gov/expapi/verbs/answered
             // statement.Verb.Id=http://adlnet.gov/expapi/verbs/experienced
         {
             // statement.Verb.Id=http://adlnet.gov/expapi/verbs/answered
             // statement.Verb.Id=http://adlnet.gov/expapi/verbs/experienced
-
+            var dtNow = DateTime.UtcNow.ToString("yyyyMMdd_HHmmss");
             if (statement.Verb.Id.IndexOf("passed")>-1)
             {
             if (statement.Verb.Id.IndexOf("passed")>-1)
             {
-                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} statement.Verb.Id={1}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), statement.Verb.Id);
+                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} statement.Verb.Id={1}. statement={2}", dtNow, statement.Verb.Id, JsonConvert.SerializeObject(statement));
 
                 //parse statement to db variables
                 var email = statement.Actor.Mbox.Substring(7);
 
                 //parse statement to db variables
                 var email = statement.Actor.Mbox.Substring(7);
@@ -24,15 +25,40 @@ namespace CPE.App.Api.Helpers
                 var lname = statement.Actor.Name.Substring(statement.Actor.Name.LastIndexOf(" ") + 1);
                 var courseUrl = statement.Object.Id.Substring(statement.Object.Id.LastIndexOf("/") + 1);
                 var courseName = statement.Object.Definition.Name.EnUs;
                 var lname = statement.Actor.Name.Substring(statement.Actor.Name.LastIndexOf(" ") + 1);
                 var courseUrl = statement.Object.Id.Substring(statement.Object.Id.LastIndexOf("/") + 1);
                 var courseName = statement.Object.Definition.Name.EnUs;
+                bool done;
 
                 //cpe has test data with multiple, currently valid purchases of the same course for one user, which causes problems but is not a real-world problem.
                 //elucidat tracks all users globally by email address so a tincan statement won't identify a specific purchase here 
                 //unless we create unique email addy (e.g. email+ticket@mail.com) when originally logging them in to content
 
                 //cpe has test data with multiple, currently valid purchases of the same course for one user, which causes problems but is not a real-world problem.
                 //elucidat tracks all users globally by email address so a tincan statement won't identify a specific purchase here 
                 //unless we create unique email addy (e.g. email+ticket@mail.com) when originally logging them in to content
-                var course = BaseController.Database.PurchasedCourses.FirstOrDefault(c => c.Email == email  && c.ContentUrl == courseUrl && c.CertificateDate == null);
+                var course = BaseController.Database.PurchasedCourses.FirstOrDefault(c =>
+                    c.Email == email && c.ContentUrl == courseUrl && c.CertificateDate == null);
                 if (course == null)
                 {
                 if (course == null)
                 {
-                    Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} no action, cert already earned email={1} courseName={2}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName);
+                    Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} no action 1, cert already earned email={1} courseName={2}", dtNow, email, courseName);
                     //no action, cert already earned
                     //no action, cert already earned
+                    //try
+                    //{
+                    //    course = BaseController.Database.PurchasedCourses.FirstOrDefault(c => c.Email == email && c.ContentUrl == courseUrl && c.CertificateDate!=null);
+                    //    if (course == null)
+                    //    {
+                    //        Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} no action, course == null, select courseName={1} from db with CertificateDate.", dtNow, courseName);
+                    //    }
+
+                    //    Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} no action, select courseName={1} from db with CertificateDate. course={2}", dtNow,  courseName, JsonConvert.SerializeObject(course));
+
+                    //    done = SendEmailHelper.SendCertificateEmail(course);
+
+                    //    Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} no action, send courseName={1} from db to email={2} successfully", dtNow, courseName, email);
+                    //}
+                    //catch (Exception exception)
+                    //{
+                    //    var innerException = "";
+                    //    if (exception.InnerException != null) innerException = exception.InnerException.ToString();
+                    //    Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} email={1} courseName={2} exception={3}", dtNow, email, courseName, exception.ToString()+ innerException);
+                    //}
+
+                    //Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} cert sent email={1} courseName={2}", dtNow, email, courseName);
+
                     return true;
                 }
 
                     return true;
                 }
 
@@ -43,12 +69,12 @@ namespace CPE.App.Api.Helpers
                 }
                 catch (Exception exception)
                 {
                 }
                 catch (Exception exception)
                 {
-                    Utilities.LogWrapper.Error("[TinCanHelper][HandleStatement] {0} email={1} courseName={2} exception={3}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName, exception.ToString());
+                    Utilities.LogWrapper.Error("[TinCanHelper][HandleStatement] {0} email={1} courseName={2} exception={3}", dtNow, email, courseName, exception.ToString());
                 }
 
                 }
 
-                var done = SendEmailHelper.SendCertificateEmail(course);
+                done = SendEmailHelper.SendCertificateEmail(course);
 
 
-                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} cert sent email={1} courseName={2}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName);
+                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} cert sent email={1} courseName={2}", dtNow, email, courseName);
 
                 //umm why am i not returning done here? 
                 return true;
 
                 //umm why am i not returning done here? 
                 return true;
@@ -57,7 +83,7 @@ namespace CPE.App.Api.Helpers
 
             if (statement.Verb.Id.IndexOf("failed") > -1)
             {
 
             if (statement.Verb.Id.IndexOf("failed") > -1)
             {
-                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} statement.Verb.Id={1}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), statement.Verb.Id);
+                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} statement.Verb.Id={1}. statement={2}", dtNow, statement.Verb.Id, JsonConvert.SerializeObject(statement));
 
                 //parse statement to db variables
                 var email = statement.Actor.Mbox.Substring(7);
 
                 //parse statement to db variables
                 var email = statement.Actor.Mbox.Substring(7);
@@ -76,7 +102,7 @@ namespace CPE.App.Api.Helpers
                     return true;
                 }
 
                     return true;
                 }
 
-                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} course.Ticket={1}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), course.Ticket);
+                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} course.Ticket={1}", dtNow, course.Ticket);
 
                 if (!course.FailedAttempts.HasValue)
                 {
 
                 if (!course.FailedAttempts.HasValue)
                 {
@@ -89,10 +115,10 @@ namespace CPE.App.Api.Helpers
                 }
                 catch (Exception exception)
                 {
                 }
                 catch (Exception exception)
                 {
-                    Utilities.LogWrapper.Error("[TinCanHelper][HandleStatement] {0} email={1} courseName={2} exception={3}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName, exception.ToString());
+                    Utilities.LogWrapper.Error("[TinCanHelper][HandleStatement] {0} email={1} courseName={2} exception={3}", dtNow, email, courseName, exception.ToString());
                 }
 
                 }
 
-                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} failure recorded email={1} courseName={2}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName);
+                Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} failure recorded email={1} courseName={2}", dtNow, email, courseName);
 
                 return true;
             }
 
                 return true;
             }
index 60d407d..8dc71cb 100644 (file)
@@ -1,47 +1,39 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!--
   For more information on how to configure your ASP.NET application, please visit
   http://go.microsoft.com/fwlink/?LinkId=301879
   -->
 <configuration>
   <configSections>
 <!--
   For more information on how to configure your ASP.NET application, please visit
   http://go.microsoft.com/fwlink/?LinkId=301879
   -->
 <configuration>
   <configSections>
-    
+    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
-  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --><sectionGroup name="elmah">
-      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
-      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
-      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
-      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
-    </sectionGroup></configSections>
+  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
   <connectionStrings>
   <connectionStrings>
-    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-CPE.App.Api-20151016073126.mdf;Initial Catalog=aspnet-CPE.App.Api-20151016073126;Integrated Security=True" providerName="System.Data.SqlClient" />-->
-    <!--<add name="CPE.DATA" connectionString="Data Source=cpeonlinewebcasts.com;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=webcpe_reporting;Password=Pa$$w0rd" providerName="System.Data.SqlClient" />-->
-      <!--<add name="CPE.DATA" connectionString="Data Source=DESKTOP-6Q8LB2M\SQL2014;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=intesolver" providerName="System.Data.SqlClient"/>
-      <add name="CPE.DATA.Local" connectionString="Data Source=DESKTOP-6Q8LB2M\SQL2014;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=intesolver" providerName="System.Data.SqlClient"/>-->
-    <add name="CPE.DATA" connectionString="Data Source=localhost;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=intesolver" providerName="System.Data.SqlClient" />
-    <add name="CPE.DATA.Local" connectionString="Data Source=localhost;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=intesolver" providerName="System.Data.SqlClient" />
+    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-CPE.App.Api-20151016073126.mdf;Initial Catalog=aspnet-CPE.App.Api-20151016073126;Integrated Security=True" providerName="System.Data.SqlClient" />
+   <add name="CPE.DATA" connectionString="Data Source=DESKTOP-Q4S6BS5;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=1" providerName="System.Data.SqlClient" />
+    <add name="CPE.DATA.Local" connectionString="Data Source=DESKTOP-Q4S6BS5;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=1" providerName="System.Data.SqlClient"/>
+       <!--<add name="CPE.DATA" connectionString="Data Source=localhost;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=webcpe_reporting;Password=Pa$$w0rd" providerName="System.Data.SqlClient" />-->
+       <!--<add name="CPE.DATA.Local" connectionString="Data Source=localhost;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=webcpe_reporting;Password=Pa$$w0rd" providerName="System.Data.SqlClient" />-->
+
 
   </connectionStrings>
 
   </connectionStrings>
+  <log4net configSource="log4net.config" />
   <appSettings>
   <appSettings>
-    <add key="LrsEndpoint" value="http://api.cpeonlinewebcasts.com/api/statements" />
-    <add key="LrsEndpointUsername" value="admin" />
-    <add key="LrsEndpointPassword" value="password" />
-    <add key="EmailSender" value="csreg@cpeincmail.com" />
-    <add key="EmailReceiver" value="sswebcast@cpeincmail.com" />
-    <add key="EmailSubject" value="Self-Study Webcast Certificate of Completion" />
-    <add key="RouteDebugger:Enabled" value="true" />
- <!--   <add key="Elucidat.PublicKey" value="FE966693-65D7-0AE0-2CC6-E576109A0BF5" /> CPE's public key-->
-    <add key="Elucidat.PublicKey" value="1558A022-336C-6922-4B1F-AD3505839D5A" />
-    <add key="Elucidat.SecretKey" value="A393E5ED-C79F-4EB7-7DAE-9CB6C090B9E8" />
-    <!--<add key="Elucidat.Secretkey" value="9CB149B8-F419-36FB-CCD3-D45864BC7B1E" /> secret key for CPE-->
-    <add key="Elucidat.BaseUrl" value="https://api.elucidat.com/v2/" />
-    <add key="elmah.mvc.disableHandler" value="false" /><add key="elmah.mvc.disableHandleErrorFilter" value="false" />
-    <add key="elmah.mvc.requiresAuthentication" value="false" />
-    <add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
-    <add key="elmah.mvc.allowedRoles" value="*" />
-    <add key="elmah.mvc.allowedUsers" value="*" />
-    <add key="elmah.mvc.route" value="elmah" />
-    <add key="elmah.mvc.UserAuthCaseSensitive" value="true" />
+    <add key="LrsEndpoint" value="http://api.cpeonlinewebcasts.com/api/statements"/>
+    <add key="LrsEndpointUsername" value="admin"/>
+    <add key="LrsEndpointPassword" value="password"/>
+    <add key="EmailSender" value="csreg@cpeincmail.com"/>
+    <add key="EmailReceiver" value="sswebcast@cpeincmail.com"/>
+       <add key="EmailSubject" value="Your certificate of completion from CPE Inc." />
+    <add key="MS_WebHookReceiverSecret_GitHub" value="c54c44faafdf9584547f8209a8033ee47994f9a1" />
+       <add key="MS_WebHookReceiverSecret_Elucidat" value="FE966693-65D7-0AE0-2CC6-E576109A0BF5" />
+    <add key="MS_WebHookReceiverSecret_GenericJson" value="12345678901234567890123456789012" />
+    <add key="RouteDebugger:Enabled" value="false" />
+       <add key="Elucidat.PublicKey" value="FE966693-65D7-0AE0-2CC6-E576109A0BF5" /> 
+    <add key="Elucidat.Secretkey" value="9CB149B8-F419-36FB-CCD3-D45864BC7B1E" />      
+       <add key="Elucidat.BaseUrl" value="https://api.elucidat.com/v2/"/>
+       
+       <add key="CertLink" value="http://api.cpeonlinewebcasts.com/Certificate?a={0}&amp;b={1}&amp;c={2}"/>
   </appSettings>
   <!--
     For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
   </appSettings>
   <!--
     For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
       </system.Web>
   -->
   <system.web>
       </system.Web>
   -->
   <system.web>
-
-    <customErrors mode="On" redirectMode="ResponseRedirect" >
-     
-    </customErrors>
     <authentication mode="None" />
     <compilation debug="true" targetFramework="4.5" />
     <httpRuntime />
     <pages controlRenderingCompatibilityVersion="4.0" />
     <authentication mode="None" />
     <compilation debug="true" targetFramework="4.5" />
     <httpRuntime />
     <pages controlRenderingCompatibilityVersion="4.0" />
-  <httpModules>
-      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
-      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
-      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
-    </httpModules></system.web>
+  </system.web>
   <system.webServer>
   <system.webServer>
+    <httpErrors errorMode="Detailed" existingResponse="PassThrough"></httpErrors>
     <modules>
       <remove name="FormsAuthentication" />
     <modules>
       <remove name="FormsAuthentication" />
-    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /><add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /></modules>
+    </modules>
     
   <handlers>
       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
       <remove name="OPTIONSVerbHandler" />
       <remove name="TRACEVerbHandler" />
       <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
     
   <handlers>
       <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
       <remove name="OPTIONSVerbHandler" />
       <remove name="TRACEVerbHandler" />
       <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
-    </handlers><validation validateIntegratedModeConfiguration="false" /></system.webServer>
+    </handlers>
+        <directoryBrowse enabled="false" /></system.webServer>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
     </compilers>
   </system.codedom>
       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
     </compilers>
   </system.codedom>
-<elmah>
-  </elmah></configuration>
+</configuration>
index c2cb045..b0a26e4 100644 (file)
@@ -2,7 +2,7 @@
 <log4net debug="true">
   <root>
     <level value="DEBUG" />
 <log4net debug="true">
   <root>
     <level value="DEBUG" />
-    <appender-ref ref="AdoNetAppender" />
+    <!--<appender-ref ref="AdoNetAppender" />-->
     <appender-ref ref="FileAppender" />
   </root>
   <appender name="FileAppender" type="log4net.Appender.FileAppender">
     <appender-ref ref="FileAppender" />
   </root>
   <appender name="FileAppender" type="log4net.Appender.FileAppender">
@@ -17,7 +17,7 @@
     <bufferSize value="1" />
     <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <!-- Prod -->
     <bufferSize value="1" />
     <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <!-- Prod -->
-       <connectionString="Data Source=cpeonlinewebcasts.com;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=webcpe_reporting;Password=Pa$$w0rd" />
+       <connectionString value="Data Source=DESKTOP-Q4S6BS5;Initial Catalog=webcpe_reporting;Persist Security Info=True;User ID=sa;Password=1" />
     <commandText value="INSERT INTO ServiceLog ([Created],[ServiceMethod],[Details]) VALUES (@log_date, @logger, @message)" />
     <parameter>
       <parameterName value="@log_date" />
     <commandText value="INSERT INTO ServiceLog ([Created],[ServiceMethod],[Details]) VALUES (@log_date, @logger, @message)" />
     <parameter>
       <parameterName value="@log_date" />
index 7312f94..bd180d3 100644 (file)
@@ -29,6 +29,7 @@
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
     <WebGreaseLibPath>..\..\..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
     <WebGreaseLibPath>..\..\..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>
+    <Use64BitIISExpress />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <Compile Include="Helpers\AdobeMeetingConnection.cs" />
     <Compile Include="Helpers\ElucidatMeetingConnection.cs" />
     <Compile Include="Helpers\ReleaseHelper.cs" />
     <Compile Include="Helpers\AdobeMeetingConnection.cs" />
     <Compile Include="Helpers\ElucidatMeetingConnection.cs" />
     <Compile Include="Helpers\ReleaseHelper.cs" />
+    <Compile Include="Helpers\SendEmailHelper.cs" />
     <Compile Include="Helpers\VerifyAccess.cs" />
     <Compile Include="Models\AdobeModels\AdobeMeetingView.cs" />
     <Compile Include="Models\AdobeModels\AdobeSessionViewModel.cs" />
     <Compile Include="Helpers\VerifyAccess.cs" />
     <Compile Include="Models\AdobeModels\AdobeMeetingView.cs" />
     <Compile Include="Models\AdobeModels\AdobeSessionViewModel.cs" />
index 227a3c1..813d055 100644 (file)
@@ -406,7 +406,7 @@ namespace CPE.App.Web.Controllers {
         public ActionResult Email() {
             var email = new MailMessage {
                 To = {
         public ActionResult Email() {
             var email = new MailMessage {
                 To = {
-                    "tallen@intesolv.com"
+                    "sophia@sophicsystems.com"
                 },
                 Subject = "[CPE] Email Test",
                 Body = "Email test has been received.",
                 },
                 Subject = "[CPE] Email Test",
                 Body = "Email test has been received.",
@@ -417,6 +417,23 @@ namespace CPE.App.Web.Controllers {
 
             return Redirect("/");
         }
 
             return Redirect("/");
         }
+        public ActionResult SendCerificateEmail(string email, string url, string key)
+        {
+            if (key != "q1w2e3") return Content("Bad key");
+            var course = Database.PurchasedCourses
+                .Where(c => c.Email == email && c.ContentUrl == url)
+                .OrderByDescending(c => c.CertificateDate).FirstOrDefault();
+
+            var done = SendEmailHelperWeb.SendCertificateEmail(course);
+
+            var s = url.Split('-');
+            var courseName = Database.CourseDetails
+                .FirstOrDefault(c => c.ReleaseCode == s[1])?.Name;
+
+            Utilities.LogWrapper.Info("[TinCanHelper][HandleStatement] {0} cert sent email={1} courseName={2}", DateTime.UtcNow.ToString("yyyyMMdd_HHmmss"), email, courseName);
+
+            return Content("Certificate send successfully");
+        }
 
         [HttpPost]
         public ActionResult Admin(string login, string passcode) {
 
         [HttpPost]
         public ActionResult Admin(string login, string passcode) {
diff --git a/CPE/CPE.App/CPE.App.Web/Helpers/SendEmailHelper.cs b/CPE/CPE.App/CPE.App.Web/Helpers/SendEmailHelper.cs
new file mode 100644 (file)
index 0000000..93128b5
--- /dev/null
@@ -0,0 +1,27 @@
+using System.Configuration;
+using CPE.App.Web.Models;
+using System.Net.Mail;
+
+namespace CPE.App.Web.Helpers
+{
+    public class SendEmailHelperWeb
+    {
+        public static bool SendCertificateEmail(PurchasedCourse course)
+        {
+            //elucidat cert email
+            var cDate = course.CertificateDate.Value.ToString("yyyyMMdd");
+            MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailSender"], course.Email); 
+            SmtpClient client = new SmtpClient();
+            client.Port = 25;
+            client.DeliveryMethod = SmtpDeliveryMethod.Network;
+            client.UseDefaultCredentials = false;
+            client.Host = "localhost";
+            mail.Subject = ConfigurationManager.AppSettings["EmailSubject"];            
+            string mailBodyText = CPE.Utilities.Email.RenderEmail(course.ContentUrl, course.CertificateDate, course.Ticket);
+            mail.Body = mailBodyText;
+            mail.IsBodyHtml = true;
+            client.Send(mail);
+            return true;
+        }
+    }
+}
\ No newline at end of file