Exemple #1
0
        private void buttonJournalFilter_Click(object sender, EventArgs e)
        {
            listViewJournal.Items.Clear();

            if (-1 == this.toolStripComboBoxCharacterSelection.SelectedIndex)
            {
                return;
            }

            CharacterObject charObj = (CharacterObject)
                                      this.toolStripComboBoxCharacterSelection.SelectedItem;

            CharacterJournalCollection col = new CharacterJournalCollection();
            IDBCollection       icol       = col as IDBCollection;
            JournalFilterObject obj        = comboBoxJournalFilter.SelectedItem as JournalFilterObject;

            if (null != obj)
            {
                if (1 == obj.Count)
                {
                    icol.SetConstraint((long)CharacterJournal.QueryValues.refType,
                                       new DBConstraint(DBConstraint.QueryConstraints.Equal, obj.Value(0)));
                }
                else if (0 != obj.Count)
                {
                    throw new NotImplementedException();
                }
            }

            DateTime start = dateTimePickerCharJournalStart.Value;
            DateTime end   = dateTimePickerCharJournalEnd.Value;

            if (!checkBoxCharJournalStartUseTime.Checked)
            {
                start = start.Date;
            }
            if (!checkBoxCharJournalEndUseTime.Checked)
            {
                end = end.Date.AddDays(1).AddSeconds(-1);
            }

            icol.SetConstraint((long)CharacterJournal.QueryValues.CharID,
                               new DBConstraint(DBConstraint.QueryConstraints.Equal, long.Parse(charObj.CharID)));
            icol.SetConstraint((long)CharacterJournal.QueryValues.date,
                               new DBConstraint(DBConstraint.QueryConstraints.Between,
                                                start.ToOADate(), end.ToOADate()));

            icol.SetSortConstraint((long)CharacterJournal.QueryValues.date,
                                   new DBSortConstraint(DBSortConstraint.SortConstraints.Ascending));

            if (Database.DatabaseError.NoError == this.m_db.ReadRecord(icol))
            {
                IDBCollectionContents icolcon = col as IDBCollectionContents;
                for (long i = 0; i < icolcon.Count(); ++i)
                {
                    listViewJournal.Items.Add(new JournalListViewItem(icolcon.GetRecordInterface(i).GetDataObject() as JournalObject));
                }
                //listViewJournal.Items.Add(new JournalListViewItem(null));
            }
        }
Exemple #2
0
        private static string CheckRequestCache(Database db, RequestID rid, string UserID, string url)
        {
            DateTime dt = TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now);
            RequestCacheCollection col  = new RequestCacheCollection();
            IDBCollection          icol = (IDBCollection)col;

            icol.SetConstraint((long)RequestCache.QueryValues.UserID,
                               new DBConstraint(DBConstraint.QueryConstraints.Equal, UserID));
            icol.SetConstraint((long)RequestCache.QueryValues.ValidUntil,
                               new DBConstraint(DBConstraint.QueryConstraints.Greater, dt.ToOADate().ToString()));
            icol.SetConstraint((long)RequestCache.QueryValues.url,
                               new DBConstraint(DBConstraint.QueryConstraints.Equal, url));

            db.ReadRecord((IDBCollection)col);
            IDBCollectionContents ccol = (IDBCollectionContents)col;

            if (0 == ccol.Count())
            {
                return(null);
            }
            IDBRecord     rec = ccol.GetRecordInterface(0);
            RequestObject obj = (RequestObject)rec.GetDataObject();

            Logger.ReportNotice("Using cached response, can make a new call after " + obj.ValidUntil.ToString());
            return(Compression.Decompress(obj.Response));
        }
        private CorpWalletNameObjectWritable ReadWalletNames()
        {
            if (-1 == this.toolStripComboBoxCharacterSelection.SelectedIndex)
            {
                return(CreateDefaultWalletNames());
            }

            CharacterObject charObj = (CharacterObject)
                                      this.toolStripComboBoxCharacterSelection.SelectedItem;

            CorpWalletNameCollection col  = new CorpWalletNameCollection();
            IDBCollection            icol = col as IDBCollection;

            icol.SetConstraint((long)CorpWalletName.QueryValues.CorpID,
                               new DBConstraint(DBConstraint.QueryConstraints.Equal, charObj.CorpID));

            Database.DatabaseError dbErr = this.m_db.ReadRecord(icol);
            if (dbErr != Database.DatabaseError.NoError &&
                dbErr != Database.DatabaseError.NoRecordsFound
                )
            {
                // should report to logging
                return(CreateDefaultWalletNames());
            }

            IDBCollectionContents icolcon = col as IDBCollectionContents;

            if (0 == icolcon.Count())
            {
                return(CreateDefaultWalletNames());
            }

            return(icolcon.GetRecordInterface(0).GetDataObject() as CorpWalletNameObjectWritable);
        }
        private DatabaseError CheckVersion()
        {
            VersionCollection ver  = new VersionCollection();
            IDBCollection     icol = ver as IDBCollection;

            icol.SetConstraint((long)Version.QueryValues.TableName,
                               new DBConstraint(DBConstraint.QueryConstraints.Equal, "Version"));
            DatabaseError err = ReadRecord(icol);

            if (DatabaseError.NoRecordsFound == err || DatabaseError.ExceptionSQL == err)
            {
                return(m_ErrorCode = DatabaseError.CheckFailed_Unidentifiable);
            }

            IDBCollectionContents icolcon = ver as IDBCollectionContents;
            VersionObject         vobj    = icolcon.GetRecordInterface(0).GetDataObject() as VersionObject;

            if (vobj.VersionNumber != Version.VersionNumber)
            {
                return(m_ErrorCode = DatabaseError.CheckFailed_IncorrectVersion);
            }
            return(m_ErrorCode = DatabaseError.NoError);
        }
