diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs.orig b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs.orig new file mode 100644 index 0000000..ef63915 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs.orig @@ -0,0 +1,384 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using log4net; +using AIAHTML5.API.Constants; +using AIAHTML5.API.Models; +using System.Collections; + +<<<<<<< HEAD +using System.Data.SqlClient;namespace AIAHTML5.API.Controllers +======= +using System.Data.SqlClient; +namespace AIAHTML5.API.Controllers +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 +{ + public class AuthenticateController : ApiController + { + // GET api/authenticate + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/authenticate/5 + public string Get(int id) + { + return "value"; + } + + // POST api/authenticate + public HttpResponseMessage Post([FromBody]JObject credentials) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside POST"); + + dynamic authenticationRepsonse; + DateTime blockTime; + bool isUserBlocked; + + try + { + + //01.get the user detail to autheticate the user + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials); + + if (userInfo != null) + { + // 02 Check user is authenticated or not by login credential match + bool isUserAuthenticated = AIAHTML5.API.Models.Users.checkUserAuthenticity(credentials, userInfo); + + if (isUserAuthenticated) + { + if (userInfo.IsActive) + { + //03. check if user is blocked + isUserBlocked = AIAHTML5.API.Models.Users.checkUserBlockStatus(userInfo.Id, out blockTime); + + if (!isUserBlocked) + { + //04.delete past wrong login attempts of user + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); + if (wrongAttemptDeteledCount < 0) + { + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); + } + //05. + GetModulesBasedOnUserType(userInfo); + + // authenticationRepsonse = JsonConvert.SerializeObject(userInfo); + } + + else + { + + //compare block time of user with current time if user is blocked + DateTime blockDuration = blockTime.AddDays(1); + var difference = DateTime.Compare(DateTime.Now, blockDuration); + + //check if credentials are valid credentials + //bool isCorrectLoginId, isCorrectPassword; + //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword); + + if (difference >= 0) + { + //means 24 hours block time is finished + userInfo.IsBlocked = false; + + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id); + if (wrongAttemptDeteledCount < 0) + { + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); + } + + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads + GetModulesBasedOnUserType(userInfo); + + } + else + { + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; + } + } + } + else + { + //CODE REVIW: validate that is this tarnslated by UI because we need to show message to user if he is inactive + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_NOT_ACTIVE; + + //05.4 check the License expiration irespective of either user is active + //or not because on AIA, we shows the License expiration message + //for inactive users too + + CheckLicenseStatus(userInfo); + + } + } + + else + { + //this come in picture when user input wrong passowrd + + //get wrong attempt count of user + int previousIncorrectLoginAttempts = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id); + userInfo.IncorrectLoginAttemptCount = previousIncorrectLoginAttempts + 1; + userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; + + //01. insert wrong attempt in dtabase + int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptOfUser(userInfo.Id, previousIncorrectLoginAttempts); + + if (updateCount < 0) + { + //Put the log in log file + logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id); + } + //else + //{ + if (userInfo.IncorrectLoginAttemptCount > 4) + { + userInfo.IsBlocked = true; + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; + } +<<<<<<< HEAD + + + } + + authenticationRepsonse = JsonConvert.SerializeObject(userInfo); + +======= + + + } + + authenticationRepsonse = JsonConvert.SerializeObject(userInfo); + +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + + else + { + authenticationRepsonse = AIAConstants.USER_NOT_FOUND; + } + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) }; + } +<<<<<<< HEAD + catch(SqlException e){ +======= + catch (SqlException e) + { +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + + logger.Fatal("SqlException occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + + ArrayList supportMailList = UserUtility.GetSupportMailList(); + string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); + +<<<<<<< HEAD + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; +======= + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + catch (Exception e) + { + + logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + + ArrayList supportMailList = UserUtility.GetSupportMailList(); + string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); +<<<<<<< HEAD + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; + +======= + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; + +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + + } + + private static void GetModulesBasedOnUserType(User userInfo) + { + //based on old .net code(AIA flex), we get modules based on licenseId if licenseid>0. + //we verified in database that only superadmin has no licenseid so getting all modules for supeadmin + int licenseId, editionId; + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); + + userInfo.LicenseId = licenseId; + userInfo.EditionId = editionId; + + //if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN) +<<<<<<< HEAD + if(userInfo.LicenseId == 0) +======= + if (userInfo.LicenseId == 0) +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + { + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); + + //Insert user login detail + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); + } + else + { + CheckLicenseStatus(userInfo); + +<<<<<<< HEAD + if(!userInfo.IsSubscriptionExpired){ + GetModulesBasedOnLicense(userInfo,false); +======= + if (!userInfo.IsSubscriptionExpired) + { + GetModulesBasedOnLicense(userInfo, false); +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + } + } + + private static void CheckLicenseStatus(User userInfo) + { + //05.1 For normal user need to get the license details, get the license id for authenticated user + //int licenseId, editionId; + //AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId); + + //userInfo.LicenseId = licenseId; + //userInfo.EditionId = editionId; + + //05.2 get license details + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId); + + if (userInfo.LicenseInfo != null) + { + //05.3 get licenseSubscription details + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); + + //05.4 check the License expiration irespective of either user is active or not because on AIA + //we shows the License expiration message for inactive users too + string expirationDate = null; + bool isLicenseExpired = false; + + if (userInfo.LicenseSubscriptions != null) + { + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate); + } + +<<<<<<< HEAD + if (isLicenseExpired) +======= + if (isLicenseExpired) +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + { + userInfo.IsSubscriptionExpired = isLicenseExpired; + userInfo.SubscriptionExpirationDate = expirationDate; + } +<<<<<<< HEAD + } + + else + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= "+userInfo.LicenseId); +======= + else + { + //check Modesty settings for this license + + userInfo.IsModestyOn = AIAHTML5.API.Models.Users.IsModestyActiveForThisLicense(userInfo.LicenseId); + + + } + } + + else + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= " + userInfo.LicenseId); +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + } + + private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired) + { +<<<<<<< HEAD + + //05.6.1 + if (userInfo.LicenseInfo.IsActive) + { + if (!userInfo.LicenseInfo.IsTermAccepted) + { + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions(); + foreach (Hashtable item in termsList) + { + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString(); + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString(); + } + } + else + { + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); + + //Insert user login detail + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); +======= + + //05.6.1 + if (userInfo.LicenseInfo.IsActive) + { + if (!userInfo.LicenseInfo.IsTermAccepted) + { + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions(); + foreach (Hashtable item in termsList) + { + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString(); + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString(); +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + } + else + { +<<<<<<< HEAD + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE; + + } + } + +======= + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); + + //Insert user login detail + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); + } + } + else + { + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE; + + } + } + +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + + + // PUT api/authenticate/5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api/authenticate/5 + public void Delete(int id) + { + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js.orig b/400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js.orig new file mode 100644 index 0000000..7d0b606 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js.orig @@ -0,0 +1,245 @@ +AIA.controller("3dAController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", +function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile) { + + + $scope.showTabButton = false; + $scope.threeDAnatomyData; + $scope.Id; + $scope.$on('$viewContentLoaded', function (event) { + var currentURL = $location.path(); + var selectedModuleName = ''; + //set module title + angular.forEach($rootScope.userModules, function (value, key) { +<<<<<<< HEAD + if (value.slug === currentURL.replace('/', '')) { + selectedModuleName = value.name; +======= + // if (value.slug === currentURL.replace('/', '')) { + if (value.slug === "3d-anatomy-list") { + selectedModuleName = value.name; +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + } + $rootScope.currentActiveModuleTitle = selectedModuleName; + }) + if ($rootScope.refreshcheck == null) { + $location.path('/'); + } + $scope.scroll(); + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json') + promise.then( + function (result) { + $scope.threeDAnatomyData = result; + + // $scope.selectedThreeDAdata = $scope.threeDAnatomyData.root.ThreeDAData; + + $scope.selectedThreeDAdata = new jinqJs() + .from($scope.threeDAnatomyData.root.ThreeDAData) + .orderBy([{ field: '_Title', sort: 'asc' }]) + .select(); + + // console.log($scope.selectedCIListViewData); + $('#grid-view').empty(); + angular.forEach($scope.selectedThreeDAdata, function (value, key) { + $scope.imagePath = "~/../content/images/3da/thumbnails/" + value._ThumbnailImage; + + var $el = $('
' + + '
' + + '' + + '

' + value._Title + '

').appendTo('#grid-view'); + + + $compile($el)($scope); + + $(".sidebar").mCustomScrollbar({ + autoHideScrollbar: true, + //theme:"rounded" + }); + + }); + + }, + function (error) { + // handle errors here + console.log(' $scope.threeDAnatomyData = ' + error.statusText); + } + ); + + }); + $scope.scroll = function () { + // $window.scrollTo(0, 0); + $("html,body").scrollTop(0); + //alert("scroll"); + } + $scope.IsVisible = function () { + //$scope.scroll(); + + $location.url("/3dAnatomy"); + + } + + + $scope.Open3DModel = function ($event) { + $rootScope.currentBodyViewId = $event.currentTarget.id; + if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") { + var ThreeDTitle = []; + ThreeDTitle = new jinqJs() + .from($scope.selectedThreeDAdata) + .where('_id = ' + $event.currentTarget.id) + .select('_Title'); + + $rootScope.ViewTitle = ThreeDTitle[0]._Title; + } + else { + $rootScope.ViewTitle = $event.currentTarget.textContent; + + } + + + localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle); + localStorage.setItem("currentBodyViewId", $event.currentTarget.id); + + var u = $location.url(); + $location.url('/3d-anatomy-details'); + + } + + $scope.Open3DModelBody = function () { + + if ($rootScope.refreshcheck == null) { + $location.path('/'); + + } + $rootScope.isLoading = true; + $('#spinner').css('visibility', 'visible'); + //alert($rootScope.getLocalStorageValue("currentBodyViewId")); + $scope.voId3D = $rootScope.getLocalStorageValue("currentBodyViewId"); + + //alert($scope.voId3D); + + + //once you get id in scope push detail in jspanel content + + var openViews; +<<<<<<< HEAD + if ($rootScope.openViews.length > 0) { + openViews = new jinqJs() + .from($rootScope.openViews) + .where("BodyViewId==" + $scope.voId3D) + .select(); + } + var counter = 1; + var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson"); + + if (openViews != null && openViews.length > 0) { + angular.forEach(openViews, function (value, key) { + + if (value.body - views == tittle) { + tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++; + $rootScope.currentActiveViewTitle = tittle; + localStorage.setItem("currentViewTitle", tittle); + } + + }); + } + else { + localStorage.setItem("currentViewTitle", tittle); + + } +======= + //if ($rootScope.openViews.length > 0) { + // openViews = new jinqJs() + // .from($rootScope.openViews) + // .where("BodyViewId==" + $scope.voId3D) + // .select(); + //} + //var counter = 1; + var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson"); + $rootScope.currentActiveViewTitle = tittle; + localStorage.setItem("currentViewTitle", tittle); + //if (openViews != null && openViews.length > 0) { + // angular.forEach(openViews, function (value, key) { + + // if (value.body - views == tittle) { + // tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++; + // $rootScope.currentActiveViewTitle = tittle; + // localStorage.setItem("currentViewTitle", tittle); + // } + + // }); + //} + //else { + // localStorage.setItem("currentViewTitle", tittle); + + //} +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693 + + // alert($rootScope.getLocalStorageValue("currentViewTitle")); + + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json') + promise.then( + function (result) { + $scope.threeDAnatomyData = result; + + var clicked3dAview = []; + clicked3dAview = new jinqJs().from($scope.threeDAnatomyData.root.ThreeDAData) + .where('_id == ' + $scope.voId3D) + .select('_Title', '_3dimagepath'); + $scope.Selected3DImagePath = clicked3dAview[0]._3dimagepath; + $scope.threeDBodySystemTitle = clicked3dAview[0]._Title; + + if (clicked3dAview.length > 0) { + + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + + $.jsPanel({ + id: '3DImagePanel', + selector: '.threeDView', + theme: 'success', + currentController: '3dAController', + parentSlug: '3d-anatomy-list', + content: '
' + + '' + + '
', + title: $rootScope.getLocalStorageValue("currentViewTitle"), + position: { + top: 70, + left: 1, + }, + + size: { width: $(window).outerWidth() - 20, height: $(window).outerHeight() - 10 }, + + }); + + $rootScope.currentSlug = '3d-anatomy-details'; + + $rootScope.openViews.push( + { + "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, + "slug": $rootScope.currentSlug + }); + + + } + + + }, + function (error) { + // handle errors here + console.log(' $scope.CIllustrationData = ' + error.statusText); + } + + ); + $('#ThreeDView').css("height", $(window).outerHeight()); + + $('#ThreeDView').css("width", $(window).outerWidth()); + + } + + + +}] + + + +); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index e35382e..bd78b97 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -363,8 +363,18 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.userModules = result.Modules; //1. set haveRoleAdmin = false because LicenseInfo is not null - $rootScope.haveRoleAdmin = false; + if (result.LicenseTypeId != 5) { + + $rootScope.haveRoleAdmin = true; + + } + if (result.UserTypeId == 8){ + + $rootScope.haveRoleAdmin = false; + } + $("#modestyDiv").css("pointer-events", "none"); + $("#modestyDiv").css("opacity", 0.5); //2. if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html index 8bd06d1..2a7f896 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html @@ -51,7 +51,7 @@ -