Ejemplo n.º 1
0
        public Questor(QuestorfrmMain form1)
        {
            _mParent = form1;
            _lastQuestorPulse = DateTime.UtcNow;

            _defense = new Defense();
            _combatMissionsBehavior = new CombatMissionsBehavior();
            _combatHelperBehavior = new CombatHelperBehavior();
            _dedicatedBookmarkSalvagerBehavior = new DedicatedBookmarkSalvagerBehavior();
            _directionalScannerBehavior = new DirectionalScannerBehavior();
            _debugHangarsBehavior = new DebugHangarsBehavior();
            _miningBehavior = new MiningBehavior();
            //_backgroundbehavior = new BackgroundBehavior();
            _cleanup = new Cleanup();
            _watch = new Stopwatch();
            _innerspaceCommands = new InnerspaceCommands();
            _statistics = new Statistics();

            Cache.Instance.ScheduleCharacterName = Logging._character;
            Cache.Instance.NextStartupAction = DateTime.UtcNow;
            // State fixed on ExecuteMission
            _States.CurrentQuestorState = QuestorState.Idle;

            if (Cache.Instance.DirectEve == null)
            {
                Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange);
                Cache.Instance.CloseQuestorCMDLogoff = false;
                Cache.Instance.CloseQuestorCMDExitGame = true;
                Cache.Instance.CloseQuestorEndProcess = true;
                Settings.Instance.AutoStart = true;
                Cache.Instance.ReasonToStopQuestor = "Error on Loading DirectEve, maybe server is down";
                Cache.Instance.SessionState = "Quitting";
                Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor);
                return;
            }

            try
            {
                if (Cache.Instance.DirectEve.HasSupportInstances())
                {
                    //Logging.Log("Questor", "You have a valid directeve.lic file and have instances available", Logging.Orange);
                }
                else
                {
                    //Logging.Log("Questor", "You have 0 Support Instances available [ _directEve.HasSupportInstances() is false ]", Logging.Orange);
                }

            }
            catch (Exception exception)
            {
                Logging.Log("Questor", "Exception while checking: _directEve.HasSupportInstances() in questor.cs - exception was: [" + exception + "]", Logging.Orange);
            }

            Cache.Instance.StopTimeSpecified = Program.StopTimeSpecified;
            Cache.Instance.MaxRuntime = Program.MaxRuntime;
            if (Program.StartTime.AddMinutes(10) < Program.StopTime)
            {
                Cache.Instance.StopTime = Program.StopTime;
                Logging.Log("Questor", "Schedule: setup correctly: stoptime is [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
            }
            else
            {
                Cache.Instance.StopTime = DateTime.Now.AddHours(Time.Instance.QuestorScheduleNotUsed_Hours);
                Logging.Log("Questor", "Schedule: NOT setup correctly: stoptime  set to [" + Time.Instance.QuestorScheduleNotUsed_Hours + "] hours from now at [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
                Logging.Log("Questor", "You can correct this by editing schedules.xml to have an entry for this toon", Logging.Orange);
                Logging.Log("Questor", "Ex: <char user=\"" + Settings.Instance.CharacterName + "\" pw=\"MyPasswordForEVEHere\" name=\"MyLoginNameForEVEHere\" start=\"06:45\" stop=\"08:10\" start2=\"09:05\" stop2=\"14:20\"/>", Logging.Orange);
                Logging.Log("Questor", "make sure each toon has its own innerspace profile and specify the following startup program line:", Logging.Orange);
                Logging.Log("Questor", "dotnet questor questor -x -c \"MyEVECharacterName\"", Logging.Orange);
            }

            Cache.Instance.StartTime = Program.StartTime;
            Cache.Instance.QuestorStarted_DateTime = DateTime.UtcNow;

            // get the current process
            Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

            // get the physical mem usage
            Cache.Instance.TotalMegaBytesOfMemoryUsed = ((currentProcess.WorkingSet64 / 1024) / 1024);
            Logging.Log("Questor", "EVE instance: totalMegaBytesOfMemoryUsed - " + Cache.Instance.TotalMegaBytesOfMemoryUsed + " MB", Logging.White);
            Cache.Instance.SessionIskGenerated = 0;
            Cache.Instance.SessionLootGenerated = 0;
            Cache.Instance.SessionLPGenerated = 0;
            Settings.Instance.CharacterMode = "none";

            try
            {
                Cache.Instance.DirectEve.OnFrame += EVEOnFrame;
            }
            catch (Exception ex)
            {
                Logging.Log("Questor", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White);
                Cache.Instance.CloseQuestorCMDLogoff = false;
                Cache.Instance.CloseQuestorCMDExitGame = true;
                Cache.Instance.CloseQuestorEndProcess = true;
                Settings.Instance.AutoStart = true;
                Cache.Instance.ReasonToStopQuestor = "Error on DirectEve.OnFrame, maybe the DirectEVE license server is down";
                Cache.Instance.SessionState = "Quitting";
                Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor);
            }
        }
