PixelLocator.cs
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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("mongodb://192.168.90.43:27017");
var client = new MongoClient();
var db = client.GetDatabase("AIAHTML5");
var col = db.GetCollection<BsonDocument>("DAImages");
var pipeline = new BsonDocument[]
{
new BsonDocument{{"$unwind", "$terms"}},
new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", Convert.ToInt32(systemNumber)).Add("bodyViewIndex", Convert.ToInt32(bodyViewIndex)).Add("layerNumber", Convert.ToInt32(layerNumber)).Add("zoom", Convert.ToInt32(zoom)) }},
new BsonDocument { {"$project", new BsonDocument()
.Add("_id", 0)
.Add("terms", 1)
.Add("bodyRegionId", 1)
} }
};
var pixelData = col.Aggregate<BsonDocument>(pipeline).ToList();
return pixelData.ToJson();
}
catch (Exception e)
{
string error = e.Message + "..STACKTRACE: " + e.StackTrace;
return error;
}
}
}
}