Commit 45356ddfb69093d3f3017a8ef939583bff7956cf

Authored by Birendra
2 parents 818ff616 ad5a3a1f

Merge branch 'Bug#23043_1' into AIA_Develop

400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj
... ... @@ -14,7 +14,7 @@
14 14 <RootNamespace>AIAHTML5.API</RootNamespace>
15 15 <AssemblyName>AIAHTML5.API</AssemblyName>
16 16 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
17   - <UseIISExpress>true</UseIISExpress>
  17 + <UseIISExpress>false</UseIISExpress>
18 18 <IISExpressSSLPort />
19 19 <IISExpressAnonymousAuthentication />
20 20 <IISExpressWindowsAuthentication />
... ... @@ -181,7 +181,7 @@
181 181 <AutoAssignPort>True</AutoAssignPort>
182 182 <DevelopmentServerPort>63874</DevelopmentServerPort>
183 183 <DevelopmentServerVPath>/</DevelopmentServerVPath>
184   - <IISUrl>http://localhost:63874/</IISUrl>
  184 + <IISUrl>http://localhost/AIAHTML5.API</IISUrl>
185 185 <NTLMAuthentication>False</NTLMAuthentication>
186 186 <UseCustomServer>False</UseCustomServer>
187 187 <CustomServerUrl>http://182.19.10.91/AIAHTML5</CustomServerUrl>
... ...
400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs
... ... @@ -49,7 +49,7 @@ namespace AIAHTML5.API.Constants
49 49 public const string VALIDATED_CLIENT = "Valid Client.";
50 50 public const string INVALID_CLIENT = "InValid Client.";
51 51 public const string MSG_NOT_AUTHORIZE_SITE_USER = "User is not authorized.";
52   -
  52 + public const string SETTINGS_SAVE_FAILURE = "We are unable to save your Settings. Please try again.";
53 53  
54 54 public const string STATUS_OK = "ok";
55 55 public const string STATUS_NOT_OK = "notok";
... ...
400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs
... ... @@ -19,6 +19,10 @@ namespace AIAHTML5.API.Constants
19 19 public const string UPDATE_LICENSE_TERM_STATUS = "UpdateLicenseTermAcceptedStatus";
20 20 public const string GET_TERMS_AND_CONDITIONS = "GetTermsAndConditions";
21 21 public const string INSERT_LOGIN_DETAIL = "InsertLoginDetail";
  22 + public const string SAVE_SETTINGS = "usp_SaveUserSettings";
  23 + public const string GET_SETTINGS = "usp_GetUserSettings";
  24 +
  25 +
22 26 public const string INSERT_INCORRECT_LOGIN_ATTEMPTS = "InsertIncorrectLoginAttempt";
23 27 public const string GET_INCORRECT_LOGIN_ATTEMPTS = "GetIncorrectLoginAttempt";
24 28 public const string UPDATE_INCORRECT_LOGIN_ATTEMPTS = "UpdateIncorrectLoginAttempts";
... ...
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... ... @@ -261,9 +261,24 @@ namespace AIAHTML5.API.Controllers
261 261 }
262 262  
263 263 // get exported image detail
264   -
265 264 userInfo.UserExportImageDetail = GetLicenseExportImageDetail(userInfo.LicenseId);
  265 +
266 266 }
  267 + //get use settings
  268 + string skintone;
  269 + string modesty;
  270 + User us = AIAHTML5.API.Models.Users.GetUserSelectedSettings(userInfo.Id, out skintone, out modesty);
  271 + if (us != null)
  272 + {
  273 + userInfo.userselectedModesty = modesty;
  274 + userInfo.userSelectedSkintone = skintone;
  275 + }
  276 + else
  277 + {
  278 + userInfo.userselectedModesty = null;
  279 + userInfo.userSelectedSkintone = null;
  280 +
  281 + }
