diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs
index 8031fde..82d7b83 100644
--- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs
+++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs
@@ -160,20 +160,29 @@ namespace AIAHTML5.API.Models
}
}
- internal static dynamic UpdateLicenseTerm(string accNumber)
+ internal static dynamic UpdateLicenseTerm(Newtonsoft.Json.Linq.JObject userLicenseInfo)
{
ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
- logger.Debug(" inside UpdateLicenseTerm for AccountNumber = " + accNumber);
+ logger.Debug(" inside UpdateLicenseTerm for AccountNumber = " + userLicenseInfo["licenseeAccountNumber"].ToString() + ", LicenseId: " + userLicenseInfo["userLicenseId"].ToString());
Newtonsoft.Json.Linq.JObject userInfo = new Newtonsoft.Json.Linq.JObject();
- userInfo.Add("accountNumber", accNumber);
+
dynamic result;
+ string accountNumber = userLicenseInfo["licenseeAccountNumber"].ToString();
+
+ userInfo.Add("accountNumber", accountNumber);
+
try
{
- result = DBModel.UpdateLicenseTermStatus(accNumber);
+ result = DBModel.UpdateLicenseTermStatus(accountNumber);
+
+ if (result < 0)
+ {
+ logger.Fatal("Unable to update LicenseTermAccepted status for AccountNumber =" + accountNumber);
+ }
}
catch (Exception ex)
{
- logger.Fatal("Exception in UpdateLicenseTerm for AccountNumber =" + accNumber + " Exception= " + ex.Message + ", STACKTRACE: " + ex.StackTrace);
+ logger.Fatal("Exception in UpdateLicenseTerm for AccountNumber =" + accountNumber + " Exception= " + ex.Message + ", STACKTRACE: " + ex.StackTrace);
ArrayList supportMailList = UserUtility.GetSupportMailList();
string mailSubject = "SQL Exception intimation mail";
@@ -247,25 +256,27 @@ namespace AIAHTML5.API.Models
return false;
}
- internal static string SubscriptionExpirationDateString(int licenseId)
+ internal static string getLicenseExpirationDate(int licenseId, out bool isLicenseExpired)
{
+ isLicenseExpired = false;
DBModel objModel = new DBModel();
LicenseSubscriptionDetails licenseSubscription = objModel.GetLicenseSubscriptionDetailsByLicenseId(licenseId);
- string subscritptionExpirationDateString = null;
+ string subscritptionExpirationDate = null;
if (licenseSubscription != null)
{
DateTime? subscriptionValidThrough = licenseSubscription.SubscriptionValidThrough;
if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date)
{
- subscritptionExpirationDateString = null;
+ isLicenseExpired = false;
}
else
{
- subscritptionExpirationDateString = licenseSubscription.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
+ isLicenseExpired = true;
+ subscritptionExpirationDate = licenseSubscription.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
}
}
- return subscritptionExpirationDateString;
+ return subscritptionExpirationDate;
}
internal static ArrayList getModuleListByLicenseId(int licenseId)
@@ -286,16 +297,6 @@ namespace AIAHTML5.API.Models
return result;
}
- internal static int insertWrongAttemptofUser(int userId)
- {
- int result = 0;
- DBModel objModel = new DBModel();
-
- result = objModel.InsertIncorrectLoginAttempts(userId);
-
- return result;
- }
-
internal static int checkNoOfWrongAttempts(int userId)
{
int result = 0;
@@ -307,11 +308,19 @@ namespace AIAHTML5.API.Models
}
internal static int saveWrongAttemptofUser(int userId)
- {
+ {
+ int wrongAttemptCount = Users.checkNoOfWrongAttempts(userId);
int result = 0;
DBModel objModel = new DBModel();
- result = objModel.UpdateIncorrectLoginAttempts(userId);
+ if (wrongAttemptCount < 1)
+ {
+ result = objModel.InsertIncorrectLoginAttempts(userId);
+ }
+ else
+ {
+ result = objModel.UpdateIncorrectLoginAttempts(userId);
+ }
return result;
}
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
index 16aaf45..2c96eba 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
@@ -86,13 +86,16 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
userMessage: null,
unblockUser: null
};
+ $rootScope.userLicenseInfo = {
+ userLicenseId: 0,
+ licenseeAccountNumber: null
+ };
$rootScope.userData;
$rootScope.userModules;
$rootScope.passwordMismatchMessage;
$rootScope.isVisibleLogin;
$rootScope.haveRoleAdmin;
$rootScope.checked = false;
- $rootScope.licenseeAccountNumber = null;
var isfilloptionChecked = "";
var isOutlineOptionChecked = "";
$rootScope.forgotPwdModalShow = function () {
@@ -130,95 +133,62 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
.then(
function (result) {
- if (result == 'true') {
-
- $rootScope.userModules = UserModules;
- $rootScope.isVisibleLogin = false;
- $location.path('/');
-
+ if (result == LoginConstants.USER_NOT_FOUND) {
+ $rootScope.isVisibleLogin = true;
+ // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
+ $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
+ $("#messageModal").modal('show');
+ }
+ else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) {
+ //alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS;
+ $("#messageModal").modal('show');
+ }
+ else if (result == LoginConstants.SQL_CONNECTION_ERROR) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginConstants.SQL_CONNECTION_ERROR_MESSAGE;
+ $("#messageModal").modal('show');
}
else {
- if (result == LoginConstants.USER_NOT_FOUND) {
- $rootScope.isVisibleLogin = true;
- // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
- $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
- $("#messageModal").modal('show');
- }
- else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) {
- //alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS;
- $("#messageModal").modal('show');
- }
- else if (result == LoginConstants.SQL_CONNECTION_ERROR) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginConstants.SQL_CONNECTION_ERROR_MESSAGE;
- $("#messageModal").modal('show');
- }
- else {
- if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
+ if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
- if ($("#messageModal").length > 0) {
- $("#messageModal").modal('hide');
- }
- if (result == LoginMessageConstants.INVALID_USER) {
+ if ($("#messageModal").length > 0) {
+ $("#messageModal").modal('hide');
+ }
+ if (result == LoginMessageConstants.INVALID_USER) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
+ $("#messageModal").modal('show');
+ }
+ else if (!result.IsCorrectPassword) {
+ if (result.IncorrectLoginAttemptCount < 5) {
$rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
+ $rootScope.errorMessage = LoginMessageConstants.INVALID_PASSWORD;
$("#messageModal").modal('show');
}
- else if (!result.IsCorrectPassword) {
- if (result.IncorrectLoginAttemptCount < 5) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.INVALID_PASSWORD;
- $("#messageModal").modal('show');
- }
- else {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.USER_BLOCKED;
- $("#messageModal").modal('show');
- }
- }
else {
- if ((!result.IsSubscriptionExpired) && (result.UserType == UserTypeConstants.SUPER_ADMIN) || result.UserType == UserTypeConstants.GENERAL_ADMIN && result.IsActive) {
- $rootScope.userData = result;
- $rootScope.userModules = result.Modules;
- $rootScope.isVisibleLogin = false;
- $rootScope.haveRoleAdmin = false;
- localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
- $('#dvUserModulesInfo').modal('show');
- $location.path('/');
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.USER_BLOCKED;
+ $("#messageModal").modal('show');
+ }
+ }
+ else {
+ if (result.UserType == UserTypeConstants.SUPER_ADMIN || result.UserType == UserTypeConstants.GENERAL_ADMIN && result.IsActive) { //(!result.IsSubscriptionExpired) &&
+ $rootScope.userData = result;
+ $rootScope.userModules = result.Modules;
+ $rootScope.isVisibleLogin = false;
+ $rootScope.haveRoleAdmin = false;
+ localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
+ $('#dvUserModulesInfo').modal('show');
+ $location.path('/');
- }
- //else if ((!result.IsSubscriptionExpired) && (result.UserType== UserTypeConstants.CLIENT_ADMIN || result.UserType== UserTypeConstants.DISTRICT_ADMIN || result.UserType== UserTypeConstants.SINGLE_USER ||result.UserType== UserTypeConstants.RESELLER) && result.License.IsTermAccepted) {}
-
- else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
- if (result.UserType == UserTypeConstants.CLIENT_ADMIN || result.UserType == UserTypeConstants.DISTRICT_ADMIN || result.UserType == UserTypeConstants.SINGLE_USER || result.UserType == UserTypeConstants.RESELLER) {
- if (result.License.IsTermAccepted) {
- $rootScope.userData = result;
- $rootScope.userModules = result.Modules;
- $rootScope.isVisibleLogin = false;
- $rootScope.haveRoleAdmin = true;
- $rootScope.licenseeAccountNumber = result.License.AccountNumber;
- localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
- $('#dvUserModulesInfo').modal('show');
- $location.path('/');
+ }
+ //else if ((!result.IsSubscriptionExpired) && (result.UserType== UserTypeConstants.CLIENT_ADMIN || result.UserType== UserTypeConstants.DISTRICT_ADMIN || result.UserType== UserTypeConstants.SINGLE_USER ||result.UserType== UserTypeConstants.RESELLER) && result.License.IsTermAccepted) {}
- }
- else {
- if ($('#dvTerms').length > 0) {
- $('#dvTerms').html(result.TermsOfServiceText);
- }
- $rootScope.isVisibleLogin = true;
- $('#dvTermCondition').fadeIn();
- $rootScope.userData = result;
- $rootScope.userModules = result.Modules;
- $rootScope.haveRoleAdmin = true;
- $rootScope.licenseeAccountNumber = result.License.AccountNumber;
- localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
- $location.path('/');
- }
- }
- else {
+ else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
+ if (result.UserType == UserTypeConstants.CLIENT_ADMIN || result.UserType == UserTypeConstants.DISTRICT_ADMIN || result.UserType == UserTypeConstants.SINGLE_USER || result.UserType == UserTypeConstants.RESELLER) {
+ if (result.License.IsTermAccepted) {
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
$rootScope.isVisibleLogin = false;
@@ -226,42 +196,63 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
$('#dvUserModulesInfo').modal('show');
$location.path('/');
+
+ }
+ else {
+ if ($('#dvTerms').length > 0) {
+ $('#dvTerms').html(result.TermsOfServiceText);
+ }
+ $rootScope.isVisibleLogin = true;
+ $('#dvTermCondition').fadeIn();
+ $rootScope.userData = result;
+ $rootScope.haveRoleAdmin = true;
+ localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
+ $location.path('/');
}
}
- else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
- $("#messageModal").modal('show');
- }
- else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
- $("#messageModal").modal('show');
- }
- else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
- $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
- $("#messageModal").modal('show');
- }
- else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
- $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
- $("#messageModal").modal('show');
- }
- else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && !result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
- $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
- $("#messageModal").modal('show');
- }
- else if (typeof(result.License) != "undefined" && !result.IsActive) {
- $rootScope.isVisibleLogin = true;
- $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
- $("#messageModal").modal('show');
+ else {
+ $rootScope.userData = result;
+ $rootScope.userModules = result.Modules;
+ $rootScope.isVisibleLogin = false;
+ $rootScope.haveRoleAdmin = true;
+ localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
+ $('#dvUserModulesInfo').modal('show');
+ $location.path('/');
}
}
+ else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
+ $("#messageModal").modal('show');
+ }
+ else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
+ $("#messageModal").modal('show');
+ }
+ else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
+ $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
+ $("#messageModal").modal('show');
+ }
+ else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
+ $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
+ $("#messageModal").modal('show');
+ }
+ else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && !result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
+ $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
+ $("#messageModal").modal('show');
+ }
+ else if (typeof (result.License) != "undefined" && !result.IsActive) {
+ $rootScope.isVisibleLogin = true;
+ $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
+ $("#messageModal").modal('show');
+ }
}
}
}
@@ -279,14 +270,20 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
$rootScope.UpdateLicenseTermStatus = function () {
$('#dvTermCondition').fadeOut();
var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
- if ($rootScope.licenseeAccountNumber != null) {
+ if (currentUserDetails) {
+ var userInfo = JSON.parse(currentUserDetails);
+ }
+ if (userInfo.License.AccountNumber != null && userInfo.License.Id != 0) {
+ $rootScope.userLicenseInfo.userLicenseId = userInfo.License.Id;
+ $rootScope.userLicenseInfo.licenseeAccountNumber = userInfo.License.AccountNumber;
- AuthenticationService.UpdateLicenseTerm($rootScope.licenseeAccountNumber)
+ AuthenticationService.UpdateLicenseTerm($rootScope.userLicenseInfo)
.then(function (result) {
- if (result === LoginMessageConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) {
+ if (result.Modules !=="" && result.Modules !== null) { // LoginMessageConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) {
console.log(' Term and Condition acceptance status updated successfully.');
if (currentUserDetails) {
var userInfo = JSON.parse(currentUserDetails);
+ userInfo.Modules = result.Modules;
if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
$rootScope.isVisibleLogin = false;