public static void Export(DataTable data, string name)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Title = "Export " + name + " data to csv";
            dialog.Filter = "csv files (*.csv)|*.csv";
            dialog.AddExtension = true;
            dialog.DefaultExt = ".csv";
            dialog.OverwritePrompt = true;
            dialog.InitialDirectory = UserAccount.Settings.CSVExportDir;
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                _filename = dialog.FileName;
                CSVExport expObj = new CSVExport();
                Thread t1 = new Thread(new ParameterizedThreadStart(expObj.DoExport));
                t1.TrySetApartmentState(ApartmentState.STA);
                ProgressDialog prgDialog = new ProgressDialog("Building " + name + " CSV file...", expObj);
                t1.Start(data);
                prgDialog.ShowDialog();
            }
        }
        private void RecalculateAutoCon()
        {
            SortedList<object, string> options = new SortedList<object, string>();
            List<CharCorpOption> charcorps = UserAccount.CurrentGroup.GetCharCorpOptions(APIDataType.Assets);
            charcorps.Sort();
            foreach (CharCorpOption opt in charcorps)
            {
                options.Add(opt.Corp ? opt.CharacterObj.CorpID : opt.CharacterObj.CharID, opt.Name);
            }
            OptionPicker picker = new OptionPicker("Select Owner", "Select a character or corporation to generate" +
                " courier contracts for.", options);
            if (picker.ShowDialog() == DialogResult.OK)
            {
                ProgressDialog progress = new ProgressDialog("Generating Contracts...", _autocon);
                object param = picker.SelectedItem;
                Thread t0 = new Thread(new ParameterizedThreadStart(AutoCon));
                t0.SetApartmentState(ApartmentState.STA);
                t0.Start(param);
                DialogResult result = progress.ShowDialog();
                if (result == DialogResult.OK)
                {
                    _contractsBindingSource.DataSource = _contracts;

                    Text = "Viewing " + _contractsBindingSource.Count + " contracts";
                }
                else if (result == DialogResult.Cancel)
                {
                    // Stop our worker thread if the user has cancelled out of the progress dialog.
                    t0.Abort();
                    t0.Join();

                    MessageBox.Show("Auto-contractor was cancelled, the contracts window will now close.",
                        "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
        }
Example #3
0
        private void RepairDatabase()
        {
            VerifyDatabase verify = new VerifyDatabase();
            Thread t0 = new Thread(new ThreadStart(verify.Run));
            ProgressDialog dialog = new ProgressDialog("Verifying Data", verify);
            t0.Start();
            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                t0.Abort();
                t0.Join();

                MessageBox.Show("Data integrity check was cancelled.",
                    "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            this.Visible = false;

            if (rdbAPIXML.Checked)
            {
                System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
                dialog.Filter = "XML files|*.xml";
                dialog.Title = "Import EVE API Data";
                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                {
                    XmlDocument xml = new XmlDocument();
                    xml.Load(dialog.FileName);
                    APIDataType type = EveAPI.GetFileType(xml);
                    APICharacter character = UserAccount.CurrentGroup.Accounts[0].Chars[0];
                    int walletID = 0;
                    CharOrCorp corc = CharOrCorp.Char;
                    bool Cancel = false;

                    // Determine correct APICharacter instance to use when loading the data.
                    SortedList<object, string> options = new SortedList<object, string>();
                    List<CharCorpOption> charcorps = UserAccount.CurrentGroup.GetCharCorpOptions();
                    charcorps.Sort();
                    foreach (CharCorpOption opt in charcorps)
                    {
                        if (!options.ContainsKey(opt.Data.ID)) { options.Add(opt.Data.ID, opt.Name); }
                    }

                    OptionPicker picker = new OptionPicker("Select Char/Corp",
                        "Please select the character or corp to use when loading this " + type.ToString() +
                        " file into the database.", options);

                    if (picker.ShowDialog() != DialogResult.Cancel)
                    {
                        long chosenID = (long)picker.SelectedItem;
                        bool corp = false;
                        character = UserAccount.CurrentGroup.GetCharacter(chosenID, ref corp);
                        corc = corp ? CharOrCorp.Corp : CharOrCorp.Char;

                        if ((type == APIDataType.Journal || type == APIDataType.Transactions) &&
                            corc == CharOrCorp.Corp)
                        {
                            SortedList<object, string> options2 = new SortedList<object, string>();
                            foreach(EMMADataSet.WalletDivisionsRow wallet in character.WalletDivisions)
                            {
                                options2.Add(wallet.ID, wallet.Name + " (" + wallet.ID + ")");
                            }
                            OptionPicker picker2 = new OptionPicker("Select Wallet",
                                "Please select the corporate wallet to be used when loading this journal data.",
                                options2);
                            if (picker2.ShowDialog() == DialogResult.Cancel)
                            {
                                Cancel = true;
                            }
                            else
                            {
                                walletID = (int)picker2.SelectedItem;
                            }
                        }

                        if (!Cancel)
                        {
                            IProgressDialog prgDialog = null;

                            switch (type)
                            {
                                case APIDataType.Transactions:
                                    prgDialog = new ProgressDialog("Loading Transactions", character);
                                    character.ProcessTransactionsXML(xml, corc, (short)walletID);
                                    prgDialog.ShowDialog();
                                    break;
                                case APIDataType.Journal:
                                    prgDialog = new ProgressDialog("Loading Journal Data", character);
                                    character.ProcessJournalXML(xml, corc, (short)walletID);
                                    prgDialog.ShowDialog();
                                    break;
                                case APIDataType.Assets:
                                    prgDialog = new DetailProgressDialog("Loading Assets", character);
                                    character.ProcessAssetXML(xml, corc);
                                    prgDialog.ShowDialog();
                                    break;
                                case APIDataType.Orders:
                                    prgDialog = new ProgressDialog("Loading Orders", character);
                                    character.ProcessOrdersXML(xml, corc);
                                    prgDialog.ShowDialog();
                                    break;
                                case APIDataType.IndustryJobs:
                                    prgDialog = new ProgressDialog("Loading Industry Jobs", character);
                                    character.ProcessIndustryJobsXML(xml, corc);
                                    prgDialog.ShowDialog();
                                    break;
                                case APIDataType.Unknown:
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }

            }
            else if (rdbEveIncome.Checked)
            {

            }
            else if (rdbEMMA.Checked)
            {
                System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
                dialog.Filter = "EMMA data files (*.DAT, *.CDAT)|*.dat;*.cdat";
                dialog.Title = "Import EMMA Data";
                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                {
                    Thread t1 = new Thread(new ParameterizedThreadStart(LoadEMMAFile));
                    t1.SetApartmentState(ApartmentState.STA);
                    ProgressDialog progress = new ProgressDialog("Importing EMMA Data...", this);
                    t1.Start(dialog.FileName);
                    DialogResult result = progress.ShowDialog();
                    if (result == DialogResult.Cancel)
                    {
                        // Stop our worker thread if the user has cancelled out of the progress dialog.
                        t1.Abort();
                        t1.Join();

                        MessageBox.Show("Import was cancelled.\r\nAny data already committed to the " +
                            "database will still be there.", "Notification", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
            }

            this.Close();
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (useDataFrom.Count > 0)
            {
                parameters = new Dictionary<string, object>();
                List<FinanceAccessParams> finParams = new List<FinanceAccessParams>();
                List<AssetAccessParams> assetParams = new List<AssetAccessParams>();

                this.Visible = false;
                this.DialogResult = DialogResult.Cancel;

                ReportType thisType = (ReportType)cmbReportTypes.SelectedItem;

                if (thisType.NeedFinanceAccessParams || paramFormToRun.NeedFinanceParams)
                {
                    Dictionary<long, List<int>>.Enumerator enumerator = useDataFrom.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        // If we are accessing all wallets for a corp then no need to bether with this
                        // as the default is to access everything when a blank list is supplied.
                        List<short> walletIDs = new List<short>();
                        if (enumerator.Current.Value.Count < 7)
                        {
                            foreach (short walletId in enumerator.Current.Value)
                            {
                                walletIDs.Add(walletId);
                            }
                        }

                        finParams.Add(new FinanceAccessParams(enumerator.Current.Key, walletIDs));
                    }
                    parameters.Add("FinanceAccessParams", finParams);
                    paramFormToRun.Parameters = parameters;
                    if (paramFormToRun.NeedFinanceParams) { paramFormToRun.FinanceParams = finParams; }
                }
                if (thisType.NeedAssetAccessParams || paramFormToRun.NeedAssetParams)
                {
                    foreach (object item in lstOwners.CheckedItems)
                    {
                        bool done = false;
                        CharCorpOption owner = (CharCorpOption)item;

                        foreach (AssetAccessParams character in assetParams)
                        {
                            if (character.OwnerID == owner.Data.ID)
                            {
                                done = true;
                            }
                        }

                        if (!done)
                        {
                            assetParams.Add(new AssetAccessParams(owner.Data.ID));
                        }
                    }
                    parameters.Add("AssetAccessParams", assetParams);
                    paramFormToRun.Parameters = parameters;
                    if (paramFormToRun.NeedAssetParams) { paramFormToRun.AssetParams = assetParams; }
                }

                // Go off to appropriate parameter form now.
                if (paramFormToRun.ShowDialog() != DialogResult.Cancel)
                {
                    parameters = paramFormToRun.Parameters;
                    reportToRun = paramFormToRun.Report;

                    Thread t1 = new Thread(BuildReport);
                    t1.SetApartmentState(ApartmentState.STA);
                    ProgressDialog prgDialog = new ProgressDialog("Building Report...", reportToRun);
                    Thread.Sleep(100);
                    t1.Start();
                    if (prgDialog.ShowDialog() == DialogResult.OK)
                    {
                        ShowReport(reportToRun, showAmountsIn);
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        // Stop our worker thread if the user has cancelled out of the progress dialog.
                        t1.Abort();
                        t1.Join();

                        MessageBox.Show("Report creation was cancelled.",
                            "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("No characters or corporations selected", "Warning",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }