using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Soap;

namespace Valg.EVA.Skanning.ServicesModel.Internal.UploadWebService
{
    internal class DebugWriteTransferContent
    {
        
        
        
        
        
        public static void SaveTransferFiles(string reportingUnitIdentifier, byte[] tokenArchive, string userId, string roleId, string areaPath, string electionPath, byte[] resultArchive, string eCountUpload)
        {
            try
            {
                var directoryInfo = Directory.CreateDirectory(reportingUnitIdentifier);
                File.WriteAllBytes(directoryInfo.FullName + @"\tokenArchive.zip", tokenArchive);
                File.WriteAllBytes(directoryInfo.FullName + @"\resultArchive.zip", resultArchive);
                File.WriteAllText(directoryInfo.FullName + @"\userId.txt", userId);
                File.WriteAllText(directoryInfo.FullName + @"\roleId.txt", roleId);
                File.WriteAllText(directoryInfo.FullName + @"\areaPath.txt", areaPath);
                File.WriteAllText(directoryInfo.FullName + @"\electionPath.txt", electionPath);
                File.WriteAllText(directoryInfo.FullName + @"\eCountUpload.txt", eCountUpload);

                var soapFormatter = new SoapFormatter();
                var tokenFileStream = new FileStream(directoryInfo.FullName + @"\tokenArchive.zip.soap", FileMode.Create);
                soapFormatter.Serialize(tokenFileStream, tokenArchive);

                var resultFileStream = new FileStream(directoryInfo.FullName + @"\resultArchive.zip.soap", FileMode.Create);
                soapFormatter.Serialize(resultFileStream, resultArchive);

            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
    }
}
