Commit 28a790059316e9b4db6c2295609da71db22cd88e

Authored by Nikita Kulshreshtha
2 parents e8147401 d7c77eb1

Merge branch 'Bug34241+AdminDisable' of http://gitlab.ebix.com/ADAM/AIAHTML5 into Develop

Showing 36 changed files with 3364 additions and 3 deletions
400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs.orig 0 → 100644
  1 +using Newtonsoft.Json;
  2 +using Newtonsoft.Json.Linq;
  3 +using System;
  4 +using System.Collections.Generic;
  5 +using System.Linq;
  6 +using System.Net;
  7 +using System.Net.Http;
  8 +using System.Web.Http;
  9 +using log4net;
  10 +using AIAHTML5.API.Constants;
  11 +using AIAHTML5.API.Models;
  12 +using System.Collections;
  13 +
  14 +<<<<<<< HEAD
  15 +using System.Data.SqlClient;namespace AIAHTML5.API.Controllers
  16 +=======
  17 +using System.Data.SqlClient;
  18 +namespace AIAHTML5.API.Controllers
  19 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  20 +{
  21 + public class AuthenticateController : ApiController
  22 + {
  23 + // GET api/authenticate
  24 + public IEnumerable<string> Get()
  25 + {
  26 + return new string[] { "value1", "value2" };
  27 + }
  28 +
  29 + // GET api/authenticate/5
  30 + public string Get(int id)
  31 + {
  32 + return "value";
  33 + }
  34 +
  35 + // POST api/authenticate
  36 + public HttpResponseMessage Post([FromBody]JObject credentials)
  37 + {
  38 + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
  39 + logger.Debug("inside POST");
  40 +
  41 + dynamic authenticationRepsonse;
  42 + DateTime blockTime;
  43 + bool isUserBlocked;
  44 +
  45 + try
  46 + {
  47 +
  48 + //01.get the user detail to autheticate the user
  49 + User userInfo = AIAHTML5.API.Models.Users.getUserDetails(credentials);
  50 +
  51 + if (userInfo != null)
  52 + {
  53 + // 02 Check user is authenticated or not by login credential match
  54 + bool isUserAuthenticated = AIAHTML5.API.Models.Users.checkUserAuthenticity(credentials, userInfo);
  55 +
  56 + if (isUserAuthenticated)
  57 + {
  58 + if (userInfo.IsActive)
  59 + {
  60 + //03. check if user is blocked
  61 + isUserBlocked = AIAHTML5.API.Models.Users.checkUserBlockStatus(userInfo.Id, out blockTime);
  62 +
  63 + if (!isUserBlocked)
  64 + {
  65 + //04.delete past wrong login attempts of user
  66 + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
  67 + if (wrongAttemptDeteledCount < 0)
  68 + {
  69 + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
  70 + }
  71 + //05.
  72 + GetModulesBasedOnUserType(userInfo);
  73 +
  74 + // authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
  75 + }
  76 +
  77 + else
  78 + {
  79 +
  80 + //compare block time of user with current time if user is blocked
  81 + DateTime blockDuration = blockTime.AddDays(1);
  82 + var difference = DateTime.Compare(DateTime.Now, blockDuration);
  83 +
  84 + //check if credentials are valid credentials
  85 + //bool isCorrectLoginId, isCorrectPassword;
  86 + //AIAHTML5.API.Models.Users.isCredentialCorrect(credentials, userInfo, out isCorrectLoginId, out isCorrectPassword);
  87 +
  88 + if (difference >= 0)
  89 + {
  90 + //means 24 hours block time is finished
  91 + userInfo.IsBlocked = false;
  92 +
  93 + int wrongAttemptDeteledCount = AIAHTML5.API.Models.Users.deletePastWrongAttempts(userInfo.Id);
  94 + if (wrongAttemptDeteledCount < 0)
  95 + {
  96 + logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id);
  97 + }
  98 +
  99 + //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads
  100 + GetModulesBasedOnUserType(userInfo);
  101 +
  102 + }
  103 + else
  104 + {
  105 + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
  106 + }
  107 + }
  108 + }
  109 + else
  110 + {
  111 + //CODE REVIW: validate that is this tarnslated by UI because we need to show message to user if he is inactive
  112 + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_NOT_ACTIVE;
  113 +
  114 + //05.4 check the License expiration irespective of either user is active
  115 + //or not because on AIA, we shows the License expiration message
  116 + //for inactive users too
  117 +
  118 + CheckLicenseStatus(userInfo);
  119 +
  120 + }
  121 + }
  122 +
  123 + else
  124 + {
  125 + //this come in picture when user input wrong passowrd
  126 +
  127 + //get wrong attempt count of user
  128 + int previousIncorrectLoginAttempts = AIAHTML5.API.Models.Users.checkNoOfWrongAttempts(userInfo.Id);
  129 + userInfo.IncorrectLoginAttemptCount = previousIncorrectLoginAttempts + 1;
  130 + userInfo.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH;
  131 +
  132 + //01. insert wrong attempt in dtabase
  133 + int updateCount = AIAHTML5.API.Models.Users.saveWrongAttemptOfUser(userInfo.Id, previousIncorrectLoginAttempts);
  134 +
  135 + if (updateCount < 0)
  136 + {
  137 + //Put the log in log file
  138 + logger.Fatal("Unable to Update past wrong login attempts for userId= " + userInfo.Id);
  139 + }
  140 + //else
  141 + //{
  142 + if (userInfo.IncorrectLoginAttemptCount > 4)
  143 + {
  144 + userInfo.IsBlocked = true;
  145 + userInfo.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
  146 + }
  147 +<<<<<<< HEAD
  148 +
  149 +
  150 + }
  151 +
  152 + authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
  153 +
  154 +=======
  155 +
  156 +
  157 + }
  158 +
  159 + authenticationRepsonse = JsonConvert.SerializeObject(userInfo);
  160 +
  161 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  162 + }
  163 +
  164 + else
  165 + {
  166 + authenticationRepsonse = AIAConstants.USER_NOT_FOUND;
  167 + }
  168 + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(authenticationRepsonse) };
  169 + }
  170 +<<<<<<< HEAD
  171 + catch(SqlException e){
  172 +=======
  173 + catch (SqlException e)
  174 + {
  175 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  176 +
  177 + logger.Fatal("SqlException occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
  178 +
  179 + ArrayList supportMailList = UserUtility.GetSupportMailList();
  180 + string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT;
  181 + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
  182 + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
  183 +
  184 +<<<<<<< HEAD
  185 + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) };
  186 +=======
  187 + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) };
  188 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  189 + }
  190 + catch (Exception e)
  191 + {
  192 +
  193 + logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace);
  194 +
  195 + ArrayList supportMailList = UserUtility.GetSupportMailList();
  196 + string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT;
  197 + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace;
  198 + UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody);
  199 +<<<<<<< HEAD
  200 +
  201 + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) };
  202 +
  203 +=======
  204 +
  205 + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) };
  206 +
  207 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  208 + }
  209 +
  210 + }
  211 +
  212 + private static void GetModulesBasedOnUserType(User userInfo)
  213 + {
  214 + //based on old .net code(AIA flex), we get modules based on licenseId if licenseid>0.
  215 + //we verified in database that only superadmin has no licenseid so getting all modules for supeadmin
  216 + int licenseId, editionId;
  217 + AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
  218 +
  219 + userInfo.LicenseId = licenseId;
  220 + userInfo.EditionId = editionId;
  221 +
  222 + //if (userInfo.UserType == AIAHTML5.API.Models.User.SUPER_ADMIN)
  223 +<<<<<<< HEAD
  224 + if(userInfo.LicenseId == 0)
  225 +=======
  226 + if (userInfo.LicenseId == 0)
  227 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  228 + {
  229 + userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList();
  230 +
  231 + //Insert user login detail
  232 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  233 + }
  234 + else
  235 + {
  236 + CheckLicenseStatus(userInfo);
  237 +
  238 +<<<<<<< HEAD
  239 + if(!userInfo.IsSubscriptionExpired){
  240 + GetModulesBasedOnLicense(userInfo,false);
  241 +=======
  242 + if (!userInfo.IsSubscriptionExpired)
  243 + {
  244 + GetModulesBasedOnLicense(userInfo, false);
  245 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  246 + }
  247 + }
  248 + }
  249 +
  250 + private static void CheckLicenseStatus(User userInfo)
  251 + {
  252 + //05.1 For normal user need to get the license details, get the license id for authenticated user
  253 + //int licenseId, editionId;
  254 + //AIAHTML5.API.Models.Users.getLicenseIdForThisUser(userInfo.Id, out licenseId, out editionId);
  255 +
  256 + //userInfo.LicenseId = licenseId;
  257 + //userInfo.EditionId = editionId;
  258 +
  259 + //05.2 get license details
  260 + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(userInfo.LicenseId);
  261 +
  262 + if (userInfo.LicenseInfo != null)
  263 + {
  264 + //05.3 get licenseSubscription details
  265 + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId);
  266 +
  267 + //05.4 check the License expiration irespective of either user is active or not because on AIA
  268 + //we shows the License expiration message for inactive users too
  269 + string expirationDate = null;
  270 + bool isLicenseExpired = false;
  271 +
  272 + if (userInfo.LicenseSubscriptions != null)
  273 + {
  274 + isLicenseExpired = AIAHTML5.API.Models.Users.checkIfLicenseExpired(userInfo.LicenseSubscriptions, out expirationDate);
  275 + }
  276 +
  277 +<<<<<<< HEAD
  278 + if (isLicenseExpired)
  279 +=======
  280 + if (isLicenseExpired)
  281 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  282 + {
  283 + userInfo.IsSubscriptionExpired = isLicenseExpired;
  284 + userInfo.SubscriptionExpirationDate = expirationDate;
  285 + }
  286 +<<<<<<< HEAD
  287 + }
  288 +
  289 + else
  290 + {
  291 + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
  292 + logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= "+userInfo.LicenseId);
  293 +=======
  294 + else
  295 + {
  296 + //check Modesty settings for this license
  297 +
  298 + userInfo.IsModestyOn = AIAHTML5.API.Models.Users.IsModestyActiveForThisLicense(userInfo.LicenseId);
  299 +
  300 +
  301 + }
  302 + }
  303 +
  304 + else
  305 + {
  306 + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
  307 + logger.Debug("userInfo.LicenseInfo is null for userInfo.LicenseId= " + userInfo.LicenseId);
  308 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  309 + }
  310 + }
  311 +
  312 + private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired)
  313 + {
  314 +<<<<<<< HEAD
  315 +
  316 + //05.6.1
  317 + if (userInfo.LicenseInfo.IsActive)
  318 + {
  319 + if (!userInfo.LicenseInfo.IsTermAccepted)
  320 + {
  321 + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions();
  322 + foreach (Hashtable item in termsList)
  323 + {
  324 + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString();
  325 + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString();
  326 + }
  327 + }
  328 + else
  329 + {
  330 + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
  331 +
  332 + //Insert user login detail
  333 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  334 +=======
  335 +
  336 + //05.6.1
  337 + if (userInfo.LicenseInfo.IsActive)
  338 + {
  339 + if (!userInfo.LicenseInfo.IsTermAccepted)
  340 + {
  341 + ArrayList termsList = AIAHTML5.API.Models.Users.getTermsAndConditions();
  342 + foreach (Hashtable item in termsList)
  343 + {
  344 + userInfo.TermsAndConditionsTitle = item[AIAConstants.KEY_TITLE].ToString();
  345 + userInfo.TermsAndConditionsText = item[AIAConstants.KEY_CONTENT].ToString();
  346 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  347 + }
  348 + }
  349 + else
  350 + {
  351 +<<<<<<< HEAD
  352 + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE;
  353 +
  354 + }
  355 + }
  356 +
  357 +=======
  358 + userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId);
  359 +
  360 + //Insert user login detail
  361 + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id);
  362 + }
  363 + }
  364 + else
  365 + {
  366 + userInfo.LoginFailureCauseId = ErrorHelper.E_LICENCE_IS_INACTIVE;
  367 +
  368 + }
  369 + }
  370 +
  371 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  372 +
  373 +
  374 + // PUT api/authenticate/5
  375 + public void Put(int id, [FromBody]string value)
  376 + {
  377 + }
  378 +
  379 + // DELETE api/authenticate/5
  380 + public void Delete(int id)
  381 + {
  382 + }
  383 + }
  384 +}
0 385 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js.orig 0 → 100644
  1 +AIA.controller("3dAController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile",
  2 +function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile) {
  3 +
  4 +
  5 + $scope.showTabButton = false;
  6 + $scope.threeDAnatomyData;
  7 + $scope.Id;
  8 + $scope.$on('$viewContentLoaded', function (event) {
  9 + var currentURL = $location.path();
  10 + var selectedModuleName = '';
  11 + //set module title
  12 + angular.forEach($rootScope.userModules, function (value, key) {
  13 +<<<<<<< HEAD
  14 + if (value.slug === currentURL.replace('/', '')) {
  15 + selectedModuleName = value.name;
  16 +=======
  17 + // if (value.slug === currentURL.replace('/', '')) {
  18 + if (value.slug === "3d-anatomy-list") {
  19 + selectedModuleName = value.name;
  20 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  21 + }
  22 + $rootScope.currentActiveModuleTitle = selectedModuleName;
  23 + })
  24 + if ($rootScope.refreshcheck == null) {
  25 + $location.path('/');
  26 + }
  27 + $scope.scroll();
  28 + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
  29 + promise.then(
  30 + function (result) {
  31 + $scope.threeDAnatomyData = result;
  32 +
  33 + // $scope.selectedThreeDAdata = $scope.threeDAnatomyData.root.ThreeDAData;
  34 +
  35 + $scope.selectedThreeDAdata = new jinqJs()
  36 + .from($scope.threeDAnatomyData.root.ThreeDAData)
  37 + .orderBy([{ field: '_Title', sort: 'asc' }])
  38 + .select();
  39 +
  40 + // console.log($scope.selectedCIListViewData);
  41 + $('#grid-view').empty();
  42 + angular.forEach($scope.selectedThreeDAdata, function (value, key) {
  43 + $scope.imagePath = "~/../content/images/3da/thumbnails/" + value._ThumbnailImage;
  44 +
  45 + var $el = $('<div id="3dView' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '">'
  46 + + '<div class="thumbnail">'
  47 + + '<img id="' + value._id + '"ng-src="' + $scope.imagePath + '" alt="" title="' + value._Title + '" data-ng-click="Open3DModel($event)" >'
  48 + + '<div class="caption"><p>' + value._Title + '</p></div></div></div>').appendTo('#grid-view');
  49 +
  50 +
  51 + $compile($el)($scope);
  52 +
  53 + $(".sidebar").mCustomScrollbar({
  54 + autoHideScrollbar: true,
  55 + //theme:"rounded"
  56 + });
  57 +
  58 + });
  59 +
  60 + },
  61 + function (error) {
  62 + // handle errors here
  63 + console.log(' $scope.threeDAnatomyData = ' + error.statusText);
  64 + }
  65 + );
  66 +
  67 + });
  68 + $scope.scroll = function () {
  69 + // $window.scrollTo(0, 0);
  70 + $("html,body").scrollTop(0);
  71 + //alert("scroll");
  72 + }
  73 + $scope.IsVisible = function () {
  74 + //$scope.scroll();
  75 +
  76 + $location.url("/3dAnatomy");
  77 +
  78 + }
  79 +
  80 +
  81 + $scope.Open3DModel = function ($event) {
  82 + $rootScope.currentBodyViewId = $event.currentTarget.id;
  83 + if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
  84 + var ThreeDTitle = [];
  85 + ThreeDTitle = new jinqJs()
  86 + .from($scope.selectedThreeDAdata)
  87 + .where('_id = ' + $event.currentTarget.id)
  88 + .select('_Title');
  89 +
  90 + $rootScope.ViewTitle = ThreeDTitle[0]._Title;
  91 + }
  92 + else {
  93 + $rootScope.ViewTitle = $event.currentTarget.textContent;
  94 +
  95 + }
  96 +
  97 +
  98 + localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle);
  99 + localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
  100 +
  101 + var u = $location.url();
  102 + $location.url('/3d-anatomy-details');
  103 +
  104 + }
  105 +
  106 + $scope.Open3DModelBody = function () {
  107 +
  108 + if ($rootScope.refreshcheck == null) {
  109 + $location.path('/');
  110 +
  111 + }
  112 + $rootScope.isLoading = true;
  113 + $('#spinner').css('visibility', 'visible');
  114 + //alert($rootScope.getLocalStorageValue("currentBodyViewId"));
  115 + $scope.voId3D = $rootScope.getLocalStorageValue("currentBodyViewId");
  116 +
  117 + //alert($scope.voId3D);
  118 +
  119 +
  120 + //once you get id in scope push detail in jspanel content
  121 +
  122 + var openViews;
  123 +<<<<<<< HEAD
  124 + if ($rootScope.openViews.length > 0) {
  125 + openViews = new jinqJs()
  126 + .from($rootScope.openViews)
  127 + .where("BodyViewId==" + $scope.voId3D)
  128 + .select();
  129 + }
  130 + var counter = 1;
  131 + var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson");
  132 +
  133 + if (openViews != null && openViews.length > 0) {
  134 + angular.forEach(openViews, function (value, key) {
  135 +
  136 + if (value.body - views == tittle) {
  137 + tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++;
  138 + $rootScope.currentActiveViewTitle = tittle;
  139 + localStorage.setItem("currentViewTitle", tittle);
  140 + }
  141 +
  142 + });
  143 + }
  144 + else {
  145 + localStorage.setItem("currentViewTitle", tittle);
  146 +
  147 + }
  148 +=======
  149 + //if ($rootScope.openViews.length > 0) {
  150 + // openViews = new jinqJs()
  151 + // .from($rootScope.openViews)
  152 + // .where("BodyViewId==" + $scope.voId3D)
  153 + // .select();
  154 + //}
  155 + //var counter = 1;
  156 + var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson");
  157 + $rootScope.currentActiveViewTitle = tittle;
  158 + localStorage.setItem("currentViewTitle", tittle);
  159 + //if (openViews != null && openViews.length > 0) {
  160 + // angular.forEach(openViews, function (value, key) {
  161 +
  162 + // if (value.body - views == tittle) {
  163 + // tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++;
  164 + // $rootScope.currentActiveViewTitle = tittle;
  165 + // localStorage.setItem("currentViewTitle", tittle);
  166 + // }
  167 +
  168 + // });
  169 + //}
  170 + //else {
  171 + // localStorage.setItem("currentViewTitle", tittle);
  172 +
  173 + //}
  174 +>>>>>>> a3f0825d877d83f47a713081fef2e780c2d2c693
  175 +
  176 + // alert($rootScope.getLocalStorageValue("currentViewTitle"));
  177 +
  178 + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
  179 + promise.then(
  180 + function (result) {
  181 + $scope.threeDAnatomyData = result;
  182 +
  183 + var clicked3dAview = [];
  184 + clicked3dAview = new jinqJs().from($scope.threeDAnatomyData.root.ThreeDAData)
  185 + .where('_id == ' + $scope.voId3D)
  186 + .select('_Title', '_3dimagepath');
  187 + $scope.Selected3DImagePath = clicked3dAview[0]._3dimagepath;
  188 + $scope.threeDBodySystemTitle = clicked3dAview[0]._Title;
  189 +
  190 + if (clicked3dAview.length > 0) {
  191 +
  192 + $rootScope.isLoading = false;
  193 + $('#spinner').css('visibility', 'hidden');
  194 +
  195 + $.jsPanel({
  196 + id: '3DImagePanel',
  197 + selector: '.threeDView',
  198 + theme: 'success',
  199 + currentController: '3dAController',
  200 + parentSlug: '3d-anatomy-list',
  201 + content: '<div class="col-sm-12">' +
  202 + '<object data="' + $scope.Selected3DImagePath + '" width="100%" height="800px" type="image/svg+xml"></object>' +
  203 + '</div><script>$(document).ready(function(){var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {var threeDivWidth = $("#ThreeDView").css("width");$("#ThreeDView").css({"left":"0px","width":"100%","min-idth": threeDivWidth}); var jspanelContainerWidth = $(".jsPanel-content").css("width"); $(".jsPanel-content").css({ "width": "100%", "min-width": jspanelContainerWidth}); $("#3DImagePanel").css("width", "100%"); }});</script>',
  204 + title: $rootScope.getLocalStorageValue("currentViewTitle"),
  205 + position: {
  206 + top: 70,
  207 + left: 1,
  208 + },
  209 +
  210 + size: { width: $(window).outerWidth() - 20, height: $(window).outerHeight() - 10 },
  211 +
  212 + });
  213 +
  214 + $rootScope.currentSlug = '3d-anatomy-details';
  215 +
  216 + $rootScope.openViews.push(
  217 + {
  218 + "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
  219 + "slug": $rootScope.currentSlug
  220 + });
  221 +
  222 +
  223 + }
  224 +
  225 +
  226 + },
  227 + function (error) {
  228 + // handle errors here
  229 + console.log(' $scope.CIllustrationData = ' + error.statusText);
  230 + }
  231 +
  232 + );
  233 + $('#ThreeDView').css("height", $(window).outerHeight());
  234 +
  235 + $('#ThreeDView').css("width", $(window).outerWidth());
  236 +
  237 + }
  238 +
  239 +
  240 +
  241 +}]
  242 +
  243 +
  244 +
  245 +);
0 246 \ No newline at end of file
... ...
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -363,8 +363,18 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
363 363 $rootScope.userModules = result.Modules;
364 364  
365 365 //1. set haveRoleAdmin = false because LicenseInfo is not null
366   - $rootScope.haveRoleAdmin = false;
  366 + if (result.LicenseTypeId != 5) {
  367 +
  368 + $rootScope.haveRoleAdmin = true;
  369 +
  370 + }
  371 + if (result.UserTypeId == 8){
  372 +
  373 + $rootScope.haveRoleAdmin = false;
  374 + }
367 375  
  376 + $("#modestyDiv").css("pointer-events", "none");
  377 + $("#modestyDiv").css("opacity", 0.5);
368 378 //2.
369 379 if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
370 380  
... ...
400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html
... ... @@ -51,7 +51,7 @@
51 51 </ul>
52 52 </li>
53 53 <!--redirecting to Admin-->
54   - <li class ="navbarItem"><a ng-click="reDirectURLToAdmin()" style="cursor: pointer;">Admin</a></liclass>
  54 + <li class ="navbarItem"><a ng-click="reDirectURLToAdmin()" ng-show="haveRoleAdmin" style="cursor: pointer;">Admin</a></li>
55 55 </ul>
56 56 <ul class="nav navbar-nav navbar-right">
57 57 <li class="visible-xs"><a href="" ng-click="LogoutUser()">Logout</a></li>
... ...
400-SOURCECODE/AIAHTML5.Web/index.aspx
... ... @@ -577,7 +577,7 @@
577 577 </div>
578 578 </div>
579 579 <div class="">
580   - <div class="col-sm-6">
  580 + <div class="col-sm-6" id="modestyDiv" >
