diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 123ad82..fea8783 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -19,6 +19,7 @@ + true @@ -109,11 +110,13 @@ + Global.asax + diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/PixelLocationsController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/PixelLocationsController.cs new file mode 100644 index 0000000..d127aca --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/PixelLocationsController.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using AIAHTML5.API.Models; + +namespace AIAHTML5.API.Controllers +{ + public class PixelLocationsController : ApiController + { + // GET: api/PixelLocations + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET: api/PixelLocations/5 + public HttpResponseMessage Get(string layerNumber, string bodyViewIndex, string systemNumber, string zoomLevel) + { + dynamic bodyRegions = PixelLocator.GetBodyRegionsPixelData(layerNumber, bodyViewIndex, systemNumber, zoomLevel); + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(bodyRegions) }; + } + + // POST: api/PixelLocations + public void Post([FromBody]string value) + { + } + + // PUT: api/PixelLocations/5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE: api/PixelLocations/5 + public void Delete(int id) + { + } + } +} diff --git a/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs b/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs new file mode 100644 index 0000000..c50d4b9 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs @@ -0,0 +1,51 @@ +using MongoDB.Bson; +using MongoDB.Driver; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace AIAHTML5.API.Models +{ + public class PixelLocator + { + + internal static dynamic GetBodyRegionsPixelData(string layerNumber, string bodyViewIndex, string systemNumber, string zoom) + { + try + { + var client = new MongoClient("localhost:27017"); + var db = client.GetDatabase("AIAHTML5"); + + var col = db.GetCollection("DAImages"); + + var pipeline = new BsonDocument[] + { + new BsonDocument{ {"$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)) }}, + new BsonDocument{{"$unwind", "$terms"}}, + new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)) }}, + new BsonDocument{ { "$match", new BsonDocument("bodyViewIndex", Convert.ToInt32(bodyViewIndex)) }}, + new BsonDocument{ { "$match", new BsonDocument("layerNumber", Convert.ToInt32(layerNumber)) }}, + new BsonDocument{ { "$match", new BsonDocument("zoom", Convert.ToInt32(zoom)) }}, + + new BsonDocument { {"$project", new BsonDocument() + .Add("_id", 0) + .Add("terms", 1) + .Add("bodyRegionId", 1) + .Add("layerNumber", 1) + .Add("bodyViewIndex", 1) + } } + }; + + + var pixelData = col.Aggregate(pipeline).ToList(); + + return pixelData.ToJson(); + } + catch (Exception e) + { + return "error"; + } + } +} +} diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll index 3a0f416..2cdb446 100644 --- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll +++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.dll diff --git a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb index f6b437f..4379e65 100644 --- a/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb +++ b/400-SOURCECODE/AIAHTML5.API/bin/AIAHTML5.API.pdb diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 30e501c..a868c63 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -1,8 +1,8 @@  'use strict'; -AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService", -function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService) { +AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "DataService","TermService", + function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, DataService, TermService) { $scope.genderId = ""; @@ -2831,12 +2831,14 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.highlightedBR = []; - if ($scope.layerNumber == 224) { + // if ($scope.layerNumber == 224) { var matchedTermListPath = '~/../content/data/json/da/body-views/1/BodySystem_' + $rootScope.systemNumber + '.json'; var grayImageDataVar = null; - DataService.getJson(matchedTermListPath) + // DataService.getJson(matchedTermListPath) + TermService.getTermData($scope.layerNumber, $rootScope.voId, $rootScope.systemNumber, $rootScope.zoomInOut) + .then( function (result) { console.log('1. HighlightBodyByTermListForBodySystem is called'); @@ -3032,7 +3034,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }); - } + // } } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/TermService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/TermService.js new file mode 100644 index 0000000..714090c --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/TermService.js @@ -0,0 +1,28 @@ +AIA.factory('TermService', function ($http, $q) { + return { + getTermData: function (layerNo, BodyViewId, systemNo, zoomLevel) { + + var deferred = $q.defer(); + //var URL = 'http://localhost:86/api/PixelLocations?layerNumber=' + layerNo + '&bodyViewIndex=' + BodyViewId + '&systemNumber=' + systemNo + '&zoomLevel=' + zoomLevel + '' + var URL = '/API/api/PixelLocations?layerNumber=' + layerNo + '&bodyViewIndex=' + BodyViewId + '&systemNumber=' + systemNo + '&zoomLevel=' + zoomLevel + '' + + $http({ + method: 'get', + url: URL, + headers: { + 'Content-Type': 'application/json', + } + + }) + .success(function (data, status, headers, config) { + + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error status= ' + status) + deferred.reject(status); + }); + return deferred.promise; + }, + } +}) \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html index 6f6a657..c6c3229 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.html +++ b/400-SOURCECODE/AIAHTML5.Web/index.html @@ -1433,6 +1433,7 @@ +