private void buttonCorpJournalFetch_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); CorporationJournalCollection collection = EveApi.GetCorporationJournalList(m_db, id, charObj.CharID, charObj.CorpID, null, "1000", true, true, true); if (null == collection) { return; } Logger.ReportNotice("Using BulkLoader"); collection.DoBulkLoader(m_db); Logger.ReportNotice("Done With BulkLoader"); }
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); }
public static CorporationJournalCollection GetCorporationJournalList( Database db, EveApiId id, string CharID, string CorpID, string beforeRefID, string CorpDivision, bool bAutoWalk, bool bAllDivisions, bool bUseCache) { if (!id.IsFullKey()) { return(new CorporationJournalCollection()); // return empty } CorporationJournalCollection journal = null; long division = 1000; if (null != CorpDivision && !bAllDivisions) { division = long.Parse(CorpDivision); } long lastDivisionCount = 0; do { long remainder = 0; long lastCount = 0; do { StringBuilder BuildUrl = new StringBuilder(); BuildUrl.AppendFormat("{0}{1}?userID={2}&characterID={3}&apiKey={4}", ApiSite, CorpJournalEntries, id.UserId, CharID, id.Key); BuildUrl.AppendFormat("&accountKey={0}", division.ToString()); if (null != beforeRefID && 0 < long.Parse(beforeRefID)) { BuildUrl.AppendFormat("&beforeRefID={0}", beforeRefID); } string url = BuildUrl.ToString(); string str = CheckRequestCache(db, RequestID.CorporationJournal, id.UserId, url); if (null == str) { Stream s = openUrl(url); if (null == s) { return((null != journal) ? journal : (new CorporationJournalCollection())); } str = new StreamReader(s).ReadToEnd(); WriteRequestCache(db, RequestID.CorporationJournal, id.UserId, url, str); } else if (!bUseCache) { break; // not allowed to use caching } XmlDocument xmlDoc = GetXml(new StringReader(str)); if (null != xmlDoc) { if (null == journal) { journal = new CorporationJournalCollection(CorpID, division.ToString(), xmlDoc); } else { journal.AppendList(CorpID, division.ToString(), xmlDoc); } } if (null == journal) { remainder = -1; } else { IDBCollectionContents con = (IDBCollectionContents)journal; if (0 == con.Count() - lastDivisionCount) { remainder = -1; } else if (lastCount == con.Count() - lastDivisionCount) { remainder = -1; } else { lastCount = con.Count() - lastDivisionCount; remainder = lastCount % 1000; if (0 == remainder) { IDBRecord rec1 = con.GetRecordInterface(con.Count() - 1000); JournalObject obj1 = (JournalObject)rec1.GetDataObject(); IDBRecord rec2 = con.GetRecordInterface(con.Count() - 1); JournalObject obj2 = (JournalObject)rec2.GetDataObject(); beforeRefID = Math.Min(obj1.refID, obj2.refID).ToString(); TimeSpan span = obj2.date.Subtract(obj1.date); if (span.Days >= 7) { remainder = -1; // more than a week, so no more accessable } } } } } while (0 == remainder && bAutoWalk); lastDivisionCount += lastCount; if (bAllDivisions) { ++division; } else { division = 1007; } } while (division <= 1006); return(journal); }
private void buttonCorpJournalFilter_Click(object sender, EventArgs e) { listViewCorpJournal.Items.Clear(); if (-1 == this.toolStripComboBoxCharacterSelection.SelectedIndex) { return; } CharacterObject charObj = (CharacterObject) this.toolStripComboBoxCharacterSelection.SelectedItem; CorporationJournalCollection col = new CorporationJournalCollection(); IDBCollection icol = col as IDBCollection; JournalFilterObject obj = comboBoxCorpJournalFilter.SelectedItem as JournalFilterObject; if (null != obj) { if (1 == obj.Count) { icol.SetConstraint((long)CorporationJournal.QueryValues.refType, new DBConstraint(DBConstraint.QueryConstraints.Equal, obj.Value(0))); } else if (0 != obj.Count) { throw new NotImplementedException(); } } JournalFilterObject WalletObj = comboBoxCorpJournal.SelectedItem as JournalFilterObject; if (null != WalletObj) { if (1 == WalletObj.Count) { icol.SetConstraint((long)CorporationJournal.QueryValues.Division, new DBConstraint(DBConstraint.QueryConstraints.Equal, WalletObj.Value(0))); } else if (0 != WalletObj.Count) { throw new NotImplementedException(); } } DateTime start = dateTimePickerCorpJournalStart.Value; DateTime end = dateTimePickerCorpJournalEnd.Value; if (!checkBoxCorpJournalStartUseTime.Checked) { start = start.Date; } if (!checkBoxCorpJournalEndUseTime.Checked) { end = end.Date.AddDays(1).AddSeconds(-1); } icol.SetConstraint((long)CorporationJournal.QueryValues.CorpID, new DBConstraint(DBConstraint.QueryConstraints.Equal, long.Parse(charObj.CorpID))); icol.SetConstraint((long)CorporationJournal.QueryValues.date, new DBConstraint(DBConstraint.QueryConstraints.Between, start.ToOADate(), end.ToOADate())); icol.SetSortConstraint((long)CorporationJournal.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) { listViewCorpJournal.Items.Add(new JournalListViewItem(icolcon.GetRecordInterface(i).GetDataObject() as JournalObject)); } } }