Commit 68649f512e03b0197b5d235f9c5f5c14246fd424

Authored by Birendra
1 parent 893e59ac

added user session in AIA application

400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs
... ... @@ -119,9 +119,10 @@ namespace AIAHTML5.ADMIN.API.Controllers
119 119 bool Status = false;
120 120 int userId = jsonData["userId"].Value<Int32>();
121 121 string tagName = jsonData["tagName"].Value<string>();
  122 + bool isAlreadyLoggedIn = jsonData["isAlreadyLoggedIn"].Value<bool>();
122 123 try
123 124 {
124   - Status = UserModel.ManageUserLoginStatus(dbContext, userId, tagName);
  125 + Status = UserModel.ManageUserLoginStatus(dbContext, userId, tagName, isAlreadyLoggedIn);
125 126  
126 127 return Request.CreateResponse(HttpStatusCode.OK, Status.ToString());
127 128 }
... ...
400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs
... ... @@ -4995,7 +4995,7 @@ namespace AIAHTML5.ADMIN.API.Entity
4995 4995 return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_InsertAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, iUserTypeIdParameter, sEmailIdParameter, iSecurityQuesIdParameter, sSecurityAnswerParameter, iCreatorIdParameter, iLicenseIdParameter, iEditionIdParameter, status);
4996 4996 }
4997 4997  
4998   - public virtual ObjectResult<Nullable<bool>> usp_ManageUserLoginStatus(Nullable<int> userId, string tag)
  4998 + public virtual ObjectResult<Nullable<bool>> usp_ManageUserLoginStatus(Nullable<int> userId, string tag, Nullable<bool> isAlreadyLogin)
4999 4999 {
5000 5000 var userIdParameter = userId.HasValue ?
5001 5001 new ObjectParameter("userId", userId) :
... ... @@ -5005,7 +5005,11 @@ namespace AIAHTML5.ADMIN.API.Entity
5005 5005 new ObjectParameter("tag", tag) :
5006 5006 new ObjectParameter("tag", typeof(string));
5007 5007  
5008   - return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<bool>>("usp_ManageUserLoginStatus", userIdParameter, tagParameter);
  5008 + var isAlreadyLoginParameter = isAlreadyLogin.HasValue ?
  5009 + new ObjectParameter("isAlreadyLogin", isAlreadyLogin) :
  5010 + new ObjectParameter("isAlreadyLogin", typeof(bool));
  5011 +
  5012 + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<Nullable<bool>>("usp_ManageUserLoginStatus", userIdParameter, tagParameter, isAlreadyLoginParameter);
5009 5013 }
5010 5014 }
5011 5015 }
... ...
400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx
... ... @@ -1410,6 +1410,7 @@
1410 1410 <Function Name="usp_ManageUserLoginStatus" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
1411 1411 <Parameter Name="userId" Type="int" Mode="In" />
1412 1412 <Parameter Name="tag" Type="varchar" Mode="In" />
  1413 + <Parameter Name="isAlreadyLogin" Type="bit" Mode="In" />
1413 1414 </Function>
1414 1415 <Function Name="usp_SaveLabExerciseAttempts" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
1415 1416 <Parameter Name="UserId" Type="int" Mode="In" />
... ... @@ -3005,6 +3006,7 @@
3005 3006 <FunctionImport Name="usp_ManageUserLoginStatus" ReturnType="Collection(Boolean)">
3006 3007 <Parameter Name="userId" Mode="In" Type="Int32" />
3007 3008 <Parameter Name="tag" Mode="In" Type="String" />
  3009 + <Parameter Name="isAlreadyLogin" Mode="In" Type="Boolean" />
3008 3010 </FunctionImport>
3009 3011 </EntityContainer>
3010 3012 <ComplexType Name="DA_GetBaseLayer_Result">
... ... @@ -4329,6 +4331,7 @@
4329 4331 <Property Type="Int32" Name="UserTypeId" Nullable="true" />
4330 4332 <Property Type="Int32" Name="EditionTypeId" Nullable="true" />
4331 4333 <Property Type="Boolean" Name="LoginStatus" Nullable="true" />
  4334 + <Property Type="String" Name="TotalLogin" Nullable="true" MaxLength="50" />
