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();
                }
            }
        }
예제 #2
0
        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 btnNewContract_Click(object sender, EventArgs e)
        {
            ContractType type = ContractType.Any;
            if(cmbType.SelectedValue != null)
            {
                type = (ContractType)cmbType.SelectedValue;
            }

            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 create" +
                " a contract for.", options);
            if (picker.ShowDialog() == DialogResult.OK)
            {
                Cursor = Cursors.WaitCursor;
                try
                {
                    CourierCalc courierCalc = new CourierCalc((long)picker.SelectedItem, type);
                    courierCalc.ShowDialog();
                    RefreshList();
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
예제 #4
0
        private void LoadEMMAFile(object filenameData)
        {
            int maxStatus = 7;
            string filename = (string)filenameData;
            string tmpLoadDir = string.Format("{0}Temp{1}Load{1}",
                Globals.AppDataDir, Path.DirectorySeparatorChar);
            UpdateStatus(0, maxStatus, "", "Decompressing files", false);
            try
            {
                Directory.CreateDirectory(tmpLoadDir);
                float saveVersion = Compression.DecompressDirectory(filename, tmpLoadDir);

                if (saveVersion == 0)
                {
                    UpdateStatus(0, 0, "Error: File version is too old", "", true);
                }
                else if (saveVersion == 1)
                {
                    if (filename.ToUpper().EndsWith(".CDAT"))
                    {
                        Dictionary<int, int> IDChanges = new Dictionary<int, int>();
                        try
                        {
                            PublicCorps.LoadOldEmmaXML(tmpLoadDir + "CorpData.xml", ref IDChanges);
                            Dividends.LoadOldEmmaXML(tmpLoadDir + "Dividends.xml", IDChanges);
                            WebLinks.LoadOldEmmaXML(tmpLoadDir + "WebLinks.xml", IDChanges);
                            // Try to link journal entries to the dividends
                            Dividends.UpdateFromJournal(true);
                            UpdateStatus(1, 1, "Complete", "", true);
                        }
                        catch (ThreadAbortException abortEx)
                        {
                            // User has closed the progress dialog so just throw the exception to the next level.
                            throw abortEx;
                        }
                        catch (Exception ex)
                        {
                            EMMAException emmaEx = ex as EMMAException;
                            if (emmaEx == null)
                            {
                                emmaEx = new EMMAException(ExceptionSeverity.Error, "Problem importing old EMMA public corp data", ex);
                            }
                            UpdateStatus(-1, -1, "Error", ex.Message, true);
                        }
                    }
                    else
                    {
                        APICharacter character = UserAccount.CurrentGroup.Accounts[0].Chars[0];
                        CharOrCorp corc = CharOrCorp.Char;

                        // 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)
                        {
                            options.Add(opt.Data, opt.Name);
                        }

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

                        if (picker.ShowDialog() != DialogResult.Cancel)
                        {
                            CharCorp chosen = (CharCorp)picker.SelectedItem;
                            character = chosen.characterObj;
                            corc = chosen.corp ? CharOrCorp.Corp : CharOrCorp.Char;
                        }

                        LoadOldDataParams parameters = new LoadOldDataParams();
                        parameters.dataDirectory = tmpLoadDir;
                        parameters.corc = corc;
                        parameters.character = character;
                        LoadOldEMMAData(parameters);
                    }
                }
                else if (saveVersion == 2)
                {
                }
            }
            catch (ThreadAbortException)
            {
                // User has closed the progress dialog so just allow the execution to fall out of this loop.
            }
        }
예제 #5
0
        /// <summary>
        /// Get the specified item. itemName can be the whole name or just part of a name.
        /// </summary>
        /// <param name="itemName"></param>
        /// <returns></returns>
        public static EveDataSet.invTypesRow GetItem(string itemName)
        {
            EveDataSet.invTypesDataTable table = new EveDataSet.invTypesDataTable();
            EveDataSet.invTypesRow retVal = null;

            lock (tableAdapter)
            {
                tableAdapter.FillByName(table, itemName);
            }
            if (table.Count == 1)
            {
                retVal = table[0];
            }
            else
            {
                lock (tableAdapter)
                {
                    tableAdapter.FillByName(table, "%" + itemName + "%");
                }

                if (table.Count < 1)
                {
                    throw new EMMADataException(ExceptionSeverity.Error, "No item found matching '" + itemName + "'");
                }
                else if (table.Count > 1)
                {
                    SortedList<object, string> options = new SortedList<object, string>();
                    foreach (EveDataSet.invTypesRow item in table)
                    {
                        options.Add(item.typeID, item.typeName);
                    }
                    OptionPicker picker = new OptionPicker("Select Item", "Choose the specific item you want from " +
                        "those listed below.", options);
                    if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                    {
                        retVal = table.FindBytypeID((int)picker.SelectedItem);
                    }
                }
                else
                {
                    retVal = table[0];
                }
            }

            return retVal;
        }
예제 #6
0
        public static PublicCorp GetCorp(string corpName)
        {
            PublicCorp retVal = null;
            EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable();
            EMMADataSet.PublicCorpsRow rowData = null;

            lock (tableAdapter)
            {
                tableAdapter.FillByName(table, corpName);
            }
            if (table.Count == 1)
            {
                rowData = table[0];
            }
            else
            {
                lock (tableAdapter)
                {
                    tableAdapter.FillByName(table, "%" + corpName + "%");
                }

                if (table.Count < 1)
                {
                    throw new EMMADataMissingException(ExceptionSeverity.Error, "No public corp found " +
                        "matching '" + corpName + "'", "PublicCorps", corpName);
                }
                else if (table.Count > 1)
                {
                    SortedList<object, string> options = new SortedList<object, string>();
                    foreach (EMMADataSet.PublicCorpsRow corp in table)
                    {
                        options.Add(corp.CorpID, corp.CorpName);
                    }
                    OptionPicker picker = new OptionPicker("Select Corp (" + corpName + ")",
                        "Choose the specific corp you want from those listed below.", options);
                    if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                    {
                        rowData = table.FindByCorpID((int)picker.SelectedItem);
                    }
                }
                else
                {
                    rowData = table[0];
                }
            }

            if (rowData != null) { retVal = new PublicCorp(rowData); }
            return retVal;
        }
예제 #7
0
        /// <summary>
        /// Get the specified station. stationName can be the whole name or just part of a name.
        /// </summary>
        /// <param name="itemName"></param>
        /// <returns></returns>
        public static EveDataSet.staStationsRow GetStation(string stationName)
        {
            EveDataSet.staStationsDataTable table = new EveDataSet.staStationsDataTable();
            EveDataSet.staStationsRow retVal = null;

            lock (stationsTableAdapter)
            {
                stationsTableAdapter.FillByName(table, "%" + stationName + "%");
            }

            if (table.Count < 1)
            {
                throw new EMMADataException(ExceptionSeverity.Error, "No station found matching '" + stationName + "'");
            }
            else if (table.Count > 1)
            {
                SortedList<object, string> options = new SortedList<object, string>();
                foreach (EveDataSet.staStationsRow station in table)
                {
                    options.Add(station.stationID, station.stationName);
                }
                OptionPicker picker = new OptionPicker("Select Station", "Choose the specific station you " +
                    "want from those listed below.", options);
                if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                {
                    retVal = table.FindBystationID((int)picker.SelectedItem);
                }
            }
            else
            {
                retVal = table[0];
            }

            return retVal;
        }
예제 #8
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (rdbCSV.Checked)
            {
                SortedList<object, string> options = new SortedList<object, string>();
                Type enumType = typeof(Table);
                foreach (string value in Enum.GetNames(enumType))
                {
                    options.Add(Enum.Parse(enumType, value), value);
                }
                OptionPicker dialog = new OptionPicker("Data to export", "Choose the data that " +
                    "you wish to export from EMMA.\r\nNote that you can also create CSV files " +
                    "from any report by right clicking it and choosing the 'export to CSV option'",
                    options);
                if (dialog.ShowDialog() != DialogResult.Cancel)
                {
                    Table result = (Table)dialog.SelectedItem;

                    ExportCSV(result);

                    this.Close();
                }
            }
            else if (rdbAPIXML.Checked)
            {
                ExportXML();
            }
        }