Exemple #5
0
        private void MarkTableVersion(IDBCollection col)
        {
            VersionCollection vcol  = new VersionCollection();
            IDBCollection     ivcol = vcol as IDBCollection;

            ivcol.SetConstraint((long)Version.QueryValues.TableName,
                                new DBConstraint(DBConstraint.QueryConstraints.Equal, col.GetTableName()));

            if (Database.DatabaseError.NoError == this.ReadRecord(ivcol))
            {
                IDBCollectionContents icont = vcol as IDBCollectionContents;
                (icont.GetRecordInterface(0).GetDataObject() as VersionObjectInternal).VersionNumber = col.GetVersionNumber();
                InsertOrUpdateRecord(vcol);
            }
            else
            {
                IDBRecord             irec = ivcol.CreateBlankRecord();
                VersionObjectInternal obj  = irec.GetDataObject() as VersionObjectInternal;
                obj.TableName     = col.GetTableName();
                obj.VersionNumber = col.GetVersionNumber();
                InsertOrUpdateRecord(irec);
            }
        }
        private void buttonCorpMissioner_Click(object sender, EventArgs e)
        {
            CorpMissionerTotal = 0;
            CorpMissionerRuns  = 0;
            CorpMissionerPeople.Clear();

            if (-1 == this.toolStripComboBoxCharacterSelection.SelectedIndex)
            {
                return;
            }

            Character.CharacterObject charObj = (Character.CharacterObject)
                                                this.toolStripComboBoxCharacterSelection.SelectedItem;

            DateTime start = dateTimePickerCorpMissionerStart.Value;
            DateTime end   = dateTimePickerCorpMissionerEnd.Value;

            start = start.Date;
            end   = end.Date.AddDays(1).AddSeconds(-1);

            int[] types = { 33, 34, 85 };
            foreach (int typ in types)
            {
                CorporationJournalCollection col = new CorporationJournalCollection();
                IDBCollection icol = col as IDBCollection;
                icol.SetConstraint((long)CorporationJournal.QueryValues.CorpID,
                                   new DBConstraint(DBConstraint.QueryConstraints.Equal, charObj.CorpID));
                icol.SetConstraint((long)CorporationJournal.QueryValues.Division,
                                   new DBConstraint(DBConstraint.QueryConstraints.Equal, 1000));
                // set date range
                icol.SetConstraint((long)CorporationJournal.QueryValues.date,
                                   new DBConstraint(DBConstraint.QueryConstraints.Between,
                                                    start.ToOADate(), end.ToOADate()));
                // set Sorting
                icol.SetSortConstraint((long)CorporationJournal.QueryValues.ownerName2,
                                       new DBSortConstraint(DBSortConstraint.SortConstraints.Ascending));

                // do Agent Rewards
                icol.SetConstraint((long)CorporationJournal.QueryValues.refType,
                                   new DBConstraint(DBConstraint.QueryConstraints.Equal, typ));
                if (Database.DatabaseError.NoError == m_db.ReadRecord(icol))
                {
                    IDBCollectionContents icolcon = col as IDBCollectionContents;
                    for (long i = 0; i < icolcon.Count(); ++i)
                    {
                        InsertMissionerRecord(icolcon.GetRecordInterface(i).GetDataObject() as JournalObject, typ);
                    }
                }
            }

            CorpMissionerPeople.Sort(delegate(CorpMissionerPerson p1, CorpMissionerPerson p2) { return(p2.Total.CompareTo(p1.Total)); });
            this.listViewCorpMissioner.Items.Clear();
            foreach (CorpMissionerPerson person in CorpMissionerPeople)
            {
                ListViewItem item = new ListViewItem();
                item.Text = person.Name;
                item.SubItems.Add(person.Runs.ToString());
                item.SubItems.Add(string.Format("{0:#,##0.00;(#,##0.00);''}", person.Total));
                this.listViewCorpMissioner.Items.Add(item);
            }

            ListViewItem itemTotal = new ListViewItem();

            itemTotal.Text = "Total";
            itemTotal.SubItems.Add(CorpMissionerRuns.ToString());
            itemTotal.SubItems.Add(string.Format("{0:#,##0.00;(#,##0.00);''}", CorpMissionerTotal));
            this.listViewCorpMissioner.Items.Add(itemTotal);
        }
