コード例 #1
0
        public MessageTO getJobCompletedResponse(MessageTO request)
        {
            MessageTO response = new MessageTO();

            response.MessageType = MessageTypeTO.JobCompletedResponse;

            if (request == null || String.IsNullOrEmpty(request.Configuration.SiteCode) ||
                String.IsNullOrEmpty(request.Configuration.QueryConfigurations.RootNode.Value.File))
            {
                //LOG.Debug("Received an invalid job completed request from the client - unable to process: " + request.Configuration.ToString());
                logging.Log.LOG("Problem with job complete request!");
                response.MessageType = MessageTypeTO.Error;
                response.Error       = "Invalid request!";
                return(response);
            }

            try
            {
                String  sqlProvider      = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlProvider];
                String  connectionString = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlConnectionString];
                ISqlDao sqlDao           = new SqlDaoFactory().getSqlDao(new SqlConnectionFactory().getConnection(sqlProvider, connectionString));
                if (request.ExtractorReport != null)
                {
                    try
                    {
                        logging.Log.LOG("Saving successful job report...");
                        sqlDao.saveReport(request.ExtractorReport);
                    }
                    catch (Exception exc)
                    {
                        logging.Log.LOG("Unable to save extractors report: " + request.Configuration.SiteCode + " - " + request.Configuration.QueryConfigurations.RootNode.Value.File + ", " + exc.Message);
                    }
                }
                // get last IEN from message and save to tracking table
                sqlDao.saveLastIen(request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File, request.ExtractorReport.StartIen, request.ExtractorReport.LastIen, request.ExtractorReport.BatchId);
                // unlock site from locks table
                sqlDao.unlockSite(request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File);
                // the remove function keys off the site code and vista file - those are the only params we need
                Extractors.Remove(new Extractor("", 0, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File, DateTime.Now));
                CompletedExtractions.Push(request.Configuration);
                ActiveExtractions.Remove(request.Configuration);
                // all done with site?
                try
                {
                    checkSiteCompleteAndTrigger(request.ExtractorReport.BatchId, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File);
                }
                catch (Exception triggerExc) // shouldn't fail job complete request if there is a problem with this - we just won't create the trigger
                {
                    logging.Log.LOG("An unexpected error occured when checking if it was ok to create the trigger for site " + request.Configuration.SiteCode + "\r\n\r\n" + triggerExc.ToString());
                }
                response.Message = "Nice Work!";
            }
            catch (Exception exc)
            {
                logging.Log.LOG(exc.Message);
                response.MessageType = MessageTypeTO.Error;
                response.Error       = exc.ToString();
            }

            // handle post process in separate thread
            Thread postProcessThread = new Thread(new ParameterizedThreadStart(RequestHandler.getInstance().postProcess));

            postProcessThread.Start(request);

            return(response);
        }
コード例 #2
0
        static void extractBcmaFromCdw(string[] args)
        {
            String sitecode = args[0];
            KeyValuePair <String, String> range = getRangeFromCdw(sitecode);

            //String startIenFirstWorker = args[1];
            //String lastIenFromCdw = getGreatestCdwIen(sitecode);
            logging.Log.LOG(String.Format("IEN range from CDW for {0} : {1} to {2}", sitecode, range.Key, range.Value));

            Int32 workerThreads = 8;

            IList <String> startPoints = getStartPointsForWorkerThreads(range.Key, range.Value, workerThreads);

            ExtractorConfiguration config = getExtractorConfig("53.79");

            config.QueryConfigurations.RootNode.Value.IdentifiedFiles = config.QueryConfigurations.RootNode.Value.Identifier = "";
            config.QueryConfigurations.RootNode.Children = new List <TreeNode <QueryConfiguration> >();
            config.SiteCode = config.Sites = sitecode;

            logging.Log.LOG(String.Format("Getting ready to use {0} workers to extract top level file from Vista", workerThreads.ToString()));

            IList <Task> allTasks = new List <Task>();

            for (int i = 0; i < startPoints.Count - 1; i++)
            {
                String start = startPoints[i];
                String end   = startPoints[i + 1];
                Task   vs    = new Task(() => extractWithStopIen(config, start, end));
                allTasks.Add(vs);
                vs.Start();
            }

            Task lastChunk = new Task(() => extractWithStopIen(config, startPoints[startPoints.Count - 1], range.Value));

            allTasks.Add(lastChunk);
            lastChunk.Start();

            foreach (Task t in allTasks)
            {
                t.Wait();
            }

            logging.Log.LOG("Finished extracting top level file from Vista!! Only CDW subfiles left...");

            MdoVistaDao.getInstance().shutdownPool(); // don't need our vista cxns any more - let's be nice and shutdown our connections

            try
            {
                createBcmaSubFileTables(sitecode, range.Key, range.Value);
            }
            catch (Exception exc)
            {
                logging.Log.LOG(exc.ToString());
            }

            try
            {
                logging.Log.LOG("Getting ready to update IEN tracking table...");
                ISqlDao dao = new SqlDaoFactory().getSqlDao(new SqlConnectionFactory().getConnection(ConfigurationManager.AppSettings["SqlProvider"], ConfigurationManager.AppSettings["SqlConnectionString"]));
                dao.saveLastIen(sitecode, "53.79", range.Key, range.Value, "20010101125959");
                logging.Log.LOG("Successfully updated IEN tracking table!");
            }
            catch (Exception exc)
            {
                logging.Log.LOG(String.Format("Oh geez... there was a problem updating the IEN tracking table with start IEN {0} and stop IEN {1} for site {2}", range.Key, range.Value, sitecode) + " - " + exc.Message);
            }

            logging.Log.LOG("Finished with hybrid BCMA extraction. Wicked cool.");

            return;
        }