Exemple #1
0
        internal static List <DirectAgentMission> GetAgentMissions(DirectEve directEve)
        {
            var missions = new List <DirectAgentMission>();

            var pyMissions = directEve.GetLocalSvc("journal").Attribute("agentjournal").Item(0).ToList();

            foreach (var pyMission in pyMissions)
            {
                var mission = new DirectAgentMission(directEve);
                mission.State     = (int)pyMission.Item(0);
                mission.Important = (bool)pyMission.Item(1);
                mission.Type      = (string)pyMission.Item(2);

                if ((int)pyMission.Item(3) > 0)
                {
                    mission.Name = (string)directEve.PySharp.Import("localization").Call("GetByMessageID", (int)pyMission.Item(3));
                }
                else
                {
                    mission.Name = "none";
                    continue;
                }

                mission._pyAgentId = pyMission.Item(4);
                mission.AgentId    = (long)pyMission.Item(4);

                mission.ExpiresOn = (DateTime)pyMission.Item(5);
                mission.Bookmarks = pyMission.Item(6).ToList().Select(b => new DirectAgentMissionBookmark(directEve, b)).ToList();
                missions.Add(mission);
            }

            return(missions);
        }
Exemple #2
0
        /// <summary>
        ///   Returns the mission for a specific agent
        /// </summary>
        /// <param name="agentId"></param>
        /// <param name="ForceUpdate"> </param>
        /// <returns>null if no mission could be found</returns>
        public DirectAgentMission GetAgentMission(long agentId, bool ForceUpdate)
        {
            if (DateTime.UtcNow < NextGetAgentMissionAction)
            {
                if (FirstAgentMission != null)
                {
                    return FirstAgentMission;
                }

                return null;
            }

            try
            {
                if (ForceUpdate || myAgentMissionList == null || !myAgentMissionList.Any())
                {
                    myAgentMissionList = DirectEve.AgentMissions.Where(m => m.AgentId == agentId).ToList();
                    NextGetAgentMissionAction = DateTime.UtcNow.AddSeconds(5);
                }

                if (myAgentMissionList.Any())
                {
                    FirstAgentMission = myAgentMissionList.FirstOrDefault();
                    return FirstAgentMission;
                }

                return null;
            }
            catch (Exception exception)
            {
                Logging.Log("Cache.Instance.GetAgentMission", "DirectEve.AgentMissions failed: [" + exception + "]", Logging.Teal);
                return null;
            }
        }
        internal static List<DirectAgentMission> GetAgentMissions(DirectEve directEve)
        {
            var missions = new List<DirectAgentMission>();

            var pyMissions = directEve.GetLocalSvc("journal").Attribute("agentjournal").Item(0).ToList();

            foreach (var pyMission in pyMissions)
            {
                var mission = new DirectAgentMission(directEve);
                mission.State = (int) pyMission.Item(0);
                mission.Important = (bool) pyMission.Item(1);
                mission.Type = (string) pyMission.Item(2);

                if ((int) pyMission.Item(3) > 0)
                    mission.Name = (string) directEve.PySharp.Import("localization").Call("GetByMessageID", (int) pyMission.Item(3));
                else
                {
                    mission.Name = "none";
                    continue;
                }

                mission._pyAgentId = pyMission.Item(4);
                mission.AgentId = (long) pyMission.Item(4);

                mission.ExpiresOn = (DateTime) pyMission.Item(5);
                mission.Bookmarks = pyMission.Item(6).ToList().Select(b => new DirectAgentMissionBookmark(directEve, b)).ToList();
                missions.Add(mission);
            }

            return missions;
        }