示例#1
0
        /// <summary>
        /// Add a new station to the stations table with the specified ID and name.
        /// </summary>
        /// <param name="stationID"></param>
        /// <param name="stationName"></param>
        public static void AddStation(long stationID, string stationName, long solarSystemID, long corpID)
        {
            try
            {
                EveDataSet.staStationsDataTable table = new EveDataSet.staStationsDataTable();
                // First make sure this station is not already in the database.
                lock (stationsTableAdapter)
                {
                    stationsTableAdapter.FillByIDs(table, stationID.ToString());
                }
                EveDataSet.staStationsRow data = table.FindBystationID((int)stationID);

                if (data == null)
                {
                    EveDataSet.staStationsRow newRow = table.NewstaStationsRow();
                    newRow.stationID = (int)stationID;
                    newRow.stationName = stationName;
                    newRow.corporationID = (int)corpID;
                    newRow.solarSystemID = (int)solarSystemID;
                    EveDataSet.mapSolarSystemsRow systemData = SolarSystems.GetSystem(solarSystemID);
                    newRow.constellationID = systemData.constellationID;
                    newRow.regionID = systemData.regionID;

                    table.AddstaStationsRow(newRow);

                    stationsTableAdapter.Update(table);
                }
                else
                {
                    bool update = false;
                    if (!data.stationName.Equals(stationName))
                    {
                        data.stationName = stationName;
                        update = true;
                    }
                    if (data.IscorporationIDNull() || data.corporationID != corpID)
                    {
                        data.corporationID = (int)corpID;
                        update = true;
                    }
                    if (update)
                    {
                        stationsTableAdapter.Update(data);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new EMMADataException(ExceptionSeverity.Error, "Problem adding station to database.", ex);
            }
        }
示例#2
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;
        }