Beispiel #1
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var logFiles = DBMLogFileManager.Instance.DetectLogs(path);

            if (logFiles.Count > 0)
            {
                progressBar1.Invoke(new Action(() =>
                {
                    progressBar1.Maximum = logFiles.Count - 1;
                }));

                zipPath = $"{zipPath}.zip";
                using (ZipArchive zip = ZipFile.Open(zipPath, ZipArchiveMode.Create))
                {
                    for (int i = 0; i < logFiles.Count; i++)
                    {
                        backgroundWorker.ReportProgress(i);
                        DBMLogFileManager.Instance.SaveLogs(zipPath, zip, logFiles[i]);
                    }
                }

                if (MessageBox.Show("Do you want to delete the Log-Files ?", AppConstants.WindowCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DBMLogFileManager.Instance.DeleteLogs(this, logFiles);
                }

                if (MessageBox.Show("Do you want to transmit the Log-Files ?", AppConstants.WindowCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (DBMUtils.IsZipFileGenerated(zipPath))
                    {
                        DBMLogFileManager.Instance.SendWebReq(zipPath);
                        File.Delete(zipPath);
                    }
                    else
                    {
                        MessageBox.Show("There is no Zip-File to transmit !", AppConstants.WindowCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("No Log-Files found!", AppConstants.WindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #2
0
        public List <string> DetectLogs(string dayzPath)
        {
            List <string> logs = new List <string>();

            long fileSize = 0L;

            var extensionCollection = System.Enum.GetNames(typeof(DayZLogFileExt));

            for (int i = 0; i < extensionCollection.Count(); i++)
            {
                logs.AddRange(Directory.GetFiles(dayzPath, $"*.{extensionCollection[i]}"));
            }

            for (int j = 0; j < logs.Count; j++)
            {
                fileSize += new FileInfo(logs[j]).Length;
            }

            MessageBox.Show($"Found: {logs.Count} files with a size of: {DBMUtils.BytesToString (fileSize)} !", AppConstants.WindowCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);

            return(logs);
        }
Beispiel #3
0
        public void SendWebReq(string zipPath)
        {
            try
            {
                if (DBMUtils.IsZipFileGenerated(zipPath) == true)
                {
                    System.Net.WebClient Client = new System.Net.WebClient();
                    Client.Headers.Add("Content-Type", "binary/octet-stream");

                    byte[] result = Client.UploadFile("https://report.deutschebohrmaschine.de/upload.php", "POST", zipPath);

                    string response = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
                    MessageBox.Show(response);
                }
                else
                {
                    MessageBox.Show("No Zip-Archive has been found!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }