Commit f8f1bf206110cb650f19a8c657f62470f8d31e70

Authored by Nikita Kulshreshtha
2 parents 8d862269 1f8c4a8b

Merge branch 'emailreviewcode' into Develop

400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs
@@ -217,7 +217,58 @@ namespace AIAHTML5.API.Controllers @@ -217,7 +217,58 @@ namespace AIAHTML5.API.Controllers
217 217
218 218
219 219
  220 + //[HttpPost]
  221 + //public HttpResponseMessage Hi(int userId)
  222 + //{
  223 + // return Request.CreateResponse(HttpStatusCode.OK, userId.ToString());
  224 + //}
  225 + [Route("GetUserProfile/{userId}")]
  226 + [HttpGet]
  227 + public IHttpActionResult GetUserProfile(int userId)
  228 + {
  229 + //dbContext.Configuration.ProxyCreationEnabled = false;
  230 + try
  231 + {
  232 + return Ok("Hello");
  233 + }
  234 + catch (Exception ex)
  235 + {
  236 + throw ex;
  237 + }
  238 + //return ToJson(dbContext.AIAUsers.Where(u => u.Id == userId).AsEnumerable());
220 239
  240 + }
  241 + [Route("api/LabExercise/SendEmail")]
  242 + [HttpPost]
  243 + public HttpResponseMessage SendEmail([FromBody]JObject User)
  244 + {
  245 + ArrayList aar = new ArrayList();
  246 + if (User["EmailTo"].ToString().ToLower().Contains(';'))
  247 + {
  248 + string[] words = User["EmailTo"].ToString().Split(';');
  249 + foreach (string word in words)
  250 + {
  251 + Console.WriteLine(word);
  252 + aar.Add(word);
  253 + }
  254 + }
  255 + else
  256 + {
  257 + aar.Add(User["EmailTo"].ToString());
  258 + }
  259 + if (Convert.ToBoolean(User["ReportCheck"]) == true)
  260 + {
  261 + aar.Add(User["EmailAdd"].ToString());
  262 + }
  263 + AIAHTML5.API.Models.UserUtility.SendEmail(User, aar, User["EmailAdd"].ToString(), User["reportTitle"].ToString(), User["reportImage"].ToString(), true);
  264 + return Request.CreateResponse(HttpStatusCode.OK);
  265 + }
  266 + [Route("api/LabExercise/GetParameter")]
  267 + [HttpGet]
  268 + public IEnumerable<string> GetParameter()
  269 + {
  270 + return new string[] { "val1", "val2" };
  271 + }
221 272
222 273
223 274
400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs
@@ -283,7 +283,7 @@ namespace AIAHTML5.API.Models @@ -283,7 +283,7 @@ namespace AIAHTML5.API.Models
283 } 283 }
284 } 284 }
285 285
286 - public static bool SendEmail(Newtonsoft.Json.Linq.JObject userInfo, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "") 286 + public static bool SendEmail(Newtonsoft.Json.Linq.JObject userInfo, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "", bool isCalForLabExerciseReport=false)
287 { 287 {
288 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); 288 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
289 logger.Debug("Inside SendEmail with UserInfo =" + userInfo); 289 logger.Debug("Inside SendEmail with UserInfo =" + userInfo);
@@ -301,9 +301,10 @@ namespace AIAHTML5.API.Models @@ -301,9 +301,10 @@ namespace AIAHTML5.API.Models
301 { 301 {
302 lstToAddress.Add(email); 302 lstToAddress.Add(email);
303 } 303 }
304 -  
305 - emailMessage = "Unable to process request for ";  
306 - 304 + if (!isCalForLabExerciseReport)
  305 + emailMessage = "Unable to process request for ";
  306 + else
  307 + emailMessage = " ";
307 if (UserUtility.CheckIfPropertyExists(userInfo, "username") && !string.IsNullOrEmpty(userInfo["username"].ToString())) 308 if (UserUtility.CheckIfPropertyExists(userInfo, "username") && !string.IsNullOrEmpty(userInfo["username"].ToString()))
308 emailMessage += "username: <b>" + userInfo["username"].ToString() + "</b>"; 309 emailMessage += "username: <b>" + userInfo["username"].ToString() + "</b>";
309 if (UserUtility.CheckIfPropertyExists(userInfo, "password") && !string.IsNullOrEmpty(userInfo["password"].ToString())) 310 if (UserUtility.CheckIfPropertyExists(userInfo, "password") && !string.IsNullOrEmpty(userInfo["password"].ToString()))
@@ -316,24 +317,26 @@ namespace AIAHTML5.API.Models @@ -316,24 +317,26 @@ namespace AIAHTML5.API.Models
316 if (string.IsNullOrEmpty(sender)) 317 if (string.IsNullOrEmpty(sender))
317 senderEmailId = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]); 318 senderEmailId = Convert.ToString(ConfigurationManager.AppSettings["SenderEmailAddress"]);
318 else 319 else
319 - senderEmailId = sender; 320 + senderEmailId = sender;
320 321
321 emailMessage += mailBody; 322 emailMessage += mailBody;
322 323
323 emailMessage = emailMessage.Replace("\n", "<br/>"); 324 emailMessage = emailMessage.Replace("\n", "<br/>");
324 325
325 - emailMessage += "<br/><br/>";  
326 - 326 + // emailMessage += "<br/><br/>";
  327 + emailMessage = "<html><head></head><body>" + emailMessage + "</body></html>";
327 emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]); 328 emailUtility.sHostName = Convert.ToString(ConfigurationManager.AppSettings["HostAddress"]);
328 emailUtility.sFromAddress = senderEmailId; 329 emailUtility.sFromAddress = senderEmailId;
329 emailUtility.bIsBodyHtml = true; 330 emailUtility.bIsBodyHtml = true;
330 - emailUtility.bEnableSsl = false; 331 + // emailUtility.bEnableSsl = false;
  332 + emailUtility.bEnableSsl = true;
331 emailUtility.sSubject = mailSubject; 333 emailUtility.sSubject = mailSubject;
332 emailUtility.sBodyText = emailMessage; 334 emailUtility.sBodyText = emailMessage;
333 - emailUtility.iPort = 25; 335 + //emailUtility.iPort = 25;
  336 + emailUtility.iPort = 587;
334 emailUtility.sToAddresses = lstToAddress; 337 emailUtility.sToAddresses = lstToAddress;
335 emailUtility.sBccAddresses = lstBccAddress; 338 emailUtility.sBccAddresses = lstBccAddress;
336 - 339 + emailUtility.sUserName = senderEmailId;
337 emailUtility.SendSmtpEmail(); 340 emailUtility.SendSmtpEmail();
338 return true; 341 return true;
339 } 342 }
400-SOURCECODE/AIAHTML5.API/Utility/EmailUtility.cs
@@ -39,7 +39,7 @@ namespace AIAHTML5.API.Utility @@ -39,7 +39,7 @@ namespace AIAHTML5.API.Utility
39 System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]); 39 System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential(mm.From.ToString(), ConfigurationManager.AppSettings["SenderPassword"]);
40 smtp.Credentials = NetworkCred; 40 smtp.Credentials = NetworkCred;
41 smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); 41 smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);
42 - 42 + smtp.EnableSsl = false;
43 smtp.Send(mm); 43 smtp.Send(mm);
44 } 44 }
45 catch (Exception e) 45 catch (Exception e)
400-SOURCECODE/AIAHTML5.API/Web.config
@@ -32,13 +32,22 @@ @@ -32,13 +32,22 @@
32 32
33 <appSettings> 33 <appSettings>
34 <add key="Copyrightyear" value="2018" /> 34 <add key="Copyrightyear" value="2018" />
35 - <add key="SenderEmailAddress" value="support@interactiveanatomy.com" /> 35 +
  36 + <add key="SenderEmailAddress" value="ayush.jain@ebix.com" />
  37 + <add key="ErrorNotificationEmailAddress" value="ayush.jain@ebix.com" />
  38 + <add key="SenderPassword" value="Change1t" />
  39 + <add key="SMTPAddress" value="smtp.emailsrvr.com" />
  40 + <add key="SMTPPort" value="587" />
  41 + <add key="EnableSSL" value="true" />
  42 +
  43 + <!--<add key="SenderEmailAddress" value="support@interactiveanatomy.com" />
36 <add key="SenderEmailAddress" value="support@interactiveanatomy.com" /> 44 <add key="SenderEmailAddress" value="support@interactiveanatomy.com" />
37 <add key="ErrorNotificationEmailAddress" value="support@interactiveanatomy.com" /> 45 <add key="ErrorNotificationEmailAddress" value="support@interactiveanatomy.com" />
38 <add key="SenderPassword" value="" /> 46 <add key="SenderPassword" value="" />
39 <add key="SMTPAddress" value="10.100.12.13" /> 47 <add key="SMTPAddress" value="10.100.12.13" />
40 <add key="SMTPPort" value="25" /> 48 <add key="SMTPPort" value="25" />
41 - <add key="EnableSSL" value="false" /> 49 + <add key="EnableSSL" value="false" />-->
  50 +
42 <add key="Site_Url" value ="http://qa.beta.interactiveanatomy.com/"/> 51 <add key="Site_Url" value ="http://qa.beta.interactiveanatomy.com/"/>
43 <add key ="HostAddress" value="10.100.12.13" /> 52 <add key ="HostAddress" value="10.100.12.13" />
44 <add key="AdminSupport" value="amrita.vishnoi@ebix.com,nikita.kulshreshtha@ebix.com"/> 53 <add key="AdminSupport" value="amrita.vishnoi@ebix.com,nikita.kulshreshtha@ebix.com"/>
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
@@ -1288,8 +1288,55 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, @@ -1288,8 +1288,55 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter,
1288 } 1288 }
1289 1289
1290 } 1290 }
  1291 + $scope.reportCopyStatus = false;
  1292 + $scope.SendLabEXMailToUser = function (User) {
  1293 + var reportHtml = '';
  1294 + reportHtml += '<table style="width:100%;"><thead><th style="padding:15px;border:1px solid #cccccc"><strong>Question</strong></th><th style="padding:15px;border:1px solid #cccccc"><strong>Activity Title</strong></th><th style="padding:15px;border:1px solid #cccccc"><strong>Status</strong></th></thead><tbody>';
  1295 + $("#resultLabData tr").each(function () {
  1296 + reportHtml += '<tr>';
  1297 + $(this).children("td").each(function () {
  1298 + if ($(this).text() == " Review") {
  1299 + }
  1300 + else{
  1301 + reportHtml += '<td style="border:1px solid #cccccc;padding:15px;">' + $(this).text() + '</td>';
  1302 + }
  1303 + });
  1304 + reportHtml += '</tr>';
1291 1305
  1306 + });
  1307 + reportHtml += '</tbody></table>';
  1308 + $scope.reportImage = "<table style='width:100%;'><tr><td style='padding:15px;'><strong>"+$("#submitResultHtml .panel-heading .row div:nth-child(1)").text()+"</strong></td><td style='padding:15px;'>Performance Report</td><td style='padding:15px;text-align:right;'><span>" + $("#submitResultHtml .panel-heading .row div:nth-child(3)").text() + "</span></td></tr></table><table style='width:100%;'><thead><th style='text-align:center;padding:15px;border:1px solid #cccccc;'><strong>Total Question</strong></th><th style='border:1px solid #cccccc;text-align:center;padding:15px;'><strong>Correct Answers</strong></th><th style='border:1px solid #cccccc;padding:15px;text-align:center;'><strong>Incorrect Answers</strong></th></thead><tr><td style='border:1px solid #cccccc;padding:15px;text-align:center;'><span>" + $("#questionStatus tbody tr td:nth-child(1)").text() + "</span></td><td style='text-align:center;border:1px solid #cccccc;padding:15px;'><span>" + $("#questionStatus tbody tr td:nth-child(2)").text() + "</span></td><td style='text-align:center;border:1px solid #cccccc;padding:15px;'><span>" + $("#questionStatus tbody tr td:nth-child(3)").text() + "</span></td></tr></table><br/><br/>" + reportHtml + "";
  1309 + $scope.reportTitle = "Lab Exercise Report for " + $("#submitResultHtml .panel-heading .row div:nth-child(1)").text();
  1310 + $scope.senderEmails = $("#emailTo").val();
  1311 +
  1312 +
  1313 + LabExerciseService.LabExerciseReport(User, $scope.reportImage, $scope.reportTitle, $scope.reportCopyStatus, $scope.senderEmails).then(
1292 1314
  1315 + function (result) {
  1316 + console.log(result);
  1317 + },
  1318 + function (error) {
  1319 + console.log(error.statusText);
  1320 + }
  1321 + )
  1322 + // for closing email popup
  1323 + $rootScope.closeLabExEmailModel();
  1324 + }
  1325 + $rootScope.closeLabExEmailModel = function () {
  1326 + document.getElementById("LabExerciseForm").reset();
  1327 + $scope.LabExForm.$setPristine();
  1328 + $scope.LabExForm.$setUntouched();
  1329 + document.body.style.overflow = "scroll";
  1330 + document.getElementById('labExModalbackground').style.display = "none";
  1331 + document.getElementById('labExModalID').style.display = "none";
  1332 + $scope.reportCopyStatus = false;
  1333 + }
  1334 + $rootScope.sendMail = function () {
  1335 + window.scrollTo(0, 0);
  1336 + document.body.style.overflow = "hidden";
  1337 + document.getElementById('labExModalbackground').style.display = "block";
  1338 + document.getElementById('labExModalID').style.display = "block";
  1339 + }
1293 1340
1294 }] 1341 }]
1295 1342
400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js
@@ -49,5 +49,34 @@ @@ -49,5 +49,34 @@
49 }); 49 });
50 return deferred.promise; 50 return deferred.promise;
51 }, 51 },
  52 +
  53 + // code of email report
  54 + LabExerciseReport: function (User, reportImage, reportTitle, reportCopyStatus, senderEmail) {
  55 + User.reportImage = reportImage;
  56 + User.reportTitle = reportTitle;
  57 + User.ReportCheck = reportCopyStatus;
  58 + User.EmailTo = senderEmail;
  59 + var deferred = $q.defer();
  60 + // var jsonData = { 'EmailTo': User.EmailTo, 'EmailAdd': User.EmailAdd };
  61 + $http.post('http://192.168.90.19:91/API/api/LabExercise/SendEmail', JSON.stringify(User), {
  62 +
  63 + headers: {
  64 + 'Content-Type': 'application/json'
  65 + },
  66 + // data: { Users: JSON.stringify(jsonData) }
  67 + })
  68 +
  69 + .success(function (data, status, headers, config) {
  70 +
  71 + console.log('success')
  72 + deferred.resolve(data);
  73 + }).error(function (data, status, headers, config) {
  74 +
  75 + console.log('error')
  76 + deferred.reject(data);
  77 + });
  78 + return deferred.promise;
  79 + }
  80 +
52 } 81 }
53 }) 82 })
54 \ No newline at end of file 83 \ No newline at end of file
400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
@@ -11,6 +11,111 @@ @@ -11,6 +11,111 @@
11 <div class="clearfix"></div> 11 <div class="clearfix"></div>
12 </div> 12 </div>
13 13
  14 +
  15 +
  16 + <!--report email pop up code-->
  17 +
  18 +
  19 +
  20 +
  21 + <div id="labExModalbackground"></div>
  22 + <!-- Lab Ex -->
  23 + <div class="labExModal" id="labExModalID">
  24 + <div class="modal-content">
  25 + <div class="modal-header">
  26 + <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="closeLabExEmailModel()"><span aria-hidden="true">ร—</span></button>
  27 + <h4 class="modal-title" id="myModalLabel">Email your performance report</h4>
  28 + </div>
  29 +
  30 + <div class="modal-body paddTop15">
  31 + <div class="modal-body paddTop15">
  32 +
  33 + <form class="form-horizontal" name="LabExForm" id="LabExerciseForm" ng-submit="SendLabEXMailToUser(User)">
  34 + <div class="form-group">
  35 + <div class="col-sm-5 control-label">
  36 + <label>*Email To: (Email address)</label>
  37 + </div>
  38 +
  39 + <div class="col-sm-7">
  40 + <!--<input type="email" class="form-control" name="senderEmail" ng-model="User.EmailTo" required="required" />-->
  41 + <input type="email" name="usremail" class="form-control" required="required" id="emailTo" multiple />
  42 + <div class="help-block">*Use ',' to separate multiple email ids. </div>
  43 + <!--<div class="help-block" style="color:red;" ng-if="LabExForm.senderEmail.$error.pattern">Please Enter valid Email Address</div>-->
  44 + </div>
  45 + </div>
  46 +
  47 + <div class="form-group">
  48 + <div class="col-sm-5 control-label">
  49 + <label>*Your name:</label>
  50 + </div>
  51 + <div class="col-sm-7">
  52 + <input type="text" name="name" class="form-control" ng-model="User.Name" ng-pattern="/^([a-zA-Z]+\s?)*$/" required="required" />
  53 + <div class="help-block" style="color:red;" ng-if="LabExForm.name.$error.pattern"> Please enter your Name</div>
  54 + <!--<div class="help-block" style="color:red;" id="nameHelpBlock"> Please Enter your Name </div>-->
  55 + </div>
  56 + </div>
  57 +
  58 + <div class="form-group">
  59 + <div class="col-sm-5 control-label">
  60 + <label for="">*Your Email Address:</label>
  61 + </div>
  62 + <div class="col-sm-7">
  63 + <!--<input type="text" class="form-control" name="receiverEmail" ng-model="User.EmailAdd" ng-pattern="/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/" required="required" />-->
  64 + <input type="email" class="form-control" name="receiverEmail" ng-model="User.EmailAdd" required="required" />
  65 +
  66 + <!--<div class="help-block" style="color:red;" id="emailHelpBlock"> Please Enter your Email Address </div>-->
  67 + <!--<div class="help-block" style="color:red;" ng-if="LabExForm.receiverEmail.$error.pattern"> Please Enter valid Email Address</div>-->
  68 + </div>
  69 + </div>
  70 +
  71 + <div class="form-group">
  72 + <div class="col-sm-5 control-label">
  73 + <label for="">Send me a copy of the report</label>
  74 + </div>
  75 + <div class="col-sm-7">
  76 + <input type="checkbox" style="margin-top: 12px;" ng-model="reportCopyStatus" />
  77 + </div>
  78 + </div>
  79 +
  80 + <div class="form-group">
  81 + <div class="col-sm-5 control-label">
  82 + <label for="">Note(optional)</label>
  83 + </div>
  84 + <div class="col-sm-7">
  85 + <textarea name="" id="" class="form-control" cols="30" rows="5" ng-model="User.comments"></textarea>
  86 + <div class="help-block">255 character limit </div>
  87 + </div>
  88 + </div>
  89 +
  90 +
  91 + <div class="form-group">
  92 + <div class="col-sm-5 control-label">
  93 +
  94 + </div>
  95 + <div class="col-sm-7">
  96 + <button type="submit" class="btn btn-primary btn-block">Send Mail</button>
  97 +
  98 + </div>
  99 + </div>
  100 +
  101 + </form>
  102 +
  103 + </div>
  104 +
  105 + </div>
  106 +
  107 + </div>
  108 + </div>
  109 +
  110 +
  111 +
  112 +
  113 +
  114 +
  115 +
  116 +
  117 +
  118 +
