Beispiel #1
0
 public async Task ClearCatalogAsync()
 {
     using (var mdb = await MdbContext.CreateMdbContextAsync(_cn).ConfigureAwait(false))
     {
         await _syncronizer.DropDbSchemaAsync(mdb).ConfigureAwait(false);
     }
 }
Beispiel #2
0
 public async Task <JMXSchema> SaveSchemaAsync(JMXSchema schema)
 {
     using (var mdb = await MdbContext.CreateMdbContextAsync(_cn).ConfigureAwait(false))
     {
         await _syncronizer.SaveSchemaAsync(mdb, schema).ConfigureAwait(false);
     }
     lock (objLock)
         _schemaCache[schema.ObjectName] = schema;
     foreach (var fk in schema.ForeignKeys)
     {
         if (fk.RefObjectName.IsEmpty())
         {
             throw new ArgumentNullException("Property RefObjectName can't be empty");
         }
         lock (objLock)
         {
             if (_parentRelations.ContainsKey(fk.RefObjectName))
             {
                 _parentRelations[fk.RefObjectName].Add(schema.ObjectName);
             }
             else
             {
                 _parentRelations.Add(fk.RefObjectName, new List <string>()
                 {
                     schema.ObjectName
                 });
             }
         }
     }
     return(schema);
 }
Beispiel #3
0
        public async Task DropSchemaAsync(string objectName)
        {
            JMXObjectName name = objectName;

            using (var mdb = await MdbContext.CreateMdbContextAsync(_cn).ConfigureAwait(false))
            {
                await _syncronizer.DropSchemaAsync(mdb, name.AreaName, name.ObjectName).ConfigureAwait(false);
            }
            lock (objLock)
                _schemaCache.Remove(name.ToString());
        }
Beispiel #4
0
        async Task executeTestAsync()
        {
            using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings()
            {
                DateFolderMask = "yyyy-MM-dd"
            }))
            {
                MdbContextOptions.GetOptions().CommandTimeout = 120;
                using (var ctx = await MdbContext.CreateMdbContextAsync(_cn))
                {
                    l.Debug("Test 1 Start ");
                    int    i   = 0;
                    string sql = @"Create Table TestTable(
					ID		uniqueidentifier	not null primary key,
					Name	varchar(128)	not null,
					DateOper	datetime	not null,
					Notes	varchar(256)	null,
					Handle	int				not null)"                                    ;
                    i = await ctx.ExecuteAsync(sql);

                    l.Debug($"Test 1 Finish rows result {i}");

                    l.Debug("Test 2 Start ");
                    sql = @"Insert Into TestTable (ID, Name, DateOper, Handle)
					Values(@ID, @Name, @DateOper, @Handle)"                    ;

                    i = 0;
                    for (; i < 1000; i++)
                    {
                        await ctx.ExecuteAsync(sql,
                                               new MdbParameter("@ID", Guid.NewGuid()),
                                               new MdbParameter("@Name", "Тестовая строка № " + i.ToString()),
                                               new MdbParameter("@DateOper", vbo.Date().AddDays(i - 1000)),
                                               new MdbParameter("@Handle", i) { NullIfEmpty = false });;
                    }
                    l.Debug($"Test 2 Finish rows result {i}");
                    l.Debug("Test 3 Start ");
                    i = 0;
                    using (var dr = await ctx.GetReaderAsync("Select * From TestTable Order By Handle"))
                    {
                        for (; dr.Read(); i++)
                        {
                            l.Debug(dr.GetRowJSON());
                        }
                    }
                    l.Debug($"Test 3 Finish rows result {i}");
                    l.Debug("Test 4 Start ");
                    sql = "Drop Table TestTable";
                    i   = await ctx.ExecuteAsync(sql);

                    l.Debug($"Test 4 Finish rows result {i}");
                }
            }
        }
Beispiel #5
0
        public async Task <JMXSchema> SyncSchemaAsync(string objectName)
        {
            JMXObjectName name = objectName;

            using (var mdb = await MdbContext.CreateMdbContextAsync(_cn).ConfigureAwait(false))
            {
                var schema = await _syncronizer.SyncSchemaAsync(mdb, name.AreaName, name.ObjectName).ConfigureAwait(false);

                lock (objLock)
                    _schemaCache[schema.ObjectName] = schema;
                return(schema);
            }
        }
Beispiel #6
0
 async Task _createContextTestAsync()
 {
     using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         Type t = null;
         l.Debug("SpeedTest 1 Start ");
         int i = 0;
         for (i = 0; i < 1000000; i++)
         {
             using (var ctx = await MdbContext.CreateMdbContextAsync(_cn))
             {
             }
         }
         l.Debug($"SpeedTest 1 Finish {i} count result {t}");
     }
 }
Beispiel #7
0
 async Task _getReaderSpeedTestAsync()
 {
     using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         DateTime t = DateTime.MinValue;
         //Caching pool
         int i = 0;
         for (i = 0; i < 100; i++)
         {
             using (var ctx = await MdbContext.CreateMdbContextAsync(_cn))
             {
             }
         }
         using (var ctx = await MdbContext.CreateMdbContextAsync(_cn))
         {
             l.Debug("SpeedTestAsync 1 Start ");
             MdbContextOptions.GetOptions().CommandTimeout = 120;
             for (i = 0; i < 1000; i++)
             {
                 using (var dr = await ctx.GetReaderAsync("Select * From PayDocs Where Handle = @handle",
                                                          new MdbParameter("@handle", 3999758)))
                 {
                     dr.Read();
                 }
             }
             l.Debug($"SpeedTestAsync 1 Finish {i} count result {i}");
             l.Debug("SpeedTestAsync 2 Start ");
             for (i = 0; i < 1000; i++)
             {
                 using (var dr = await ctx.GetReaderAsync("Select * From PayDocs Where Handle = @handle",
                                                          "@handle", 3999758))
                 {
                     dr.Read();
                 }
             }
             l.Debug($"SpeedTestAsync 2 Finish {i} count result {i}");
         }
     }
 }
Beispiel #8
0
        public async Task <JMXSchema> GetSchemaAsync(string objectName)
        {
            JMXObjectName name = objectName;

            if (_schemaCache.TryGetValue(name, out JMXSchema schema))
            {
                schema.SchemaProvider = this;
                return(schema);
            }
            using (var mdb = await MdbContext.CreateMdbContextAsync(_cn).ConfigureAwait(false))
            {
                schema = await _syncronizer.GetSchemaAsync(mdb, name.AreaName, name.ObjectName).ConfigureAwait(false);

                lock (objLock)
                {
                    if (!_schemaCache.ContainsKey(name))
                    {
                        _schemaCache.Add(name, schema);
                    }
                }
            }
            return(schema);
        }