Beispiel #1
0
        /*
         * Retrieves a response.
         */
        public cnpResponse ReceiveFromCnp(string batchFileName)
        {
            var useEncryption = config.GetValue("useEncryption");
            var pgpPassphrase = config.GetValue("pgpPassphrase");

            cnpFile.CreateDirectory(this.responseDirectory);

            var responseFilePath      = Path.Combine(this.responseDirectory, batchFileName);
            var batchResponseDir      = this.responseDirectory;
            var finalResponseFilePath = responseFilePath;

            // Decrypt the file.
            if ("true".Equals(useEncryption))
            {
                batchResponseDir      = Path.Combine(responseDirectory, "encrypted");
                finalResponseFilePath =
                    Path.Combine(batchResponseDir, batchFileName);
                cnpFile.CreateDirectory(finalResponseFilePath);
            }
            communication.FtpPickUp(finalResponseFilePath, config, batchFileName);

            if ("true".Equals(useEncryption))
            {
                responseFilePath = responseFilePath.Replace(".encrypted", "");
                PgpHelper.DecryptFile(finalResponseFilePath, responseFilePath, pgpPassphrase);
            }

            // Deserialize and return the response.
            var cnpResponse = VersionedXMLDeserializer.Deserialize <cnpResponse>(File.ReadAllText(responseFilePath), this.config.GetVersion());

            return(cnpResponse);
        }
Beispiel #2
0
        public cnpResponse receiveFromCnp(string batchFileName)
        {
            var useEncryption = config.ContainsKey("useEncryption")? config["useEncryption"] : "false";
            var pgpPassphrase = config.ContainsKey("pgpPassphrase")? config["pgpPassphrase"] : "";

            cnpFile.createDirectory(responseDirectory);

            var responseFilePath      = Path.Combine(responseDirectory, batchFileName);
            var batchResponseDir      = responseDirectory;
            var finalResponseFilePath = responseFilePath;

            if ("true".Equals(useEncryption))
            {
                batchResponseDir      = Path.Combine(responseDirectory, "encrypted");
                finalResponseFilePath =
                    Path.Combine(batchResponseDir, batchFileName);
                cnpFile.createDirectory(finalResponseFilePath);
            }
            communication.FtpPickUp(finalResponseFilePath, batchFileName);

            if ("true".Equals(useEncryption))
            {
                responseFilePath = responseFilePath.Replace(".encrypted", "");
                PgpHelper.DecryptFile(finalResponseFilePath, responseFilePath, pgpPassphrase);
            }

            var cnpResponse = (cnpResponse)cnpXmlSerializer.DeserializeObjectFromFile(responseFilePath);

            return(cnpResponse);
        }