ApplicationSettings.cs
1.83 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
47
48
49
50
51
52
53
54
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Configuration;
namespace AIAHTML5.Server.Models
{
public class ApplicationSettings
{
public static dynamic GetApplicationSettings(string applicationName, string userId = null)
{
try
{
var client = new MongoClient();
var db = client.GetDatabase(ConfigurationManager.AppSettings["database"]);
var col = db.GetCollection<dynamic>("app-settings");
dynamic appSettings = col.Find(Builders<dynamic>.Filter.Eq("app", applicationName)).Limit(1).SingleOrDefault();
//if (userId != null)
//{
// var colUser = db.GetCollection<dynamic>("users");
// dynamic user = colUser.Find(Builders<dynamic>.Filter.Eq("_id", ObjectId.Parse(userId))).SingleOrDefault();
// if (user != null)
// {
// string role = user.role.ToString();
// for (int i = 0; i < appSettings.menu.menuItems.Count; i++)
// {
// //List<dynamic> menuItems = new List<dynamic>();
// for (int j = 0; j < appSettings.menu.menuItems[i].roles.Count; j++)
// {
// if (appSettings.menu.menuItems[i].roles[j].ToString() == role)
// {
// }
// }
// }
// }
//}
return appSettings;
}
catch (Exception ex)
{
return null;
}
}
}
}