public static Models.Character GetCharacter(string characterName, long apikey, string vcode)
        {
            var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);

            List<string> list = new List<String>();
            list.Add(characterName);
            Dictionary<string, long> dict = api.ConvertNamesToIDs(list);

            try
            {
                dict = api.ConvertNamesToIDs(list);
            }
            catch(Exception ex)
            {
                return new Models.Character() { info = new Character.Models.info() { name = characterName, character_id = 0, corporation_id = 0, alliance_id = 0, faction_id = 0, sec_status = 0.0 }, history = null };
            }
            if ((dict[characterName] == null) || (dict[characterName] == 0))
            {
                return new Models.Character() { info = new Character.Models.info() { name = characterName, character_id = 0, corporation_id = 0, alliance_id = 0, faction_id = 0, sec_status = 0.0 }, history = null };
            }
            else
            {
                return GetCharacter(dict[characterName]);
            }
        }
Exemple #2
0
        public static Models.EveCharacter GetCharacter(string characterName, long apikey, string vcode)
        {
            var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);

            List <string> list = new List <String>();

            list.Add(characterName);
            Dictionary <string, long> dict = api.ConvertNamesToIDs(list);

            try
            {
                dict = api.ConvertNamesToIDs(list);
            }
            catch (Exception ex)
            {
                return(new Models.EveCharacter()
                {
                    _currentTime = DateTime.Now.ToString(),
                    _cachedUntil = DateTime.Now.ToString(),
                    //,
                    //result = new EveCharacter.Models.result() {
                    //characterName = characterName,
                    //characterID = 0,
                    //corporationID = 0,
                    //corporation = ex.Message,
                    //bloodline = string.Empty,
                    //securityStatus = 0.0,
                    //corporationDate = new DateTime(),
                    //race = string.Empty,
                    //employmentHistory = null
                    //}
                });
            }
            if ((dict[characterName] == null) || (dict[characterName] == 0))
            {
                return(new Models.EveCharacter()
                {
                    _currentTime = DateTime.Now.ToString(),
                    _cachedUntil = DateTime.Now.ToString(),
                    //    ,
                    //result = new EveCharacter.Models.result()
                    //{
                    //    characterName = characterName,
                    //    characterID = 0,
                    //    corporationID = 0,
                    //    corporation = string.Empty,
                    //    bloodline = string.Empty,
                    //    securityStatus = 0.0,
                    //    corporationDate = new DateTime(),
                    //    race = string.Empty,
                    //    employmentHistory = null
                    //}
                });
            }
            else
            {
                return(GetCharacter(dict[characterName]));
            }
        }
        public static Models.EveCharacter GetCharacter(string characterName, long apikey, string vcode)
        {
            var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);

            List<string> list = new List<String>();
            list.Add(characterName);
            Dictionary<string, long> dict = api.ConvertNamesToIDs(list);
            try
            {
                dict = api.ConvertNamesToIDs(list);
            }
            catch (Exception ex)
            {
                return new Models.EveCharacter()
                {
                    _currentTime = DateTime.Now.ToString(),
                    _cachedUntil = DateTime.Now.ToString(),
                    //,
                    //result = new EveCharacter.Models.result() {
                                    //characterName = characterName,
                                    //characterID = 0,
                                    //corporationID = 0,
                                    //corporation = ex.Message,
                                    //bloodline = string.Empty,
                                    //securityStatus = 0.0,
                                    //corporationDate = new DateTime(),
                                    //race = string.Empty,
                                    //employmentHistory = null
                    //}
                };
            }
            if ((dict[characterName] == null) || (dict[characterName] == 0))
            {
                return new Models.EveCharacter()
                {
                    _currentTime = DateTime.Now.ToString(),
                    _cachedUntil = DateTime.Now.ToString(),
                    //    ,
                    //result = new EveCharacter.Models.result()
                    //{
                    //    characterName = characterName,
                    //    characterID = 0,
                    //    corporationID = 0,
                    //    corporation = string.Empty,
                    //    bloodline = string.Empty,
                    //    securityStatus = 0.0,
                    //    corporationDate = new DateTime(),
                    //    race = string.Empty,
                    //    employmentHistory = null
                    //}
                };
            }
            else
            {
                return GetCharacter(dict[characterName]);
            }
        }
Exemple #4
0
        private EveAI.Live.EveApi getApi()
        {
            if (this.api == null)

                {
                this.api = new EveAI.Live.EveApi(keyID,vCode,characterID);
                }

                return this.api;
        }