4332 4335 </ComplexType>
4333 4336 <ComplexType Name="usp_GetUserTyeByAccountNumber_Result">
4334 4337 <Property Type="Byte" Name="Id" Nullable="true" />
... ... @@ -6296,6 +6299,7 @@
6296 6299 <ScalarProperty Name="UserTypeId" ColumnName="UserTypeId" />
6297 6300 <ScalarProperty Name="EditionTypeId" ColumnName="EditionTypeId" />
6298 6301 <ScalarProperty Name="LoginStatus" ColumnName="LoginStatus" />
  6302 + <ScalarProperty Name="TotalLogin" ColumnName="TotalLogin" />
6299 6303 </ComplexTypeMapping>
6300 6304 </ResultMapping>
6301 6305 </FunctionImportMapping>
... ...
400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsersList_Result.cs
... ... @@ -30,5 +30,6 @@ namespace AIAHTML5.ADMIN.API.Entity
30 30 public Nullable<int> UserTypeId { get; set; }
31 31 public Nullable<int> EditionTypeId { get; set; }
32 32 public Nullable<bool> LoginStatus { get; set; }
  33 + public string TotalLogin { get; set; }
33 34 }
34 35 }
... ...
400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs
... ... @@ -65,12 +65,12 @@ namespace AIAHTML5.ADMIN.API.Models
65 65 return false;
66 66 }
67 67 }
68   - public static bool ManageUserLoginStatus(AIADatabaseV5Entities dbContext, int userId, string tagName)
  68 + public static bool ManageUserLoginStatus(AIADatabaseV5Entities dbContext, int userId, string tagName, bool isAlreadyLoggedIn)
69 69 {
70 70 bool loginStatus = false;
71 71 try
72 72 {
73   - loginStatus = Convert.ToBoolean(dbContext.usp_ManageUserLoginStatus(userId, tagName).FirstOrDefault());
  73 + loginStatus = Convert.ToBoolean(dbContext.usp_ManageUserLoginStatus(userId, tagName, isAlreadyLoggedIn).FirstOrDefault());
74 74  
75 75 return loginStatus;
76 76 }
... ...
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs
... ... @@ -512,8 +512,9 @@ namespace AIAHTML5.API.Controllers
512 512 {
513 513 int userId = jsonData["userId"].Value<int>();
514 514 string tagName = jsonData["tagName"].Value<string>();
  515 + bool isAlreadyLoggedIn = jsonData["isAlreadyLoggedIn"].Value<bool>();
515 516  
516   - loginStatus = AIAHTML5.API.Models.Users.GetUserLoginStatus(userId, tagName);
  517 + loginStatus = AIAHTML5.API.Models.Users.GetUserLoginStatus(userId, tagName, isAlreadyLoggedIn);
517 518  
518 519 return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(loginStatus) };
519 520 }
... ...
400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... ... @@ -348,7 +348,7 @@ namespace AIAHTML5.API.Models
348 348 return objUser;
349 349 }
350 350  
351   - internal static string GetUserLoginStatus(int userId,string tagName)
  351 + internal static string GetUserLoginStatus(int userId,string tagName,bool isAlreadyLoggedIn)
352 352 {
353 353 string status=string.Empty;
354 354 DBModel objModel = new DBModel();
... ... @@ -363,7 +363,7 @@ namespace AIAHTML5.API.Models
363 363 cmd.CommandType = CommandType.StoredProcedure;
364 364 cmd.Parameters.AddWithValue("@userId", userId);
365 365 cmd.Parameters.AddWithValue("@tag", tagName);
366   -
  366 + cmd.Parameters.AddWithValue("@isAlreadyLogin", isAlreadyLoggedIn);
367 367 adapter = new SqlDataAdapter(cmd);
368 368 adapter.Fill(ds);
369 369  
... ...
400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... ... @@ -315,10 +315,10 @@ namespace AIAHTML5.API.Models
315 315 return objUser;
316 316 }
317 317  
318   - internal static string GetUserLoginStatus(int userId, string tagName)
  318 + internal static string GetUserLoginStatus(int userId, string tagName,bool isAlreadyLoggedIn)
