Example #1
0
        /// <summary>
        /// Gets the accounting skill level and broker skill level of a character.
        /// </summary>
        /// <param name="actorID"></param>
        /// <returns>Tuple<Accounting,Broker></returns>
        public Tuple<int, int> GetTradingSkillLevels(long actorID)
        {
            var api = new CharacterSheet(keyID, vCode, actorID.ToString());
            if (!api.Query())
                throw new InvalidOperationException("Error querying character information.");

            var accounting = api.skills.FirstOrDefault(s => s.typeID == (decimal) SkillTypes.Accounting);
            var accountingLevel = accounting != null ? accounting.level : 0;

            var brokerRelations = api.skills.FirstOrDefault(s => s.typeID == (decimal)SkillTypes.BrokerRelations);
            var brokerRelationsLevel = brokerRelations != null ? brokerRelations.level : 0;

            return new Tuple<int, int>(accountingLevel, brokerRelationsLevel);
        }
        private void BtnOkClick(object sender, RoutedEventArgs e)
        {
            btnOk.IsEnabled = false;
            pbLoading.Visibility = Visibility.Visible;
            var chara = (CharWrapper) cbChars.SelectedItem;

            var worker = new BackgroundWorker();
            _getStandingAccess = true;
            worker.RunWorkerCompleted += delegate
                                             {
                                                 if (_getStandingAccess == true) DialogResult = true;
                                                 else Dispatcher.Invoke(new Action(Close));
                                             };
            worker.DoWork += delegate
                                 {
                                     var sheet = new CharacterSheet(chara.KeyId, chara.VCode,
                                                                    chara.CharId.ToString(CultureInfo.InvariantCulture));
                                     sheet.Query();

                                     foreach (CharacterSheet.Skill skill in sheet.skills)
                                     {
                                         if (skill.typeID == 3446) //"Broker Relations"
                                             Settings.BrokerRelations = skill.level;
                                         if (skill.typeID == 16622) //"Accounting" 
                                             Settings.Accounting = skill.level;
                                     }

                                     Dispatcher.Invoke(new Action(delegate
                                                                      {
                                                                          var aisfw =
                                                                              new ApiImportSelectFactionWindow(chara)
                                                                                  {
                                                                                      Topmost = true,
                                                                                      Top = Top + 10,
                                                                                      Left = Left + 10,
                                                                                  };
                                                                          _getStandingAccess = aisfw.ShowDialog();
                                                                          if (_getStandingAccess == true)
                                                                          {
                                                                              Settings.CorpStanding = aisfw.Corp;
                                                                              Settings.FactionStanding = aisfw.Faction;
                                                                          }
                                                                          else
                                                                          {
                                                                              _getStandingAccess = false;
                                                                          }
                                                                      }));

                                     Settings.ProfileName = chara.Charname;
                                 };

            worker.RunWorkerAsync();
        }