diff --git a/400-SOURCECODE/AIAHTML5.API/App_Start/WebApiConfig.cs b/400-SOURCECODE/AIAHTML5.API/App_Start/WebApiConfig.cs index 8c03032..fa90bbe 100644 --- a/400-SOURCECODE/AIAHTML5.API/App_Start/WebApiConfig.cs +++ b/400-SOURCECODE/AIAHTML5.API/App_Start/WebApiConfig.cs @@ -1,24 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Http; - -namespace AIAHTML5.API -{ - public static class WebApiConfig - { - public static void Register(HttpConfiguration config) - { - // Web API configuration and services - - // Web API routes - config.MapHttpAttributeRoutes(); - - config.Routes.MapHttpRoute( - name: "DefaultApi", - routeTemplate: "api/{controller}/{id}", - defaults: new { id = RouteParameter.Optional } - ); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.Http; + +namespace AIAHTML5.API +{ + public static class WebApiConfig + { + public static void Register(HttpConfiguration config) + { + // Web API configuration and services + + // Web API routes + config.MapHttpAttributeRoutes(); + + config.Routes.MapHttpRoute( + name: "DefaultApi", + routeTemplate: "api/{controller}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + } + } +} diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs index 9f619b9..77fa802 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs @@ -217,7 +217,58 @@ namespace AIAHTML5.API.Controllers + [HttpPost] + public HttpResponseMessage Hi(int userId) + { + return Request.CreateResponse(HttpStatusCode.OK, userId.ToString()); + } + [Route("GetUserProfile/{userId}")] + [HttpGet] + public IHttpActionResult GetUserProfile(int userId) + { + //dbContext.Configuration.ProxyCreationEnabled = false; + try + { + return Ok("Hello"); + } + catch (Exception ex) + { + throw ex; + } + //return ToJson(dbContext.AIAUsers.Where(u => u.Id == userId).AsEnumerable()); + } + [Route("api/LabExercise/SendEmail")] + [HttpPost] + public HttpResponseMessage SendEmail([FromBody]JObject User) + { + ArrayList aar = new ArrayList(); + if (User["EmailTo"].ToString().ToLower().Contains(';')) + { + string[] words = User["EmailTo"].ToString().Split(';'); + foreach (string word in words) + { + Console.WriteLine(word); + aar.Add(word); + } + } + else + { + aar.Add(User["EmailTo"].ToString()); + } + if (Convert.ToBoolean(User["ReportCheck"]) == true) + { + aar.Add(User["EmailAdd"].ToString()); + } + AIAHTML5.API.Models.UserUtility.SendEmail(User, aar, User["EmailAdd"].ToString(), User["reportTitle"].ToString(), User["reportImage"].ToString()); + return Request.CreateResponse(HttpStatusCode.OK); + } + [Route("api/LabExercise/GetParameter")] + [HttpGet] + public IEnumerable GetParameter() + { + return new string[] { "val1", "val2" }; + } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs index 0154fb2..88f12bc 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs @@ -302,8 +302,8 @@ namespace AIAHTML5.API.Models lstToAddress.Add(email); } - emailMessage = "Unable to process request for "; - + //emailMessage = "Unable to process request for "; + emailMessage = " "; if (UserUtility.CheckIfPropertyExists(userInfo, "username") && !string.IsNullOrEmpty(userInfo["username"].ToString())) emailMessage += "username: " + userInfo["username"].ToString() + ""; if (UserUtility.CheckIfPropertyExists(userInfo, "password") && !string.IsNullOrEmpty(userInfo["password"].ToString())) @@ -316,24 +316,26 @@ namespace AIAHTML5.API.Models if (string.IsNullOrEmpty(sender)) senderEmailId = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]); else - senderEmailId = sender; + senderEmailId = sender; emailMessage += mailBody; emailMessage = emailMessage.Replace("\n", "
"); - emailMessage += "

"; - + // emailMessage += "

"; + emailMessage = "" + emailMessage + ""; emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]); emailUtility.sFromAddress = senderEmailId; emailUtility.bIsBodyHtml = true; - emailUtility.bEnableSsl = false; + // emailUtility.bEnableSsl = false; + emailUtility.bEnableSsl = true; emailUtility.sSubject = mailSubject; emailUtility.sBodyText = emailMessage; - emailUtility.iPort = 25; + //emailUtility.iPort = 25; + emailUtility.iPort = 587; emailUtility.sToAddresses = lstToAddress; emailUtility.sBccAddresses = lstBccAddress; - + emailUtility.sUserName = senderEmailId; emailUtility.SendSmtpEmail(); return true; } diff --git a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs index a2152f0..960420c 100644 --- a/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs +++ b/400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs @@ -39,7 +39,7 @@ namespace AIAHTML5.API.Utility System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]); smtp.Credentials = NetworkCred; smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); - + smtp.EnableSsl = false; smtp.Send(mm); } catch (Exception e) diff --git a/400-SOURCECODE/AIAHTML5.API/Web.config b/400-SOURCECODE/AIAHTML5.API/Web.config index ee162e6..dd98f5d 100644 --- a/400-SOURCECODE/AIAHTML5.API/Web.config +++ b/400-SOURCECODE/AIAHTML5.API/Web.config @@ -32,13 +32,22 @@ - + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index c3736a0..8720462 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -1288,8 +1288,55 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, } } + $scope.reportCopyStatus = false; + $scope.SendLabEXMailToUser = function (User) { + var reportHtml = ''; + reportHtml += ''; + $("#resultLabData tr").each(function () { + reportHtml += ''; + $(this).children("td").each(function () { + if ($(this).text() == " Review") { + } + else{ + reportHtml += ''; + } + }); + reportHtml += ''; + }); + reportHtml += '
QuestionActivity TitleStatus
' + $(this).text() + '
'; + $scope.reportImage = "
"+$("#submitResultHtml .panel-heading .row div:nth-child(1)").text()+"Performance Report" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "
Total QuestionCorrect AnswersIncorrect Answers
" + $("#questionStatus tbody tr td:nth-child(1)").text() + "" + $("#questionStatus tbody tr td:nth-child(2)").text() + "" + $("#questionStatus tbody tr td:nth-child(3)").text() + "


" + reportHtml + ""; + $scope.reportTitle = "Lab Exercise Report for " + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text(); + $scope.senderEmails = $("#emailTo").val(); + + + LabExerciseService.LabExerciseReport(User, $scope.reportImage, $scope.reportTitle, $scope.reportCopyStatus, $scope.senderEmails).then( + function (result) { + console.log(result); + }, + function (error) { + console.log(error.statusText); + } + ) + // for closing email popup + $rootScope.closeLabExEmailModel(); + } + $rootScope.closeLabExEmailModel = function () { + document.getElementById("LabExerciseForm").reset(); + $scope.LabExForm.$setPristine(); + $scope.LabExForm.$setUntouched(); + document.body.style.overflow = "scroll"; + document.getElementById('labExModalbackground').style.display = "none"; + document.getElementById('labExModalID').style.display = "none"; + $scope.reportCopyStatus = false; + } + $rootScope.sendMail = function () { + window.scrollTo(0, 0); + document.body.style.overflow = "hidden"; + document.getElementById('labExModalbackground').style.display = "block"; + document.getElementById('labExModalID').style.display = "block"; + } }] diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js index 71e274f..32bc076 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js @@ -49,5 +49,34 @@ }); return deferred.promise; }, + + // code of email report + LabExerciseReport: function (User, reportImage, reportTitle, reportCopyStatus, senderEmail) { + User.reportImage = reportImage; + User.reportTitle = reportTitle; + User.ReportCheck = reportCopyStatus; + User.EmailTo = senderEmail; + var deferred = $q.defer(); + // var jsonData = { 'EmailTo': User.EmailTo, 'EmailAdd': User.EmailAdd }; + $http.post('http://192.168.90.19:91/API/api/LabExercise/SendEmail', JSON.stringify(User), { + + headers: { + 'Content-Type': 'application/json' + }, + // data: { Users: JSON.stringify(jsonData) } + }) + + .success(function (data, status, headers, config) { + + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + + console.log('error') + deferred.reject(data); + }); + return deferred.promise; + } + } }) \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index 06cfb89..2106c46 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -11,6 +11,111 @@
+ + + + + + + +
+ +
+ +
+ + + + + + + + + +

LAB Ex ...

@@ -100,7 +205,7 @@
- +
@@ -135,7 +240,7 @@
Total Question