Пример #1
0
        /// <summary>
        /// Process all encrypted production files
        /// </summary>
        /// <param name="adjudicationFiles"></param>
        /// <param name="fileLocation"></param>
        /// <param name="isDebug"></param>
        private static void ProcessProdFiles(IEnumerable <string> adjudicationFiles, string fileLocation, bool isDebug)
        {
            //Create ProcessAdjudications object to process production files
            ProcessAdjudications pa = new Adjudications.ProcessAdjudications(isDebug);

            //Iterate through encrypted files
            foreach (string encryptedFile in adjudicationFiles)
            {
                //Decrypt file
                byte[] buffer = new byte[] { };
                Tuple <int, string> processedInformation = new Tuple <int, string>(0, "");
                string decryptedFile = string.Empty;
                decryptedFile = fileLocation + u.GenerateDecryptedFilename(Path.GetFileNameWithoutExtension(encryptedFile));
                buffer        = File.ReadAllBytes(encryptedFile);
                buffer.WriteToFile(decryptedFile, Cryptography.Security.Decrypt, true);

                //Process decrypted file
                processedInformation = pa.ProcessAdjudicationFile(decryptedFile);

                //Attempt to delete decrypted and original file
                //Catch all IOException errors and write them to log
                try
                {
                    File.Delete(encryptedFile);
                    File.Delete(decryptedFile);
                }
                catch (IOException e)
                {
                    log.Error(e.Message);
                }

                //Send summary email
                SendSummary(decryptedFile, processedInformation, isDebug);

                //If Item2 is null or empty, call BackupSummaryFile
                if (string.IsNullOrEmpty(processedInformation.Item2))
                {
                    BackupSummaryFile(false);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Processes all non-encrypted debug files
        /// </summary>
        /// <param name="adjudicationFiles"></param>
        /// <param name="fileLocation"></param>
        /// <param name="isDebug"></param>
        private static void ProcessDebugFiles(IEnumerable <string> adjudicationFiles, string fileLocation, bool isDebug)
        {
            //Create ProcessAdjudications object used for debug files
            ProcessAdjudications pa = new Adjudications.ProcessAdjudications(isDebug);

            //Iterate through debug files
            foreach (string debugFile in adjudicationFiles)
            {
                //Declare tuple to store processing progress
                //1 = Total Processed
                //2 = Errors
                Tuple <int, string> processedInformation = new Tuple <int, string>(0, "");

                //Call ProcessAdjudicationFile using ProcessAdjudications object previously declared
                processedInformation = pa.ProcessAdjudicationFile(debugFile);

                //Attempt to delete original file and catch any IOException errors
                //Write any errors to log
                try
                {
                    File.Delete(debugFile);
                }
                catch (IOException e)
                {
                    log.Error(e.Message);
                }

                //Send an email summary
                SendSummary(debugFile, processedInformation, isDebug);

                //If Item2 null or empty, call BackupSummaryFile
                if (string.IsNullOrEmpty(processedInformation.Item2))
                {
                    BackupSummaryFile(true);
                }
            }
        }