Ejemplo n.º 1
0
        public static void AddMongDbContext(this IServiceCollection services, IConfiguration config)
        {
            string filePath         = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), StringNormalizer.JSON_FILE_NAME);
            var    stringNormalizer = new StringNormalizer(filePath);

            services.AddSingleton <IStringNormalizer>(stringNormalizer);

            var connString        = config.GetValue <string>("MongoConnString");
            var customConnections = config.GetSection("CustomConnections").Get <List <CustomMongoConnection> >();

            foreach (var cc in customConnections)
            {
                if (cc.ConnectionString == null)
                {
                    cc.ConnectionString = connString;
                }
            }
            var provinceDbInfo = customConnections.Where(c => c.Type == nameof(Province)).FirstOrDefault();
            var provinceDb     = new MongoDbContext(provinceDbInfo.DBName, provinceDbInfo.ConnectionSettings);

            var dbs = new ProvinceDBs {
                CommonDb = provinceDb
            };
            var dbName = config.GetValue <string>("DBName");

            foreach (var p in provinceDb.FindGetResults <Province>(p => p.Applications.Contains("PM")))
            {
                var db = new MongoDbContext(dbName + "-" + p.Prefix, connString,
                                            customConnections: customConnections,
                                            objectPreprocessor: stringNormalizer);
                dbs.Add(p.Prefix, db);
            }

            services.AddSingleton(dbs);
        }
Ejemplo n.º 2
0
 public BaseController(ProvinceDBs dbs)
 {
     this.dbs = dbs;
     dbs.CommonDb.GetUserNameFunc = () => Username;
     foreach (var k in dbs.Keys)
     {
         dbs[k].GetUserNameFunc = () => Username;
     }
 }
Ejemplo n.º 3
0
 public EquipmentsController(ProvinceDBs dbs) : base(dbs)
 {
 }
 public TotalReportController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 5
0
 public CityController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 6
0
 public SubscriberController(ProvinceDBs dbs, DataTableFactory tableFactory) : base(dbs)
 {
     this.tableFactory = tableFactory;
 }
Ejemplo n.º 7
0
 public CommCenterController(ProvinceDBs dbs, DataExporter dataExporter) : base(dbs)
 {
     this.dataExporter = dataExporter;
 }
Ejemplo n.º 8
0
 public DashboardController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 9
0
 public DataExporter(ProvinceDBs dbs, DataTableFactory tableFactory)
 {
     this.dbs          = dbs;
     this.tableFactory = tableFactory;
 }
 public ChangesReportController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 11
0
 public BillsController(ProvinceDBs dbs, DataTableFactory tableFactory) : base(dbs)
 {
     this.tableFactory = tableFactory;
 }
Ejemplo n.º 12
0
 public PlaceController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 13
0
 public AccountController(ProvinceDBs dbs) : base(dbs)
 {
 }
Ejemplo n.º 14
0
 public EquipmentsPmController(ProvinceDBs dbs, IStringNormalizer stringNormalizer) : base(dbs)
 {
     this.stringNormalizer = stringNormalizer;
 }
Ejemplo n.º 15
0
 public BillsImportController(ProvinceDBs dbs) : base(dbs)
 {
 }