267 282 }
268 283  
269 284 private static void CheckLicenseStatus(User userInfo)
... ... @@ -361,6 +376,43 @@ namespace AIAHTML5.API.Controllers
361 376 return insertImageResult;
362 377 }
363 378  
  379 +
  380 +
  381 + [HttpPost]
  382 + [Route("api/SaveUserSettings")]
  383 + public HttpResponseMessage SaveUserSettings([FromBody]JObject jsonData)
  384 + {
  385 + int Status = 0;
  386 + dynamic responseData;
  387 + User settings = new User();
  388 +
  389 + try
  390 + {
  391 + settings.userselectedModesty =jsonData["modesty"].Value<string>();
  392 + settings.userSelectedSkintone = jsonData["skintone"].Value<string>();
  393 + settings.userSelectedFont = null;
  394 + settings.Id= jsonData["userId"].Value<int>();
  395 +
  396 + Status = AIAHTML5.API.Models.Users.SaveUserSelectedSettings(settings);
  397 + if (Status == 1)
  398 +
  399 + {
  400 + responseData = "1";
  401 +
  402 + }
  403 + else
  404 + {
  405 + responseData = AIAConstants.SETTINGS_SAVE_FAILURE;
  406 + }
  407 + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(responseData) };
  408 +
  409 + }
  410 + catch (Exception ex)
  411 + {
  412 + // Log exception code goes here
  413 + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
  414 + }
  415 + }
364 416 // PUT api/authenticate/5
365 417 public void Put(int id, [FromBody]string value)
366 418 {
... ...
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... ... @@ -310,6 +310,53 @@ namespace AIAHTML5.API.Models
310 310 return objUser;
311 311 }
312 312  
  313 + internal User GetSelectedSettings(int userId)
  314 + {
  315 + logger.Debug(" Inside GetSelectedSettings for userId = " + userId);
  316 +
  317 + User objUser = null;
  318 + DBModel objModel = new DBModel();
  319 +
  320 + SqlConnection conn = new SqlConnection(dbConnectionString);
  321 + SqlCommand cmd = new SqlCommand();
  322 + SqlDataAdapter adapter;
  323 + SqlParameter param;
  324 + DataSet ds = new DataSet();
  325 +
  326 + cmd.Connection = conn;
  327 + cmd.CommandText = DBConstants.GET_SETTINGS;
  328 + cmd.CommandType = CommandType.StoredProcedure;
  329 +
  330 + param = new SqlParameter("@iUserId", userId);
  331 + param.Direction = ParameterDirection.Input;
  332 + param.DbType = DbType.Int32;
  333 + cmd.Parameters.Add(param);
  334 +
  335 + adapter = new SqlDataAdapter(cmd);
  336 + adapter.Fill(ds);
  337 +
  338 +
  339 + if (ds != null && ds.Tables.Count > 0)
  340 + {
  341 + DataTable dt = ds.Tables[0];
  342 +
  343 + if (dt.Rows.Count > 0)
  344 + {
  345 + foreach (DataRow dr in dt.Rows)
  346 + {
  347 + objUser = new User();
  348 +
  349 + objUser.Id = Convert.ToInt32(dr["UserId"]);
  350 + objUser.userSelectedSkintone = dr["Skintone"].ToString();
  351 + objUser.userselectedModesty = dr["Modesty"].ToString();
  352 + logger.Debug("objUser.Id= " + objUser.Id + ",objUser.userselectedModesty= " + objUser.userselectedModesty + ",objUser.userSelectedSkintone= " + objUser.userSelectedSkintone + ",objUser.Password= " + objUser.Password + ",objUser.SecurityQuestionId= " + objUser.SecurityQuestionId);
  353 + }
  354 + }
  355 + }
  356 +
  357 + return objUser;
  358 + }
  359 +
313 360 internal static int UpdateUserPassword(dynamic userInfo, string loginId, string emailId)
314 361 {
315 362 logger.Debug(" Inside UpdateUserPassword for LoginId: " + loginId + ", EmailId: " + emailId);
... ... @@ -637,6 +684,42 @@ namespace AIAHTML5.API.Models
637 684 return result;
638 685 }
639 686  
  687 +
  688 + internal int SaveSettings(User settings)
  689 + {
  690 + logger.Debug(" inside InsertSettings for UserId= " + settings.Id);
  691 +
  692 + int result = 0;
  693 + SqlConnection conn = null;
  694 + try
  695 + {
  696 + conn = new SqlConnection(dbConnectionString);
  697 + SqlCommand cmd = new SqlCommand();
  698 + conn.Open();
  699 + cmd.Connection = conn;
  700 + cmd.CommandText = DBConstants.SAVE_SETTINGS;
  701 + cmd.CommandType = CommandType.StoredProcedure;
  702 + cmd.Parameters.AddWithValue("@iUserId", settings.Id);
  703 + cmd.Parameters.AddWithValue("@iModesty", settings.userselectedModesty);
  704 + cmd.Parameters.AddWithValue("@iSkintone",settings. userSelectedSkintone);
  705 + cmd.Parameters.AddWithValue("@ifont","" );
  706 +
  707 +
  708 + result = cmd.ExecuteNonQuery();
  709 + }
  710 + catch (SqlException ex)
  711 + {
  712 + logger.Fatal("Exception in InsertLoginDetails for UserId= " + settings.Id + ", Exception= " + ex.Message + ", STACKTRACE=" + ex.StackTrace);
  713 + throw;
  714 + }
  715 + finally
  716 + {
  717 + conn.Dispose();
  718 + }
  719 +
  720 + return result;
  721 + }
  722 +
