// Convert all batch objects into xml and place them in cnpRequest, then build the Session file. public string Serialize() { var xmlHeader = "<?xml version='1.0' encoding='utf-8'?>\r\n<cnpRequest version=\"12.5\"" + " xmlns=\"http://www.vantivcnp.com/schema\" " + "numBatchRequests=\"" + numOfCnpBatchRequest + "\">"; var xmlFooter = "\r\n</cnpRequest>"; // Create the Session file. finalFilePath = cnpFile.createRandomFile(requestDirectory, Path.GetFileName(finalFilePath), ".xml", cnpTime); var filePath = finalFilePath; // Add the header into the Session file. cnpFile.AppendLineToFile(finalFilePath, xmlHeader); // Add authentication. cnpFile.AppendLineToFile(finalFilePath, authentication.Serialize()); // batchFilePath is not null when some batch is added into the batch request. if (batchFilePath != null) { cnpFile.AppendFileToFile(finalFilePath, batchFilePath); } else { throw new CnpOnlineException("No batch was added to the CnpBatch!"); } // Add the footer into Session file cnpFile.AppendLineToFile(finalFilePath, xmlFooter); finalFilePath = null; return(filePath); }
public string Serialize() { string xmlHeader = "<?xml version='1.0' encoding='utf-8'?>\r\n<litleRequest version=\"9.3\"" + " xmlns=\"http://www.litle.com/schema\" " + "numBatchRequests=\"" + numOfLitleBatchRequest + "\">"; string xmlFooter = "\r\n</litleRequest>"; string filePath; finalFilePath = litleFile.createRandomFile(requestDirectory, Path.GetFileName(finalFilePath), ".xml", litleTime); filePath = finalFilePath; litleFile.AppendLineToFile(finalFilePath, xmlHeader); litleFile.AppendLineToFile(finalFilePath, authentication.Serialize()); if (batchFilePath != null) { litleFile.AppendFileToFile(finalFilePath, batchFilePath); } else { throw new LitleOnlineException("No batch was added to the LitleBatch!"); } litleFile.AppendLineToFile(finalFilePath, xmlFooter); finalFilePath = null; return(filePath); }
public string Serialize() { string xmlHeader = generateXmlHeader(); string xmlFooter = generateXmlFooter(); string filePath; finalFilePath = litleFile.createRandomFile(requestDirectory, Path.GetFileName(finalFilePath), ".xml", litleTime); filePath = finalFilePath; litleFile.AppendLineToFile(finalFilePath, xmlHeader); litleFile.AppendLineToFile(finalFilePath, authentication.Serialize()); if (batchFilePath != null) { litleFile.AppendFileToFile(finalFilePath, batchFilePath); } else { throw new LitleOnlineException("No batch was added to the LitleBatch!"); } litleFile.AppendLineToFile(finalFilePath, xmlFooter); finalFilePath = null; return(filePath); }