private void DemandDomain()
 {
     lock (sync) {
         if (domain != null)
         {
             return;
         }
         domain = DomainBuilder.BuildDomain();
     }
 }
        public Project ConnectToDatabase(string name, string url)
        {
            Project project = GetProject() as Project;

            if (project != null)
            {
                DomainUrl     domainUrl  = new DomainUrl(url);
                DomainBuilder builder    = DomainBuilderFactory.GetDomainBuilder(domainUrl);
                DataDomain    dataDomain = builder.BuildDomain();
                dataDomain.Name = name;
                project.AddDataDomain(dataDomain);
                return(project);
            }
            return(null);
        }
Example #3
0
        static void Main(string serialNumber, string logpFile, bool verbose = false, bool create = false)
        {
            var args = new Arguments(serialNumber, logpFile, create, verbose)
                       .Validate();

            var i    = new Importer();
            var data = i.Import(logpFile);

            var domain = DomainBuilder.BuildDomain(create);

            try
            {
                using (var session = domain.OpenSession())
                {
                    if (!session.IsActive)
                    {
                        session.Activate();
                    }
                    using (var trn = session.OpenTransaction())
                    {
                        var persister = new Persister();
                        persister.Persist(data);
                        trn.Complete();
                    }
                }
                Console.WriteLine($"Import of file {logpFile} successfull.");
            } catch (Exception e) {
                var c = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Import failed : {e.Message}");
                if (verbose)
                {
                    Console.WriteLine(e.StackTrace);
                }
                Console.ForegroundColor = c;
                Environment.ExitCode    = 1;
            }
        }