Ejemplo n.º 2
0
        public Questor(QuestorfrmMain form1)
        {
            _mParent          = form1;
            _lastQuestorPulse = DateTime.UtcNow;

            _defense = new Defense();
            _combatMissionsBehavior            = new CombatMissionsBehavior();
            _combatHelperBehavior              = new CombatHelperBehavior();
            _dedicatedBookmarkSalvagerBehavior = new DedicatedBookmarkSalvagerBehavior();
            _directionalScannerBehavior        = new DirectionalScannerBehavior();
            _debugHangarsBehavior              = new DebugHangarsBehavior();
            _miningBehavior = new MiningBehavior();
            //_backgroundbehavior = new BackgroundBehavior();
            _cleanup            = new Cleanup();
            _watch              = new Stopwatch();
            _innerspaceCommands = new InnerspaceCommands();
            _statistics         = new Statistics();

            Cache.Instance.ScheduleCharacterName = Logging._character;
            Cache.Instance.NextStartupAction     = DateTime.UtcNow;
            // State fixed on ExecuteMission
            _States.CurrentQuestorState = QuestorState.Idle;

            if (Cache.Instance.DirectEve == null)
            {
                Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange);
                Cache.Instance.CloseQuestorCMDLogoff   = false;
                Cache.Instance.CloseQuestorCMDExitGame = true;
                Cache.Instance.CloseQuestorEndProcess  = true;
                Settings.Instance.AutoStart            = true;
                Cache.Instance.ReasonToStopQuestor     = "Error on Loading DirectEve, maybe server is down";
                Cache.Instance.SessionState            = "Quitting";
                Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor);
                return;
            }

            try
            {
                if (Cache.Instance.DirectEve.HasSupportInstances())
                {
                    //Logging.Log("Questor", "You have a valid directeve.lic file and have instances available", Logging.Orange);
                }
                else
                {
                    //Logging.Log("Questor", "You have 0 Support Instances available [ _directEve.HasSupportInstances() is false ]", Logging.Orange);
                }
            }
            catch (Exception exception)
            {
                Logging.Log("Questor", "Exception while checking: _directEve.HasSupportInstances() in questor.cs - exception was: [" + exception + "]", Logging.Orange);
            }

            Cache.Instance.StopTimeSpecified = Program.StopTimeSpecified;
            Cache.Instance.MaxRuntime        = Program.MaxRuntime;
            if (Program.StartTime.AddMinutes(10) < Program.StopTime)
            {
                Cache.Instance.StopTime = Program.StopTime;
                Logging.Log("Questor", "Schedule: setup correctly: stoptime is [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
            }
            else
            {
                Cache.Instance.StopTime = DateTime.Now.AddHours(Time.Instance.QuestorScheduleNotUsed_Hours);
                Logging.Log("Questor", "Schedule: NOT setup correctly: stoptime  set to [" + Time.Instance.QuestorScheduleNotUsed_Hours + "] hours from now at [" + Cache.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
                Logging.Log("Questor", "You can correct this by editing schedules.xml to have an entry for this toon", Logging.Orange);
                Logging.Log("Questor", "Ex: <char user=\"" + Settings.Instance.CharacterName + "\" pw=\"MyPasswordForEVEHere\" name=\"MyLoginNameForEVEHere\" start=\"06:45\" stop=\"08:10\" start2=\"09:05\" stop2=\"14:20\"/>", Logging.Orange);
                Logging.Log("Questor", "make sure each toon has its own innerspace profile and specify the following startup program line:", Logging.Orange);
                Logging.Log("Questor", "dotnet questor questor -x -c \"MyEVECharacterName\"", Logging.Orange);
            }

            Cache.Instance.StartTime = Program.StartTime;
            Cache.Instance.QuestorStarted_DateTime = DateTime.UtcNow;

            // get the current process
            Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

            // get the physical mem usage
            Cache.Instance.TotalMegaBytesOfMemoryUsed = ((currentProcess.WorkingSet64 / 1024) / 1024);
            Logging.Log("Questor", "EVE instance: totalMegaBytesOfMemoryUsed - " + Cache.Instance.TotalMegaBytesOfMemoryUsed + " MB", Logging.White);
            Cache.Instance.SessionIskGenerated  = 0;
            Cache.Instance.SessionLootGenerated = 0;
            Cache.Instance.SessionLPGenerated   = 0;
            Settings.Instance.CharacterMode     = "none";

            try
            {
                Cache.Instance.DirectEve.OnFrame += EVEOnFrame;
            }
            catch (Exception ex)
            {
                Logging.Log("Questor", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White);
                Cache.Instance.CloseQuestorCMDLogoff   = false;
                Cache.Instance.CloseQuestorCMDExitGame = true;
                Cache.Instance.CloseQuestorEndProcess  = true;
                Settings.Instance.AutoStart            = true;
                Cache.Instance.ReasonToStopQuestor     = "Error on DirectEve.OnFrame, maybe the DirectEVE license server is down";
                Cache.Instance.SessionState            = "Quitting";
                Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor);
            }
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            DateTimeForLogs = DateTime.Now;
            //Logging.Log("BuyLPI", "BuyLPI: Test", Logging.White);
            //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: Test2"));

            if (args.Length == 0)
            {
                ////InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: 0 arguments"));
                //Logging.Log("QuestorTest1", "Syntax:", Logging.White);
                //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]", Logging.White);
                //Logging.Log("QuestorTest1", "(Quantity is optional)", Logging.White);
                //Logging.Log("QuestorTest1", "", Logging.White);
                //Logging.Log("QuestorTest1", "Example:", Logging.White);
                //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10", Logging.White);
                //Logging.Log("QuestorTest1", "*OR*", Logging.White);
                //Logging.Log("QuestorTest1", "DotNet BuyLPI BuyLPI 27339 10", Logging.White);
                //return;
            }

            if (args.Length >= 1)
            {
                //_type = args[0];
            }

            if (args.Length >= 2)
            {
                //int dummy;
                //if (!int.TryParse(args[1], out dummy))
                //{
                //    Logging.Log("QuestorTest1", "Quantity must be an integer, 0 - " + int.MaxValue, Logging.White);
                //    return;
                //}
                //
                //if (dummy < 0)
                //{
                //    Logging.Log("QuestorTest1", "Quantity must be a positive number", Logging.White);
                //    return;
                //}
                //
                //_quantity = dummy;
                //_totalQuantityOfOrders = dummy;
            }

            Cache.Instance.QuestorStarted_DateTime = DateTime.UtcNow;

            InnerspaceCommands.CreateLavishCommands();
            //InnerspaceEvents.CreateLavishEvents();

            //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "Starting BuyLPI... - innerspace Echo"));
            Logging.Log("QuestorTest1", "Starting QuestorTest1...", Logging.White);
            _cleanup = new Cleanup();
            Cache.Instance.DirectEve          = new DirectEve();
            Cache.Instance.DirectEve.OnFrame += OnFrame;

            // Sleep until we're done
            while (_done.AddSeconds(5) > DateTime.UtcNow)
            {
                Thread.Sleep(50);
            }

            Cache.Instance.DirectEve.Dispose();
            Logging.Log("QuestorTest1", "QuestorTest1 finished.", Logging.White);
            //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: Finished 2"));
        }
