private void InitCloudServices()
        {
            AnalysisRequestService arService = (AnalysisRequestService)entityService;

            if (arService.analysisRequestPendingCloudMessageService == null || arService.cloudStorageService == null)
            {
                arService.InitCloudServices(UserContact.GNOrganization.AWSConfigId);
            }
        }
Пример #2
0
        private static void ReStartFailedAnalysis(AnalysisRequestService analysisRequestService, GNAnalysisRequest analysisRequest)
        {
            if (RESTART_ANALYSIS_FEATURE_ACTIVE)
            {
                try
                {
                    //get analysis request from db
                    GNAnalysisRequest ar = analysisRequestService.db.GNAnalysisRequests
                                           .Include(a => a.AnalysisType)
                                           .Include(a => a.GNAnalysisRequestGNSamples.Select(s => s.GNSample).Select(s => s.CloudFiles))
                                           .Include(a => a.AnalysisStatus)
                                           .Include(a => a.AnalysisResult)
                                           .Where(a => a.Id == analysisRequest.Id)
                                           .FirstOrDefault();

                    //determine if analysis re-start is allowed
                    ar = analysisRequestService.IsValidSampleSet(ar);
                    ar.CanReStartAnalysis = analysisRequestService.IsAnalysisRestartAllowed(ar, FORCE_RESTART_ANALYSIS);

                    //restart analysis
                    if (ar.CanReStartAnalysis && ar.IsFailedRequest)
                    {
                        LogUtil.Info(logger, "Restart Analysis for AR ID [" + ar.Id + "]...");
                        System.Console.WriteLine("\nRestart Analysis for AR ID [" + ar.Id + "]...");

                        var t = Task.Run(async delegate
                        {
                            var arService = new AnalysisRequestService(new GNEntityModelContainer(), new IdentityModelContainer());

                            //get user contact
                            GNContact userContact = arService.db.GNContacts.Find(ar.CreatedBy);

                            if (arService.analysisRequestPendingCloudMessageService == null || arService.cloudStorageService == null)
                            {
                                arService.InitCloudServices(userContact.GNOrganization.AWSConfigId);
                            }

                            await arService.StartAnalysis(userContact, ar.Id);
                        });
                    }
                    else
                    {
                        LogUtil.Info(logger, "UNABLE to Restart Analysis for AR ID [" + ar.Id + "]...");
                        System.Console.WriteLine("\nUNABLE to Restart Analysis for AR ID [" + ar.Id + "]...");
                    }
                }
                catch (Exception e)
                {
                    LogUtil.Error(logger, "Unable to Process Failure of Analysis " + analysisRequest.Id + " : " + e.Message, e);
                }
            }
        }