Commit 0abda49b265d15316591b1ab13afbfbfbb7b301d

Authored by Utkarsh Singh
1 parent e59b83bd

Committing restructured code

400-SOURCECODE/AIAHTML5.API/Models/Users.cs
... ... @@ -160,20 +160,29 @@ namespace AIAHTML5.API.Models
160 160 }
161 161 }
162 162  
163   - internal static dynamic UpdateLicenseTerm(string accNumber)
  163 + internal static dynamic UpdateLicenseTerm(Newtonsoft.Json.Linq.JObject userLicenseInfo)
164 164 {
165 165 ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
166   - logger.Debug(" inside UpdateLicenseTerm for AccountNumber = " + accNumber);
  166 + logger.Debug(" inside UpdateLicenseTerm for AccountNumber = " + userLicenseInfo["licenseeAccountNumber"].ToString() + ", LicenseId: " + userLicenseInfo["userLicenseId"].ToString());
167 167 Newtonsoft.Json.Linq.JObject userInfo = new Newtonsoft.Json.Linq.JObject();
168   - userInfo.Add("accountNumber", accNumber);
  168 +
169 169 dynamic result;
  170 + string accountNumber = userLicenseInfo["licenseeAccountNumber"].ToString();
  171 +
  172 + userInfo.Add("accountNumber", accountNumber);
  173 +
170 174 try
171 175 {
172   - result = DBModel.UpdateLicenseTermStatus(accNumber);
  176 + result = DBModel.UpdateLicenseTermStatus(accountNumber);
  177 +
  178 + if (result < 0)
  179 + {
  180 + logger.Fatal("Unable to update LicenseTermAccepted status for AccountNumber =" + accountNumber);
  181 + }
173 182 }
174 183 catch (Exception ex)
175 184 {
176   - logger.Fatal("Exception in UpdateLicenseTerm for AccountNumber =" + accNumber + " Exception= " + ex.Message + ", STACKTRACE: " + ex.StackTrace);
  185 + logger.Fatal("Exception in UpdateLicenseTerm for AccountNumber =" + accountNumber + " Exception= " + ex.Message + ", STACKTRACE: " + ex.StackTrace);
177 186  
178 187 ArrayList supportMailList = UserUtility.GetSupportMailList();
179 188 string mailSubject = "SQL Exception intimation mail";
... ... @@ -247,25 +256,27 @@ namespace AIAHTML5.API.Models
247 256 return false;
248 257 }
249 258  
250   - internal static string SubscriptionExpirationDateString(int licenseId)
  259 + internal static string getLicenseExpirationDate(int licenseId, out bool isLicenseExpired)
251 260 {
  261 + isLicenseExpired = false;
252 262 DBModel objModel = new DBModel();
253 263 LicenseSubscriptionDetails licenseSubscription = objModel.GetLicenseSubscriptionDetailsByLicenseId(licenseId);
254   - string subscritptionExpirationDateString = null;
  264 + string subscritptionExpirationDate = null;
255 265  
256 266 if (licenseSubscription != null)
257 267 {
258 268 DateTime? subscriptionValidThrough = licenseSubscription.SubscriptionValidThrough;
259 269 if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date)
260 270 {
261   - subscritptionExpirationDateString = null;
  271 + isLicenseExpired = false;
262 272 }
263 273 else
264 274 {
265   - subscritptionExpirationDateString = licenseSubscription.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
  275 + isLicenseExpired = true;
  276 + subscritptionExpirationDate = licenseSubscription.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
266 277 }
267 278 }
268   - return subscritptionExpirationDateString;
  279 + return subscritptionExpirationDate;
269 280 }
270 281  
271 282 internal static ArrayList getModuleListByLicenseId(int licenseId)
... ... @@ -286,16 +297,6 @@ namespace AIAHTML5.API.Models
286 297 return result;
287 298 }
288 299  
289   - internal static int insertWrongAttemptofUser(int userId)
290   - {
291   - int result = 0;
292   - DBModel objModel = new DBModel();
293   -
294   - result = objModel.InsertIncorrectLoginAttempts(userId);
295   -
296   - return result;
297   - }
298   -
299 300 internal static int checkNoOfWrongAttempts(int userId)
300 301 {
301 302 int result = 0;
... ... @@ -307,11 +308,19 @@ namespace AIAHTML5.API.Models
307 308 }
308 309  
309 310 internal static int saveWrongAttemptofUser(int userId)
310   - {
  311 + {
  312 + int wrongAttemptCount = Users.checkNoOfWrongAttempts(userId);
311 313 int result = 0;
312 314 DBModel objModel = new DBModel();
313 315  
314   - result = objModel.UpdateIncorrectLoginAttempts(userId);
  316 + if (wrongAttemptCount < 1)
  317 + {
  318 + result = objModel.InsertIncorrectLoginAttempts(userId);
  319 + }
  320 + else
  321 + {
  322 + result = objModel.UpdateIncorrectLoginAttempts(userId);
  323 + }
315 324  
316 325 return result;
317 326 }
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -86,13 +86,16 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
86 86 userMessage: null,
87 87 unblockUser: null
88 88 };
  89 + $rootScope.userLicenseInfo = {
  90 + userLicenseId: 0,
  91 + licenseeAccountNumber: null
  92 + };