Exemple #7
0
        private DatabaseError RepairDatabaseVersion()
        {
            DatabaseError err = m_ErrorCode;

            if (err != DatabaseError.CheckFailed_IncorrectVersion &&
                err != DatabaseError.CheckFailed_Unidentifiable
                )
            {
                return(m_ErrorCode = DatabaseError.Unexpected);
            }

            DialogResult ret = DialogResult.No;

            if (err == DatabaseError.CheckFailed_Unidentifiable)
            {
                ret = MessageBox.Show(String.Format(DBUpgradeWarning, "Your database version was not reconized.\r\n"),
                                      "Upgrade Database Version?", MessageBoxButtons.YesNo);
            }
            else
            {
                ret = MessageBox.Show(String.Format(DBUpgradeWarning, "Your database version is out-of-date."),
                                      "Upgrade Database Version?", MessageBoxButtons.YesNo);
            }

            if (ret != DialogResult.Yes)
            {
                return(m_ErrorCode = DatabaseError.UserAborted);
            }

            if (err == DatabaseError.CheckFailed_Unidentifiable)
            {
                this.ExecuteCommand("DROP TABLE " + Version.TableName);
                Version v = new Version();
                CreateTable(v);
                ExecuteCommand(String.Format(
                                   "INSERT INTO Version (TableName) SELECT name FROM sqlite_master; " +
                                   "UPDATE Version SET VersionNumber=0; " +
                                   "UPDATE Version SET VersionNumber={0} WHERE TableName='{1}'",
                                   Version.VersionNumber, Version.TableName));
            }

            foreach (IDBCollection col in m_Tables)
            {
                VersionCollection vercol  = new VersionCollection();
                IDBCollection     ivercol = vercol as IDBCollection;
                ivercol.SetConstraint((long)Version.QueryValues.TableName,
                                      new DBConstraint(DBConstraint.QueryConstraints.Equal, col.GetTableName()));
                DatabaseError colErr = ReadRecord(vercol);

                if (DatabaseError.NoError == colErr)
                {
                    IDBCollectionContents iconVercol = vercol as IDBCollectionContents;
                    IDBRecord             rec        = iconVercol.GetRecordInterface(0);
                    VersionObjectInternal obj        = rec.GetDataObject() as VersionObjectInternal;
                    if (obj.VersionNumber == col.GetVersionNumber())
                    {
                        Logger.ReportNotice(String.Format("Table '{0}' version is up to date.", col.GetTableName()));
                    }
                    else
                    {
                        Logger.ReportNotice(String.Format("Table '{0}' version mismatch ({1}!={2}). Recreating",
                                                          col.GetTableName(), obj.VersionNumber, col.GetVersionNumber()));
                        IDBUpgrade icolUpgrade = col as IDBUpgrade;
                        colErr = icolUpgrade.Upgrade(this, obj.VersionNumber);
                        if (colErr != DatabaseError.NoError)
                        {
                            return(m_ErrorCode = DatabaseError.Unexpected);
                        }
                        obj.VersionNumber = col.GetVersionNumber();
                        this.UpdateRecord(rec);
                    }
                }
                else if (DatabaseError.NoRecordsFound == colErr)
                {
                    Logger.ReportNotice(String.Format("Table '{0}' missing. Creating new", col.GetTableName()));
                    colErr = this.CreateTable(col.CreateBlankRecord());
                    if (colErr != DatabaseError.NoError)
                    {
                        return(m_ErrorCode = DatabaseError.Unexpected);
                    }

                    IDBRecord             rec = ivercol.CreateBlankRecord();
                    VersionObjectInternal obj = rec.GetDataObject() as VersionObjectInternal;
                    obj.TableName     = col.GetTableName();
                    obj.VersionNumber = col.GetVersionNumber();
                    InsertRecord(rec);
                }
                else
                {
                    return(m_ErrorCode = DatabaseError.Unexpected);
                }
            }

            return(m_ErrorCode = DatabaseError.NoError);
        }