Пример #1
0
        private void extensions_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            long   extSize       = tManager.DataCore.GetExtensionSize(e.Node.Text);
            string formattedSize = StringExt.FormatToSize(extSize);

            if (e.Node.Text != "all")
            {
                extensions.Nodes[e.Node.Text].Nodes[1].Text = "Size: " + formattedSize;
            }
        }
Пример #2
0
 private void populate_selection_info(IndexEntry entry)
 {
     Invoke(new MethodInvoker(delegate {
         string ext      = entry.Extension;
         dataId.Text     = entry.DataID.ToString();
         offset.Text     = entry.Offset.ToString();
         size.Text       = StringExt.FormatToSize(entry.Length);
         encrypted.Text  = tManager.DataCore.ExtensionEncrypted(ext).ToString();
         extension.Text  = ext;
         uploadPath.Text = entry.DataPath;
     }));
 }
Пример #3
0
        private async void load_file(string fileName, byte[] fileBytes)
        {
            try
            {
                actionSW.Reset();
                actionSW.Start();

                await Task.Run(() => { core.ParseBuffer(fileBytes); });
            }
            catch (Exception ex)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.ERROR, ex);
                MessageBox.Show(ex.Message, "RDB Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                actionSW.Stop();

                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "{0} entries loaded from: {1} ({2}) in {3}ms", core.RowCount, fileName, StringExt.FormatToSize(fileBytes.Length), actionSW.ElapsedMilliseconds.ToString("D4"));
                tManager.SetText(key, fileName);
                initializeGrid();
            }
        }
Пример #4
0
        private async void copyBtn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("You are about to copy all the listed files into the choosen dump directory!\n\nDo you want to continue?", "Input Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            bool copy = default;

            int total     = grid.Rows.Count;
            int count     = total;
            int failCount = 0;

            prgBar.Maximum = total;

            while (count > 0)
            {
                DataGridViewRow row = grid.Rows[0];

                copy = false;

                string name       = row.Cells["name"].Value.ToString();
                string sourceFldr = row.Cells["source"].Value.ToString();
                string extFldr    = row.Cells["destination"].Value.ToString();
                string destFldr   = $"{dumpDir}\\{extFldr}";
                string exists     = row.Cells["exists"].Value.ToString();

                string source      = $"{sourceFldr}\\{name}";
                string destination = $"{dumpDir}\\{extFldr}\\{name}";

                if (exists == "Yes")
                {
                    if (configMan["OverwriteExisting", "DumpUpdater"])
                    {
                        copy = true;
                    }

                    if (!copy)
                    {
                        FileInfo srcInfo  = new FileInfo(source);
                        FileInfo destInfo = new FileInfo(destination);

                        string srcSize  = StringExt.FormatToSize(srcInfo.Length);
                        string destSize = StringExt.FormatToSize(destInfo.Length);

                        string srcDate  = srcInfo.CreationTime.ToString("yyyy-MM-dd");
                        string destDate = destInfo.CreationTime.ToString("yyyy-MM-dd");

                        if (MessageBox.Show($"{name} already exists in the dump!\n\n" +
                                            $"Existing File: Created: {destDate} Size: {destSize}\n" +
                                            $"New Info: Created: {srcDate} Size: {srcSize}\n\n" +
                                            $"Do you want to overwrite it?", "File Conflict", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            copy = true;
                        }
                    }
                }
                else
                {
                    copy = true;
                }

                if (copy)
                {
                    if (File.Exists(destination))
                    {
                        File.Delete(destination);
                    }

                    if (!Directory.Exists(destFldr))
                    {
                        copy = false;
                        MessageBox.Show($"The destination folder: {destFldr} does not exist!", "Directory Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                    if (copy)
                    {
                        try
                        {
                            statusLb.Text = $"Copying {name}...";

                            await Task.Run(() => { File.Copy(source, destination); });
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show($"Could not copy {name}\n\nMessage: {ex.Message}", "Exception Occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        failCount++;
                    }
                }

                grid.Rows.Remove(row);

                prgBar.Value = total - count;

                count--;
            }

            if (failCount > 0)
            {
                MessageBox.Show($"{failCount} files could not be copied into the dump directory!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            prgBar.Maximum = 100;
            prgBar.Value   = 0;
            statusLb.Text  = string.Empty;
        }