14 <div class="col-sm-12"> 119 <div class="col-sm-12">
15 <div class="pull-left btn-group LabEx-Panel-state-minimized" id="LabExMinimizedId"> 120 <div class="pull-left btn-group LabEx-Panel-state-minimized" id="LabExMinimizedId">
16 <p class="pull-left" style="color:#fff">LAB Ex ...</p> 121 <p class="pull-left" style="color:#fff">LAB Ex ...</p>
@@ -100,7 +205,7 @@ @@ -100,7 +205,7 @@
100 <div class="panel-body no-padding"> 205 <div class="panel-body no-padding">
101 <div class="row"> 206 <div class="row">
102 <div class="col-sm-12 table-responsive "> 207 <div class="col-sm-12 table-responsive ">
103 - <table class="table table-hover table-condensed bg-white"> 208 + <table class="table table-hover table-condensed bg-white" id="questionStatus">
104 <thead> 209 <thead>
105 <tr class="active"> 210 <tr class="active">
106 <th class="text-center">Total Question</th> 211 <th class="text-center">Total Question</th>
@@ -135,7 +240,7 @@ @@ -135,7 +240,7 @@
135 </div> 240 </div>
136 <div class="panel-footer"> 241 <div class="panel-footer">
137 <div class="text-center"> 242 <div class="text-center">
138 - <button class="btn btn-sm btn-primary"> 243 + <button class="btn btn-sm btn-primary" ng-click="sendMail()">
139 Email 244 Email
140 </button> 245 </button>
141 246
400-SOURCECODE/AIAHTML5.Web/themes/default/css/bootstrap/3.3.6/main.css
@@ -1281,4 +1281,42 @@ footer .browserIcons @@ -1281,4 +1281,42 @@ footer .browserIcons
1281 #UserPassword 1281 #UserPassword
1282 { 1282 {
1283 -webkit-text-security: disc; 1283 -webkit-text-security: disc;
1284 - }  
1285 \ No newline at end of file 1284 \ No newline at end of file
  1285 + }
  1286 +
  1287 +/*email pop up css*/
  1288 +
  1289 +#labExModalID {
  1290 + display: none;
  1291 + position: absolute;
  1292 + z-index: 12000001;
  1293 + margin: auto;
  1294 + top: 50px;
  1295 + left: 0;
  1296 + right: 0;
  1297 + bottom: 0;
  1298 + width: 50%;
  1299 +}
  1300 +#labExModalbackground
  1301 +{
  1302 + background-color: black;
  1303 + bottom: 0px;
  1304 + display: none;
  1305 + height: 100%; left: 0px;
  1306 + opacity: 0.5;
  1307 + position: fixed;
  1308 + right: 0px; top: 0px;
  1309 + width: 100%;
  1310 + z-index: 12000000;
  1311 +}
  1312 +#nameHelpBlock
  1313 + {
  1314 + display:none;
  1315 +}
  1316 +#emailHelpBlock
  1317 +{
  1318 + display:none;
  1319 +}
  1320 +#emailToHelpBlock
  1321 +{
  1322 + display:none;
  1323 +}
1286 \ No newline at end of file 1324 \ No newline at end of file