640 723 internal int InsertIncorrectLoginAttempts(int userId)
641 724 {
642 725 logger.Debug(" inside InsertIncorrectLoginAttempts for UserId= " + userId);
... ...
400-SOURCECODE/AIAHTML5.API/Models/User.cs
... ... @@ -39,6 +39,10 @@ namespace AIAHTML5.API.Models
39 39 public ArrayList Modules { get; set; }
40 40 public int siteId { get; set; }
41 41 public string pwd { get; set; }
  42 + public String userSelectedSkintone { get; set; }
  43 + public string userselectedModesty { get; set; }
  44 + public string userSelectedFont { get; set; }
  45 +
42 46  
43 47 public License LicenseInfo { get; set; }
44 48 public LicenseSubscriptionDetails LicenseSubscriptions { get; set; }
... ...
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... ... @@ -149,6 +149,8 @@ namespace AIAHTML5.API.Models
149 149 return result;
150 150 }
151 151  
  152 +
  153 +
152 154 internal static bool isUSerActive(User user)
153 155 {
154 156 if (user.IsActive)
... ... @@ -306,6 +308,33 @@ namespace AIAHTML5.API.Models
306 308 }
307 309  
308 310  
  311 + internal static int SaveUserSelectedSettings(User selectedSettings)
  312 + {
  313 + logger.Debug("inside SaveUserSelectedSettings for Image =" + selectedSettings.Id);
  314 +
  315 + int result = 0;
  316 +
  317 + DBModel objModel = new DBModel();
  318 + result = objModel.SaveSettings(selectedSettings);
  319 +
  320 + return result;
  321 + }
  322 +
  323 + internal static User GetUserSelectedSettings(int userId,out string skintone, out string modesty)
  324 + {
  325 + logger.Debug("inside GetUserSelectedSettings for userid =" + userId);
  326 +
  327 + skintone = null;
  328 + modesty = null;
  329 + DBModel objModel = new DBModel();
  330 + User result = objModel.GetSelectedSettings(userId);
  331 + if (result != null)
  332 + {
  333 + skintone = result.userSelectedSkintone;
  334 + modesty = result.userselectedModesty;
  335 + }
  336 + return result;
  337 + }
