Esempio n. 1
0
        private Job BuildJob(Attempt attempt, Recipe recipe, DbBroker dbBroker)
        {
            var log = Log.GetLogger();

            try
            {
                var jb  = new JobBuilder(new ValueComparer(), dbBroker);
                var job = jb.Build(recipe, attempt);
                return(job);
            }
            catch (JobBuilder.StudyNotFoundException ex)
            {
                log.Info($"{ex.Message} Accession: [{attempt.CurrentAccession}]");
                return(null);
            }
            catch (DirectoryNotFoundException ex)
            {
                if (ex.Message.ToLower().Contains("workable series were found"))
                {
                    log.Info($"{ex.Message} Accession: [{attempt.CurrentAccession}]");
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                log.Info($"{ex.Message} Attempt [{attempt.Id}] failed during build.");
                @attempt.Comment = ex.Message;
            }

            return(null);
        }
Esempio n. 2
0
        private void CleanupDatabase()
        {
            var log = Log.GetLogger();
            var cfg = CapiConfig.GetConfig();

            if (cfg == null)
            {
                throw new ApplicationException("Unable to find config file.");
            }
            var dbBroker = new DbBroker(cfg.AgentDbConnectionString);

            if (dbBroker.Database.EnsureCreated())
            {
                log.Info("Database not found, so it has been created.");
            }
            else
            {
                log.Info("Database found.");
            }

            if (!dbBroker.Database.CanConnect())
            {
                log.Error("Could not connect to database using string: " + cfg.AgentDbConnectionString);
            }
            else
            {
                log.Info("DB Connection established");
            }

            try
            {
                log.Info("DB Connection good? " + dbBroker.Database.CanConnect());
                var failedCases = dbBroker.GetCaseByStatus("Processing");

                foreach (var c in failedCases)
                {
                    var tmp = c;
                    tmp.Status = "Pending";
                    dbBroker.Attempts.Update(tmp);
                    dbBroker.SaveChanges();
                }
                var failedJobs = dbBroker.GetJobByStatus("Processing");
                foreach (var j in failedJobs)
                {
                    var tmp = j;
                    tmp.Status = "Failed";
                    dbBroker.Jobs.Update(tmp);
                    dbBroker.SaveChanges();
                }
            }
            catch (Exception e)
            {
                log.Error("Error while accesing database. If this is due to an incompatible schema, maybe try wiping the database and starting again?");
                log.Error(e);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dicomServices"></param>
 /// <param name="imgProcFactory">ImageProcessing Factory</param>
 /// <param name="valueComparer"></param>
 /// <param name="fileSystem">Provides extra filesystem capabilities</param>
 /// <param name="processBuilder">Builds exe or java processes and executes them</param>
 /// <param name="capiConfig">CAPI configuration</param>
 /// <param name="log">Log4Net logger</param>
 /// <param name="context">Agent Repository (DbContext) to communicate data with database</param>
 public JobBuilder(IValueComparer valueComparer, DbBroker context)
 {
     _valueComparer = valueComparer;
     _log           = Log.GetLogger();
     _context       = context;
 }