예제 #1
0
        private void buttonTransactionFilter_Click(object sender, EventArgs e)
        {
            this.listViewTransactions.Items.Clear();

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

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

            CharacterTransactionCollection col = new CharacterTransactionCollection();
            IDBCollection           icol       = col as IDBCollection;
            TransactionFilterObject obj        = comboBoxTransactionFilter.SelectedItem as TransactionFilterObject;

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

            DateTime start = dateTimePickerCharTransactionStart.Value;
            DateTime end   = dateTimePickerCharTransactionEnd.Value;

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

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

            icol.SetSortConstraint((long)CharacterTransaction.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)
                {
                    listViewTransactions.Items.Add(new TransactionListViewItem(icolcon.GetRecordInterface(i).GetDataObject() as TransactionObject));
                }
            }
        }
예제 #2
0
        private void buttonTransactionFetch_Click(object sender, EventArgs e)
        {
            if (-1 == this.toolStripComboBoxCharacterSelection.SelectedIndex)
            {
                return;
            }

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

            EveApiId id = new EveApiId(charObj.UserID, charObj.FullKey);
            CharacterTransactionCollection collection =
                EveApi.GetCharacterTransactionList(m_db, id, charObj.CharID, null, true);

            if (null == collection)
            {
                return;
            }

            Logger.ReportNotice("Using BulkLoader");
            collection.DoBulkLoader(m_db);
            Logger.ReportNotice("Done With BulkLoader");
        }
예제 #3
0
        public static CharacterTransactionCollection GetCharacterTransactionList(Database db, EveApiId id,
                                                                                 string CharID, string beforeTransId, bool bAutoWalk, bool bUseCache)
        {
            if (!id.IsFullKey())
            {
                return(new CharacterTransactionCollection()); // return empty
            }
            CharacterTransactionCollection journal = null;
            long remainder = 0;
            long lastCount = 0;

            do
            {
                string url = String.Format("{0}{1}?userID={2}&characterID={3}&apiKey={4}&accountKey=1000",
                                           ApiSite, CharWalletTransactions, id.UserId, CharID, id.Key);
                if (null != beforeTransId && 0 < long.Parse(beforeTransId))
                {
                    url += String.Format("&beforeTransID={0}", beforeTransId);
                }

                string str = CheckRequestCache(db, RequestID.CharacterJournal, id.UserId, url);
                if (null == str)
                {
                    str = new StreamReader(openUrl(url)).ReadToEnd();
                    WriteRequestCache(db, RequestID.CharacterJournal, id.UserId, url, str);
                }
                else if (!bUseCache)
                {
                    break; // not allowed to use caching
                }

                XmlDocument xmlDoc = GetXml(new StringReader(str));
                if (null == xmlDoc)
                {
                    break;
                }

                if (null == journal)
                {
                    journal = new CharacterTransactionCollection(CharID, xmlDoc);
                }
                else
                {
                    journal.AppendList(CharID, xmlDoc);
                }

                if (null == journal)
                {
                    remainder = -1;
                }
                else
                {
                    IDBCollectionContents con = (IDBCollectionContents)journal;
                    if (0 == con.Count())
                    {
                        remainder = -1;
                    }
                    else if (lastCount == con.Count())
                    {
                        remainder = -1;
                    }
                    else
                    {
                        lastCount = con.Count();
                        remainder = con.Count() % 1000;
                        if (0 == remainder)
                        {
                            IDBRecord         rec1 = con.GetRecordInterface(con.Count() - 1000);
                            TransactionObject obj1 = (TransactionObject)rec1.GetDataObject();
                            IDBRecord         rec2 = con.GetRecordInterface(con.Count() - 1);
                            TransactionObject obj2 = (TransactionObject)rec2.GetDataObject();
                            beforeTransId = Math.Min(obj1.transID, obj2.transID).ToString();
                            TimeSpan span = (obj2.date > obj1.date) ? obj2.date.Subtract(obj1.date) :
                                            obj1.date.Subtract(obj2.date);

                            if (span.Days >= 7)
                            {
                                remainder = -1; // more than a week, so no more accessable
                            }
                        }
                    }
                }
            } while (0 == remainder && bAutoWalk);

            if (null == journal)
            {
                return(new CharacterTransactionCollection());
            }
            return(journal);
        }