89 93 $rootScope.userData;
90 94 $rootScope.userModules;
91 95 $rootScope.passwordMismatchMessage;
92 96 $rootScope.isVisibleLogin;
93 97 $rootScope.haveRoleAdmin;
94 98 $rootScope.checked = false;
95   - $rootScope.licenseeAccountNumber = null;
96 99 var isfilloptionChecked = "";
97 100 var isOutlineOptionChecked = "";
98 101 $rootScope.forgotPwdModalShow = function () {
... ... @@ -130,95 +133,62 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
130 133 .then(
131 134  
132 135 function (result) {
133   - if (result == 'true') {
134   -
135   - $rootScope.userModules = UserModules;
136   - $rootScope.isVisibleLogin = false;
137   - $location.path('/');
138   -
  136 + if (result == LoginConstants.USER_NOT_FOUND) {
  137 + $rootScope.isVisibleLogin = true;
  138 + // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
  139 + $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
  140 + $("#messageModal").modal('show');
  141 + }
  142 + else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) {
  143 + //alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
  144 + $rootScope.isVisibleLogin = true;
  145 + $rootScope.errorMessage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS;
  146 + $("#messageModal").modal('show');
  147 + }
  148 + else if (result == LoginConstants.SQL_CONNECTION_ERROR) {
  149 + $rootScope.isVisibleLogin = true;
  150 + $rootScope.errorMessage = LoginConstants.SQL_CONNECTION_ERROR_MESSAGE;
  151 + $("#messageModal").modal('show');
139 152 }
140 153 else {
141   - if (result == LoginConstants.USER_NOT_FOUND) {
142   - $rootScope.isVisibleLogin = true;
143   - // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
144   - $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
145   - $("#messageModal").modal('show');
146   - }
147   - else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) {
148   - //alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
149   - $rootScope.isVisibleLogin = true;
150   - $rootScope.errorMessage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS;
151   - $("#messageModal").modal('show');
152   - }
153   - else if (result == LoginConstants.SQL_CONNECTION_ERROR) {
154   - $rootScope.isVisibleLogin = true;
155   - $rootScope.errorMessage = LoginConstants.SQL_CONNECTION_ERROR_MESSAGE;
156   - $("#messageModal").modal('show');
157   - }
158   - else {
159   - if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
  154 + if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
160 155  
161   - if ($("#messageModal").length > 0) {
162   - $("#messageModal").modal('hide');
163   - }
164   - if (result == LoginMessageConstants.INVALID_USER) {
  156 + if ($("#messageModal").length > 0) {
  157 + $("#messageModal").modal('hide');
  158 + }
  159 + if (result == LoginMessageConstants.INVALID_USER) {
  160 + $rootScope.isVisibleLogin = true;
  161 + $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
  162 + $("#messageModal").modal('show');
  163 + }
  164 + else if (!result.IsCorrectPassword) {
  165 + if (result.IncorrectLoginAttemptCount < 5) {
165 166 $rootScope.isVisibleLogin = true;
166   - $rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
  167 + $rootScope.errorMessage = LoginMessageConstants.INVALID_PASSWORD;
167 168 $("#messageModal").modal('show');
168 169 }
169   - else if (!result.IsCorrectPassword) {
170   - if (result.IncorrectLoginAttemptCount < 5) {
171   - $rootScope.isVisibleLogin = true;
172   - $rootScope.errorMessage = LoginMessageConstants.INVALID_PASSWORD;
173   - $("#messageModal").modal('show');
174   - }
175   - else {
176   - $rootScope.isVisibleLogin = true;
177   - $rootScope.errorMessage = LoginMessageConstants.USER_BLOCKED;
178   - $("#messageModal").modal('show');
179   - }
180   - }
181 170 else {
182   - if ((!result.IsSubscriptionExpired) && (result.UserType == UserTypeConstants.SUPER_ADMIN) || result.UserType == UserTypeConstants.GENERAL_ADMIN && result.IsActive) {
183   - $rootScope.userData = result;
184   - $rootScope.userModules = result.Modules;
185   - $rootScope.isVisibleLogin = false;
186   - $rootScope.haveRoleAdmin = false;
187   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
188   - $('#dvUserModulesInfo').modal('show');
189   - $location.path('/');
  171 + $rootScope.isVisibleLogin = true;
  172 + $rootScope.errorMessage = LoginMessageConstants.USER_BLOCKED;
  173 + $("#messageModal").modal('show');
  174 + }
  175 + }
  176 + else {
  177 + if (result.UserType == UserTypeConstants.SUPER_ADMIN || result.UserType == UserTypeConstants.GENERAL_ADMIN && result.IsActive) { //(!result.IsSubscriptionExpired) &&
  178 + $rootScope.userData = result;
  179 + $rootScope.userModules = result.Modules;
  180 + $rootScope.isVisibleLogin = false;
  181 + $rootScope.haveRoleAdmin = false;
  182 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  183 + $('#dvUserModulesInfo').modal('show');
  184 + $location.path('/');
190 185  
191   - }
192   - //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) {}
193   -
194   - else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
195   - if (result.UserType == UserTypeConstants.CLIENT_ADMIN || result.UserType == UserTypeConstants.DISTRICT_ADMIN || result.UserType == UserTypeConstants.SINGLE_USER || result.UserType == UserTypeConstants.RESELLER) {
196   - if (result.License.IsTermAccepted) {
197   - $rootScope.userData = result;
198   - $rootScope.userModules = result.Modules;
199   - $rootScope.isVisibleLogin = false;
200   - $rootScope.haveRoleAdmin = true;
201   - $rootScope.licenseeAccountNumber = result.License.AccountNumber;
202   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
203   - $('#dvUserModulesInfo').modal('show');
204   - $location.path('/');
  186 + }
  187 + //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) {}
205 188  
206   - }
207   - else {
208   - if ($('#dvTerms').length > 0) {
209   - $('#dvTerms').html(result.TermsOfServiceText);
210   - }
211   - $rootScope.isVisibleLogin = true;
212   - $('#dvTermCondition').fadeIn();
213   - $rootScope.userData = result;
214   - $rootScope.userModules = result.Modules;
215   - $rootScope.haveRoleAdmin = true;
216   - $rootScope.licenseeAccountNumber = result.License.AccountNumber;
217   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
218   - $location.path('/');
219   - }
220   - }
221   - else {
  189 + else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
  190 + if (result.UserType == UserTypeConstants.CLIENT_ADMIN || result.UserType == UserTypeConstants.DISTRICT_ADMIN || result.UserType == UserTypeConstants.SINGLE_USER || result.UserType == UserTypeConstants.RESELLER) {
  191 + if (result.License.IsTermAccepted) {
222 192 $rootScope.userData = result;
223 193 $rootScope.userModules = result.Modules;
224 194 $rootScope.isVisibleLogin = false;
... ... @@ -226,42 +196,63 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
226 196 localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
227 197 $('#dvUserModulesInfo').modal('show');
228 198 $location.path('/');
  199 +
  200 + }
  201 + else {
  202 + if ($('#dvTerms').length > 0) {
  203 + $('#dvTerms').html(result.TermsOfServiceText);
  204 + }
  205 + $rootScope.isVisibleLogin = true;
  206 + $('#dvTermCondition').fadeIn();
  207 + $rootScope.userData = result;
  208 + $rootScope.haveRoleAdmin = true;
  209 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  210 + $location.path('/');
229 211 }
230 212 }
231   - else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
232   - $rootScope.isVisibleLogin = true;
233   - $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
234   - $("#messageModal").modal('show');
235   - }
236   - else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
237   - $rootScope.isVisibleLogin = true;
238   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
239   - $("#messageModal").modal('show');
240   - }
241   - else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
242   - $rootScope.isVisibleLogin = true;
243   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
244   - $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
245   - $("#messageModal").modal('show');
246   - }
247   - else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && result.IsActive) {
248   - $rootScope.isVisibleLogin = true;
249   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
250   - $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
251   - $("#messageModal").modal('show');
252   - }
253   - else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && !result.IsActive) {
254   - $rootScope.isVisibleLogin = true;
255   - $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDateString + '.';
256   - $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
257   - $("#messageModal").modal('show');
258   - }
259   - else if (typeof(result.License) != "undefined" && !result.IsActive) {
260   - $rootScope.isVisibleLogin = true;
261   - $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
262   - $("#messageModal").modal('show');
  213 + else {
  214 + $rootScope.userData = result;
  215 + $rootScope.userModules = result.Modules;
  216 + $rootScope.isVisibleLogin = false;
  217 + $rootScope.haveRoleAdmin = true;
  218 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  219 + $('#dvUserModulesInfo').modal('show');
  220 + $location.path('/');
263 221 }
264 222 }
  223 + else if ((!result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
  224 + $rootScope.isVisibleLogin = true;
  225 + $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
  226 + $("#messageModal").modal('show');
  227 + }
  228 + else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && result.IsActive) {
  229 + $rootScope.isVisibleLogin = true;
  230 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
  231 + $("#messageModal").modal('show');
  232 + }
  233 + else if ((result.IsSubscriptionExpired) && (result.License != null) && (result.License.IsActive) && !result.IsActive) {
  234 + $rootScope.isVisibleLogin = true;
  235 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
  236 + $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
  237 + $("#messageModal").modal('show');
  238 + }
  239 + else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && result.IsActive) {
  240 + $rootScope.isVisibleLogin = true;
  241 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
  242 + $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
  243 + $("#messageModal").modal('show');
  244 + }
  245 + else if ((result.IsSubscriptionExpired) && (result.License != null) && !(result.License.IsActive) && !result.IsActive) {
  246 + $rootScope.isVisibleLogin = true;
  247 + $rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
  248 + $rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
  249 + $("#messageModal").modal('show');
  250 + }
  251 + else if (typeof (result.License) != "undefined" && !result.IsActive) {
  252 + $rootScope.isVisibleLogin = true;
  253 + $rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
  254 + $("#messageModal").modal('show');
  255 + }
265 256 }
266 257 }
267 258 }
... ... @@ -279,14 +270,20 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
279 270 $rootScope.UpdateLicenseTermStatus = function () {
280 271 $('#dvTermCondition').fadeOut();
281 272 var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
282   - if ($rootScope.licenseeAccountNumber != null) {
  273 + if (currentUserDetails) {
  274 + var userInfo = JSON.parse(currentUserDetails);
  275 + }
  276 + if (userInfo.License.AccountNumber != null && userInfo.License.Id != 0) {
  277 + $rootScope.userLicenseInfo.userLicenseId = userInfo.License.Id;
  278 + $rootScope.userLicenseInfo.licenseeAccountNumber = userInfo.License.AccountNumber;
283 279  
284   - AuthenticationService.UpdateLicenseTerm($rootScope.licenseeAccountNumber)
  280 + AuthenticationService.UpdateLicenseTerm($rootScope.userLicenseInfo)
285 281 .then(function (result) {
286   - if (result === LoginMessageConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) {
  282 + if (result.Modules !=="" && result.Modules !== null) { // LoginMessageConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) {
287 283 console.log(' Term and Condition acceptance status updated successfully.');
288 284 if (currentUserDetails) {
289 285 var userInfo = JSON.parse(currentUserDetails);
  286 + userInfo.Modules = result.Modules;
290 287  
291 288 if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
292 289 $rootScope.isVisibleLogin = false;
... ...