/// <summary />
        public bool RepositoryExists()
        {
            ValidateService();

            using (var serverFactory = SystemCoreInteractDomain.GetCoreFactory(ServerName, Port))
            {
                var core = serverFactory.CreateChannel();
                return(core.RepositoryExists(this.RepositoryId));
            }
        }
Ejemplo n.º 2
0
        //private static void TestThreading()
        //{
        //    try
        //    {
        //        //using (var repo = new DatastoreRepository<MyItem>(repoID, SERVER, PORT))
        //        //{
        //        //    var schema = repo.GetSchema();
        //        //    repo.UpdateSchema(schema);
        //        //}

        //        var timer = Stopwatch.StartNew();
        //        var COUNTER = 0;
        //        var tasks = new List<Task>();

        //        for (var ii = 0; ii < 20000; ii++)
        //        {
        //            var t = Task.Factory.StartNew(() =>
        //            {
        //                try
        //                {
        //                    using (var factory = SystemCoreInteractDomain.GetRepositoryFactory(SERVER, PORT))
        //                    {
        //                        var service = factory.CreateChannel();
        //                        Interlocked.Increment(ref COUNTER);
        //                        var timer2 = Stopwatch.StartNew();
        //                        service.TestHit();
        //                        timer2.Stop();
        //                        Interlocked.Decrement(ref COUNTER);
        //                        Console.WriteLine($"COUNTER={COUNTER}, Elapsed={timer2.ElapsedMilliseconds}");
        //                    }
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.ToString());
        //                }
        //            });
        //            tasks.Add(t);

        //        }//);

        //        Console.WriteLine("Loaded Tasks");
        //        Task.WaitAll(tasks.ToArray());
        //        timer.Stop();

        //        Console.WriteLine($"Elapsed={timer.ElapsedMilliseconds}");
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //}
        #endregion

        public static bool IsDatastoreReady()
        {
            try
            {
                using (var factory = SystemCoreInteractDomain.GetCoreFactory("localhost"))
                {
                    var server = factory.CreateChannel();
                    return(server.IsSystemReady());
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 /// <summary />
 public virtual bool DeleteRepository()
 {
     using (var serverFactory = SystemCoreInteractDomain.GetCoreFactory(ServerName, Port))
     {
         var core = serverFactory.CreateChannel();
         (core as IContextChannel).OperationTimeout = new TimeSpan(0, 0, 120); //Timeout=2m
         if (core.RepositoryExists(this.RepositoryId))
         {
             core.DeleteRepository(new RepositorySchema {
                 ID = this.RepositoryId
             });
         }
     }
     return(true);
 }
        /// <summary />
        public virtual void CreateRepository(RepositorySchema repositorySchema)
        {
            ValidateService();

            if (repositorySchema.ID == Guid.Empty)
            {
                throw new Exception("Invalid ID for repository");
            }
            if (RepositoryExists())
            {
                return;
            }

            using (var factory = SystemCoreInteractDomain.GetCoreFactory(ServerName, Port))
            {
                var core = factory.CreateChannel();
                (core as IContextChannel).OperationTimeout = new TimeSpan(0, 0, 120); //Timeout=2m
                core.SaveRepository(repositorySchema);
            }
        }
 /// <summary />
 protected virtual void CreateConnection()
 {
     this.ChannelFactory   = SystemCoreInteractDomain.GetRepositoryFactory(this.ServerName, this.Port);
     this.DataModelService = this.ChannelFactory.CreateChannel();
     (this.DataModelService as IContextChannel).OperationTimeout = new TimeSpan(0, 0, 120); //Timeout=2m
 }