Exemplo n.º 1
0
    private static string ZipData(string pathToLog, string pathToWrapperLog, string pathToSdkLog, string pathToDb, string userName, string hashedPass, string esn, string previousEsn)
    {
        string str = AppLog.GenerateNewFilePath("package");

        using (FileStream fileStream = File.Create(str))
        {
            ZipOutputStream zipOutputStream = new ZipOutputStream(fileStream)
            {
                Password = "******"
            };
            zipOutputStream.SetLevel(3);
            AppLog.PutStreamToZip("z", zipOutputStream, new MemoryStream(Encoding.UTF8.GetBytes(AppLog.GenerateEncryptedUserDetails(userName, hashedPass, esn, previousEsn))));
            AppLog.PutStreamToZip("l", zipOutputStream, File.OpenRead(pathToLog));
            AppLog.PutStreamToZip("d", zipOutputStream, File.OpenRead(pathToDb));
            if (File.Exists(pathToWrapperLog))
            {
                AppLog.PutStreamToZip("wl", zipOutputStream, File.Open(pathToWrapperLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            }
            if (File.Exists(pathToSdkLog))
            {
                AppLog.PutStreamToZip("sdkl", zipOutputStream, File.Open(pathToSdkLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            }
            string unityLogFilePath = AppLog.GetUnityLogFilePath();
            if (!string.IsNullOrEmpty(unityLogFilePath) && File.Exists(unityLogFilePath))
            {
                AppLog.PutStreamToZip("log", zipOutputStream, File.Open(unityLogFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            }
            zipOutputStream.Close();
        }
        return(str);
    }