Ejemplo n.º 4
0
        public void RunOnceAfterStartup()
        {
            if (!_runOnceAfterStartupalreadyProcessed && DateTime.UtcNow > Cache.Instance.QuestorStarted_DateTime.AddSeconds(15))
            {
                if (Settings.Instance.CharacterXMLExists && DateTime.UtcNow > Cache.Instance.NextStartupAction)
                {
                    Cache.Instance.DirectEve.Skills.RefreshMySkills();
                    _runOnceAfterStartupalreadyProcessed = true;

                    Cache.Instance.IterateShipTargetValues("RunOnceAfterStartup");                 // populates ship target values from an XML
                    Cache.Instance.IterateInvTypes("RunOnceAfterStartup");                         // populates the prices of items (cant we use prices from the game now?!)
                    Cache.Instance.IterateUnloadLootTheseItemsAreLootItems("RunOnceAfterStartup"); // populates the list of items we never want in our local cargo (used mainly in unloadloot)

                    if (Settings.Instance.UseInnerspace)
                    {
                        InnerspaceCommands.CreateLavishCommands();

                        UpdateMissionName();

                        //enable windowtaskbar = on, so that minimized windows do not make us die in a fire.
                        Logging.Log("RunOnceAfterStartup", "Running Innerspace command: timedcommand 100 windowtaskbar on " + Settings.Instance.CharacterName, Logging.White);
                        LavishScript.ExecuteCommand("timedcommand 100 windowtaskbar on " + Settings.Instance.CharacterName);

                        if (Settings.Instance.EVEWindowXSize >= 100 && Settings.Instance.EVEWindowYSize >= 100)
                        {
                            Logging.Log("RunOnceAfterStartup", "Running Innerspace command: timedcommand 150 WindowCharacteristics -size " + Settings.Instance.EVEWindowXSize + "x" + Settings.Instance.EVEWindowYSize, Logging.White);
                            LavishScript.ExecuteCommand("timedcommand 150 WindowCharacteristics -size " + Settings.Instance.EVEWindowXSize + "x" + Settings.Instance.EVEWindowYSize);
                            Logging.Log("RunOnceAfterStartup", "Running Innerspace command: timedcommand 200 WindowCharacteristics -pos " + Settings.Instance.EVEWindowXPosition + "," + Settings.Instance.EVEWindowYPosition, Logging.White);
                            LavishScript.ExecuteCommand("timedcommand 200 WindowCharacteristics -pos " + Settings.Instance.EVEWindowXPosition + "," + Settings.Instance.EVEWindowYPosition);
                        }

                        if (Settings.Instance.MinimizeEveAfterStartingUp)
                        {
                            Logging.Log("RunOnceAfterStartup", "MinimizeEveAfterStartingUp is true: Minimizing EVE with: WindowCharacteristics -visibility minimize", Logging.White);
                            LavishScript.ExecuteCommand("WindowCharacteristics -visibility minimize");
                        }

                        if (Settings.Instance.LoginQuestorArbitraryOSCmd)
                        {
                            Logging.Log("RunOnceAfterStartup", "After Questor Login: executing LoginQuestorArbitraryOSCmd", Logging.White);
                            LavishScript.ExecuteCommand("Echo [${Time}] OSExecute " + Settings.Instance.LoginQuestorOSCmdContents.ToString(CultureInfo.InvariantCulture));
                            LavishScript.ExecuteCommand("OSExecute " + Settings.Instance.LoginQuestorOSCmdContents.ToString(CultureInfo.InvariantCulture));
                            Logging.Log("RunOnceAfterStartup", "Done: executing LoginQuestorArbitraryOSCmd", Logging.White);
                        }

                        if (Settings.Instance.LoginQuestorLavishScriptCmd)
                        {
                            Logging.Log("RunOnceAfterStartup", "After Questor Login: executing LoginQuestorLavishScriptCmd", Logging.White);
                            LavishScript.ExecuteCommand("Echo [${Time}] runscript " + Settings.Instance.LoginQuestorLavishScriptContents.ToString(CultureInfo.InvariantCulture));
                            LavishScript.ExecuteCommand("runscript " + Settings.Instance.LoginQuestorLavishScriptContents.ToString(CultureInfo.InvariantCulture));
                            Logging.Log("RunOnceAfterStartup", "Done: executing LoginQuestorLavishScriptCmd", Logging.White);
                        }

                        Logging.MaintainConsoleLogs();
                    }
                }
                else
                {
                    Logging.Log("RunOnceAfterStartup", "Settings.Instance.CharacterName is still null", Logging.Orange);
                    Cache.Instance.NextStartupAction     = DateTime.UtcNow.AddSeconds(10);
                    _runOnceAfterStartupalreadyProcessed = false;
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        public Questor()
        {
            //Logging.tryToLogToFile = true;
            _lastQuestorPulse = DateTime.UtcNow;

            _combatMissionsBehavior = new CombatMissionsBehavior();
            _combatHelperBehavior = new CombatHelperBehavior();
            _dedicatedBookmarkSalvagerBehavior = new DedicatedBookmarkSalvagerBehavior();
            _debugHangarsBehavior = new DebugHangarsBehavior();
            //_backgroundbehavior = new BackgroundBehavior();
            _watch = new Stopwatch();
            _innerspaceCommands = new InnerspaceCommands();

            Time.Instance.NextStartupAction = DateTime.UtcNow;
            // State fixed on ExecuteMission
            _States.CurrentQuestorState = QuestorState.Idle;

            if (!EveCom.EVEFrame.SubLicenses.Any())
            {
                Logging.Log("Startup", "Error on Loading EveCom, no licenses! maybe server is down?", Logging.Orange);
                QuestorCache.Instance.CloseQuestorCMDLogoff = false;
                QuestorCache.Instance.CloseQuestorCMDExitGame = true;
                QuestorCache.Instance.CloseQuestorEndProcess = true;
                QuestorSettings.Instance.AutoStart = true;
                Cleanup.ReasonToStopQuestor = "Error on Loading EveCom, no licenses! maybe server is down?";
                Cleanup.SignalToQuitQuestorAndEveAndRestartInAMoment = true;
                Cleanup.CloseQuestor(Cleanup.ReasonToStopQuestor);
                return;
            }

            if (LoginToEVE.StartTime.AddMinutes(10) < LoginToEVE.StopTime)
            {
                Time.Instance.StopTime = LoginToEVE.StopTime;
                Logging.Log("Questor", "Schedule: setup correctly: stoptime is [" + Time.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
            }
            else
            {
                Time.Instance.StopTime = DateTime.Now.AddHours(Time.Instance.QuestorScheduleNotUsed_Hours);
                Logging.Log("Questor", "Schedule: NOT setup correctly: stoptime  set to [" + Time.Instance.QuestorScheduleNotUsed_Hours + "] hours from now at [" + Time.Instance.StopTime.ToShortTimeString() + "]", Logging.Orange);
                Logging.Log("Questor", "You can correct this by editing schedules.xml to have an entry for this toon", Logging.Orange);
                Logging.Log("Questor", "Ex: <char user=\"" + QuestorSettings.Instance.CharacterName + "\" pw=\"MyPasswordForEVEHere\" name=\"MyLoginNameForEVEHere\" start=\"06:45\" stop=\"08:10\" start2=\"09:05\" stop2=\"14:20\"/>", Logging.Orange);
                Logging.Log("Questor", "make sure each toon has its own innerspace profile and specify the following startup program line:", Logging.Orange);
                Logging.Log("Questor", "dotnet questor questor -x -c \"MyEVECharacterName\"", Logging.Orange);
            }

            Time.Instance.StartTime = LoginToEVE.StartTime;
            Time.Instance.QuestorStarted_DateTime = DateTime.UtcNow;

            // get the current process
            Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();

            // get the physical mem usage
            QuestorCache.Instance.TotalMegaBytesOfMemoryUsed = ((currentProcess.WorkingSet64 + 1 / 1024) / 1024);
            Logging.Log("Questor", "EVE instance: totalMegaBytesOfMemoryUsed - " + QuestorCache.Instance.TotalMegaBytesOfMemoryUsed + " MB", Logging.White);
            Statistics.SessionIskGenerated = 0;
            Statistics.SessionLootGenerated = 0;
            Statistics.SessionLPGenerated = 0;
            QuestorSettings.Instance.CharacterMode = "none";

            try
            {
                EveCom.EVEFrame.OnFrame += QuestorPulse; //the onframe routine is now located in evecomframework.core (thus triggered by our queing QuestorPulse)

                //Logging.Log("Questor", "Queue QuestorPulse using EVEComFramework.States", Logging.White);
                //QueueState(QuestorPulse);

            }
            catch (Exception ex)
            {
                Logging.Log("Questor", "EVECom.OnFrame: Exception [" + ex + "]", Logging.White);
                QuestorCache.Instance.CloseQuestorCMDLogoff = false;
                QuestorCache.Instance.CloseQuestorCMDExitGame = true;
                QuestorCache.Instance.CloseQuestorEndProcess = true;
                QuestorSettings.Instance.AutoStart = true;
                Cleanup.ReasonToStopQuestor = "Error on EVECom.OnFrame, maybe the EVECom license server is down";
                Cleanup.SignalToQuitQuestorAndEveAndRestartInAMoment = true;
                Cleanup.CloseQuestor(Cleanup.ReasonToStopQuestor);
            }

            Logging.Log("Questor", "Questor.", Logging.White);
        }