581 581 <h5 class="font13 bolder">Modesty Settings</h5>
582 582 <img src="~/../content/images/common/adam-leaf.png" alt="" class="pull-left marginR5">
583 583 <div class="radio">
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_DeleteLicense.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_DeleteLicense]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_DeleteLicense]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_DeleteLicense]
  6 + @iLicenseId int
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 + BEGIN TRY
  13 + BEGIN TRANSACTION
  14 + DECLARE @iLicenseTypeId TINYINT
  15 + DECLARE @cGetDetail CURSOR
  16 + DECLARE @iSiteId INT
  17 + DECLARE @iUserId INT
  18 + DECLARE @sErrorStatus CHAR(2)
  19 +
  20 + SET @sErrorStatus = 'ok'
  21 + SET @iLicenseTypeId = (SELECT LicenseTypeId FROM License WHERE Id = @iLicenseId)
  22 +
  23 + -- check if license is site license
  24 + IF @iLicenseTypeId = 3
  25 + BEGIN
  26 + -- delete records from tables which store information about building level account
  27 + SET @cGetDetail = CURSOR FAST_FORWARD FOR SELECT SiteId FROM SiteToLicenseEdition WHERE LicenseEditionId IN (SELECT Id FROM LicenseToEdition WHERE LicenseId = @iLicenseId)
  28 + OPEN @cGetDetail
  29 + FETCH NEXT FROM @cGetDetail INTO @iSiteId
  30 + WHILE @@FETCH_STATUS = 0
  31 + BEGIN
  32 + DELETE FROM AIAUserToSite WHERE SiteId = @iSiteId
  33 + DELETE FROM SiteToLicenseEdition WHERE SiteId = @iSiteId
  34 + DELETE FROM Site WHERE Id = @iSiteId
  35 +
  36 + FETCH NEXT FROM @cGetDetail INTO @iSiteId
  37 + END
  38 + CLOSE @cGetDetail
  39 + END
  40 + -- delete records from tables which store information about user
  41 + SET @cGetDetail = CURSOR FAST_FORWARD FOR SELECT Userid FROM AIAUserToLicenseEdition WHERE LicenseEditionId IN (SELECT Id FROM LicenseToEdition WHERE LicenseId = @iLicenseId)
  42 + OPEN @cGetDetail
  43 + FETCH NEXT FROM @cGetDetail INTO @iUserId
  44 + WHILE @@FETCH_STATUS = 0
  45 + BEGIN
  46 + DELETE FROM AIAUserToLicenseEdition WHERE Userid = @iUserId
  47 + DELETE FROM LoginDetail WHERE UserId = @iUserId
  48 + DELETE FROM SessionManager WHERE UserId = @iUserId
  49 + DELETE FROM IncorrectLoginAttempts WHERE UserId = @iUserId
  50 + DELETE FROM UserGroupToAIAUser WHERE UserId = @iUserId
  51 + DELETE FROM AIAUser WHERE Id = @iUserId
  52 +
  53 + FETCH NEXT FROM @cGetDetail INTO @iUserId
  54 + END
  55 + CLOSE @cGetDetail
  56 + -- delete records from tables which store information about the license
  57 + DELETE FROM UserGroup WHERE LicenseId = @iLicenseId
  58 + DELETE FROM LicenseToEdition WHERE LicenseId = @iLicenseId
  59 + DELETE FROM SingleUserDetail WHERE LicenseId = @iLicenseId
  60 + DELETE FROM LicenseSubscriptionDetail WHERE LicenseId = @iLicenseId
  61 + DELETE FROM License WHERE Id = @iLicenseId
  62 +
  63 + COMMIT TRANSACTION
  64 + SELECT @sErrorStatus as SPStatus
  65 + END TRY
  66 + BEGIN CATCH
  67 + IF @@TRANCOUNT > 0
  68 + ROLLBACK TRANSACTION
  69 + SELECT Error_Message() as SPStatus
  70 + END CATCH
  71 +
  72 +END
  73 +
  74 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_EC_GetAccountTypeList.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_EC_GetAccountTypeList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_EC_GetAccountTypeList]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_EC_GetAccountTypeList]
  6 + -- Add the parameters for the stored procedure here
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 +
  13 + -- Insert statements for procedure here
  14 +select Id,Title
  15 +from AccountType where IsActive=1
  16 +
  17 +END
  18 +
  19 +
  20 +
  21 +
  22 +
  23 +
  24 +
  25 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_EC_GetCountryList.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_EC_GetCountryList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_EC_GetCountryList]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_EC_GetCountryList]
  6 + -- Add the parameters for the stored procedure here
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 +
  13 +SELECT Id, CountryName
  14 +FROM Country
  15 +ORDER BY (case CountryCode when 'US' THEN 0 ELSE Id END)
  16 +
  17 +END
  18 +
  19 +
  20 +
  21 +
  22 +
  23 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_EC_GetSecurityQuestionList.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_EC_GetSecurityQuestionList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_EC_GetSecurityQuestionList]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_EC_GetSecurityQuestionList]
  6 + -- Add the parameters for the stored procedure here
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 +
  13 + -- Insert statements for procedure here
  14 +select Id,Title
  15 +from SecurityQuestion
  16 +
  17 +END
  18 +
  19 +
  20 +
  21 +
  22 +
  23 +
  24 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_EC_GetStateList.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_EC_GetStateList]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_EC_GetStateList]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_EC_GetStateList]
  6 + -- Add the parameters for the stored procedure here
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 +
  13 + -- Insert statements for procedure here
  14 +select Id,StateName
  15 +from State
  16 +
  17 +END
  18 +
  19 +
  20 +
  21 +
  22 +
  23 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetBlockedUserByAccNoAndType.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetBlockedUserByAccNoAndType]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetBlockedUserByAccNoAndType]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetBlockedUserByAccNoAndType]
  6 + -- Add the parameters for the stored procedure here
  7 + @iUserTypeId tinyint, @iLicenseId int
  8 +AS
  9 +BEGIN
  10 + -- returns the metadata
  11 + IF 1=0 BEGIN
  12 + SET FMTONLY OFF
  13 + END
  14 + SELECT DISTINCT
  15 + AIAUser.Id,
  16 + AIAUser.FirstName,
  17 + AIAUser.LastName,
  18 + AIAUser.LoginId,
  19 + AIAUser.Password,
  20 + AIAUser.EmailId,
  21 + ISNULL(License.AccountNumber,'') AccountNumber,
  22 + IncorrectLoginAttempts.LoginTime
  23 + FROM
  24 + IncorrectLoginAttempts
  25 + INNER JOIN AIAUser ON IncorrectLoginAttempts.UserId = AIAUser.Id
  26 + INNER JOIN UserType ON AIAUser.UserTypeId = UserType.Id
  27 + LEFT JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId
  28 + LEFT JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
  29 + LEFT JOIN License ON LicenseToEdition.LicenseId = License.Id
  30 + WHERE
  31 + IncorrectLoginAttempts.CntIncorrectLogins >= 5
  32 + AND UserType.Priority >= (SELECT UserType.Priority FROM UserType WHERE UserType.Id=@iUserTypeId)
  33 + AND ((@iLicenseId =0) OR (License.Id = @iLicenseId))
  34 + AND License.IsActive = 1
  35 +END
  36 +
  37 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetCancelledLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetCancelledLicenses]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetCancelledLicenses]
  6 + -- Add the parameters for the stored procedure here
  7 + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint,
  8 + @iAccountTypeId tinyint , @sZip varchar(20) = '', @iStateId int, @iCountryId int,@pageNo int, @pageLength int, @recordCount int out
  9 +AS
  10 +BEGIN
  11 +
  12 + IF 1=0 BEGIN
  13 + SET FMTONLY OFF
  14 + END
  15 + -- SET NOCOUNT ON added to prevent extra result sets from
  16 + SET NOCOUNT ON;
  17 + DECLARE @dtFromDate DATETIME
  18 + DECLARE @dtToDate DATETIME
  19 + DECLARE @cGetLicenseID CURSOR
  20 + DECLARE @iLicenseId INT
  21 + DECLARE @iLicenseSubscriptionDetail INT
  22 + DECLARE @sAccountNumber VARCHAR(50)
  23 + DECLARE @sLicenseeName VARCHAR(100)
  24 + DECLARE @sLicenseType VARCHAR(50)
  25 + DECLARE @sInstitutionName VARCHAR(100)
  26 + DECLARE @dtStartDate DATETIME
  27 + DECLARE @dtEndDate DATETIME
  28 + DECLARE @dtLicenseCreationDate DATETIME
  29 + DECLARE @mSubscriptionPrice MONEY
  30 + DECLARE @sAccountType VARCHAR(50)
  31 + DECLARE @sEdition VARCHAR(200)
  32 + DECLARE @iCardNumber INT
  33 +
  34 +
  35 + -- convert the datatype of fromdate & todate parameter to datetime
  36 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  37 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  38 +
  39 + -- create a temporary table to store the desired results of cancelled licenses on the basis of parameter
  40 + CREATE TABLE #CancelledLicenseReport
  41 + (
  42 + AccountNumber VARCHAR(50),
  43 + LicenseeName VARCHAR(100),
  44 + LicenseType VARCHAR(50),
  45 + InstitutionName VARCHAR(100),
  46 + Edition VARCHAR(200),
  47 + ValidFrom DATETIME,
  48 + ValidThrough DATETIME,
  49 + LicenseCreationDate DATETIME,
  50 + Price MONEY,
  51 + AccountType VARCHAR(50),
  52 + CardNumber INT
  53 + )
  54 +
  55 + -- define the forward only, read-only cursor
  56 + SET @cGetLicenseID = CURSOR FAST_FORWARD
  57 + FOR
  58 + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id)
  59 + FROM LicenseSubscriptionDetail
  60 + INNER JOIN License ON License.Id = LicenseSubscriptionDetail.LicenseId
  61 + WHERE (License.CancellationDate BETWEEN @dtFromDate AND @dtToDate) AND
  62 + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END))
  63 + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END))
  64 + GROUP BY LicenseSubscriptionDetail.LicenseId
  65 + --HAVING (MAX(SubscriptionValidThrough) BETWEEN @dtFromDate AND @dtToDate)
  66 +
  67 + -- open & fetch the cursor variables into the local variables
  68 + OPEN @cGetLicenseID
  69 + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId, @iLicenseSubscriptionDetail
  70 + -- start of while loop
  71 + WHILE @@FETCH_STATUS = 0
  72 + BEGIN
  73 +
  74 + SET @sEdition = ''
  75 + -- fetch the accountnumber, licenseename, licensetype, startdate, enddate, subscriptionprice, accountype of a license
  76 + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = LicenseeName, @sLicenseType = LicenseType,
  77 + @sInstitutionName = InstitutionName,
  78 + @dtStartDate = SubscriptionValidFrom, @dtEndDate = SubscriptionValidThrough,
  79 + @dtLicenseCreationDate = CreationDate,
  80 + @mSubscriptionPrice = TotalAmount, @sAccountType = AccountType, @iCardNumber = CardNumber
  81 + FROM
  82 + (
  83 + SELECT AccountNumber, (LicenseeFirstName+' '+LicenseeLastName) as LicenseeName,
  84 + LicenseType.Title as LicenseType, License.InstitutionName,
  85 + AccountType.Title as AccountType, LicenseSubscriptionDetail.TotalAmount,
  86 + LicenseSubscriptionDetail.SubscriptionValidFrom, LicenseSubscriptionDetail.SubscriptionValidThrough,
  87 + License.CreationDate,
  88 + DATEDIFF(dd,GETDATE(),License.CancellationDate) as DaysRemaining, (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber
  89 + FROM License
  90 + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id
  91 + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id
  92 + INNER JOIN State ON License.StateId = State.Id
  93 + INNER JOIN Country ON License.CountryId = Country.Id
  94 + INNER JOIN LicenseSubscriptionDetail ON License.Id = LicenseSubscriptionDetail.LicenseId
  95 + WHERE License.IsActive = 0
  96 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END)
  97 + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END)
  98 + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END)
  99 + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END)
  100 + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END)
  101 + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail
  102 + AND License.LicenseTypeId <> 5
  103 + ) t1
  104 +
  105 + -- check whether the above query returns any row
  106 + IF @@Rowcount > 0
  107 + BEGIN
  108 + -- fetch all the editions mapped as a string with a license
  109 + SELECT @sEdition = Edition.Title + '; ' + @sEdition
  110 + FROM LicenseToEdition INNER JOIN Edition
  111 + ON LicenseToEdition.EditionId = Edition.Id
  112 + WHERE LicenseToEdition.LicenseId = @iLicenseId
  113 + -- remove the trailing comma-separator from the edition-string
  114 + --AMI SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1);
  115 + IF LEN(@sEdition)> 1
  116 + -- remove the trailing comma-separator from the edition-string
  117 + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1)
  118 + ELSE
  119 + SET @sEdition = @sEdition
  120 +
  121 + -- insert into the temporary table
  122 + INSERT INTO #CancelledLicenseReport
  123 + (AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,ValidFrom,ValidThrough,LicenseCreationDate,Price,AccountType,CardNumber)
  124 + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate,@mSubscriptionPrice,@sAccountType,@iCardNumber)
  125 + END
  126 + -- fetch the next record from cursor
  127 + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId,@iLicenseSubscriptionDetail
  128 + -- end of while loop
  129 + END
  130 + -- close the cursor to free up resources
  131 + CLOSE @cGetLicenseID
  132 + DEALLOCATE @cGetLicenseID
  133 +
  134 + -- Selecting the desired result from temporary table
  135 + --SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate,
  136 + -- CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber
  137 + --FROM #CancelledLicenseReport ORDER BY AccountNumber
  138 +
  139 +
  140 + SELECT RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, StartDate,
  141 + EndDate,LicenseCreationDate,SubscriptionPrice, CardNumber
  142 + from (
  143 + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate,
  144 + CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber
  145 + FROM #CancelledLicenseReport) as Tempt
  146 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo
  147 + ORDER BY AccountNumber
  148 +
  149 + --Calculate total number of records
  150 + select @recordCount = count(ResultTable.AccountNumber)
  151 + from (
  152 + SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate,
  153 + CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber
  154 + FROM #CancelledLicenseReport) as ResultTable
  155 +
  156 +
  157 + -- Dropping the temporary table
  158 + DROP TABLE #CancelledLicenseReport
  159 +END
  160 +
  161 +
  162 +
  163 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetCustomerSummary]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetCustomerSummary]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetCustomerSummary]
  6 + -- Add the parameters for the stored procedure here
  7 + @sAccoutNumber varchar(50)='', @sLicenseeFullName varchar(100)='', @iStartPrice numeric(14,2), @iEndPrice numeric(14,2),
  8 + @iLicenseType tinyint, @iAccountType tinyint, @sZip varchar(20) = '', @iState int,
  9 + @iCountry int,@pageNo int, @pageLength int, @recordCount int out
  10 +AS
  11 +BEGIN
  12 + IF 1=0 BEGIN
  13 + SET FMTONLY OFF
  14 + END
  15 + -- SET NOCOUNT ON added to prevent extra result sets from
  16 + SET NOCOUNT ON
  17 + DECLARE @cGetLicenseDetails CURSOR
  18 + DECLARE @iLicenseId INT
  19 + DECLARE @sAccountNumber VARCHAR(50)
  20 + DECLARE @sLicenseeName VARCHAR(100)
  21 + DECLARE @iLicenseTypeId TINYINT
  22 + DECLARE @sLicenseType VARCHAR(50)
  23 + DECLARE @dtStartDate DATETIME
  24 + DECLARE @dtEndDate DATETIME
  25 + DECLARE @sAccountType VARCHAR(50)
  26 + DECLARE @iAccountTypeId TINYINT
  27 + DECLARE @sLicenseStatus VARCHAR(8)
  28 + DECLARE @sEdition VARCHAR(200)
  29 + DECLARE @bExists bit
  30 + DECLARE @sLicenseState VARCHAR(50)
  31 + DECLARE @sLicenseZip VARCHAR(20)
  32 + DECLARE @sLicenseCountry VARCHAR(50)
  33 + DECLARE @sInstitutionName VARCHAR(100)
  34 + DECLARE @dtLicenseCreationDate DATETIME
  35 + DECLARE @mSubscriptionPrice MONEY
  36 + DECLARE @iLicenseSubscriptionId INT
  37 + DECLARE @sEmailId VARCHAR(100)
  38 + DECLARE @iCardNumber INT
  39 +
  40 + -- create a temporary table to store the desired results of licenses on the basis of parameter
  41 + CREATE TABLE #CustomerReport
  42 + (
  43 + AccountNumber VARCHAR(50),
  44 + LicenseeName VARCHAR(100),
  45 + LicenseType VARCHAR(50),
  46 + Edition VARCHAR(200),
  47 + Email VARCHAR(100),
  48 + ValidFrom DATETIME,
  49 + ValidThrough DATETIME,
  50 + AccountType VARCHAR(50),
  51 + LicenseStatus VARCHAR(8),
  52 + Price MONEY,
  53 + LicenseState VARCHAR(50),
  54 + LicenseZip VARCHAR(20),
  55 + LicenseCountry VARCHAR(50),
  56 + InstitutionName VARCHAR(100),
  57 + LicenseCreationDate DATETIME,
  58 + CardNumber INT
  59 + )
  60 +
  61 + SET @sLicenseeFullName = REPLACE(@sLicenseeFullName,' ',' OR ')
  62 +
  63 + -- define the forward only, read-only cursor
  64 + SET @cGetLicenseDetails = CURSOR FAST_FORWARD
  65 + FOR
  66 + SELECT License.Id, License.AccountNumber, (License.LicenseeFirstName+' '+License.LicenseeLastName),
  67 + License.LicenseTypeId, License.AccountTypeId, License.EmailId,
  68 + (CASE License.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) as LicenseStatus,
  69 + State.StateName, License.Zip, Country.CountryName,
  70 + License.InstitutionName,License.CreationDate,
  71 + (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber
  72 + FROM License WITH (NOLOCK)
  73 + INNER JOIN State WITH (NOLOCK) ON License.StateId = State.Id
  74 + INNER JOIN Country WITH (NOLOCK) ON License.CountryId = Country.Id
  75 + WHERE
  76 + License.AccountNumber = (CASE WHEN LEN(@sAccoutNumber)>0 THEN @sAccoutNumber ELSE License.AccountNumber END)
  77 + AND License.LicenseTypeId = (CASE WHEN @iLicenseType > 0 THEN @iLicenseType ELSE License.LicenseTypeId END)
  78 + AND License.AccountTypeId = (CASE WHEN @iAccountType > 0 THEN @iAccountType ELSE License.AccountTypeId END)
  79 + AND State.Id = (CASE WHEN @iState > 0 THEN @iState ELSE State.Id END)
  80 + AND Country.Id = (CASE WHEN @iCountry > 0 THEN @iCountry ELSE Country.Id END)
  81 + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END)
  82 +
  83 + -- open & fetch the cursor variables into the local variables
  84 + OPEN @cGetLicenseDetails
  85 + FETCH NEXT FROM @cGetLicenseDetails INTO @iLicenseId, @sAccountNumber, @sLicenseeName,
  86 + @iLicenseTypeId, @iAccountTypeId, @sEmailId, @sLicenseStatus, @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName,@dtLicenseCreationDate, @iCardNumber
  87 +
  88 + -- start of while loop
  89 + WHILE @@FETCH_STATUS = 0
  90 + BEGIN
  91 +
  92 + SET @sEdition = ''
  93 + SET @bExists = 1
  94 + -- fetch the latest license start/end date of a license on the basis of Subscription Start & End price if any
  95 + SELECT @dtStartDate = MAX(LicenseSubscriptionDetail.SubscriptionValidFrom),
  96 + @dtEndDate = MAX(LicenseSubscriptionDetail.SubscriptionValidThrough),
  97 + @iLicenseSubscriptionId = MAX(LicenseSubscriptionDetail.Id)
  98 + FROM LicenseSubscriptionDetail WITH (NOLOCK)
  99 + WHERE LicenseSubscriptionDetail.LicenseId = @iLicenseId
  100 + AND (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END))
  101 + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END))
  102 + GROUP BY LicenseSubscriptionDetail.LicenseId
  103 +
  104 +
  105 + -- check whether the above query returns any row
  106 + IF @@Rowcount > 0
  107 + BEGIN
  108 +
  109 + -- check whether the name of licensse matches the name entered by user
  110 +
  111 + IF LEN(@sLicenseeFullName) > 0
  112 + BEGIN
  113 + SELECT @bExists = 1
  114 + FROM License WITH (NOLOCK)
  115 + WHERE Id = @iLicenseId AND (LicenseeFirstName LIKE '%'+@sLicenseeFullName+'%' OR LicenseeLastName LIKE '%'+@sLicenseeFullName+'%') --CONTAINS((LicenseeFirstName,LicenseeLastName)
  116 + IF @@Rowcount = 0
  117 + BEGIN
  118 + SET @bExists = 0
  119 + END
  120 + END
  121 +
  122 + -- check whether the above query returns any row
  123 + IF @bExists = 1
  124 + BEGIN
  125 + -- fetch the licensetype of the license
  126 + SELECT @sLicenseType = LicenseType.Title FROM LicenseType WITH (NOLOCK)
  127 + WHERE LicenseType.Id = @iLicenseTypeId
  128 + -- fetch the accounttype of the license
  129 + SELECT @sAccountType = AccountType.Title FROM AccountType WITH (NOLOCK)
  130 + WHERE AccountType.Id = @iAccountTypeId
  131 +
  132 + -- fetch all the editions mapped as a string with a license
  133 + SELECT @sEdition = Edition.Title + '; ' + @sEdition
  134 + FROM LicenseToEdition WITH (NOLOCK) INNER JOIN Edition WITH (NOLOCK)
  135 + ON LicenseToEdition.EditionId = Edition.Id
  136 + WHERE LicenseToEdition.LicenseId = @iLicenseId
  137 +
  138 + IF LEN(@sEdition)> 1
  139 + -- remove the trailing comma-separator from the edition-string
  140 + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1)
  141 + ELSE
  142 + SET @sEdition = @sEdition
  143 +
  144 + -- fetch the price of the license
  145 + SELECT @mSubscriptionPrice = TotalAmount FROM LicenseSubscriptionDetail WITH (NOLOCK)
  146 + WHERE Id = @iLicenseSubscriptionId
  147 +
  148 + -- insert into the temporary table
  149 + INSERT INTO #CustomerReport
  150 + (AccountNumber, LicenseeName, LicenseType, Edition, Email, ValidFrom, ValidThrough, AccountType, LicenseStatus, Price, LicenseState, LicenseZip, LicenseCountry, InstitutionName, LicenseCreationDate, CardNumber)
  151 + VALUES(@sAccountNumber, @sLicenseeName, @sLicenseType, @sEdition, @sEmailId, @dtStartDate, @dtEndDate, @sAccountType, @sLicenseStatus, @mSubscriptionPrice, @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName,@dtLicenseCreationDate, @iCardNumber)
  152 + END
  153 + END
  154 + -- fetch the next record from cursor
  155 + FETCH NEXT FROM @cGetLicenseDetails INTO @iLicenseId, @sAccountNumber, @sLicenseeName,
  156 + @iLicenseTypeId, @iAccountTypeId, @sEmailId, @sLicenseStatus, @sLicenseState, @sLicenseZip, @sLicenseCountry, @sInstitutionName, @dtLicenseCreationDate, @iCardNumber
  157 + -- end of while loop
  158 + END
  159 + -- close the cursor to free up resources
  160 + CLOSE @cGetLicenseDetails
  161 + DEALLOCATE @cGetLicenseDetails
  162 +
  163 + -- Selecting the desired result from temporary table
  164 + SELECT RowNum, AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, StartDate,
  165 + EndDate, LicenseStatus, Price,
  166 + LicenseZip, LicenseState, LicenseCountry,InstitutionName,LicenseCreationDate , CardNumber
  167 + from (
  168 + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, CONVERT(VARCHAR,ValidFrom,101) as StartDate,
  169 + CONVERT(VARCHAR,ValidThrough,101) as EndDate, LicenseStatus, CONVERT(NUMERIC(14,2),Price) as Price,
  170 + LicenseZip, LicenseState, LicenseCountry,InstitutionName, CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate , CardNumber
  171 + FROM #CustomerReport WITH (NOLOCK) ) as usr
  172 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo
  173 + ORDER BY AccountNumber
  174 +
  175 + --Calculate total number of records
  176 + select @recordCount = count(ResultTable.AccountNumber)
  177 + from (
  178 + SELECT AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, CONVERT(VARCHAR,ValidFrom,101) as StartDate,
  179 + CONVERT(VARCHAR,ValidThrough,101) as EndDate, LicenseStatus, CONVERT(NUMERIC(14,2),Price) as Price,
  180 + LicenseZip, LicenseState, LicenseCountry,InstitutionName, CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate , CardNumber
  181 + FROM #CustomerReport WITH (NOLOCK) ) as ResultTable
  182 +
  183 + -- Dropping the temporary table
  184 + DROP TABLE #CustomerReport
  185 +END
  186 +
  187 +
  188 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountCodes.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetDiscountCodes]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetDiscountCodes]
  3 +GO
  4 +CREATE PROCEDURE [dbo].[usp_GetDiscountCodes]
  5 + -- Add the parameters for the stored procedure here
  6 + @sDiscountCode VARCHAR(255) = '', @sStartDate VARCHAR(20) = '', @sEndDate VARCHAR(20) = '', @pageNo int, @pageLength int, @recordCount int out
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME
  13 +
  14 + -- convert the datatype of startdate & enddate parameter to datetime
  15 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  16 + SELECT @dtEndDate = CONVERT(DATETIME,@sEndDate)
  17 +
  18 + --Get the records on the basis of parameters page length and page number rows
  19 + select LD.Id, LD.DiscountCode, LD.Percentage, LD.StartDate, LD.EndDate, LD.Status
  20 + from
  21 + (Select ROW_NUMBER() OVER (ORDER BY Id) AS RowNo, Id, DiscountCode, Percentage, CONVERT(VARCHAR(10),StartDate,101) as StartDate,
  22 + CONVERT(VARCHAR(10),EndDate,101) as EndDate, (CASE IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS Status
  23 + FROM Discount WHERE StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE StartDate END)
  24 + AND EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE EndDate END)
  25 + AND DiscountCode like (CASE WHEN LEN(@sDiscountCode) > 0 THEN '%' + @sDiscountCode + '%' ELSE DiscountCode END))
  26 + as LD
  27 + where
  28 + RowNo > @pageLength * (@pageNo - 1) AND
  29 + RowNo <= @pageLength * @pageNo
  30 +
  31 +--Calculate total number of records
  32 +select @recordCount = count(ResultTable.Id) from
  33 +(Select Id, DiscountCode, Percentage, CONVERT(VARCHAR(10),StartDate,101) as StartDate,
  34 +CONVERT(VARCHAR(10),EndDate,101) as EndDate, (CASE IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS Status
  35 +FROM Discount WHERE StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE StartDate END)
  36 +AND EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE EndDate END)
  37 +AND DiscountCode like (CASE WHEN LEN(@sDiscountCode) > 0 THEN '%' + @sDiscountCode + '%' ELSE DiscountCode END)) as ResultTable;
  38 +
  39 +END
  40 +
  41 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetDiscountReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetDiscountReport]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetDiscountReport]
  6 + -- Add the parameters for the stored procedure here
  7 + @sStartDate VARCHAR(20) = '', @sEndDate VARCHAR(20) = '', @intDiscountID INT,
  8 + @sAccoutNumber VARCHAR(16)='', @pageNo int, @pageLength int, @recordCount int out
  9 +AS
  10 +BEGIN
  11 +
  12 + IF 1=0 BEGIN
  13 + SET FMTONLY OFF
  14 + END
  15 +
  16 + -- SET NOCOUNT ON added to prevent extra result sets from
  17 + -- interfering with SELECT statements.
  18 + SET NOCOUNT ON;
  19 + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME
  20 +
  21 + -- convert the datatype of startdate & enddate parameter to datetime
  22 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  23 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  24 + IF LEN(@sAccoutNumber) > 0
  25 + BEGIN
  26 +
  27 + Select RowNum, DiscountCode, Percentage, StartDate, EndDate, DiscountStatus, TotalLicenses
  28 + from (
  29 + SELECT ROW_NUMBER() OVER (ORDER BY Discount.StartDate) AS RowNum , Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate,
  30 + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate,
  31 + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus,
  32 + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses
  33 + FROM Discount INNER JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId
  34 + INNER JOIN License ON License.Id = DiscountToLicense.LicenseId
  35 + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END)
  36 + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END)
  37 + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END)
  38 + AND License.AccountNumber = @sAccoutNumber
  39 + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as usr
  40 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by StartDate
  41 +
  42 + --Calculate total number of records
  43 + select @recordCount = count(ResultTable.DiscountCode) from (
  44 + SELECT Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate,
  45 + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate,
  46 + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus,
  47 + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses
  48 + FROM Discount INNER JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId
  49 + INNER JOIN License ON License.Id = DiscountToLicense.LicenseId
  50 + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END)
  51 + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END)
  52 + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END)
  53 + AND License.AccountNumber = @sAccoutNumber
  54 + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as ResultTable;
  55 +
  56 + END
  57 + ELSE
  58 + BEGIN
  59 +
  60 + Select RowNum, DiscountCode, Percentage, StartDate, EndDate, DiscountStatus, TotalLicenses
  61 + from (
  62 + SELECT ROW_NUMBER() OVER (ORDER BY Discount.StartDate) AS RowNum , Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate,
  63 + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate,
  64 + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus,
  65 + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses
  66 + FROM Discount LEFT JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId
  67 + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END)
  68 + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END)
  69 + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END)
  70 + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as usr
  71 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by StartDate
  72 +
  73 + --Calculate total number of records
  74 + select @recordCount = count(ResultTable.DiscountCode) from (
  75 + SELECT Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate,
  76 + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate,
  77 + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus,
  78 + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses
  79 + FROM Discount LEFT JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId
  80 + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END)
  81 + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END)
  82 + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END)
  83 + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as ResultTable;
  84 +
  85 + END
  86 +
  87 +END
  88 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetExpiringLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetExpiringLicenses]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetExpiringLicenses] --'2010-01-01','2020-01-01',0,1,0,0,'',0,0,1,10,0
  6 + -- Add the parameters for the stored procedure here
  7 + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2),
  8 + @iLicenseTypeId int, @iAccountTypeId int, @sZip varchar(20)=null, @iStateId int, @iCountryId int
  9 + ,@pageNo int, @pageLength int, @recordCount int out
  10 +AS
  11 +BEGIN
  12 +
  13 + IF 1=0 BEGIN
  14 + SET FMTONLY OFF
  15 + END
  16 +
  17 + -- SET NOCOUNT ON added to prevent extra result sets from
  18 + SET NOCOUNT ON;
  19 + DECLARE @dtFromDate DATETIME
  20 + DECLARE @dtToDate DATETIME
  21 + DECLARE @cGetLicenseId CURSOR
  22 + DECLARE @iLicenseId INT
  23 + DECLARE @iLicenseSubscriptionDetail INT
  24 + DECLARE @sAccountNumber VARCHAR(50)
  25 + DECLARE @sLicenseeName VARCHAR(100)
  26 + DECLARE @sLicenseType VARCHAR(50)
  27 + DECLARE @sInstitutionName VARCHAR(100)
  28 + DECLARE @dtLicenseCreationDate DATETIME
  29 + DECLARE @dtStartDate DATETIME
  30 + DECLARE @dtEndDate DATETIME
  31 + DECLARE @mSubscriptionPrice MONEY
  32 + DECLARE @sAccountType VARCHAR(50)
  33 + DECLARE @sEdition VARCHAR(200)
  34 + DECLARE @iDaysRemaining INT
  35 + DECLARE @iCardNumber INT
  36 +
  37 + -- convert the datatype of fromdate & todate parameter to datetime
  38 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  39 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  40 +
  41 + -- create a temporary table to store the desired results of license which are going to be expire on the basis of parameter
  42 + CREATE TABLE #ExpiringLicenseReport
  43 + (
  44 + AccountNumber VARCHAR(50),
  45 + LicenseeName VARCHAR(100),
  46 + LicenseType VARCHAR(50),
  47 + InstitutionName VARCHAR(100),
  48 + Edition VARCHAR(200),
  49 + ValidFrom DATETIME,
  50 + ValidThrough DATETIME,
  51 + LicenseCreationDate DATETIME,
  52 + Price MONEY,
  53 + AccountType VARCHAR(50),
  54 + DaysRemaining INT,
  55 + CardNumber INT
  56 + )
  57 +
  58 + -- define the forward only, read-only cursor
  59 + SET @cGetLicenseId = CURSOR FAST_FORWARD
  60 + FOR
  61 + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id)
  62 + FROM LicenseSubscriptionDetail WHERE
  63 + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END))
  64 + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END))
  65 + GROUP BY LicenseSubscriptionDetail.LicenseId
  66 + HAVING (MAX(SubscriptionValidThrough) BETWEEN @dtFromDate AND @dtToDate)
  67 +
  68 + -- open & fetch the cursor variables into the local variables
  69 + OPEN @cGetLicenseId
  70 + FETCH NEXT FROM @cGetLicenseId INTO @iLicenseId, @iLicenseSubscriptionDetail
  71 + -- start of while loop
  72 + WHILE @@FETCH_STATUS = 0
  73 + BEGIN
  74 +
  75 + SET @sEdition = ''
  76 + -- fetch the accountnumber, licenseename, licensetype, startdate, enddate, subscriptionprice, accountype & days remaining to expire for a license
  77 + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = LicenseeName, @sLicenseType = LicenseType,
  78 + @sInstitutionName = InstitutionName, @dtLicenseCreationDate = CreationDate,
  79 + @dtStartDate = SubscriptionValidFrom, @dtEndDate = SubscriptionValidThrough,
  80 + @mSubscriptionPrice = TotalAmount, @sAccountType = AccountType, @iDaysRemaining = DaysRemaining, @iCardNumber = CardNumber
  81 + FROM
  82 + (
  83 + SELECT AccountNumber, (LicenseeFirstName+' '+LicenseeLastName) as LicenseeName,
  84 + LicenseType.Title as LicenseType, AccountType.Title as AccountType,
  85 + License.InstitutionName,License.CreationDate,
  86 + LicenseSubscriptionDetail.TotalAmount,
  87 + LicenseSubscriptionDetail.SubscriptionValidFrom, LicenseSubscriptionDetail.SubscriptionValidThrough,
  88 + DATEDIFF(dd,GETDATE(),LicenseSubscriptionDetail.SubscriptionValidThrough) as DaysRemaining, (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber
  89 + FROM License
  90 + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id
  91 + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id
  92 + INNER JOIN LicenseSubscriptionDetail ON License.Id = LicenseSubscriptionDetail.LicenseId
  93 + INNER JOIN State ON License.StateId = State.Id
  94 + INNER JOIN Country ON License.CountryId = Country.Id
  95 + WHERE License.IsActive = 1
  96 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END)
  97 + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END)
  98 + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END)
  99 + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END)
  100 + AND (@sZip is NULL or License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END))
  101 + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail
  102 + AND License.LicenseTypeId <> 5
  103 + ) t1
  104 + WHERE DaysRemaining>=0
  105 + -- check whether the above query returns any row
  106 + IF @@Rowcount > 0
  107 + BEGIN
  108 + -- fetch all the editions mapped as a string with a license
  109 + SELECT @sEdition = Edition.Title + '; ' + @sEdition
  110 + FROM LicenseToEdition INNER JOIN Edition
  111 + ON LicenseToEdition.EditionId = Edition.Id
  112 + WHERE LicenseToEdition.LicenseId = @iLicenseId
  113 + -- remove the trailing comma-separator from the edition-string
  114 + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1);
  115 +
  116 + -- insert into the temporary table
  117 + INSERT INTO #ExpiringLicenseReport
  118 + (AccountNumber, LicenseeName, LicenseType,InstitutionName, Edition, ValidFrom, ValidThrough,LicenseCreationDate, Price, AccountType, DaysRemaining,CardNumber)
  119 + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate, @mSubscriptionPrice,@sAccountType,@iDaysRemaining,@iCardNumber)
  120 + END
  121 + -- fetch the next record from cursor
  122 + FETCH NEXT FROM @cGetLicenseId INTO @iLicenseId,@iLicenseSubscriptionDetail
  123 + -- end of while loop
  124 + END
  125 + -- close the cursor to free up resources
  126 + CLOSE @cGetLicenseId
  127 + DEALLOCATE @cGetLicenseId
  128 +
  129 + -- Selecting the desired result from temporary table
  130 + --SELECT AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,
  131 + --CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  132 + --CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  133 + --CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, CardNumber
  134 + --FROM #ExpiringLicenseReport ORDER BY AccountNumber
  135 +
  136 +
  137 + SELECT RowNum, AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,
  138 + StartDate,EndDate,LicenseCreationDate,SubscriptionPrice,AccountType,DaysRemaining, CardNumber
  139 + from (
  140 + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,
  141 + CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  142 + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  143 + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, CardNumber
  144 + FROM #ExpiringLicenseReport) as Tempt
  145 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo
  146 + ORDER BY AccountNumber
  147 +
  148 + --Calculate total number of records
  149 + select @recordCount = count(ResultTable.AccountNumber)
  150 + from (
  151 + SELECT AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,
  152 + CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  153 + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  154 + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, CardNumber
  155 + FROM #ExpiringLicenseReport ) as ResultTable
  156 +
  157 + -- Dropping the temporary table
  158 + DROP TABLE #ExpiringLicenseReport
  159 +END
  160 +
  161 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExportedImageDetails.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetExportedImageDetails]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetExportedImageDetails]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetExportedImageDetails]
  6 + @sStartDate varchar(20) = '', @sEndDate varchar(20) = '', @sAccoutNumber varchar(50)='', @pageNo int, @pageLength int, @recordCount int out
  7 +AS
  8 +BEGIN
  9 + -- SET NOCOUNT ON added to prevent extra result sets from
  10 + -- interfering with SELECT statements.
  11 + SET NOCOUNT ON;
  12 +
  13 + Select RowNum, LicenseId, ExportedDate, ImageName, AccountNumber, OriginalFileName, Title, ModuleName, ExportLimit, UserName, imageCount
  14 + from (
  15 + SELECT ROW_NUMBER() OVER (ORDER BY LID.LicenseId) AS RowNum , LID.LicenseId,
  16 + LID.ExportedDate,
  17 + LID.ImageName,
  18 + L.AccountNumber,
  19 + LID.OriginalFileName,
  20 + LID.Title,
  21 + LID.ModuleName,
  22 + (SELECT TOP(1) LSD.NoofImages FROM LicenseSubscriptionDetail LSD WHERE LSD.LicenseId = LID.LicenseId order by LSD.SubscriptionValidFrom desc) as ExportLimit,
  23 + USR.FirstName + ' '+ USR.LastName as UserName,
  24 + (SELECT COUNT(LID1.Id) FROM LicenseImageExportDetail LID1 WHERE LID1.LicenseId = LID.LicenseId group by LID1.LicenseId) as imageCount
  25 + FROM
  26 + LicenseImageExportDetail LID
  27 + LEFT JOIN License L ON LID.LicenseId =L.Id
  28 + INNER JOIN AIAUser USR ON LID.UserId = USR.Id
  29 + WHERE
  30 + ((LEN(@sStartDate)=0) OR (LID.ExportedDate >= (CONVERT(DATETIME,@sStartDate)))) AND
  31 + ((LEN(@sEndDate)=0) OR (LID.ExportedDate <= (DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))))) AND
  32 + ((LEN(@sAccoutNumber)=0) OR (AccountNumber LIKE '%'+@sAccoutNumber+'%'))) as usr
  33 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by LicenseId
  34 +
  35 + --Calculate total number of records
  36 + select @recordCount = count(ResultTable.LicenseId) from (
  37 + SELECT LID.LicenseId,
  38 + LID.ExportedDate,
  39 + LID.ImageName,
  40 + L.AccountNumber,
  41 + LID.OriginalFileName,
  42 + LID.Title,
  43 + LID.ModuleName,
  44 + (SELECT TOP(1) LSD.NoofImages FROM LicenseSubscriptionDetail LSD WHERE LSD.LicenseId = LID.LicenseId order by LSD.SubscriptionValidFrom desc) as ExportLimit,
  45 + USR.FirstName + ' '+ USR.LastName as UserName,
  46 + (SELECT COUNT(LID1.Id) FROM LicenseImageExportDetail LID1 WHERE LID1.LicenseId = LID.LicenseId group by LID1.LicenseId) as imageCount
  47 + FROM
  48 + LicenseImageExportDetail LID
  49 + LEFT JOIN License L ON LID.LicenseId =L.Id
  50 + INNER JOIN AIAUser USR ON LID.UserId = USR.Id
  51 + WHERE
  52 + ((LEN(@sStartDate)=0) OR (LID.ExportedDate >= (CONVERT(DATETIME,@sStartDate)))) AND
  53 + ((LEN(@sEndDate)=0) OR (LID.ExportedDate <= (DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))))) AND
  54 + ((LEN(@sAccoutNumber)=0) OR (AccountNumber LIKE '%'+@sAccoutNumber+'%'))) as ResultTable;
  55 +
  56 +END
  57 +
  58 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetModuleStatusByLicenseId.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetModuleStatusByLicenseId]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetModuleStatusByLicenseId]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetModuleStatusByLicenseId]
  6 + -- Add the parameters for the stored procedure here
  7 + @iLicenseId int
  8 +AS
  9 +BEGIN
  10 + IF 1=0 BEGIN
  11 + SET FMTONLY OFF
  12 + END
  13 + -- SET NOCOUNT ON added to prevent extra result sets from
  14 + -- interfering with SELECT statements.
  15 + SET NOCOUNT ON;
  16 +
  17 + -- Insert statements for procedure here
  18 + SELECT ResourceModule.Id,ResourceModule.Title,ModuleToLicense.Status
  19 + FROM ResourceModule
  20 + INNER JOIN ModuleToLicense ON ResourceModule.Id = ModuleToLicense.ModuleId
  21 + WHERE ModuleToLicense.LicenseId = @iLicenseId
  22 +END
  23 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetNetAdSummaryReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetNetAdSummaryReport]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetNetAdSummaryReport] --'2015-05-01','2018-05-01',0,0,0,1,100,1000
  6 + -- Add the parameters for the stored procedure here
  7 + -- FromDate & ToDate are mandatory
  8 + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint,
  9 + @pageNo int, @pageLength int, @recordCount int out
  10 +AS
  11 +BEGIN
  12 +
  13 + IF 1=0 BEGIN
  14 + SET FMTONLY OFF
  15 + END
  16 +
  17 + -- SET NOCOUNT ON added to prevent extra result sets from
  18 + SET NOCOUNT ON;
  19 + DECLARE @dtFromDate DATETIME
  20 + DECLARE @dtToDate DATETIME
  21 + DECLARE @cGetSummary CURSOR
  22 + DECLARE @iLicenseId INT
  23 + DECLARE @iLicenseSubscriptioId INT
  24 + DECLARE @iActiveSubscription INT
  25 + DECLARE @iRenewSubscription INT
  26 + DECLARE @iCancelSubscription INT
  27 + DECLARE @iNetAdSubscription INT
  28 + DECLARE @sLicenseType VARCHAR(50)
  29 + DECLARE @sInstitutionname VARCHAR(100)
  30 + DECLARE @dtLicenseCreationDate DATETIME
  31 + DECLARE @sAccountType VARCHAR(50)
  32 + DECLARE @IsActive BIT
  33 + DECLARE @sRenew BIT
  34 +
  35 + -- set the default parameters to 0
  36 + SET @iActiveSubscription = 0
  37 + SET @iRenewSubscription = 0
  38 + SET @iCancelSubscription = 0
  39 +
  40 + -- convert the datatype of fromdate & todate parameter to datetime
  41 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  42 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  43 +
  44 + -- create a temporary table to store the first-level of result shown in the netad subscription report on the basis of parameter
  45 + CREATE TABLE #NetAdSummaryReport
  46 + (
  47 + LicenseType VARCHAR(50),
  48 + AccountType VARCHAR(50),
  49 + InstitutionName VARCHAR(100),
  50 + LicenseCreationDate DATETIME,
  51 + IsActive BIT,
  52 + IsRenew BIT
  53 + )
  54 + CREATE CLUSTERED INDEX IK_NetAdSummaryReport_1 ON #NetAdSummaryReport (LicenseType, AccountType)
  55 + CREATE NONCLUSTERED INDEX IK_NetAdSummaryReport_2 ON #NetAdSummaryReport (IsActive)
  56 +
  57 + -- create a temporary table
  58 + CREATE TABLE #NetAdResult
  59 + (
  60 + LicenseType VARCHAR(50),
  61 + AccountType VARCHAR(50),
  62 + InstitutionName VARCHAR(100),
  63 + LicenseCreationDate DATETIME,
  64 + ActiveSubscription INT,
  65 + RenewSubscription INT,
  66 + InActiveSubscription INT,
  67 + NetAdSubscription INT
  68 + )
  69 +
  70 + -- define the forward only, read-only cursor
  71 + SET @cGetSummary = CURSOR FAST_FORWARD
  72 + FOR
  73 + SELECT License.Id, LicenseSubscriptionDetail.Id
  74 + FROM LicenseSubscriptionDetail
  75 + INNER JOIN License ON LicenseSubscriptionDetail.LicenseId = License.Id WHERE
  76 + ((License.CancellationDate BETWEEN @dtFromDate AND @dtToDate AND License.IsActive = 0 )
  77 + OR (License.CreationDate BETWEEN @dtFromDate AND @dtToDate )
  78 + OR (RenewalDate BETWEEN @dtFromDate AND @dtToDate))
  79 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END)
  80 + AND (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END))
  81 + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END))
  82 + AND License.LicenseTypeId <> 5
  83 + GROUP BY License.Id, LicenseSubscriptionDetail.Id
  84 +
  85 +
  86 + -- open & fetch the cursor variables into the local variables
  87 + OPEN @cGetSummary
  88 + FETCH NEXT FROM @cGetSummary INTO @iLicenseId, @iLicenseSubscriptioId
  89 + -- start of while loop
  90 + WHILE @@FETCH_STATUS = 0
  91 + BEGIN
  92 +
  93 + -- fetch the licensetype, accountype & the status of a license
  94 + SELECT @sLicenseType = LicenseType.Title, @sAccountType = AccountType.Title,
  95 + @sInstitutionname = License.InstitutionName, @dtLicenseCreationDate = License.CreationDate,
  96 + @IsActive = License.IsActive,
  97 + @sRenew = (CASE WHEN LicenseSubscriptionDetail.RenewalDate IS NULL THEN 0 ELSE 1 END)
  98 + FROM License
  99 + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id
  100 + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id
  101 + INNER JOIN LicenseSubscriptionDetail ON LicenseSubscriptionDetail.LicenseId = License.Id
  102 + WHERE License.Id = @iLicenseId
  103 + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptioId
  104 +
  105 +
  106 + -- check whether the above query returns any row
  107 + IF @@Rowcount > 0
  108 + BEGIN
  109 +
  110 + IF @IsActive = 1
  111 + BEGIN
  112 + IF @sRenew = 1
  113 + BEGIN
  114 + SET @iRenewSubscription = @iRenewSubscription + 1
  115 + END
  116 + ELSE
  117 + BEGIN
  118 + SET @iActiveSubscription = @iActiveSubscription + 1
  119 + END
  120 + END
  121 + ELSE
  122 + BEGIN
  123 + IF @sRenew = 1
  124 + BEGIN
  125 + SET @iRenewSubscription = @iRenewSubscription + 1
  126 + END
  127 + ELSE
  128 + BEGIN
  129 + SET @iCancelSubscription = @iCancelSubscription + 1
  130 + END
  131 + END
  132 +
  133 + -- insert into the temporary table
  134 + INSERT INTO #NetAdSummaryReport
  135 + (LicenseType,AccountType,InstitutionName,LicenseCreationDate,IsActive,IsRenew)
  136 + VALUES(@sLicenseType,@sAccountType,@sInstitutionname,@dtLicenseCreationDate,@IsActive,@sRenew)
  137 + END
  138 + -- fetch the next record from cursor
  139 + FETCH NEXT FROM @cGetSummary INTO @iLicenseId, @iLicenseSubscriptioId
  140 + -- end of while loop
  141 + END
  142 + -- close the cursor to free up resources
  143 + CLOSE @cGetSummary
  144 + DEALLOCATE @cGetSummary
  145 +
  146 + -- Selecting the desired result from temporary table
  147 + INSERT INTO #NetAdResult (LicenseType, AccountType,InstitutionName,LicenseCreationDate,ActiveSubscription, RenewSubscription, InActiveSubscription,
  148 + NetAdSubscription)
  149 + SELECT LicenseType,AccountType,MAX(InstitutionName) as InstitutionName, MAX(LicenseCreationDate) as LicenseCreationDate,(SELECT COUNT(1) FROM #NetAdSummaryReport
  150 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 1 AND IsRenew = 0) as ActiveSubscription,
  151 + (SELECT COUNT(1) FROM #NetAdSummaryReport
  152 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsRenew = 1) as RenewSubscription,
  153 + (SELECT COUNT(1) FROM #NetAdSummaryReport
  154 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 0 AND IsRenew = 0) as InActiveSubscription,
  155 + ((SELECT COUNT(1) FROM #NetAdSummaryReport
  156 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 1 AND IsRenew = 0) + (SELECT COUNT(1) FROM #NetAdSummaryReport
  157 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsRenew = 1) - (SELECT COUNT(1) FROM #NetAdSummaryReport
  158 + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 0)) as NetAdSubscription
  159 + FROM #NetAdSummaryReport N1 GROUP BY LicenseType,AccountType
  160 +
  161 + -- to show the sum of active, renew, cancel & netad subscriptions
  162 + if((Select COUNT(*) from #NetAdResult)>0)
  163 + begin
  164 + INSERT INTO #NetAdResult (LicenseType,LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription,
  165 + NetAdSubscription) SELECT 'Total','9999-01-01', @iActiveSubscription, @iRenewSubscription, @iCancelSubscription,
  166 + (@iActiveSubscription+@iRenewSubscription-@iCancelSubscription)
  167 + End
  168 +
  169 + Select RowNum, LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription,
  170 + NetAdSubscription
  171 + from (
  172 + SELECT ROW_NUMBER() OVER (ORDER BY LicenseCreationDate Asc) AS RowNum ,LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription,
  173 + NetAdSubscription FROM #NetAdResult) as usr
  174 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by LicenseCreationDate desc
  175 +
  176 + --Calculate total number of records
  177 + select @recordCount = count(ResultTable.NetAdSubscription) from (SELECT LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription,
  178 + NetAdSubscription FROM #NetAdResult) as ResultTable;
  179 +
  180 + -- Dropping the temporary tables
  181 + DROP TABLE #NetAdSummaryReport
  182 + DROP TABLE #NetAdResult
  183 +END
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSearchUsers.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSearchUsers]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetSearchUsers]
  3 +GO
  4 +
  5 +Create PROCEDURE [dbo].[usp_GetSearchUsers]--'','','','',0,0,0,1,10,0
  6 + -- Add the parameters for the stored procedure here
  7 + @sFirstName varchar(100) = '', @sLastName varchar(100) = '', @sEmailId varchar(100) = '',
  8 + @sAccoutNumber varchar(100) ='', @iUserTypeId int, @iAccountTypeId int, @iLoginUserType int,
  9 + @pageNo int, @pageLength int, @recordCount int out
  10 +AS
  11 +BEGIN
  12 + IF 1=0 BEGIN
  13 + SET FMTONLY OFF
  14 + END
  15 +
  16 + DECLARE @SQL NVARCHAR(MAX)
  17 + -- create a temporary table to store the desired results of user on the basis of parameter
  18 + CREATE TABLE #UserResult
  19 + (
  20 + RowNums int IDENTITY PRIMARY KEY,
  21 + Id INT,
  22 + FirstName VARCHAR(100),
  23 + LastName VARCHAR(100),
  24 + LoginId VARCHAR(50),
  25 + EmailId VARCHAR(50),
  26 + UserTypeTitle VARCHAR(50),
  27 + Password VARCHAR(50),
  28 + CreationDate DATETIME,
  29 + ModifiedDate DATETIME,
  30 + AccountNumber VARCHAR(50) DEFAULT '',
  31 + AccountTypeTitle VARCHAR(50) DEFAULT '',
  32 + EditionType VARCHAR(50) DEFAULT '',
  33 + UserStatus VARCHAR(8),
  34 + UserTypeId INT,
  35 + EditionTypeId INT DEFAULT ''
  36 + )
  37 + /*SET @sFirstName = REPLACE(@sFirstName,' ',' OR ')
  38 + SET @sLastName = REPLACE(@sLastName,' ',' OR ')*/
  39 + SET @SQL = ''
  40 + IF LEN(@sAccoutNumber) > 0 OR @iAccountTypeId > 0
  41 + BEGIN
  42 + -- fetch account number, state, zip, country of the license to which the user is belonged
  43 +
  44 + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  45 + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId)
  46 + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,'''') as EmailId,
  47 + UserType.Title as UserTypeTitle, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,'''') as ModifiedDate,
  48 + ISNULL(License.AccountNumber,'''') as AccountNumber, ISNULL(AccountType.Title,'''') as AccountTypeTitle,
  49 + ISNULL(Edition.Title,'''') as EditionType,
  50 + (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END) as UserStatus,
  51 + UserType.Id as UserTypeId, ISNULL(Edition.Id,'''') as EditionTypeId
  52 + FROM AIAUser
  53 + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId
  54 + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId
  55 + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
  56 + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id
  57 + INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId
  58 + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId
  59 + WHERE
  60 + License.IsActive = 1
  61 + AND UserType.Priority >' +CONVERT(VARCHAR(20),@iLoginUserType)
  62 +
  63 + IF LEN(@sAccoutNumber)>0
  64 + BEGIN
  65 + SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+''''
  66 + END
  67 + IF @iAccountTypeId > 0
  68 + BEGIN
  69 + SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+''''
  70 + END
  71 + IF LEN(@sFirstName)>0
  72 + BEGIN
  73 + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')' --CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')'
  74 + END
  75 + IF LEN(@sLastName)>0
  76 + BEGIN
  77 + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')'
  78 + END
  79 + IF LEN(@sEmailId)>0
  80 + BEGIN
  81 + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+''''
  82 + END
  83 + IF @iUserTypeId>0
  84 + BEGIN
  85 + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+''''
  86 + END
  87 + -- select @SQL
  88 + EXEC SP_EXECUTESQL @SQL
  89 +
  90 + END
  91 + ELSE
  92 + BEGIN
  93 +
  94 + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  95 + ModifiedDate, UserStatus, UserTypeId)
  96 + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''),
  97 + AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''), UserType.Title, AIAUser.Password, AIAUser.CreationDate,
  98 + ISNULL(AIAUser.ModifiedDate,''''), (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END),
  99 + UserType.Id
  100 + FROM AIAUser
  101 + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId
  102 + WHERE UserType.Title in (''General Admin'')'
  103 +
  104 + IF LEN(@sFirstName)>0
  105 + BEGIN
  106 + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')'
  107 + END
  108 + IF LEN(@sLastName)>0
  109 + BEGIN
  110 + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')'
  111 + END
  112 + IF LEN(@sEmailId)>0
  113 + BEGIN
  114 + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+''''
  115 + END
  116 + IF @iUserTypeId>0
  117 + BEGIN
  118 + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+''''
  119 + END
  120 + -- select @SQL
  121 + EXEC SP_EXECUTESQL @SQL
  122 +
  123 + -- fetch account number, state, zip, country of the license to which the user is belonged
  124 + SET @SQL = 'INSERT INTO #UserResult (Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  125 + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId)
  126 + SELECT AIAUser.Id, ISNULL(AIAUser.FirstName,''''), ISNULL(AIAUser.LastName,''''), AIAUser.LoginId, ISNULL(AIAUser.EmailId,''''),
  127 + UserType.Title, AIAUser.Password, AIAUser.CreationDate, ISNULL(AIAUser.ModifiedDate,''''),
  128 + License.AccountNumber, AccountType.Title, Edition.Title,
  129 + (CASE AIAUser.IsActive WHEN 1 THEN ''Active'' ELSE ''Inactive'' END), UserType.Id, Edition.Id
  130 + FROM AIAUser
  131 + INNER JOIN UserType ON UserType.Id = AIAUser.UserTypeId
  132 + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId
  133 + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
  134 + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id
  135 + INNER JOIN AccountType ON AccountType.Id = License.AccountTypeId
  136 + INNER JOIN Edition ON Edition.Id = LicenseToEdition.EditionId
  137 + WHERE
  138 + UserType.Title NOT IN (''Super Admin'',''General Admin'')
  139 + AND License.IsActive = 1'
  140 +
  141 + IF LEN(@sAccoutNumber)>0
  142 + BEGIN
  143 + SET @SQL = @SQL + ' AND License.AccountNumber = '''+@sAccoutNumber+''''
  144 + END
  145 + IF @iAccountTypeId > 0
  146 + BEGIN
  147 + SET @SQL = @SQL + ' AND License.AccountTypeId = '''+CONVERT(VARCHAR(20),@iAccountTypeId)+''''
  148 + END
  149 + IF LEN(@sFirstName)>0
  150 + BEGIN
  151 + SET @SQL = @SQL + ' AND (AIAUser.FirstName LIKE ''%'+@sFirstName+'%'')'--CONTAINS(AIAUser.FirstName, '''+@sFirstName+''')'
  152 + END
  153 + IF LEN(@sLastName)>0
  154 + BEGIN
  155 + SET @SQL = @SQL + ' AND (AIAUser.LastName LIKE ''%'+@sLastName+'%'')'--CONTAINS(AIAUser.LastName, '''+@sLastName+''')'
  156 + END
  157 + IF LEN(@sEmailId)>0
  158 + BEGIN
  159 + SET @SQL = @SQL + ' AND AIAUser.EmailId = '''+@sEmailId+''''
  160 + END
  161 + IF @iUserTypeId>0
  162 + BEGIN
  163 + SET @SQL = @SQL + ' AND AIAUser.UserTypeId = '''+CONVERT(VARCHAR(20),@iUserTypeId)+''''
  164 + END
  165 + --select @SQL
  166 + EXEC SP_EXECUTESQL @SQL
  167 +
  168 + END
  169 + -- Selecting the desired result from temporary table
  170 + Select RowNum,Id, FirstName, LastName,LoginId, EmailId,UserTypeTitle, Password, CreationDate,
  171 + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId,EditionTypeId
  172 + from (
  173 + SELECT ROW_NUMBER() OVER (ORDER BY Id) AS RowNum ,Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  174 + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId FROM #UserResult) as usr
  175 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by Id --RowNum BETWEEN @pageNo AND (@pageNo - 1) * @pageLength
  176 +--SELECT RowNum, Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  177 +-- ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId FROM #UserResult
  178 +-- where RowNum > (@pageLength * (@pageNo - 1)) AND (RowNo <= (@pageLength * @pageNo)) order by RowNum
  179 + -- order by Id
  180 + -- order by Id OFFSET ((@pageNo - 1) * @pageLength) ROWS FETCH NEXT @pageLength ROWS ONLY;
  181 +
  182 +
  183 +
  184 + --Calculate total number of records
  185 + select @recordCount = count(ResultTable.Id) from (SELECT Id, FirstName, LastName, LoginId, EmailId, UserTypeTitle, Password, CreationDate,
  186 + ModifiedDate, AccountNumber, AccountTypeTitle, EditionType, UserStatus, UserTypeId, EditionTypeId FROM #UserResult) as ResultTable;
  187 +
  188 + -- Dropping the temporary table
  189 + DROP TABLE #UserResult
  190 +END
  191 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteAccoutDetail.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteAccoutDetail]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetSiteAccoutDetail]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetSiteAccoutDetail]
  6 + -- Add the parameters for the stored procedure here
  7 + @strAccountNumber varchar(50)='', @pageNo int, @pageLength int, @recordCount int out
  8 +
  9 +AS
  10 +BEGIN
  11 + -- SET NOCOUNT ON added to prevent extra result sets from
  12 + -- interfering with SELECT statements.
  13 + SET NOCOUNT ON;
  14 +
  15 + --Get the records on the basis of parameters page length and page number rows
  16 + select LD.Id, LD.SiteIp, LD.Title, LD.SiteIPTo, LD.SiteMasterIPTo, LD.CreationDate, LD.ModifiedDate, LD.InstituteName,
  17 + LD.Department, LD.UserId, LD.FirstName, LD.EmailId
  18 + from
  19 + (Select ROW_NUMBER() OVER (ORDER BY Site.Id) AS RowNo,
  20 + Site.Id,Site.SiteIp,Site.Title,ISNULL(Site.SiteIPTo,'') as SiteIPTo,ISNULL(Site.SiteMasterIPTo,'') as SiteMasterIPTo,
  21 + CONVERT(VARCHAR,Site.CreationDate,101) as CreationDate,
  22 + CONVERT(VARCHAR,Site.ModifiedDate,101) as ModifiedDate,
  23 + Site.InstituteName,Site.Department, AIAUser.Id as UserId,AIAUser.FirstName,AIAUser.EmailId
  24 + From ((Site INNER JOIN AIAUserToSite on Site.Id=AIAUserToSite.SiteId)
  25 + INNER JOIN AIAUser on AIAUserToSite.UserId = AIAUser.Id)
  26 + Where Site.IsActive=1 and Site.id in
  27 + (Select SiteID From SiteToLicenseEdition Where LicenseEditionId in
  28 + (Select Id From LicenseToEdition Where LicenseId in
  29 + (Select Id From License Where LicenseTypeId=3 and AccountNumber=@strAccountNumber))))
  30 + as LD
  31 + where
  32 + RowNo > @pageLength * (@pageNo - 1) AND
  33 + RowNo <= @pageLength * @pageNo
  34 +
  35 + --Calculate total number of records
  36 + select @recordCount = count(ResultTable.Id) from
  37 + (Select Site.Id,Site.SiteIp,Site.Title,ISNULL(Site.SiteIPTo,'') as SiteIPTo,ISNULL(Site.SiteMasterIPTo,'') as SiteMasterIPTo,
  38 + CONVERT(VARCHAR,Site.CreationDate,101) as CreationDate,
  39 + CONVERT(VARCHAR,Site.ModifiedDate,101) as ModifiedDate,
  40 + Site.InstituteName,Site.Department, AIAUser.Id as UserId,AIAUser.FirstName,AIAUser.EmailId
  41 + From ((Site INNER JOIN AIAUserToSite on Site.Id=AIAUserToSite.SiteId)
  42 + INNER JOIN AIAUser on AIAUserToSite.UserId = AIAUser.Id)
  43 + Where Site.IsActive=1 and Site.id in
  44 + (Select SiteID From SiteToLicenseEdition Where LicenseEditionId in
  45 + (Select Id From LicenseToEdition Where LicenseId in
  46 + (Select Id From License Where LicenseTypeId=3 and AccountNumber=@strAccountNumber)))) as ResultTable;
  47 +
  48 +END
  49 +
  50 +
  51 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteLicenseUsageReports]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetSiteLicenseUsageReports]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetSiteLicenseUsageReports]
  6 + -- Add the parameters for the stored procedure here
  7 + @sFromDate varchar(20), @sToDate varchar(20), @sAccoutNumber varchar(50)='', @iEditionId tinyint = 0,
  8 + @pageNo int, @pageLength int, @recordCount int out
  9 +AS
  10 +BEGIN
  11 + IF 1=0 BEGIN
  12 + SET FMTONLY OFF
  13 + END
  14 + -- SET NOCOUNT ON added to prevent extra result sets from
  15 + SET NOCOUNT ON
  16 + DECLARE @dtFromDate DATETIME
  17 + DECLARE @dtToDate DATETIME
  18 +
  19 + -- convert the datatype of fromdate & todate parameter to datetime
  20 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  21 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  22 +
  23 + Select RowNum,AccountNumber, EditionTitle, ReferalUrl, InstitutionName, LicenseCreationDate,TotalLogins,LastLogin
  24 + from (
  25 + SELECT ROW_NUMBER() OVER (ORDER BY UserLoginLog.AccountNumber) AS RowNum , UserLoginLog.AccountNumber, Edition.Title AS EditionTitle, UserLoginLog.ReferalUrl,
  26 + (SELECT License.InstitutionName FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as InstitutionName,
  27 + (SELECT CONVERT(VARCHAR,License.CreationDate,101) FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as LicenseCreationDate,
  28 + COUNT(DISTINCT UserLoginLog.LogDate) AS TotalLogins,
  29 + CONVERT(VARCHAR,MAX(UserLoginLog.LogDate),101) AS LastLogin FROM
  30 + UserLoginLog INNER JOIN Edition ON UserLoginLog.Edition = CAST(Edition.Id AS NVARCHAR)
  31 + WHERE UserLoginLog.FailureId IS NULL
  32 + AND UserLoginLog.LogDate BETWEEN @dtFromDate AND @dtToDate
  33 + AND UserLoginLog.AccountNumber = (CASE WHEN LEN(@sAccoutNumber) > 0 THEN @sAccoutNumber ELSE UserLoginLog.AccountNumber END)
  34 + AND Edition.IsActive = 1
  35 + AND Edition.Id = (CASE WHEN @iEditionId > 0 THEN @iEditionId ELSE Edition.Id END)
  36 + GROUP BY UserLoginLog.AccountNumber, Edition.Title, UserLoginLog.ReferalUrl) as usr
  37 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by AccountNumber
  38 +
  39 +
  40 + --Calculate total number of records
  41 + select @recordCount = count(ResultTable.AccountNumber) from (
  42 + SELECT UserLoginLog.AccountNumber, Edition.Title AS EditionTitle, UserLoginLog.ReferalUrl,
  43 + (SELECT License.InstitutionName FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as InstitutionName,
  44 + (SELECT CONVERT(VARCHAR,License.CreationDate,101) FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as LicenseCreationDate,
  45 + COUNT(DISTINCT UserLoginLog.LogDate) AS TotalLogins,
  46 + CONVERT(VARCHAR,MAX(UserLoginLog.LogDate),101) AS LastLogin FROM
  47 + UserLoginLog INNER JOIN Edition ON UserLoginLog.Edition = CAST(Edition.Id AS NVARCHAR)
  48 + WHERE UserLoginLog.FailureId IS NULL
  49 + AND UserLoginLog.LogDate BETWEEN @dtFromDate AND @dtToDate
  50 + AND UserLoginLog.AccountNumber = (CASE WHEN LEN(@sAccoutNumber) > 0 THEN @sAccoutNumber ELSE UserLoginLog.AccountNumber END)
  51 + AND Edition.IsActive = 1
  52 + AND Edition.Id = (CASE WHEN @iEditionId > 0 THEN @iEditionId ELSE Edition.Id END)
  53 + GROUP BY UserLoginLog.AccountNumber, Edition.Title, UserLoginLog.ReferalUrl) as ResultTable;
  54 +
  55 +END
  56 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSubscribedLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetSubscribedLicenses]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetSubscribedLicenses]
  6 + -- Add the parameters for the stored procedure here
  7 + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint,
  8 + @iAccountTypeId tinyint, @sZip varchar(20) = '', @iStateId int, @iCountryId int,@pageNo int, @pageLength int, @recordCount int out
  9 +AS
  10 +BEGIN
  11 + IF 1=0 BEGIN
  12 + SET FMTONLY OFF
  13 + END
  14 + -- SET NOCOUNT ON added to prevent extra result sets from
  15 + SET NOCOUNT ON;
  16 + DECLARE @dtFromDate DATETIME
  17 + DECLARE @dtToDate DATETIME
  18 + DECLARE @cGetLicenseID CURSOR
  19 + DECLARE @iLicenseId INT
  20 + DECLARE @iLicenseSubscriptionDetail INT
  21 + DECLARE @sAccountNumber VARCHAR(50)
  22 + DECLARE @sLicenseeName VARCHAR(100)
  23 + DECLARE @sLicenseType VARCHAR(50)
  24 + DECLARE @sInstitutionName VARCHAR(100)
  25 + DECLARE @dtStartDate DATETIME
  26 + DECLARE @dtEndDate DATETIME
  27 + DECLARE @dtLicenseCreationDate DATETIME
  28 + DECLARE @mSubscriptionPrice MONEY
  29 + DECLARE @sAccountType VARCHAR(50)
  30 + DECLARE @sEdition VARCHAR(200)
  31 + DECLARE @iCardNumber INT
  32 +
  33 +
  34 + -- convert the datatype of fromdate & todate parameter to datetime
  35 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  36 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  37 +
  38 + -- create a temporary table to store the desired results of subscribed licenses on the basis of parameter
  39 + CREATE TABLE #SubscribedLicenseReport
  40 + (
  41 + AccountNumber VARCHAR(50),
  42 + LicenseeName VARCHAR(100),
  43 + LicenseType VARCHAR(50),
  44 + InstitutionName VARCHAR(100),
  45 + Edition VARCHAR(200),
  46 + ValidFrom DATETIME,
  47 + ValidThrough DATETIME,
  48 + LicenseCreationDate DATETIME,
  49 + Price MONEY,
  50 + AccountType varchar(50),
  51 + CardNumber INT
  52 + )
  53 +
  54 + -- define the forward only, read-only cursor
  55 + SET @cGetLicenseID = CURSOR FAST_FORWARD
  56 + FOR
  57 + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id)
  58 + FROM LicenseSubscriptionDetail WHERE
  59 + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END))
  60 + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END))
  61 + GROUP BY LicenseSubscriptionDetail.LicenseId
  62 + HAVING (MAX(SubscriptionValidFrom) BETWEEN @dtFromDate AND @dtToDate)
  63 +
  64 + -- open & fetch the cursor variables into the local variables
  65 + OPEN @cGetLicenseID
  66 + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId, @iLicenseSubscriptionDetail
  67 + -- start of while loop
  68 + WHILE @@FETCH_STATUS = 0
  69 + BEGIN
  70 +
  71 + SET @sEdition = ''
  72 +
  73 + -- fetch the accountnumber, licenseename, licensetype, accountype of a license
  74 + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = (LicenseeFirstName+' '+LicenseeLastName),
  75 + @sLicenseType = LicenseType.Title, @sAccountType = AccountType.Title,
  76 + @iCardNumber = (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END),
  77 + @sInstitutionName = License.InstitutionName,@dtLicenseCreationDate = License.CreationDate
  78 + FROM License
  79 + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id
  80 + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id
  81 + INNER JOIN State ON License.StateId = State.Id
  82 + INNER JOIN Country ON License.CountryId = Country.Id
  83 + WHERE License.Id = @iLicenseId AND License.IsActive = 1
  84 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END)
  85 + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END)
  86 + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END)
  87 + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END)
  88 + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END)
  89 + AND License.LicenseTypeId <> 5
  90 +
  91 + -- check whether the above query returns any row
  92 + IF @@Rowcount > 0
  93 + BEGIN
  94 + -- fetch startdate, enddate, subscriptionprice of a license
  95 + SELECT @mSubscriptionPrice = LicenseSubscriptionDetail.TotalAmount,
  96 + @dtStartDate = LicenseSubscriptionDetail.SubscriptionValidFrom,
  97 + @dtEndDate = LicenseSubscriptionDetail.SubscriptionValidThrough
  98 + FROM LicenseSubscriptionDetail
  99 + WHERE LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail
  100 +
  101 + -- fetch all the editions mapped as a string with a license
  102 + SELECT @sEdition = Edition.Title + '; ' + @sEdition
  103 + FROM LicenseToEdition INNER JOIN Edition
  104 + ON LicenseToEdition.EditionId = Edition.Id
  105 + WHERE LicenseToEdition.LicenseId = @iLicenseId
  106 + -- remove the trailing comma-separator from the edition-string
  107 + -- AMI SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1);
  108 + IF LEN(@sEdition)> 1
  109 + -- remove the trailing comma-separator from the edition-string
  110 + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1)
  111 + ELSE
  112 + SET @sEdition = @sEdition
  113 +
  114 + -- insert into the temporary table
  115 + INSERT INTO #SubscribedLicenseReport
  116 + (AccountNumber, LicenseeName, LicenseType, InstitutionName, Edition, ValidFrom, ValidThrough,LicenseCreationDate, Price, AccountType,CardNumber)
  117 + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate,@mSubscriptionPrice,@sAccountType,@iCardNumber)
  118 + END
  119 + -- fetch the next record from cursor
  120 + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId,@iLicenseSubscriptionDetail
  121 + -- end of while loop
  122 + END
  123 + -- close the cursor to free up resources
  124 + CLOSE @cGetLicenseID
  125 + DEALLOCATE @cGetLicenseID
  126 +
  127 + -- Selecting the desired result from temporary table
  128 + --SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition,
  129 + --CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  130 + --CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  131 + --CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,CardNumber
  132 + --FROM #SubscribedLicenseReport ORDER BY AccountNumber
  133 +
  134 +
  135 + SELECT RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition,
  136 + StartDate, EndDate,
  137 + LicenseCreationDate,
  138 + SubscriptionPrice,CardNumber
  139 + from (
  140 + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition,
  141 + CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  142 + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  143 + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,CardNumber
  144 + FROM #SubscribedLicenseReport) as Tempt
  145 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo
  146 + ORDER BY AccountNumber
  147 +
  148 + select @recordCount = count(ResultTable.AccountNumber)
  149 + from (
  150 + SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition,
  151 + CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate,
  152 + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate,
  153 + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,CardNumber
  154 + FROM #SubscribedLicenseReport) as ResultTable
  155 +
  156 + -- Dropping the temporary table
  157 + DROP TABLE #SubscribedLicenseReport
  158 +END
  159 +
  160 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetUsageReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetUsageReport]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetUsageReport]
  6 + -- Add the parameters for the stored procedure here
  7 + -- FromDate & ToDate are mandatory parameters
  8 + @sFromDate varchar(20), @sToDate varchar(20), @sAccoutNumber varchar(50)='',
  9 + @sZip varchar(20) = '', @iState int, @iCountry int,
  10 + @pageNo int, @pageLength int, @recordCount int out
  11 +AS
  12 +BEGIN
  13 + IF 1=0 BEGIN
  14 + SET FMTONLY OFF
  15 + END
  16 + -- SET NOCOUNT ON added to prevent extra result sets from
  17 + SET NOCOUNT ON
  18 + DECLARE @cGetUserDetails CURSOR
  19 + DECLARE @iUserId INT
  20 + DECLARE @sAccountNumber VARCHAR(50)
  21 + DECLARE @iCardNumber INT
  22 + DECLARE @sLoginId VARCHAR(50)
  23 + DECLARE @sFirstName VARCHAR(100)
  24 + DECLARE @sLastName VARCHAR(100)
  25 + DECLARE @sUserType VARCHAR(50)
  26 + DECLARE @dtFromDate DATETIME
  27 + DECLARE @dtToDate DATETIME
  28 + DECLARE @dtLicenseCreationDate DATETIME
  29 + DECLARE @sLicenseState VARCHAR(50)
  30 + DECLARE @sLicenseZip VARCHAR(20)
  31 + DECLARE @sLicenseCountry VARCHAR(50)
  32 + DECLARE @sInstitutionName VARCHAR(100)
  33 + DECLARE @iTotalLogins INT
  34 + DECLARE @dtLastLogin DATETIME
  35 +
  36 + -- convert the datatype of fromdate & todate parameter to datetime
  37 + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate)
  38 + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate)))
  39 +
  40 + -- create a temporary table to store the results of users logged into the system within a particular time period
  41 + CREATE TABLE #UsageReport
  42 + (
  43 + LoginId VARCHAR(50),
  44 + FirstName VARCHAR(100),
  45 + LastName VARCHAR(100),
  46 + AccountNumber VARCHAR(50),
  47 + CardNumber INT,
  48 + UserType VARCHAR(50),
  49 + LicenseCreationDate DATETIME,
  50 + LicenseState VARCHAR(50),
  51 + LicenseZip VARCHAR(20),
  52 + LicenseCountry VARCHAR(50),
  53 + InstitutionName VARCHAR(100),
  54 + TotalLogins INT,
  55 + LastLoginDate DATETIME
  56 + )
  57 +
  58 + -- define the forward only, read-only cursor
  59 + SET @cGetUserDetails = CURSOR FAST_FORWARD
  60 + FOR
  61 + SELECT LoginDetail.UserId, COUNT(1) as TotalLogins, MAX(LoginDetail.LoginTime)
  62 + FROM LoginDetail WHERE
  63 + (LoginTime) BETWEEN @dtFromDate AND @dtToDate
  64 + GROUP BY LoginDetail.UserId
  65 +
  66 + -- open & fetch the cursor variables into the local variables
  67 + OPEN @cGetUserDetails
  68 + FETCH NEXT FROM @cGetUserDetails INTO @iUserId, @iTotalLogins, @dtLastLogin
  69 + -- start of while loop
  70 + WHILE @@FETCH_STATUS = 0
  71 + BEGIN
  72 + -- fetch account number, state, zip, country of the license to which the user is belonged
  73 + SELECT @sAccountNumber = License.AccountNumber,
  74 + @dtLicenseCreationDate = License.CreationDate,
  75 + @sInstitutionName = License.InstitutionName,
  76 + @sLicenseState = State.StateName,
  77 + @sLicenseZip = License.Zip,
  78 + @sLicenseCountry = Country.CountryName,
  79 + @iCardNumber = (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END)
  80 + FROM AIAUserToLicenseEdition
  81 + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
  82 + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id
  83 + INNER JOIN State ON License.StateId = State.Id
  84 + INNER JOIN Country ON License.CountryId = Country.Id
  85 + WHERE AIAUserToLicenseEdition.UserId = @iUserId
  86 + AND License.IsActive = 1
  87 + AND License.AccountNumber = (CASE WHEN LEN(@sAccoutNumber)>0 THEN @sAccoutNumber ELSE License.AccountNumber END)
  88 + AND State.Id = (CASE WHEN @iState > 0 THEN @iState ELSE State.Id END)
  89 + AND Country.Id = (CASE WHEN @iCountry > 0 THEN @iCountry ELSE Country.Id END)
  90 + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END)
  91 + --AND License.LicenseTypeId <> 5
  92 + --AND License.Country = (CASE WHEN LEN(@sCountry)>0 THEN @sCountry ELSE License.Country END)
  93 +
  94 + -- check whether the above query returns any row
  95 + IF @@Rowcount > 0
  96 + BEGIN
  97 + -- fetch loginid, firstname, lastname, usertype of the user
  98 + SELECT @sLoginId = AIAUser.LoginId, @sFirstName = AIAUser.Firstname,
  99 + @sLastName = AIAUser.LastName, @sUserType = UserType.Title
  100 + FROM AIAUser
  101 + INNER JOIN UserType ON AIAUser.UserTypeId = UserType.Id
  102 + WHERE AIAUser.Id = @iUserId
  103 + AND AIAUser.IsActive = 1
  104 +
  105 + IF @@Rowcount > 0
  106 + BEGIN
  107 + -- insert into the temporary table
  108 + INSERT INTO #UsageReport
  109 + (LoginId, FirstName, LastName, AccountNumber,CardNumber ,UserType,LicenseCreationDate, LicenseState, LicenseZip,
  110 + LicenseCountry,InstitutionName, TotalLogins, LastLoginDate)
  111 + VALUES(@sLoginId, @sFirstName, @sLastName, @sAccountNumber, @iCardNumber, @sUserType,@dtLicenseCreationDate,
  112 + @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName, @iTotalLogins, @dtLastLogin)
  113 + END
  114 + END
  115 + -- fetch the next record from cursor
  116 + FETCH NEXT FROM @cGetUserDetails INTO @iUserId, @iTotalLogins, @dtLastLogin
  117 + -- end of while loop
  118 + END
  119 + -- close the cursor to free up resources
  120 + CLOSE @cGetUserDetails
  121 + DEALLOCATE @cGetUserDetails
  122 +
  123 + -- Selecting the desired result from temporary table
  124 + --SELECT LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState,
  125 + --LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport ORDER BY AccountNumber
  126 +
  127 + Select RowNum,LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState,
  128 + LicenseCountry,InstitutionName, TotalLogins, LastLogin
  129 + from (
  130 + SELECT ROW_NUMBER() OVER (ORDER BY LoginId) AS RowNum ,LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState,
  131 + LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport) as usr
  132 + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by AccountNumber
  133 +
  134 +
  135 + --Calculate total number of records
  136 + select @recordCount = count(ResultTable.LoginId) from (SELECT LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState,
  137 + LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport) as ResultTable;
  138 + -- Dropping the temporary table
  139 + DROP TABLE #UsageReport
  140 +END
  141 +
  142 +
  143 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUserTyeByAccountNumber.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetUserTyeByAccountNumber]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_GetUserTyeByAccountNumber]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_GetUserTyeByAccountNumber]
  6 + -- Add the parameters for the stored procedure here
  7 + @iUserTypeId tinyint, @iLicenseId int
  8 +AS
  9 +BEGIN
  10 + -- returns the metadata
  11 + IF 1=0 BEGIN
  12 + SET FMTONLY OFF
  13 + END
  14 + -- SET NOCOUNT ON added to prevent extra result sets from
  15 + -- interfering with SELECT statements.
  16 + SET NOCOUNT ON;
  17 + DECLARE @sUserType varchar(50)
  18 + DECLARE @sLicenseType varchar(50)
  19 + -- create a temporary table to store the usertype according to the role and accountnumber
  20 + CREATE TABLE #UserTypeToAccountNumber
  21 + (
  22 + Id tinyint,
  23 + Title varchar(50)
  24 + )
  25 +
  26 + --SELECT @sUserType = Title FROM UserType WHERE Id = @iUserTypeId
  27 +
  28 + IF @iLicenseId = 0
  29 + BEGIN
  30 + IF @iUserTypeId = 1
  31 + BEGIN
  32 + INSERT INTO #UserTypeToAccountNumber SELECT Id, Title FROM UserType WHERE Title = 'General Admin' AND IsActive = 1
  33 + END
  34 + END
  35 + ELSE
  36 + BEGIN
  37 + SELECT @sLicenseType = LicenseType.Title FROM License INNER JOIN LicenseType ON LicenseType.Id = License.LicenseTypeId
  38 + WHERE License.Id = @iLicenseId
  39 + IF @sLicenseType = 'Site License'
  40 + BEGIN
  41 + INSERT INTO #UserTypeToAccountNumber SELECT Id, Title FROM UserType WHERE Title IN ('Client Admin', 'District Admin')
  42 + END
  43 + ELSE IF @sLicenseType = 'Concurrent License'
  44 + BEGIN
  45 + INSERT INTO #UserTypeToAccountNumber SELECT Id, Title FROM UserType WHERE Title IN ('Client Admin', 'Concurrent User') ORDER BY Priority ASC
  46 + END
  47 + END
  48 + SELECT Id,Title FROM #UserTypeToAccountNumber
  49 + -- Dropping the temporary table
  50 + DROP TABLE #UserTypeToAccountNumber
  51 +END
  52 +
  53 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_InsertAIAUser.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertAIAUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_InsertAIAUser]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_InsertAIAUser]
  6 + -- Add the parameters for the stored procedure here
  7 + @sLoginId varchar(50), @sPassword varchar(50), @sFirstname varchar(50), @sLastname varchar(50),
  8 + @iUserTypeId tinyint, @sEmailId varchar(50), @iSecurityQuesId tinyint, @sSecurityAnswer varchar(50)='',
  9 + @iCreatorId int, @iLicenseId int, @iEditionId tinyint,@Status int out
  10 +AS
  11 +BEGIN
  12 +
  13 + -- SET NOCOUNT ON added to prevent extra result sets from
  14 + -- interfering with SELECT statements.
  15 + SET NOCOUNT ON;
  16 +
  17 + BEGIN TRY
  18 + BEGIN TRANSACTION
  19 + DECLARE @iLicenseEditionId int
  20 +
  21 + DECLARE @iAIAUserId int
  22 + DECLARE @iActive tinyint
  23 + DECLARE @dtCurrentDate datetime
  24 + DECLARE @sErrorStatus char(2)
  25 + DECLARE @sInvalidLicenseToEdition varchar(100)
  26 + -- to store the user type id of general admin
  27 + DECLARE @iGAUserTypeId tinyint
  28 + -- to store the role id of general admin
  29 + DECLARE @iGARoleId tinyint
  30 + set @Status = 0;
  31 + -- set the parameters to default values
  32 + SET @iActive = 1
  33 + SET @dtCurrentDate = getdate()
  34 + SET @sErrorStatus = 'oks'
  35 + SET @sInvalidLicenseToEdition = 'Edition does not exists for this license.'
  36 +
  37 + -- fetch the usertype id of the general admin
  38 + SELECT @iGAUserTypeId = Id FROM UserType WHERE Title = 'General Admin'
  39 + -- fetch the role id of the general admin
  40 + SELECT @iGARoleId = Id FROM Role WHERE Title = 'General Admin Role'
  41 +
  42 + IF @iSecurityQuesId = 0
  43 + BEGIN
  44 + SET @iSecurityQuesId = NULL
  45 + END
  46 + IF LEN(@sSecurityAnswer) = 0
  47 + BEGIN
  48 + SET @sSecurityAnswer = NULL
  49 + END
  50 + -- insert the user detail in AIAUser
  51 + if (Select count(*) from AIAUser Where LoginId=@sLoginId)>0
  52 + begin
  53 + set @Status=1 -- UserName Already Exist
  54 + end
  55 + else if (Select count(*) from AIAUser Where EmailId=@sEmailId)>0
  56 + begin
  57 + set @Status=2 -- Email Id Already Exist
  58 + end
  59 + else
  60 + begin
  61 + INSERT INTO AIAUser(LoginId, Password, Firstname, Lastname, UserTypeId, EmailId, IsActive, SecurityQuestionId,
  62 + SecurityAnswer, CreatorId, CreationDate, ModifierId, ModifiedDate) VALUES(@sLoginId, @sPassword, @sFirstname,
  63 + @sLastname, @iUserTypeId, @sEmailId, @iActive, @iSecurityQuesId, @sSecurityAnswer,
  64 + @iCreatorId, @dtCurrentDate, @iCreatorId, @dtCurrentDate)
  65 + SET @iAIAUserId = SCOPE_IDENTITY()
  66 + -- if user type is general admin then inserts map its role with newly generated UserId
  67 + IF @iUserTypeId = @iGAUserTypeId
  68 + BEGIN
  69 + -- insert the mapping of user with role into AIAUserActivity
  70 + INSERT INTO AIAUserActivity(UserId, RoleId) VALUES(@iAIAUserId, @iGARoleId)
  71 + END
  72 + ELSE
  73 + BEGIN
  74 + -- select the id of edition mapped with the license id
  75 + SELECT @iLicenseEditionId = LicenseToEdition.Id FROM LicenseToEdition
  76 + WHERE LicenseToEdition.LicenseId = @iLicenseId AND LicenseToEdition.EditionId = @iEditionId
  77 + IF @@ROWCOUNT = 0
  78 + BEGIN
  79 + RAISERROR(@sInvalidLicenseToEdition,16,61)
  80 + END
  81 + -- insert the mapping of user with license edition into AIAUserToLicenseEdition
  82 + INSERT INTO AIAUserToLicenseEdition(UserId, LicenseEditionId) VALUES(@iAIAUserId, @iLicenseEditionId)
  83 + END
  84 + set @Status=3
  85 + End
  86 +
  87 + COMMIT TRANSACTION
  88 + --Print @Status
  89 + --SELECT @sErrorStatus as SPStatus
  90 + SELECT @Status as SPStatus
  91 + END TRY
  92 + BEGIN CATCH
  93 + IF @@TRANCOUNT > 0
  94 + ROLLBACK TRANSACTION
  95 + --set @Status=4
  96 + --SELECT @Status as SPStatus
  97 + --SELECT Error_Message() as SPStatus
  98 +
  99 + END CATCH
  100 +
  101 +END
  102 +
  103 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_InsertNewDiscount.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertNewDiscount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_InsertNewDiscount]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_InsertNewDiscount]
  6 + -- Add the parameters for the stored procedure here
  7 + @dPercentage DECIMAL(5,2), @sStartDate VARCHAR(20), @sEndDate VARCHAR(20), @sDiscountCode VARCHAR(255)=''
  8 +AS
  9 +BEGIN
  10 + -- SET NOCOUNT ON added to prevent extra result sets from
  11 + -- interfering with SELECT statements.
  12 + SET NOCOUNT ON;
  13 + BEGIN TRY
  14 + BEGIN TRANSACTION
  15 + DECLARE @iDiscountId INT, @iDiscountExists INT
  16 + DECLARE @iActive TINYINT
  17 + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME
  18 + DECLARE @sErrorStatus CHAR(2)
  19 +
  20 + SET @iActive = 1
  21 + SET @sErrorStatus = 'ok'
  22 +
  23 + -- convert the datatype of startdate & enddate parameter to datetime
  24 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  25 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  26 +
  27 + INSERT INTO Discount (Percentage, StartDate, EndDate, IsActive)
  28 + VALUES(@dPercentage, @dtStartDate, @dtEndDate, @iActive)
  29 + -- to get the last inserted discount id identity value in the current session
  30 + SET @iDiscountId = SCOPE_IDENTITY()
  31 +
  32 + IF @sDiscountCode = ''
  33 + BEGIN
  34 + SET @sDiscountCode = 'InteractiveAnatomy'+RIGHT('000'+CAST(@iDiscountId AS VARCHAR(10)), 3)
  35 + SET @iDiscountExists = (SELECT Id FROM Discount WHERE DiscountCode = @sDiscountCode)
  36 + IF @iDiscountExists > 0
  37 + BEGIN
  38 + UPDATE Discount SET IsActive = 0 WHERE Id = @iDiscountExists
  39 + END
  40 + END
  41 + UPDATE Discount SET DiscountCode = @sDiscountCode WHERE Id = @iDiscountId
  42 +
  43 + COMMIT
  44 + SELECT @sErrorStatus as SPStatus
  45 + END TRY
  46 + BEGIN CATCH
  47 + IF @@TRANCOUNT > 0
  48 + ROLLBACK TRANSACTION
  49 + SELECT Error_Message() as SPStatus
  50 + END CATCH
  51 +
  52 +END
  53 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_InsertNewLicenseAccount.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertNewLicenseAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_InsertNewLicenseAccount]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_InsertNewLicenseAccount]
  6 + -- Add the parameters for the stored procedure here
  7 + @sAccountNumber varchar(50), @sLicenseeFname varchar(50), @sLicenseeLname varchar(50),
  8 + @iLicenseTypeId tinyint, @iAccountTypeId tinyint, @sInstitutionName varchar(100)='', @sAddress1 varchar(100)='',
  9 + @sAddress2 varchar(100)='', @sCity varchar(50)='', @sZip varchar(20)='', @iStateId int, @iCountryId int,
  10 + @sPhone varchar(30) = '', @sEmailId varchar(50), @iTotalLogins int, @sStartDate varchar(20),
  11 + @sEndDate varchar(20), @sMasterIP varchar(100) = '', @sEditionList varchar(256), @iPrice numeric(14,2),@sProductKey varchar(50),
  12 + @sSiteIPTo varchar(100) = '',@sSiteMasterIPTo varchar(100) = '',@iNoofImages int
  13 +AS
  14 +BEGIN
  15 +
  16 + -- SET NOCOUNT ON added to prevent extra result sets from
  17 + -- interfering with SELECT statements.
  18 + SET NOCOUNT ON;
  19 +
  20 + BEGIN TRY
  21 + BEGIN TRANSACTION
  22 + DECLARE @cEditionLogins CURSOR
  23 + DECLARE @iLicenseId INT
  24 + DECLARE @iSiteId INT
  25 + DECLARE @iLicenseEditionId INT
  26 + DECLARE @iIsDistrictSiteAccount TINYINT
  27 + DECLARE @iActive TINYINT
  28 + DECLARE @iIsMasterIP TINYINT
  29 + DECLARE @iModesty TINYINT
  30 + DECLARE @dtStartDate DATETIME
  31 + DECLARE @dtEndDate DATETIME
  32 + DECLARE @sErrorStatus CHAR(2)
  33 + DECLARE @dtCurrentDate DATETIME
  34 + DECLARE @sitem VARCHAR(100)
  35 + DECLARE @sRecordDelimiter CHAR(1)
  36 + DECLARE @sEditionLoginDelimiter CHAR(1)
  37 + DECLARE @sCountryCode VARCHAR(10)
  38 + DECLARE @iIsInsEditionSelected TINYINT
  39 + DECLARE @iIsLibEditionSelected TINYINT
  40 + DECLARE @iIsAcademicLibEditionSelected TINYINT
  41 +
  42 + -- set the parameters to default values
  43 + SET @iActive = 1
  44 + SET @iIsMasterIP = 1
  45 + SET @iIsDistrictSiteAccount = 0
  46 + SET @iModesty = 0
  47 + SET @sRecordDelimiter = '|'
  48 + SET @sEditionLoginDelimiter = '-'
  49 + SET @dtCurrentDate = getdate()
  50 + SET @sErrorStatus = 'ok'
  51 + SET @iIsInsEditionSelected = 0;
  52 + SET @iIsLibEditionSelected = 0;
  53 + SET @iIsAcademicLibEditionSelected = 0;
  54 +
  55 + IF @iStateId = 0
  56 + BEGIN
  57 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  58 + END
  59 + -- set the state to Other if the country is Non-US
  60 + SET @sCountryCode = (SELECT CountryCode from Country WHERE Id = @iCountryId)
  61 + IF @sCountryCode != 'US'
  62 + BEGIN
  63 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  64 + END
  65 +
  66 + -- convert the datatype of startdate & enddate parameter to datetime
  67 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  68 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  69 +
  70 + INSERT INTO License(AccountNumber, LicenseeFirstName, LicenseeLastName, LicenseTypeId, AccountTypeId,
  71 + InstitutionName, EmailId, Address1, Address2, City, Zip, StateId, CountryId, Phone, TotalLogins, IsActive,
  72 + IsDistrictSiteLicense, CreationDate,ProductId) VALUES (@sAccountNumber, @sLicenseeFname, @sLicenseeLname, @iLicenseTypeId,
  73 + @iAccountTypeId, @sInstitutionName, @sEmailId, @sAddress1, @sAddress2, @sCity, @sZip, @iStateId, @iCountryId,
  74 + @sPhone, @iTotalLogins, @iActive, @iIsDistrictSiteAccount, @dtCurrentDate,@sProductKey)
  75 + -- to get the last inserted license id identity value in the current session
  76 + SET @iLicenseId = SCOPE_IDENTITY()
  77 +
  78 + INSERT INTO LicenseSubscriptionDetail(LicenseId, SubscriptionValidFrom, SubscriptionValidThrough,
  79 + TotalAmount, AmountPaid,NoofImages) VALUES(@iLicenseId, @dtStartDate, @dtEndDate, @iPrice, @iPrice,@iNoofImages)
  80 +
  81 + -- check if license is site license
  82 + IF @iLicenseTypeId = 3
  83 + BEGIN
  84 + INSERT INTO Site (SiteIP, Title, InstituteName, Address1, Address2, City, Zip, Phone,
  85 + StateId, CountryId, IsMaster, IsActive, CreationDate, SiteIPTo, SiteMasterIpTo)
  86 + VALUES(@sMasterIP, @sMasterIP, @sInstitutionName, @sAddress1, @sAddress2, @sCity, @sZip, @sPhone,
  87 + @iStateId, @iCountryId, @iIsMasterIP, @iActive, @dtCurrentDate,@sSiteIPTo, @sSiteMasterIPTo)
  88 + -- to get the last inserted site id identity value in the current session
  89 + SET @iSiteId = SCOPE_IDENTITY()
  90 + END
  91 +
  92 + SET @cEditionLogins = CURSOR FAST_FORWARD FOR SELECT item FROM dbo.fnSplit(@sEditionList,@sRecordDelimiter)
  93 + OPEN @cEditionLogins
  94 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  95 + WHILE @@FETCH_STATUS = 0
  96 + BEGIN
  97 + INSERT INTO LicenseToEdition(LicenseId, EditionId, TotalLogins, IsModesty)
  98 + SELECT @iLicenseId, SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1),
  99 + SUBSTRING(@sitem,CHARINDEX(@sEditionLoginDelimiter,@sitem)+1,LEN(@sitem)), @iModesty
  100 +
  101 + -- chekc if selected edition is instructor or library edition
  102 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) <= 4
  103 + BEGIN
  104 + SET @iIsInsEditionSelected = 1;
  105 + END
  106 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) > 4
  107 + BEGIN
  108 + SET @iIsLibEditionSelected = 1;
  109 + END
  110 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) = 9
  111 + BEGIN
  112 + SET @iIsAcademicLibEditionSelected = 1;
  113 + END
  114 +
  115 + -- check if license is site license
  116 + IF @iLicenseTypeId = 3
  117 + BEGIN
  118 + -- to get the last inserted licenseedition id identity value in the current session
  119 + SET @iLicenseEditionId = SCOPE_IDENTITY()
  120 + INSERT INTO SiteToLicenseEdition (SiteId, LicenseEditionId, IsModesty) VALUES (@iSiteId, @iLicenseEditionId, @iModesty)
  121 + END
  122 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  123 + END
  124 +
  125 + IF @iIsInsEditionSelected = 1 AND @iIsLibEditionSelected = 1
  126 + BEGIN
  127 + -- insert All resource module of license
  128 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id in (8,9,10) then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  129 + END
  130 + ELSE IF @iIsInsEditionSelected = 1 AND @iIsLibEditionSelected = 0
  131 + BEGIN
  132 + -- insert All resource module of license
  133 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id > 7 then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  134 + END
  135 + ELSE IF @iIsInsEditionSelected = 0 AND @iIsLibEditionSelected = 1
  136 + BEGIN
  137 + -- insert All resource module of license
  138 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id < 11 and ResourceModule.id <> 6 then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  139 + END
  140 +
  141 + IF @iIsAcademicLibEditionSelected = 1
  142 + BEGIN
  143 + -- insert ADAM Image Resouce to license
  144 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, 1 as Status FROM ResourceModule WHERE ResourceModule.Id = 13;
  145 + END
  146 + ELSE
  147 + BEGIN
  148 + -- insert ADAM Image Resouce to license
  149 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, 0 as Status FROM ResourceModule WHERE ResourceModule.Id = 13;
  150 + END
  151 +
  152 +
  153 + COMMIT TRANSACTION
  154 + SELECT @sErrorStatus as SPStatus
  155 + END TRY
  156 + BEGIN CATCH
  157 + IF @@TRANCOUNT > 0
  158 + ROLLBACK TRANSACTION
  159 + SELECT Error_Message() as SPStatus
  160 + END CATCH
  161 +
  162 +END
  163 +
  164 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_InsertSingleLicenseAccount.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertSingleLicenseAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_InsertSingleLicenseAccount]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_InsertSingleLicenseAccount]
  6 + -- Add the parameters for the stored procedure here
  7 + @sAccountNumber varchar(50), @sLicenseeFname varchar(50), @sLicenseeLname varchar(50), @iAccountTypeId tinyint,
  8 + @sInstitutionName varchar(100)='', @sAddress1 varchar(100)='', @sAddress2 varchar(100)='', @sCity varchar(50)='',
  9 + @sZip varchar(20)='', @iStateId int, @iCountryId int, @sPhone varchar(30)='', @sEmailId varchar(50), @iTotalLogins int,
  10 + @sStartDate varchar(20), @sEndDate varchar(20), @sEditionList varchar(256), @iPrice numeric(14,2),@sProductKey varchar(50),
  11 + @sLoginId varchar(50), @sPassword varchar(50), @iSecurityQuesId tinyint, @sSecurityAnswer varchar(50), @iCreatorId int,@iNoofImages int
  12 +AS
  13 +BEGIN
  14 +
  15 + -- SET NOCOUNT ON added to prevent extra result sets from
  16 + -- interfering with SELECT statements.
  17 + SET NOCOUNT ON;
  18 +
  19 + BEGIN TRY
  20 + BEGIN TRANSACTION
  21 + DECLARE @cEditionLogins CURSOR
  22 + DECLARE @iLicenseId INT
  23 + DECLARE @iSiteId INT
  24 + DECLARE @iLicenseEditionId INT
  25 + DECLARE @iIsDistrictSiteAccount TINYINT
  26 + DECLARE @iLicenseTypeId TINYINT
  27 + DECLARE @iUserTypeId TINYINT
  28 + DECLARE @iAIAUserId INT
  29 + DECLARE @iActive TINYINT
  30 + DECLARE @iIsMasterIP TINYINT
  31 + DECLARE @iModesty TINYINT
  32 + DECLARE @dtStartDate DATETIME
  33 + DECLARE @dtEndDate DATETIME
  34 + DECLARE @sErrorStatus CHAR(2)
  35 + DECLARE @dtCurrentDate DATETIME
  36 + DECLARE @sitem VARCHAR(100)
  37 + DECLARE @sRecordDelimiter CHAR(1)
  38 + DECLARE @sEditionLoginDelimiter CHAR(1)
  39 + DECLARE @sCountryCode VARCHAR(10)
  40 + DECLARE @iIsInsEditionSelected TINYINT
  41 + DECLARE @iIsLibEditionSelected TINYINT
  42 + DECLARE @iIsAcademicLibEditionSelected TINYINT
  43 +
  44 + -- set the parameters to default values
  45 + SET @iActive = 1
  46 + SET @iIsDistrictSiteAccount = 0
  47 + SET @iModesty = 0
  48 + SET @sRecordDelimiter = '|'
  49 + SET @sEditionLoginDelimiter = '-'
  50 + SET @dtCurrentDate = getdate()
  51 + SET @sErrorStatus = 'ok'
  52 + SET @iIsInsEditionSelected = 0;
  53 + SET @iIsLibEditionSelected = 0;
  54 + SET @iIsAcademicLibEditionSelected = 0;
  55 +
  56 + IF @iStateId = 0
  57 + BEGIN
  58 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  59 + END
  60 + -- set the state to Other if the country is Non-US
  61 + SET @sCountryCode = (SELECT CountryCode from Country WHERE Id = @iCountryId)
  62 + IF @sCountryCode != 'US'
  63 + BEGIN
  64 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  65 + END
  66 + IF @iSecurityQuesId = 0
  67 + BEGIN
  68 + SET @iSecurityQuesId = NULL
  69 + END
  70 + IF LEN(@sSecurityAnswer) = 0
  71 + BEGIN
  72 + SET @sSecurityAnswer = NULL
  73 + END
  74 + -- convert the datatype of startdate & enddate parameter to datetime
  75 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  76 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  77 +
  78 + -- fetch the licensetypeid of the single license
  79 + SELECT @iLicenseTypeId = Id from LicenseType WHERE Title = 'Single License'
  80 + -- fetch the usertypeid of the single user
  81 + SELECT @iUserTypeId = Id from UserType WHERE Title = 'Single User'
  82 +
  83 +
  84 + INSERT INTO License(AccountNumber, LicenseeFirstName, LicenseeLastName, LicenseTypeId, AccountTypeId,
  85 + InstitutionName, EmailId, Address1, Address2, City, Zip, StateId, CountryId, Phone, TotalLogins, IsActive,
  86 + IsDistrictSiteLicense, CreationDate,ProductId) VALUES (@sAccountNumber, @sLicenseeFname, @sLicenseeLname, @iLicenseTypeId,
  87 + @iAccountTypeId, @sInstitutionName, @sEmailId, @sAddress1, @sAddress2, @sCity, @sZip, @iStateId, @iCountryId,
  88 + @sPhone, @iTotalLogins, @iActive, @iIsDistrictSiteAccount, @dtCurrentDate,@sProductKey)
  89 + -- to get the last inserted license id identity value in the current session
  90 + SET @iLicenseId = SCOPE_IDENTITY()
  91 +
  92 + INSERT INTO LicenseSubscriptionDetail(LicenseId, SubscriptionValidFrom, SubscriptionValidThrough,
  93 + TotalAmount, AmountPaid,NoofImages) VALUES(@iLicenseId, @dtStartDate, @dtEndDate, @iPrice, @iPrice ,@iNoofImages)
  94 +
  95 + SET @cEditionLogins = CURSOR FAST_FORWARD FOR SELECT item FROM dbo.fnSplit(@sEditionList,@sRecordDelimiter)
  96 + OPEN @cEditionLogins
  97 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  98 + WHILE @@FETCH_STATUS = 0
  99 + BEGIN
  100 + INSERT INTO LicenseToEdition(LicenseId, EditionId, TotalLogins, IsModesty)
  101 + SELECT @iLicenseId, SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1),
  102 + SUBSTRING(@sitem,CHARINDEX(@sEditionLoginDelimiter,@sitem)+1,LEN(@sitem)), @iModesty
  103 +
  104 + -- chekc if selected edition is instructor or library edition
  105 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) <= 4
  106 + BEGIN
  107 + SET @iIsInsEditionSelected = 1;
  108 + END
  109 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) > 4
  110 + BEGIN
  111 + SET @iIsLibEditionSelected = 1;
  112 + END
  113 + IF SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1) = 9
  114 + BEGIN
  115 + SET @iIsAcademicLibEditionSelected = 1;
  116 + END
  117 +
  118 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  119 + END
  120 + SET @iLicenseEditionId = SCOPE_IDENTITY()
  121 + INSERT INTO AIAUser(LoginId, Password, Firstname, Lastname, UserTypeId, EmailId, IsActive, SecurityQuestionId, SecurityAnswer,
  122 + CreatorId, CreationDate, ModifierId, ModifiedDate) VALUES(@sLoginId, @sPassword, @sLicenseeFname, @sLicenseeLname,
  123 + @iUserTypeId, @sEmailId, @iActive, @iSecurityQuesId, @sSecurityAnswer, @iCreatorId, @dtCurrentDate, @iCreatorId, @dtCurrentDate)
  124 + SET @iAIAUserId = SCOPE_IDENTITY()
  125 +
  126 + INSERT INTO AIAUserToLicenseEdition(UserId, LicenseEditionId) VALUES(@iAIAUserId, @iLicenseEditionId)
  127 +
  128 + IF @iIsInsEditionSelected = 1 AND @iIsLibEditionSelected = 1
  129 + BEGIN
  130 + -- insert All resource module of license
  131 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id in (8,9,10) then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  132 + END
  133 + ELSE IF @iIsInsEditionSelected = 1 AND @iIsLibEditionSelected = 0
  134 + BEGIN
  135 + -- insert All resource module of license
  136 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id > 7 then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  137 + END
  138 + ELSE IF @iIsInsEditionSelected = 0 AND @iIsLibEditionSelected = 1
  139 + BEGIN
  140 + -- insert All resource module of license
  141 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id < 11 and ResourceModule.id <> 6 then 0 else 1 end as Status FROM ResourceModule WHERE ResourceModule.Id <> 13;
  142 + END
  143 +
  144 + IF @iIsAcademicLibEditionSelected = 1
  145 + BEGIN
  146 + -- insert ADAM Image Resouce to license
  147 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, 1 as Status FROM ResourceModule WHERE ResourceModule.Id = 13;
  148 + END
  149 + ELSE
  150 + BEGIN
  151 + -- insert ADAM Image Resouce to license
  152 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, 0 as Status FROM ResourceModule WHERE ResourceModule.Id = 13;
  153 + END
  154 +
  155 + COMMIT TRANSACTION
  156 + SELECT @sErrorStatus as SPStatus
  157 + END TRY
  158 + BEGIN CATCH
  159 + IF @@TRANCOUNT > 0
  160 + ROLLBACK TRANSACTION
  161 + SELECT Error_Message() as SPStatus
  162 + END CATCH
  163 +
  164 +END
  165 +
  166 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_InsertTestLicenseAccount.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_InsertTestLicenseAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_InsertTestLicenseAccount]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_InsertTestLicenseAccount]
  6 + -- Add the parameters for the stored procedure here
  7 + @sAccountNumber varchar(50), @sLicenseeFname varchar(50), @sLicenseeLname varchar(50), @sLoginId varchar(50), @sPassword varchar(50),
  8 + @sEmailId varchar(50), @iAccountTypeId tinyint, @iEditionId tinyint, @sAddress varchar(100)='', @sCity varchar(50)='',
  9 + @sZip varchar(20)='', @iStateId int, @iCountryId int, @sPhone varchar(30)='', @sStartDate varchar(20), @sEndDate varchar(20), @iCreatorId int ,@iNoofImages int
  10 +AS
  11 +BEGIN
  12 +
  13 + -- SET NOCOUNT ON added to prevent extra result sets from
  14 + -- interfering with SELECT statements.
  15 + SET NOCOUNT ON;
  16 +
  17 + BEGIN TRY
  18 + BEGIN TRANSACTION
  19 + DECLARE @iLicenseId int
  20 + DECLARE @iLicenseEditionId int
  21 + DECLARE @iAIAUserId int
  22 + DECLARE @iLicenseTypeId tinyint
  23 + DECLARE @iUserTypeId tinyint
  24 + DECLARE @iAmount tinyint
  25 + DECLARE @iTotalLogins tinyint
  26 + DECLARE @iActive tinyint
  27 + DECLARE @iModesty tinyint
  28 + DECLARE @dtStartDate datetime
  29 + DECLARE @dtEndDate datetime
  30 + DECLARE @sErrorStatus char(2)
  31 + DECLARE @dtCurrentDate datetime
  32 + DECLARE @sCountryCode VARCHAR(10)
  33 +
  34 + -- set the parameters to default values
  35 + SET @iTotalLogins = 1
  36 + SET @iActive = 1
  37 + SET @iAmount = 0
  38 + SET @iModesty = 0
  39 + SET @dtCurrentDate = getdate()
  40 + SET @sErrorStatus = 'ok'
  41 +
  42 + IF @iStateId = 0
  43 + BEGIN
  44 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  45 + END
  46 + -- set the state to Other if the country is Non-US
  47 + SET @sCountryCode = (SELECT CountryCode from Country WHERE Id = @iCountryId)
  48 + IF @sCountryCode != 'US'
  49 + BEGIN
  50 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  51 + END
  52 +
  53 + -- fetch the licensetypeid of the test account license
  54 + SELECT @iLicenseTypeId = Id from LicenseType WHERE Title = 'Test Account License'
  55 + -- fetch the usertypeid of the test account user
  56 + SELECT @iUserTypeId = Id from UserType WHERE Title = 'Test Account'
  57 +
  58 + -- convert the datatype of startdate & enddate parameter to datetime
  59 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  60 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  61 +
  62 + INSERT INTO License(AccountNumber, LicenseeFirstName, LicenseeLastName, LicenseTypeId, AccountTypeId,
  63 + EmailId, Address1, City, Zip, StateId, CountryId, Phone, TotalLogins, IsActive, IsDistrictSiteLicense,
  64 + CreationDate) VALUES (@sAccountNumber, @sLicenseeFname, @sLicenseeLname, @iLicenseTypeId, @iAccountTypeId,
  65 + @sEmailId, @sAddress, @sCity, @sZip, @iStateId, @iCountryId, @sPhone, @iTotalLogins, @iActive, 0, @dtCurrentDate )
  66 + -- to get the last inserted identity value in the current session
  67 + SET @iLicenseId = SCOPE_IDENTITY()
  68 +
  69 + INSERT INTO LicenseSubscriptionDetail(LicenseId, SubscriptionValidFrom, SubscriptionValidThrough,
  70 + TotalAmount, AmountPaid, AmountPending ,NoofImages) VALUES(@iLicenseId, @dtStartDate, @dtEndDate, @iAmount, @iAmount, @iAmount ,@iNoofImages)
  71 +
  72 + IF @iEditionId <= 4
  73 + BEGIN
  74 + -- insert All resource module of license for Instructor Edition
  75 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id > 7 then 0 else 1 end as Status FROM ResourceModule;
  76 + END
  77 + ELSE IF @iEditionId = 8
  78 + BEGIN
  79 + -- insert All resource module of license for Library Edition
  80 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id < 11 and ResourceModule.id <> 6 or ResourceModule.id = 13 then 0 else 1 end as Status FROM ResourceModule;
  81 + END
  82 + ELSE IF @iEditionId = 9
  83 + BEGIN
  84 + -- insert All resource module of license for Library Edition
  85 + INSERT INTO ModuleToLicense SELECT @iLicenseId as LicenseId,ResourceModule.Id as ModuleId, CASE when ResourceModule.id < 11 and ResourceModule.id <> 6 then 0 else 1 end as Status FROM ResourceModule;
  86 + END
  87 +
  88 + INSERT INTO LicenseToEdition(LicenseId, EditionId, TotalLogins, IsModesty)
  89 + VALUES(@iLicenseId, @iEditionId, @iTotalLogins, @iModesty)
  90 + SET @iLicenseEditionId = SCOPE_IDENTITY()
  91 +
  92 + INSERT INTO AIAUser(LoginId, Password, Firstname, Lastname, UserTypeId, EmailId, IsActive,
  93 + CreatorId, CreationDate, ModifierId, ModifiedDate) VALUES(@sLoginId, @sPassword, @sLicenseeFname, @sLicenseeLname,
  94 + @iUserTypeId, @sEmailId, @iActive, @iCreatorId, @dtCurrentDate, @iCreatorId, @dtCurrentDate)
  95 + SET @iAIAUserId = SCOPE_IDENTITY()
  96 +
  97 + INSERT INTO AIAUserToLicenseEdition(UserId, LicenseEditionId) VALUES(@iAIAUserId, @iLicenseEditionId)
  98 +
  99 + COMMIT TRANSACTION
  100 + SELECT @sErrorStatus as SPStatus
  101 + END TRY
  102 + BEGIN CATCH
  103 + IF @@TRANCOUNT > 0
  104 + ROLLBACK TRANSACTION
  105 + SELECT Error_Message() as SPStatus
  106 + END CATCH
  107 +
  108 +END
  109 +
  110 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_UpdateAiaUserPassword.sql 0 → 100644
  1 + if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateAiaUserPassword]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_UpdateAiaUserPassword]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_UpdateAiaUserPassword]
  6 + -- Add the parameters for the stored procedure here
  7 + @Id int,
  8 + @NewPassword VARCHAR(50),
  9 + @Status bit out
  10 +AS
  11 +BEGIN
  12 + -- SET NOCOUNT ON added to prevent extra result sets from
  13 + -- interfering with SELECT statements.
  14 + SET NOCOUNT ON;
  15 +
  16 + set @Status = 0;
  17 + BEGIN TRY
  18 + BEGIN TRANSACTION
  19 + UPDATE AIAUser SET Password= @NewPassword,ModifiedDate=getdate() where Id = @Id;
  20 + COMMIT TRANSACTION
  21 + set @Status = 1;
  22 + END TRY
  23 + BEGIN CATCH
  24 + IF @@TRANCOUNT > 0
  25 + ROLLBACK TRANSACTION
  26 + END CATCH
  27 +
  28 +END
  29 +
  30 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_UpdateDiscount.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateDiscount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_UpdateDiscount]
  3 +GO
  4 +
  5 +CREATE PROCEDURE [dbo].[usp_UpdateDiscount]
  6 + -- Add the parameters for the stored procedure here
  7 + @iDiscountId INT, @dPercentage DECIMAL(5,2), @sStartDate VARCHAR(20), @sEndDate VARCHAR(20), @iActive TINYINT, @sDiscountCode VARCHAR(255)=''
  8 +AS
  9 +BEGIN
  10 + -- SET NOCOUNT ON added to prevent extra result sets from
  11 + -- interfering with SELECT statements.
  12 + SET NOCOUNT ON;
  13 + BEGIN TRY
  14 + BEGIN TRANSACTION
  15 + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME
  16 + DECLARE @sErrorStatus CHAR(2)
  17 +
  18 + SET @sErrorStatus = 'ok'
  19 +
  20 + -- convert the datatype of startdate & enddate parameter to datetime
  21 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  22 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  23 +
  24 + UPDATE Discount SET Percentage = @dPercentage, StartDate = @dtStartDate, EndDate = @dtEndDate,
  25 + IsActive = @iActive, DiscountCode = @sDiscountCode WHERE Id = @iDiscountId
  26 +
  27 + COMMIT
  28 + SELECT @sErrorStatus as SPStatus
  29 + END TRY
  30 + BEGIN CATCH
  31 + IF @@TRANCOUNT > 0
  32 + ROLLBACK TRANSACTION
  33 + SELECT Error_Message() as SPStatus
  34 + END CATCH
  35 +
  36 +END
  37 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_UpdateLicenseAccount.sql 0 → 100644
  1 +
  2 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateLicenseAccount]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  3 +drop procedure [dbo].[usp_UpdateLicenseAccount]
  4 +GO
  5 +
  6 +CREATE PROCEDURE [dbo].[usp_UpdateLicenseAccount]
  7 + -- Add the parameters for the stored procedure here
  8 + @iLicenseId int, @sLicenseeFname varchar(50), @sLicenseeLname varchar(50),
  9 + @iLicenseTypeId tinyint, @iAccountTypeId tinyint, @sInstitutionName varchar(100)='', @sAddress1 varchar(100)='',
  10 + @sAddress2 varchar(100)='', @sCity varchar(50)='', @sZip varchar(20)='', @iStateId int, @iCountryId int,
  11 + @sPhone varchar(30) = '', @sEmailId varchar(50), @iIsActive tinyint, @iTotalLogins int = 0, @iIsRennew tinyint,
  12 + @sStartDate varchar(20), @sEndDate varchar(20), @sRenewDate varchar(20), @sMasterIP varchar(100) = '',
  13 + @sEditionList varchar(256), @iPrice numeric(14,2), @sProductKey varchar(50), @sSiteIPTo varchar(100) = '', @sSiteMasterIPTo varchar(100) = '',
  14 + @iNoofImages int
  15 +AS
  16 +BEGIN
  17 +
  18 + -- SET NOCOUNT ON added to prevent extra result sets from
  19 + -- interfering with SELECT statements.
  20 + SET NOCOUNT ON;
  21 +
  22 + BEGIN TRY
  23 + BEGIN TRANSACTION
  24 + DECLARE @cEditionLogins CURSOR
  25 + DECLARE @iSiteId INT
  26 + DECLARE @iLicenseEditionId INT
  27 + DECLARE @iModesty TINYINT
  28 + DECLARE @dtStartDate DATETIME
  29 + DECLARE @dtEndDate DATETIME
  30 + DECLARE @dtRenewDate DATETIME
  31 + DECLARE @sErrorStatus CHAR(2)
  32 + DECLARE @dtCurrentDate DATETIME
  33 + DECLARE @sitem VARCHAR(100)
  34 + DECLARE @sRecordDelimiter CHAR(1)
  35 + DECLARE @sEditionLoginDelimiter CHAR(1)
  36 + DECLARE @sPaymentMode VARCHAR(10)
  37 + DECLARE @iLicenseSubscriptionId INT
  38 + DECLARE @iSubscriptionId SMALLINT
  39 + DECLARE @dtCancellationDate DATETIME
  40 + DECLARE @iEditionExists TINYINT
  41 + DECLARE @sCountryCode VARCHAR(10)
  42 +
  43 + -- set the parameters to default values
  44 + SET @iModesty = 0
  45 + SET @sRecordDelimiter = '|'
  46 + SET @sEditionLoginDelimiter = '-'
  47 + SET @iSubscriptionId = NULL
  48 + SET @dtCancellationDate = NULL
  49 + SET @dtCurrentDate = getdate()
  50 + SET @sPaymentMode = 'CASH'
  51 + SET @sErrorStatus = 'ok'
  52 +
  53 + IF @iStateId = 0
  54 + BEGIN
  55 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  56 + END
  57 +
  58 + -- set the state to Other if the country is Non-US
  59 + SET @sCountryCode = (SELECT CountryCode from Country WHERE Id = @iCountryId)
  60 + IF @sCountryCode != 'US'
  61 + BEGIN
  62 + SET @iStateId = (SELECT Id FROM State WHERE StateName='Other')
  63 + END
  64 +
  65 + -- convert the datatype of startdate & enddate parameter to datetime
  66 + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate)
  67 + SELECT @dtRenewDate = CONVERT(DATETIME,@sRenewDate)
  68 + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate)))
  69 + -- if user inactive the license then set the cancellation date to current date
  70 + IF @iIsActive = 0
  71 + BEGIN
  72 + SET @dtCancellationDate = @dtCurrentDate
  73 + END
  74 +
  75 + UPDATE License SET LicenseeFirstName = @sLicenseeFname, LicenseeLastName = @sLicenseeLname,
  76 + AccountTypeId = @iAccountTypeId, InstitutionName = @sInstitutionName, EmailId = @sEmailId,
  77 + Address1 = @sAddress1, Address2 = @sAddress2, City = @sCity, Zip = @sZip, StateId = @iStateId,
  78 + CountryId = @iCountryId, Phone = @sPhone, TotalLogins = @iTotalLogins, IsActive = @iIsActive,
  79 + ModifiedDate = @dtCurrentDate, CancellationDate = @dtCancellationDate, ProductId = @sProductKey WHERE Id = @iLicenseId
  80 +
  81 + SET @iLicenseSubscriptionId = (SELECT MAX(Id) FROM LicenseSubscriptionDetail WHERE LicenseId = @iLicenseId)
  82 + -- if the subscription of license is renew
  83 + IF @iIsRennew = 1
  84 + BEGIN
  85 + -- check if license is single license
  86 + IF @iLicenseTypeId = 2
  87 + BEGIN
  88 + SET @iSubscriptionId = (SELECT SubscriptionPlanId FROM LicenseSubscriptionDetail WHERE Id = @iLicenseSubscriptionId)
  89 + END
  90 + INSERT INTO LicenseSubscriptionDetail(LicenseId, SubscriptionPlanId, SubscriptionValidFrom,
  91 + SubscriptionValidThrough, RenewalDate, PaymentMode, TotalAmount, AmountPaid,NoofImages)
  92 + VALUES(@iLicenseId, @iSubscriptionId, @dtStartDate, @dtEndDate, @dtRenewDate, @sPaymentMode, @iPrice, @iPrice,@iNoofImages)
  93 + UPDATE License SET NoOfRenewals = NoOfRenewals + 1 WHERE Id = @iLicenseId
  94 + END
  95 + ELSE
  96 + BEGIN
  97 + UPDATE LicenseSubscriptionDetail SET SubscriptionValidFrom = @dtStartDate,
  98 + SubscriptionValidThrough = @dtEndDate, TotalAmount = @iPrice, AmountPaid = @iPrice , NoofImages =@iNoofImages
  99 + WHERE Id = @iLicenseSubscriptionId
  100 + END
  101 +
  102 + -- check if license is site license
  103 + IF @iLicenseTypeId = 3
  104 + BEGIN
  105 +
  106 + SET @iSiteId = (SELECT DISTINCT Max(Site.Id) FROM LicenseToEdition
  107 + INNER JOIN SiteToLicenseEdition ON LicenseToEdition.Id = SiteToLicenseEdition.LicenseEditionId
  108 + INNER JOIN Site ON SiteToLicenseEdition.SiteId = Site.Id
  109 + WHERE LicenseToEdition.LicenseId=@iLicenseId AND Site.IsMaster=1 AND Site.IsActive=1)
  110 +
  111 + UPDATE Site SET SiteIP = @sMasterIP, Title = @sMasterIP, ModifiedDate = @dtCurrentDate,
  112 + SiteIPTo = @sSiteIPTo, SiteMasterIPTo = @sSiteMasterIPTo
  113 + WHERE Id = @iSiteId
  114 + END
  115 +
  116 + SET @cEditionLogins = CURSOR FAST_FORWARD FOR SELECT item FROM dbo.fnSplit(@sEditionList,@sRecordDelimiter)
  117 + OPEN @cEditionLogins
  118 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  119 + WHILE @@FETCH_STATUS = 0
  120 + BEGIN
  121 + SET @iEditionExists = (SELECT 1 FROM LicenseToEdition WHERE LicenseId = @iLicenseId AND EditionId = SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1))
  122 +
  123 + IF @iEditionExists IS NULL OR @iEditionExists = 0
  124 + BEGIN
  125 + INSERT INTO LicenseToEdition(LicenseId, EditionId, TotalLogins, IsModesty)
  126 + SELECT @iLicenseId, SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1),
  127 + SUBSTRING(@sitem,CHARINDEX(@sEditionLoginDelimiter,@sitem)+1,LEN(@sitem)), @iModesty
  128 + -- check if license is site license
  129 + IF @iLicenseTypeId = 3
  130 + BEGIN
  131 + -- to get the last inserted licenseedition id identity value in the current session
  132 + SET @iLicenseEditionId = SCOPE_IDENTITY()
  133 + INSERT INTO SiteToLicenseEdition (SiteId, LicenseEditionId, IsModesty) VALUES (@iSiteId, @iLicenseEditionId, @iModesty)
  134 + END
  135 + END
  136 + ELSE
  137 + BEGIN
  138 + UPDATE LicenseToEdition SET TotalLogins = SUBSTRING(@sitem,CHARINDEX(@sEditionLoginDelimiter,@sitem)+1,LEN(@sitem))
  139 + WHERE LicenseId = @iLicenseId
  140 + AND EditionId = SUBSTRING(@sitem,1,CHARINDEX(@sEditionLoginDelimiter,@sitem)-1)
  141 + END
  142 + FETCH NEXT FROM @cEditionLogins INTO @sitem
  143 + END
  144 +
  145 + COMMIT TRANSACTION
  146 + SELECT @sErrorStatus as SPStatus
  147 + END TRY
  148 + BEGIN CATCH
  149 + IF @@TRANCOUNT > 0
  150 + ROLLBACK TRANSACTION
  151 + SELECT Error_Message() as SPStatus
  152 + END CATCH
  153 +
  154 +END
  155 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_UpdateUserProfile.sql 0 → 100644
  1 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_UpdateUserProfile]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2 +drop procedure [dbo].[usp_UpdateUserProfile]
  3 +GO
  4 +CREATE PROCEDURE [dbo].[usp_UpdateUserProfile]
  5 + -- Add the parameters for the stored procedure here
  6 + @Id int,
  7 + @FirstName VARCHAR(100),
  8 + @LastName VARCHAR(100),
  9 + @EmailId varchar(50),
  10 + @Status int out
  11 +AS
  12 +BEGIN
  13 + -- SET NOCOUNT ON added to prevent extra result sets from
  14 + -- interfering with SELECT statements.
  15 + SET NOCOUNT ON;
  16 +
  17 + set @Status = 0;
  18 + BEGIN TRY
  19 + BEGIN TRANSACTION
  20 + UPDATE AIAUser SET FirstName= @FirstName, LastName= @LastName, EmailId = @EmailId
  21 + where Id = @Id;
  22 + COMMIT TRANSACTION
  23 + set @Status = 1;
  24 + END TRY
  25 + BEGIN CATCH
  26 + IF @@TRANCOUNT > 0
  27 + ROLLBACK TRANSACTION
  28 + END CATCH
  29 +
  30 +END
  31 +
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/usp_GetSiteAccountAdmin.sql 0 → 100644
  1 +USE [AIADatabaseV5]
  2 +GO
  3 +/****** Object: StoredProcedure [dbo].[usp_GetSiteAccountAdmin] Script Date: 2/1/2018 12:15:55 PM ******/
  4 +SET ANSI_NULLS ON
  5 +GO
  6 +SET QUOTED_IDENTIFIER ON
  7 +GO
  8 +-- =============================================
  9 +-- Author: magic
  10 +-- Create date: 5/6/2018
  11 +-- Description: Fetch building level accounts client admins for corresponding given Account Number.
  12 +-- =============================================
  13 +
  14 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteAccountAdmin]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  15 +drop procedure [dbo].[usp_GetSiteAccountAdmin]
  16 +GO
  17 +
  18 +CREATE PROCEDURE [dbo].[usp_GetSiteAccountAdmin]
  19 + -- Add the parameters for the stored procedure here
  20 + @AccountNumber varchar(50)=''
  21 +
  22 +AS
  23 +BEGIN
  24 + -- SET NOCOUNT ON added to prevent extra result sets from
  25 + -- interfering with SELECT statements.
  26 + SET NOCOUNT ON;
  27 +
  28 + SELECT AIAUser.Id, AIAUser.Password, AIAUser.LoginId, AIAUser.FirstName, AIAUser.UserTypeId, AIAUser.LastName, AIAUser.EmailId, AIAUser.IsActive,
  29 + AIAUser.SecurityQuestionId, AIAUser.SecurityAnswer, AIAUser.CreatorId, AIAUser.CreationDate, AIAUser.ModifierId, AIAUser.ModifiedDate,
  30 + AIAUser.DeactivationDate
  31 + FROM AIAUser
  32 + INNER JOIN AIAUserToLicenseEdition ON AIAUser.Id = AIAUserToLicenseEdition.UserId
  33 + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id
  34 + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id
  35 + WHERE (AIAUser.IsActive = 1) AND (License.AccountNumber = @AccountNumber) AND (AIAUser.UserTypeId = 4);
  36 +
  37 +END
  38 +
  39 +
  40 +
  41 +GO
... ...
500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/usp_GetSiteAccountSites.sql 0 → 100644
  1 +USE [AIADatabaseV5]
  2 +GO
  3 +/****** Object: StoredProcedure [dbo].[usp_GetSiteAccountSites] Script Date: 2/1/2018 12:15:55 PM ******/
  4 +SET ANSI_NULLS ON
  5 +GO
  6 +SET QUOTED_IDENTIFIER ON
  7 +GO
  8 +-- =============================================
  9 +-- Author: magic
  10 +-- Create date: 5/6/2018
  11 +-- Description: Fetch building level accounts details for corresponding given Account Number.
  12 +-- =============================================
  13 +
  14 +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteAccountSites]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  15 +drop procedure [dbo].[usp_GetSiteAccountSites]
  16 +GO
  17 +
  18 +CREATE PROCEDURE [dbo].[usp_GetSiteAccountSites]
  19 + -- Add the parameters for the stored procedure here
  20 + @strAccountNumber varchar(50)='', @pageNo int, @pageLength int, @recordCount int out
  21 +
  22 +AS
  23 +BEGIN
  24 + -- SET NOCOUNT ON added to prevent extra result sets from
  25 + -- interfering with SELECT statements.
  26 + SET NOCOUNT ON;
  27 +
  28 + --Get the records on the basis of parameters page length and page number rows
  29 + select LD.Id, LD.SiteIp, LD.Title, LD.SiteIPTo, LD.SiteMasterIPTo, LD.CreationDate, LD.ModifiedDate, LD.InstituteName,
  30 + LD.Department, LD.UserId, LD.FirstName, LD.EmailId
  31 + from
  32 + (Select ROW_NUMBER() OVER (ORDER BY Site.Id) AS RowNo,
  33 + Site.Id,Site.SiteIp,Site.Title,ISNULL(Site.SiteIPTo,'') as SiteIPTo,ISNULL(Site.SiteMasterIPTo,'') as SiteMasterIPTo,
  34 + CONVERT(VARCHAR,Site.CreationDate,101) as CreationDate,
  35 + CONVERT(VARCHAR,Site.ModifiedDate,101) as ModifiedDate,
  36 + Site.InstituteName, Site.Department, AIAUser.Id as UserId,AIAUser.FirstName,AIAUser.EmailId
  37 + from License join LicenseToEdition on License.Id = LicenseToEdition.LicenseId
  38 + join SiteToLicenseEdition on LicenseToEdition.Id = SiteToLicenseEdition.LicenseEditionId
  39 + join AIAUserToLicenseEdition on SiteToLicenseEdition.LicenseEditionId = AIAUserToLicenseEdition.LicenseEditionId
  40 + join AIAUserToSite on SiteToLicenseEdition.SiteId = AIAUserToSite.SiteId
  41 + join Site on SiteToLicenseEdition.SiteId = Site.Id
  42 + join AIAUser on AIAUserToLicenseEdition.UserId = AIAUser.Id
  43 + where Site.IsActive=1 and License.AccountNumber=@strAccountNumber)
  44 + as LD
  45 + where
  46 + RowNo > @pageLength * (@pageNo - 1) AND
  47 + RowNo <= @pageLength * @pageNo
  48 +
  49 + --Calculate total number of records
  50 + select @recordCount = count(ResultTable.Id) from
  51 + (Select Site.Id,Site.SiteIp,Site.Title,ISNULL(Site.SiteIPTo,'') as SiteIPTo,ISNULL(Site.SiteMasterIPTo,'') as SiteMasterIPTo,
  52 + CONVERT(VARCHAR,Site.CreationDate,101) as CreationDate,
  53 + CONVERT(VARCHAR,Site.ModifiedDate,101) as ModifiedDate,
  54 + Site.InstituteName, Site.Department, AIAUser.Id as UserId,AIAUser.FirstName,AIAUser.EmailId
  55 + from License join LicenseToEdition on License.Id = LicenseToEdition.LicenseId
  56 + join SiteToLicenseEdition on LicenseToEdition.Id = SiteToLicenseEdition.LicenseEditionId
  57 + join AIAUserToLicenseEdition on SiteToLicenseEdition.LicenseEditionId = AIAUserToLicenseEdition.LicenseEditionId
  58 + join AIAUserToSite on SiteToLicenseEdition.SiteId = AIAUserToSite.SiteId
  59 + join Site on SiteToLicenseEdition.SiteId = Site.Id
  60 + join AIAUser on AIAUserToLicenseEdition.UserId = AIAUser.Id
  61 + where Site.IsActive=1 and License.AccountNumber=@strAccountNumber) as ResultTable;
  62 +
  63 +END
  64 +
  65 +
  66 +
  67 +GO
... ...