319 319 {
320 320 string status = null;
321   - status = DBModel.GetUserLoginStatus(userId, tagName);
  321 + status = DBModel.GetUserLoginStatus(userId, tagName, isAlreadyLoggedIn);
322 322  
323 323 return status;
324 324 }
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -8,7 +8,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
8 8 //};
9 9  
10 10 $rootScope.MULTI_VIEW_ID = 401;
11   -
12 11 $rootScope.pageToOpen = 'app/widget/MainMenu.html';
13 12 $rootScope.currentBodyViewId;
14 13 $rootScope.currentActiveModuleTitle = 'Welcome to A.D.A.M. Interactive Anatomy';//Modules[0].Name;
... ... @@ -761,7 +760,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
761 760 $('.loginPanel').css('pointer-events', 'none');
762 761 $('.loginPanel').css('opacity', '0.7');
763 762 }
764   - $rootScope.AuthenticateUser = function (userInfo) {
  763 + $rootScope.AuthenticateUser = function (userInfo,isAlreadyLoggedIn) {
765 764 if (navigator.cookieEnabled) {
766 765 $rootScope.errorMessage = "";
767 766 if (userInfo.username == "" || userInfo.username == null || userInfo.username == undefined || userInfo.password == "" || userInfo.password == null || userInfo.password == undefined) {
... ... @@ -793,6 +792,10 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
793 792 result.aiaIdleTime=$rootScope.aiaIdleTime;
794 793 result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
795 794 result.aiaPingInterval=$rootScope.aiaPingInterval;
  795 + $rootScope.isAlreadyLoggedIn=isAlreadyLoggedIn==undefined?false:isAlreadyLoggedIn;
  796 + //display user name
  797 + $rootScope.userName=result.FirstName+" "+result.LastName;
  798 +
796 799  
797 800 //code for modesty setting
798 801 if (result.LicenseInfo != null) {
... ... @@ -985,11 +988,11 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
985 988 }
986 989  
987 990  
988   - if (result.UserTypeId == 6) {
989   - $('#modestyDiv').css('pointerEvent', 'none');
990   - $('#modestyDiv').css('opacity', 0.4);
991   - $("#modestyDiv").find("*").prop('disabled', true);
992   - }
  991 + // if (result.UserTypeId == 6) {
  992 + // $('#modestyDiv').css('pointerEvent', 'none');
  993 + // $('#modestyDiv').css('opacity', 0.4);
  994 + // $("#modestyDiv").find("*").prop('disabled', true);
  995 + // }
993 996  
994 997 if (result.LicenseInfo != null) {
995 998  
... ... @@ -1016,8 +1019,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1016 1019 $rootScope.userData = result;
1017 1020 $rootScope.userModules = result.Modules;
1018 1021  
1019   - $("#modestyDiv").css("pointer-events", "none");
1020   - $("#modestyDiv").css("opacity", 0.5);
  1022 + // $("#modestyDiv").css("pointer-events", "none");
  1023 + // $("#modestyDiv").css("opacity", 0.5);
1021 1024 //2.
1022 1025 localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
1023 1026  
... ... @@ -1214,10 +1217,31 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1214 1217 .then(
1215 1218 function (result) {
1216 1219 if(result!=null)
1217   - {
1218   - $rootScope.userInfo.username = result.LoginId;
1219   - $rootScope.userInfo.password = result.Password;
1220   - $rootScope.AuthenticateUser($rootScope.userInfo);
  1220 + {
  1221 + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
  1222 + ConfigurationService.getCofigValue()
  1223 + .then(
  1224 + function (configresult) {
  1225 + $rootScope.current_year = configresult.current_year;
  1226 + $rootScope.aiaIdleTime = configresult.idleTime;
  1227 + $rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
  1228 + $rootScope.aiaPingInterval = configresult.pingInterval;
  1229 + $rootScope.aiaAnimationPath = configresult.serverPath;
  1230 + $rootScope.MaxOneFileSize = configresult.fileSize;
  1231 +
  1232 + $rootScope.userInfo.username = result.LoginId;
  1233 + $rootScope.userInfo.password = result.Password;
  1234 + var loggedInUser = JSON.parse($scope.currentUserDetails);
  1235 + if(loggedInUser!==null && loggedInUser.LoginId==result.LoginId)
  1236 + {
  1237 + $rootScope.AuthenticateUser($rootScope.userInfo,true);
  1238 + }
  1239 + else
  1240 + {
  1241 + $rootScope.AuthenticateUser($rootScope.userInfo,false);
  1242 + }
  1243 + });
  1244 +
1221 1245 }
1222 1246  
1223 1247 }),
... ... @@ -1240,11 +1264,39 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1240 1264  
1241 1265 }
1242 1266 else {
1243   - console.log($rootScope.siteUrlInfo);
1244   - $rootScope.LoginDisableUI();
1245   - AuthenticationService.validateClientSite($rootScope.siteUrlInfo)
1246   - .then(
  1267 +
  1268 + console.log($rootScope.siteUrlInfo);
  1269 +
  1270 + $rootScope.LoginDisableUI();
  1271 + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
  1272 + ConfigurationService.getCofigValue()
  1273 + .then(
  1274 + function (configresult) {
  1275 + $rootScope.current_year = configresult.current_year;
  1276 + $rootScope.aiaIdleTime = configresult.idleTime;
  1277 + $rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
  1278 + $rootScope.aiaPingInterval = configresult.pingInterval;
  1279 + $rootScope.aiaAnimationPath = configresult.serverPath;
  1280 + $rootScope.MaxOneFileSize = configresult.fileSize;
  1281 +
  1282 + var loggedInUser = JSON.parse($scope.currentUserDetails);
  1283 + //check already login by account number bcz no login id for site login
  1284 + //maintain user session by licenseid of site login
  1285 + if(loggedInUser!==null && loggedInUser.AccountNumber==$rootScope.siteUrlInfo.accountNumber)
  1286 + {
  1287 + $rootScope.AuthenticateClientSiteUser($rootScope.siteUrlInfo,true);
  1288 + }
  1289 + else
  1290 + {
  1291 + $rootScope.AuthenticateClientSiteUser($rootScope.siteUrlInfo,false);
  1292 + }
  1293 + });
  1294 + }
  1295 + }
1247 1296  
  1297 + $rootScope.AuthenticateClientSiteUser = function (siteInfo,isAlreadyLoggedIn) {
  1298 + AuthenticationService.validateClientSite(siteInfo)
  1299 + .then(
1248 1300 function (result) {
1249 1301 console.log(result);
1250 1302 if (result != null) {
... ... @@ -1293,6 +1345,9 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1293 1345 result.aiaIdleTime=$rootScope.aiaIdleTime;
1294 1346 result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
1295 1347 result.aiaPingInterval=$rootScope.aiaPingInterval;
  1348 + $rootScope.isAlreadyLoggedIn=isAlreadyLoggedIn==undefined?false:isAlreadyLoggedIn;
  1349 + //display user name
  1350 + $rootScope.userName=result.FirstName+" "+result.LastName;
1296 1351 if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) {
1297 1352 //code for modesty setting
1298 1353 if (result.LicenseInfo != null) {
... ... @@ -1429,8 +1484,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1429 1484 }
1430 1485 }
1431 1486  
1432   -
1433   -
1434 1487 },
1435 1488  
1436 1489 function (error) {
... ... @@ -1445,9 +1498,6 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1445 1498 }
1446 1499 )
1447 1500  
1448   - }
1449   -
1450   -
1451 1501 }
1452 1502  
1453 1503 $scope.saveRemeberMeDetails = function (result, userInfo) {
... ... @@ -1579,6 +1629,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1579 1629 userId: null,
1580 1630 tagName: null,
1581 1631 loginStatus: null,
  1632 + isAlreadyLoggedIn:$rootScope.isAlreadyLoggedIn
1582 1633 }
1583 1634 console.log('user session start');
1584 1635 $rootScope.CheckUserSession('insert');
... ... @@ -1609,18 +1660,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1609 1660 $rootScope.CheckUserSession('update');
1610 1661 });
1611 1662  
1612   - // $(window).unload(function(event) {
1613   - // //var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource');
1614   - // if ($rootScope.closetab==true) {
1615   - // localStorage.removeItem('loggedInUserDetails');
1616   - // localStorage.clear();
1617   - // $rootScope.CheckUserSession('logout');
1618   - // return "Handler for .unload() called.";
1619   -
1620   - // }
1621   -
1622   - // });
1623   -
  1663 +
1624 1664 $window.onbeforeunload = function (e) {
1625 1665 var confirmation = {};
1626 1666 // if($location.url()!= "/") {
... ... @@ -1663,7 +1703,8 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1663 1703 //console.log('user login id: '+$rootScope.userData.Id);
1664 1704 //console.log('user login activity tag: '+tagName);
1665 1705 if($rootScope.userData==undefined) return;
1666   - $rootScope.userStatus.userId=$rootScope.userData.Id;
  1706 + //incase site user login userid is 0 so then using license id
  1707 + $rootScope.userStatus.userId=$rootScope.userData.Id==0?$rootScope.userData.LicenseId:$rootScope.userData.Id;
1667 1708 $rootScope.userStatus.tagName=tagName;
1668 1709 AuthenticationService.ManageUserLoginStatus($rootScope.userStatus)
1669 1710 .then(
... ... @@ -1671,6 +1712,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1671 1712 if(loginStatus!=null)
1672 1713 {
1673 1714 $rootScope.userStatus.loginStatus = loginStatus;
  1715 + $rootScope.userStatus.isAlreadyLoggedIn=true;
1674 1716 if(loginStatus=='False')
1675 1717 {
1676 1718 $rootScope.LogoutUserSession();
... ... @@ -1699,7 +1741,7 @@ function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, Data
1699 1741 userInfo["password"] = userInfo.Password;
1700 1742  
1701 1743  
1702   - $rootScope.AuthenticateUser(userInfo);
  1744 + $rootScope.AuthenticateUser(userInfo,true);
1703 1745  
1704 1746 if ($rootScope.refreshcheck == null) {
1705 1747  
... ...
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... ... @@ -403,7 +403,7 @@ AIA.constant(&quot;LoginConstants&quot;, {
403 403 });
404 404  
405 405 AIA.constant("LoginMessageConstants", {
406   - "USER_UPDATE_PROFILE":"Please update your profile first",
  406 + "USER_UPDATE_PROFILE":"Please update your profile first.",
407 407 "USER_OR_PASSWORD_INCORRECT": "UserId or Password is incorrect.",
408 408 "RESET_PASSWORD": "Please check you email and reset your password.",
409 409 "USERID_SENT_IN_EMAIL": "We have sent you userId in email.",
... ...
400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html
... ... @@ -48,7 +48,7 @@
48 48 <li class="navbarItem"><a ng-click="reDirectURLToAdmin()" ng-show="haveRoleAdmin" style="cursor: pointer;">Admin</a></li>
49 49 </ul>
50 50 <ul class="nav navbar-nav navbar-right">
51   - <li class="visible-xs"><a href="" ng-click="LogoutUser()">Logout</a></li>
  51 + <li class="navbarItem" style="pointer-events:none ;"><a href="#">{{userName}}</a></li>
52 52 <li class="hidden-xs marginR5 logOut" data-toggle="tooltip" data-placement="top" title="Logout"><a href="" ng-click="LogoutUser()"><i class="fa fa-power-off"></i></a></li>
53 53 </ul>
54 54 <div id="imaginary_container" style="visibility:hidden">
... ...
400-SOURCECODE/Admin/src/app/app.component.ts
... ... @@ -133,7 +133,8 @@ export class AppComponent implements OnInit {
133 133 loginManageStatus(tagname:string) {
134 134 this.userservice.ManageUserLoginStatus({
135 135 userId: this.global.UserId,
136   - tagName: tagname
  136 + tagName: tagname,
  137 + isAlreadyLoggedIn:true
137 138 }).subscribe(status => {
138 139 console.log(status);
139 140 if(status=='False')
... ...
400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts
... ... @@ -56,7 +56,7 @@ export class UserService {
56 56  
57 57 //////////Manage UserLogin Status///////////
58 58 ManageUserLoginStatus(obj: any) {
59   - var jsonData = { 'userId': obj.userId, 'tagName': obj.tagName };
  59 + var jsonData = { 'userId': obj.userId, 'tagName': obj.tagName,'isAlreadyLoggedIn': obj.isAlreadyLoggedIn };
60 60 console.log(obj);
61 61 var headers = new Headers({
62 62 'Content-Type': 'application/json'
... ...
400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.html
... ... @@ -154,7 +154,7 @@
154 154 <span *ngIf="UserEntity.UserStatus!='Active'" class="label label-default">Inactive</span>
155 155 </td>
156 156 <td>
157   - <span *ngIf="UserEntity.LoginStatus==true" class="label label-success">Logged-In</span>
  157 + <span *ngIf="UserEntity.LoginStatus==true" class="label label-success">Logged-In (Active Session: {{UserEntity.TotalLogin}})</span>
158 158 <span *ngIf="UserEntity.LoginStatus==false" class="label label-default">Logged-Out</span>
159 159 </td>
160 160 </tr>
... ...