Exemple #5
0
        private static void CheckContracts()
        {
            EveApi api;
            List <EveAI.Live.Utility.Contract> Contracts;
            Dictionary <long, EveCharacter>    Names = new Dictionary <long, EveCharacter>();
            List <long> IDs = new List <long>();
            var         now = DateTime.Now;

            DateTime lastFullRunTime = GetLastRunTime();

            Console.WriteLine(string.Format("Start Time : {0}", lastFullRunTime.ToString("yyyy-MM-dd HH:mm:ss")));

            try
            {
                api       = new EveAI.Live.EveApi("Clyde en Marland's Contract Notifier", (long)Properties.Settings.Default.CorpAPI, Properties.Settings.Default.VCode);
                Contracts = api.GetCorporationContracts().ToList().Where(contract => contract.DateIssued > lastFullRunTime).ToList();

                foreach (EveAI.Live.Utility.Contract Contract in Contracts)
                {
                    IDs.Add(Contract.IssuerID);
                }

                foreach (long Id in IDs)
                {
                    if (!Names.ContainsKey(Id))
                    {
                        Names.Add(Id, JKON.EveWho.Api.GetCharacter(Id));
                    }
                }

                foreach (EveAI.Live.Utility.Contract Contract in Contracts)
                {
                    if ((Contract.Type == EveAI.Live.Utility.Contract.ContractType.Courier) &&
                        ((Contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding) || (Contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Completed)))
                    {
                        //Console.WriteLine(string.Format("Contract notification: {0}", FormatMessage(Contract, Names[Contract.IssuerID].result.characterName)));
                        SendMessage(HyperFormatMessage(Contract, Names[Contract.IssuerID].result.characterName));
                        if (Contract.DateIssued > lastFullRunTime)
                        {
                            lastFullRunTime = Contract.DateIssued;
                        }
                    }
                }
                UpdateRunTime(lastFullRunTime);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            if (Environment.UserInteractive)
            {
                System.Threading.Thread.Sleep(10000);
            }
        }
Exemple #6
0
        public static Models.Character GetCharacter(string characterName, long apikey, string vcode)
        {
            var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);

            List <string> list = new List <String>();

            list.Add(characterName);
            Dictionary <string, long> dict = api.ConvertNamesToIDs(list);

            try
            {
                dict = api.ConvertNamesToIDs(list);
            }
            catch (Exception ex)
            {
                return(new Models.Character()
                {
                    info = new Character.Models.info()
                    {
                        name = characterName, character_id = 0, corporation_id = 0, alliance_id = 0, faction_id = 0, sec_status = 0.0
                    }, history = null
                });
            }
            if ((dict[characterName] == null) || (dict[characterName] == 0))
            {
                return(new Models.Character()
                {
                    info = new Character.Models.info()
                    {
                        name = characterName, character_id = 0, corporation_id = 0, alliance_id = 0, faction_id = 0, sec_status = 0.0
                    }, history = null
                });
            }
            else
            {
                return(GetCharacter(dict[characterName]));
            }
        }
        public ActionResult ContractStatus()
        {
            EveApi api;
            List <EveAI.Live.Utility.Contract> Contracts = new List <EveAI.Live.Utility.Contract>();
            Dictionary <long, EveCharacter>    Names     = new Dictionary <long, EveCharacter>();
            List <long> IDs = new List <long>();

            DateTime backDate = DateTime.Now.AddDays(-7).Date;

            try
            {
                api = new EveAI.Live.EveApi("Clyde en Marland's Contract Notifier", (long)Properties.Settings.Default.LogisticsCorpAPI, Properties.Settings.Default.LogisticsVCode);

                Contracts = api.GetCorporationContracts().ToList().Where(contract =>
                                                                         (contract.Type == EveAI.Live.Utility.Contract.ContractType.Courier)
                                                                         &&
                                                                         (contract.Status != EveAI.Live.Utility.Contract.ContractStatus.Deleted)
                                                                         &&
                                                                         ((contract.DateIssued >= backDate)
                                                                          ||
                                                                          (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding)
                                                                          ||
                                                                          (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.InProgress))).ToList();

                if (!User.IsInRole("Logistics"))
                {
                    try
                    {
                        var user = UserManager.FindById(User.Identity.GetUserId());
                        user.LoadApiKeys();

                        var apiKeys = user.ApiKeys.GroupBy(apiKey => apiKey.ApiKey).Select(apiKey => apiKey.First()).ToList();
                        var toons   = new List <AccountCharacter>();

                        apiKeys.ForEach(apiKey => toons.AddRange(JKON.EveWho.EveWho.GetCharacters(apiKey.ApiKey, apiKey.VerificationCode)));

                        Contracts = Contracts.Where(contract => toons.Any(toon => toon.CharacterID.Equals(contract.IssuerID))).ToList();
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message(ex.Message);
                        return(RedirectToAction("Index", "LoggedInHome"));
                    }
                }

                IDs = Contracts.Select(contract => contract.IssuerID).ToList();

                Contracts.ForEach(contract =>
                {
                    if (contract.StartStation == null)
                    {
                        var startStation      = Api.GetStation(contract.StartStationID);
                        contract.StartStation = new EveAI.SpaceStation.Station()
                        {
                            Name = startStation.stationName
                        };
                    }
                    if (contract.EndStation == null)
                    {
                        var endStation      = Api.GetStation(contract.EndStationID);
                        contract.EndStation = new EveAI.SpaceStation.Station()
                        {
                            Name = endStation.stationName
                        };
                    }
                });

                Contracts.Select(contract => contract.IssuerID).ToList().ForEach(id =>
                {
                    if (!Names.ContainsKey(id))
                    {
                        Names.Add(id, JKON.EveWho.Api.GetCharacter(id));
                    }
                });
                Contracts.Select(contract => contract.AcceptorID).ToList().ForEach(id =>
                {
                    if (!Names.ContainsKey(id))
                    {
                        Names.Add(id, JKON.EveWho.Api.GetCharacter(id));
                    }
                });

                if ((DateTime.Now.Month == 12) && (DateTime.Now.Day > 17) && (DateTime.Now.Day < 25))
                {
                    var id      = JKON.EveWho.Api.GetCharacterID(User.Identity.Name);
                    var toon1   = JKON.EveWho.Api.GetCharacter(id);
                    var toon2   = JKON.EveWho.Api.GetCorpMembers(Convert.ToInt64(Properties.Settings.Default.CorpAPI), Properties.Settings.Default.VCode).Where(member => member.Name == User.Identity.Name).FirstOrDefault();
                    var station = new Station()
                    {
                        Name = toon2.Location
                    };

                    Names.Add(id, toon1);
                    Names.Add(-1, new EveCharacter()
                    {
                        result = new JKON.EveWho.EveCharacter.Models.result()
                        {
                            characterID = -1, characterName = "Hauled By Reindeer (corp)"
                        }
                    });
                    Names.Add(-2, new EveCharacter()
                    {
                        result = new JKON.EveWho.EveCharacter.Models.result()
                        {
                            characterID = -2, characterName = "Santa Claus"
                        }
                    });

                    var contract = new EveAI.Live.Utility.Contract()
                    {
                        StartStation = new EveAI.SpaceStation.Station()
                        {
                            Name        = "Lapland VI - Santas Workshop",
                            SolarSystem = new EveAI.Map.SolarSystem()
                            {
                                Name = "North Pole"
                            }
                        },
                        EndStation   = station,
                        DateIssued   = new DateTime(2015, 12, 15),
                        DateAccepted = new DateTime(2015, 12, 17),
                        AcceptorID   = -1,
                        IssuerID     = -2,
                        Status       = GetStatus(),
                        Volume       = 10000,
                        Title        = string.Format("Christmas Presents for {0}", toon2.Name)
                    };

                    if (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding)
                    {
                        Contracts.Insert(0, contract);
                    }
                    else if (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.InProgress)
                    {
                        var index = Contracts.Where(c => c.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding).Count();
                        Contracts.Insert(index, contract);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(View(new LogisticsContractsViewModel()
            {
                DisplayContracts = Contracts, CharacterInfos = Names
            }));
        }
        public ActionResult ContractStatus()
        {
            EveApi api;
            List<EveAI.Live.Utility.Contract> Contracts = new List<EveAI.Live.Utility.Contract>();
            Dictionary<long, EveCharacter> Names = new Dictionary<long, EveCharacter>();
            List<long> IDs = new List<long>();

            DateTime backDate = DateTime.Now.AddDays(-7).Date;

            try
            {
                api = new EveAI.Live.EveApi("Clyde en Marland's Contract Notifier", (long)Properties.Settings.Default.LogisticsCorpAPI, Properties.Settings.Default.LogisticsVCode);

                Contracts = api.GetCorporationContracts().ToList().Where(contract =>
                    (contract.Type == EveAI.Live.Utility.Contract.ContractType.Courier)
                    &&
                    (contract.Status != EveAI.Live.Utility.Contract.ContractStatus.Deleted)
                    &&
                    ((contract.DateIssued >= backDate)
                    ||
                    (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding)
                    ||
                    (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.InProgress))).ToList();

                if(!User.IsInRole("Logistics"))
                {
                    try
                    {
                        var user = UserManager.FindById(User.Identity.GetUserId());
                        user.LoadApiKeys();

                        var apiKeys = user.ApiKeys.GroupBy(apiKey => apiKey.ApiKey).Select(apiKey => apiKey.First()).ToList();
                        var toons = new List<AccountCharacter>();

                        apiKeys.ForEach(apiKey => toons.AddRange(JKON.EveWho.EveWho.GetCharacters(apiKey.ApiKey, apiKey.VerificationCode)));

                        Contracts = Contracts.Where(contract => toons.Any(toon => toon.CharacterID.Equals(contract.IssuerID))).ToList();
                    }
                    catch(Exception ex)
                    {
                        ViewBag.Message(ex.Message);
                        return RedirectToAction("Index", "LoggedInHome");
                    }
                }

                IDs = Contracts.Select(contract => contract.IssuerID).ToList();

                Contracts.ForEach(contract =>
                {
                    if(contract.StartStation == null) {
                        var startStation = Api.GetStation(contract.StartStationID);
                        contract.StartStation = new EveAI.SpaceStation.Station() { Name = startStation.stationName };
                    }
                    if (contract.EndStation == null)
                    {
                        var endStation = Api.GetStation(contract.EndStationID);
                        contract.EndStation = new EveAI.SpaceStation.Station() { Name = endStation.stationName };
                    }
                });

                Contracts.Select(contract => contract.IssuerID).ToList().ForEach(id =>
                        {
                            if (!Names.ContainsKey(id))
                            {
                                Names.Add(id, JKON.EveWho.Api.GetCharacter(id));
                            }
                        });
                Contracts.Select(contract => contract.AcceptorID).ToList().ForEach(id =>
                {
                    if (!Names.ContainsKey(id))
                    {
                        Names.Add(id, JKON.EveWho.Api.GetCharacter(id));
                    }
                });

                if((DateTime.Now.Month == 12) && (DateTime.Now.Day > 17) && (DateTime.Now.Day < 25))
                {

                    var id = JKON.EveWho.Api.GetCharacterID(User.Identity.Name);
                    var toon1 = JKON.EveWho.Api.GetCharacter(id);
                    var toon2 = JKON.EveWho.Api.GetCorpMembers(Convert.ToInt64(Properties.Settings.Default.CorpAPI), Properties.Settings.Default.VCode).Where(member => member.Name == User.Identity.Name).FirstOrDefault();
                    var station = new Station()
                    {
                        Name = toon2.Location
                    };

                    Names.Add(id, toon1);
                    Names.Add(-1, new EveCharacter() { result = new JKON.EveWho.EveCharacter.Models.result() { characterID = -1, characterName = "Hauled By Reindeer (corp)" } });
                    Names.Add(-2, new EveCharacter() { result = new JKON.EveWho.EveCharacter.Models.result() { characterID = -2, characterName = "Santa Claus" } });

                    var contract = new EveAI.Live.Utility.Contract()
                    {
                        StartStation = new EveAI.SpaceStation.Station()
                        {
                            Name = "Lapland VI - Santas Workshop",
                            SolarSystem = new EveAI.Map.SolarSystem() { Name = "North Pole" }
                        },
                        EndStation = station,
                        DateIssued = new DateTime(2015, 12, 15),
                        DateAccepted = new DateTime(2015, 12, 17),
                        AcceptorID = -1,
                        IssuerID = -2,
                        Status = GetStatus(),
                        Volume = 10000,
                        Title = string.Format("Christmas Presents for {0}", toon2.Name)
                    };

                    if (contract.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding)
                    {
                        Contracts.Insert(0, contract);
                    }
                    else if(contract.Status == EveAI.Live.Utility.Contract.ContractStatus.InProgress)
                    {
                        var index = Contracts.Where(c => c.Status == EveAI.Live.Utility.Contract.ContractStatus.Outstanding).Count();
                        Contracts.Insert(index, contract);
                    }
                }
            }
            catch(Exception ex)
            {
            }

            return View(new LogisticsContractsViewModel() { DisplayContracts = Contracts, CharacterInfos = Names });
        }
Exemple #9
0
        public static List <AccountCharacter> GetCharacters(long apikey, string vcode)
        {
            var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);

            return(api.GetAccountCharacters());
        }
 public static List<AccountCharacter> GetCharacters(long apikey, string vcode)
 {
     var api = new EveAI.Live.EveApi("R3MUS Recruitment", apikey, vcode);
     return api.GetAccountCharacters();
 }