309 338  
310 339 internal static void isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, User userInfo, out bool isCorrectLoginId, out bool isCorrectPassword)
311 340 {
... ...
400-SOURCECODE/AIAHTML5.Web/Web.config
... ... @@ -21,7 +21,7 @@
21 21  
22 22 </location>
23 23 <system.webServer>
24   - <rewrite>
  24 + <!--<rewrite>
25 25 <rules>
26 26 <rule name="AngularJS Routes" stopProcessing="true">
27 27 <match url=".*" />
... ... @@ -33,7 +33,7 @@
33 33 <action type="Rewrite" url="/" />
34 34 </rule>
35 35 </rules>
36   - </rewrite>
  36 + </rewrite>-->
37 37 <staticContent>
38 38  
39 39 <remove fileExtension=".mp3" />
... ... @@ -44,7 +44,7 @@
44 44 <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
45 45 <mimeMap fileExtension=".mp3" mimeType="audio/mpeg" />
46 46 <mimeMap fileExtension=".vtt" mimeType="text/vtt" />
47   - <mimeMap fileExtension=".json" mimeType="application/json" />
  47 + <!--<mimeMap fileExtension=".json" mimeType="application/json" />-->
48 48  
49 49 </staticContent>
50 50 <defaultDocument enabled="true">
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -578,36 +578,65 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
578 578  
579 579 //code for modesty setting
580 580 if (result.LicenseInfo != null) {
581   - if (result.IsModestyOn) {
582   - $rootScope.isModestyOn = true;
583   - $rootScope.isModestyOff = false;
584   - localStorage.setItem("globalModesty", "Y");
585   - $rootScope.formsetting = {
586   - ethnicity: null,
587   - modesty: "Y"
  581 + if (result.userselectedModesty == undefined || result.userselectedModesty == null ||
  582 + result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) {
  583 + if (result.IsModestyOn) {
  584 + $rootScope.isModestyOn = true;
  585 + $rootScope.isModestyOff = false;
  586 + localStorage.setItem("globalModesty", "Y");
  587 + $rootScope.formsetting = {
  588 + ethnicity: null,
  589 + modesty: "Y"
  590 + }
  591 + $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
  592 + }
  593 + else {
  594 + $rootScope.isModestyOn = false;
  595 + $rootScope.isModestyOff = true;
  596 + localStorage.setItem("globalModesty", "N");
  597 + $rootScope.formsetting = {
  598 + ethnicity: null,
  599 + modesty: "N"
  600 + }
  601 + $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
588 602 }
589   - $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
590 603 }
591 604 else {
592   - $rootScope.isModestyOn = false;
593   - $rootScope.isModestyOff = true;
594   - localStorage.setItem("globalModesty", "N");
  605 + localStorage.setItem("globalModesty", result.userselectedModesty);
  606 + localStorage.setItem("globalEthnicity", result.userSelectedSkintone);
  607 +
595 608 $rootScope.formsetting = {
596   - ethnicity: null,
597   - modesty: "N"
  609 + ethnicity: result.userSelectedSkintone,
  610 + modesty: result.userselectedModesty
598 611 }
599 612 $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
  613 +
600 614 }
601 615 }
602 616 else {
603   - $rootScope.isModestyOn = true;
604   - $rootScope.isModestyOff = false;
605   - localStorage.setItem("globalModesty", "Y");
606   - $rootScope.formsetting = {
607   - ethnicity: null,
608   - modesty: "Y"
  617 + if (result.userselectedModesty == undefined || result.userselectedModesty == null ||
  618 + result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) {
  619 +
  620 + $rootScope.isModestyOn = true;
  621 + $rootScope.isModestyOff = false;
  622 + localStorage.setItem("globalModesty", "Y");
  623 + $rootScope.formsetting = {
  624 + ethnicity: null,
  625 + modesty: "Y"
  626 + }
  627 + $rootScope.UpdateAndCloseSetting($rootScope.formsetting);
  628 + }
  629 + else {
  630 + localStorage.setItem("globalModesty", result.userselectedModesty);
  631 + localStorage.setItem("globalEthnicity", result.userSelectedSkintone);
  632 +
  633 + $rootScope.formsetting = {
  634 + ethnicity: result.userSelectedSkintone,
  635 + modesty: result.userselectedModesty
  636 + }
  637 + $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
  638 +
609 639 }
610   - $rootScope.UpdateAndCloseSetting($rootScope.formsetting)
611 640 }
612 641 //code for modesty setting
613 642 $rootScope.aiaModesty = $rootScope.formsetting.modesty;
... ... @@ -731,6 +760,12 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
731 760  
732 761 }
733 762  
  763 + if (result.UserTypeId == 6) {
  764 + $('#modestyDiv').css('pointerEvent', 'none');
  765 + $('#modestyDiv').css('opacity', 0.4);
  766 + $("#modestyDiv").find("*").prop('disabled', true);
  767 + }
  768 +
734 769 if (result.LicenseInfo != null) {
735 770  
736 771 // set license id
... ... @@ -6051,10 +6086,15 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
6051 6086 if (currentmodsetting == 'Y') {
6052 6087 $rootScope.isModestyOn = true;
6053 6088 $rootScope.isModestyOff = false;
  6089 + $("#modon").prop("checked", true);
  6090 + $("#modoff").prop("checked", false);
  6091 +
6054 6092 }
6055 6093 else {
6056 6094 $rootScope.isModestyOn = false;
6057 6095 $rootScope.isModestyOff = true;
  6096 + $("#modon").prop("checked", false);
  6097 + $("#modoff").prop("checked", true);
6058 6098 }
6059 6099 }
6060 6100  
... ... @@ -6110,10 +6150,13 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
6110 6150  
6111 6151 }
6112 6152 $rootScope.isApplyBtnClicked = false;
6113   - $rootScope.CloseSetting = function () {
  6153 + $rootScope.CancelSetting = function () {
6114 6154 $rootScope.isCloseSettingClicked = true;
6115 6155 $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
6116 6156 $rootScope.setModestySettings($rootScope.globalSetting.modesty);
  6157 +
  6158 +
  6159 +
6117 6160 if ($rootScope.isApplyBtnClicked == false) {
6118 6161  
6119 6162 $rootScope.deSelectLanguageOptions();
... ... @@ -6125,7 +6168,48 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
6125 6168 $('#modal-settings').css("display", "none");
6126 6169 $("#modelsettingsbackground").css("display", "none");
6127 6170 }
  6171 + $rootScope.CloseSetting = function () {
  6172 + // $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
  6173 + $("#saveSettingsMessageModal").modal('show');
  6174 + $("#saveSettingsMessageModal").css('zIndex', 80000000000);
  6175 + //$('#modal-settings').css("display", "none");
  6176 + //$("#modelsettingsbackground").css("display", "none");
  6177 + }
  6178 + $rootScope.saveSettings = function () {
  6179 +
  6180 + var currentSkintone = $rootScope.globalSetting.ethnicity;
  6181 + var currentModesty = $rootScope.globalSetting.modesty;
  6182 + var setting={};
  6183 + setting.modesty =currentModesty ;
  6184 + setting.skintone = currentSkintone;
  6185 + setting.userId = $rootScope.userData.Id;
  6186 + AuthenticationService.saveSetings(setting)
  6187 + .then(
  6188 +
  6189 + function (result) {
  6190 + var k= result;
  6191 + if(result==1){
  6192 + $rootScope.errorMessage = AIAConstants.SETTINGS_SAVED ;
  6193 + $('#modal-settings').css("display", "none");
  6194 + $("#modelsettingsbackground").css("display", "none");
  6195 +
  6196 + }
  6197 + else{
  6198 + $rootScope.errorMessage =AIAConstants.SETTING_SAVE_ERROR;
6128 6199  
  6200 + }
  6201 + $("#messageModal").css('zIndex', 80000000000);
  6202 + $("#messageModal").modal('show');
  6203 +
  6204 + }),
  6205 + function (error) {
  6206 + console.log(' Error in Saving settings = ' + error.statusText);
  6207 + // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
  6208 + $rootScope.isVisibleLogin = true;
  6209 + $rootScope.errorMessage = error;
  6210 + $("#messageModal").modal('show');
  6211 + }
  6212 + }
6129 6213 $rootScope.UpdateAndCloseSetting = function (setting) {
6130 6214  
6131 6215 $rootScope.UpdateSetting(setting);
... ...
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... ... @@ -525,7 +525,9 @@ AIA.constant(&quot;AIAConstants&quot;, {
525 525 "COOKIES_MESSAGE": "You need to enable your browser's cookies to run this application.",
526 526 "SAVED_LAB_EXERCISE_NOT_FOUND": "Saved Lab Exercise not found.",
527 527 "ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.",
528   - "PLEASE_ENTER_SEARCH_TEXT":"Please enter the text to search."
  528 + "PLEASE_ENTER_SEARCH_TEXT": "Please enter the text to search.",
  529 + "SETTINGS_SAVED": "Your current settings has been saved.",
  530 + "SETTING_SAVE_ERROR":"There is some error in saving your current settings. Please try after sometime."
529 531 })
530 532  
531 533  
... ...
400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js
... ... @@ -43,6 +43,29 @@
43 43 return deferred.promise;
44 44 },
45 45  
  46 +
  47 + saveSetings: function (settings) {
  48 + var deferred = $q.defer();
  49 +
  50 + $http.post('/API/api/SaveUserSettings', JSON.stringify(settings), {
  51 + headers: {
  52 + 'Content-Type': 'application/json'
  53 + }
  54 + })
  55 + .success(function (data, status, headers, config) {
  56 + console.log('success')
  57 + deferred.resolve(data);
  58 + }).error(function (data, status, headers, config) {
  59 + console.log('error')
  60 + deferred.reject(data);
  61 + $rootScope.errorMessage = data;
  62 + $("#messageModal").modal('show');
  63 +
  64 + });
  65 + return deferred.promise;
  66 + },
  67 +
  68 +
46 69 validateClientSite: function (clientInfo) {
47 70 var deferred = $q.defer();
48 71  
... ...