Ejemplo n.º 1
0
        /// <summary>
        ///
        /// After the enumeration of the REST API is complete, this method will enumerate through the raw payloads that
        /// were retrieved; it will then use metadata in order to parse and then load the data into specific table columns.
        ///
        /// <param name="poProcess">The structure that represents the Process being currently run</param>
        /// <returns>None</returns>
        /// </summary>
        private void ApplyDataSnapshot(AceProcess poProcess)
        {
            int nTotalRecords  = 0;
            int nFailedRecords = 0;

            string sSubject = "PmdAceConsumptionServiceImpl::ApplyDataSnapshot()";

            Hashtable CurrRecord = new Hashtable();

            try
            {
                Dictionary <string, IApplicable> BucketApplyManagers = CreateApplyManagers(poProcess);

                using (AceChangeRecordReader oRecordReader = new AceChangeRecordReader(moStgConnectionMetadata, poProcess))
                {
                    foreach (Hashtable TempRecord in oRecordReader)
                    {
                        CurrRecord = TempRecord;

                        // We should probably have a better way of detecting successful records vs. error records
                        if (TempRecord.Count > 1)
                        {
                            foreach (string sTmpBucketName in BucketApplyManagers.Keys)
                            {
                                if (AreBucketValuesPresent(poProcess, sTmpBucketName, TempRecord))
                                {
                                    IApplicable ApplyManager = BucketApplyManagers[sTmpBucketName];

                                    ApplyManager.UpsertRecord(TempRecord);
                                }
                            }
                        }
                        else
                        {
                            nFailedRecords++;
                        }

                        nTotalRecords++;

                        if ((nTotalRecords % 1000) == 0)
                        {
                            LogInfo(sSubject, "Applied (" + nTotalRecords + ") records to the staging table(s)");
                            Console.Out.Flush();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogError(sSubject,
                         "ERROR!  An error has taken place with record -> Contents: (" + CurrRecord.ToString() + ")",
                         ex);
            }
        } // method()