예제 #1
0
        public void CanWriteItems()
        {
            var items = importer.Read();

            using (var file = new TempFile()) {
                var exporter = new GDFileExporter(file.filename, IsExpansion1, ModName);
                exporter.Write(items);

                // Byte wise compare
                byte[] written = File.ReadAllBytes(file.filename);
                byte[] read    = File.ReadAllBytes(SourceFile);
                written.Length.Should().Be.EqualTo(read.Length);

                for (int i = 0; i < written.Length; i++)
                {
                    written[i].Should().Be.EqualTo(read[i]);
                }

                // TOOD: Is this proper? its read related testing..
                var verifiy = exporter.Read();
                verifiy.Count.Should().Be.EqualTo(items.Count);

                foreach (var item in verifiy)
                {
                    item.BaseRecord.Should().StartWith("records/");
                }
            }
        }
예제 #2
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (buttonImport.Enabled)
            {
                FileExporter io;

                if (radioIAStash.Checked)
                {
                    io = new IAFileExporter(_filename);
                }
                else if (radioGDStash.Checked)
                {
                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    if (settings == null)
                    {
                        io = new GDFileExporter(_filename, false, string.Empty);
                    }
                    else
                    {
                        io = new GDFileExporter(_filename, settings.IsExpansion1, settings.Mod);
                    }
                }
                else
                {
                    _playerItemDao.Save(_sm.EmptyStash(_filename));
                    MessageBox.Show("Items imported", "Items imported!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                var items = io.Read();
                _playerItemDao.Import(items);

                MessageBox.Show("Items imported\nIf you already had items, you may have gotten duplicates.", "Items imported!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #3
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (buttonImport.Enabled)
            {
                FileExporter io;

                if (radioIAStash.Checked)
                {
                    io = new IAFileExporter(_filename);
                }
                else if (radioGDStash.Checked)
                {
                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    io = new GDFileExporter(_filename, settings?.Mod ?? string.Empty);
                }
                else
                {
                    _playerItemDao.Save(_sm.EmptyStash(_filename));

                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                    return;
                }

                var items = io.Read(Read(_filename));
                Logger.Debug($"Storing {items.Count} items to db");
                progressBar1.Maximum = items.Count;
                buttonImport.Enabled = false;
                Thread t = new Thread(() => {
                    ExceptionReporter.EnableLogUnhandledOnThread();
                    isLocked = true;

                    var batches = BatchUtil.ToBatches <PlayerItem>(items);
                    foreach (var batch in batches)
                    {
                        _playerItemDao.Import(batch);
                        Invoke((MethodInvoker) delegate { progressBar1.Value += batch.Count; });
                    }

                    isLocked = false;
                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success_body"),
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                });

                t.Start();
            }
        }
예제 #4
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (buttonExport.Enabled)
            {
                if (IsGdstashFormat)
                {
                    var io = new GDFileExporter(filename, false, string.Empty); // Params are not used for writing

                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    if (settings == null)
                    {
                        var items = playerItemDao.ListAll();
                        io.Write(items);
                    }
                    else
                    {
                        var items = playerItemDao.ListAll()
                                    .Where(item => item.IsHardcore == settings.IsHardcore /* && item.IsExpansion1 == settings.IsExpansion1*/);

                        if (string.IsNullOrEmpty(settings.Mod))
                        {
                            io.Write(items.Where(item => string.IsNullOrEmpty(item.Mod)).ToList());
                        }
                        else
                        {
                            io.Write(items.Where(item => item.Mod == settings.Mod).ToList());
                        }
                    }
                }
                else
                {
                    var io    = new IAFileExporter(filename);
                    var items = playerItemDao.ListAll();
                    io.Write(items);
                }

                MessageBox.Show("Items Exported!", "Items exported!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
예제 #5
0
파일: ImportMode.cs 프로젝트: gmy77/iagd
        private void buttonImport_Click(object sender, EventArgs e)
        {
            if (buttonImport.Enabled)
            {
                FileExporter io;

                if (radioIAStash.Checked)
                {
                    io = new IAFileExporter(_filename);
                }
                else if (radioGDStash.Checked)
                {
                    GDTransferFile settings = cbItemSelection.SelectedItem as GDTransferFile;
                    io = new GDFileExporter(_filename, settings?.Mod ?? string.Empty);
                }
                else
                {
                    _playerItemDao.Save(_sm.EmptyStash(_filename));

                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                    return;
                }

                var items = io.Read(Read(_filename));
                _playerItemDao.Import(items);

                MessageBox.Show(
                    RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success_body"),
                    RuntimeSettings.Language.GetTag("iatag_ui_importexport_import_success"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
            }
        }