예제 #1
0
파일: Program.cs 프로젝트: karope/Questor
        private static void Main(string[] args)
        {
            Logging.Log("GoToBM","Started",Logging.white);
            if (args.Length == 0 || args[0].Length < 1)
            {
                Logging.Log("GoToBM"," You need to supply a bookmark name",Logging.white);
                Logging.Log("GoToBM"," Ended",Logging.white);
                return;
            }
            _BM = args[0];
            _BM = _BM.ToLower();

            _directEve = new DirectEve();
            Cache.Instance.DirectEve = _directEve;
            _directEve.OnFrame += OnFrame;
            _traveler = new Traveler();
            _cleanup = new Cleanup();
            _defense = new Defense();

            while (!_done)
            {
                System.Threading.Thread.Sleep(50);
            }

            _directEve.Dispose();
            Logging.Log("GoToBM"," Exiting",Logging.white);
            return;
        }
예제 #2
0
        private static void Main()
        {
            Log("Starting test...");
            _directEve = new DirectEve();
            _directEve.OnFrame += OnFrame;

            // Sleep until we're done
            while (!_done)
                Thread.Sleep(50);

            _directEve.Dispose();
            Log("Test finished.");
        }
예제 #3
0
파일: Program.cs 프로젝트: ahaw/Questor
        private static void Main(string[] args)
        {
            Log("Starting GridMon...");
            _directEve = new DirectEve();
            _directEve.OnFrame += OnFrame;

            // Sleep until we're done
            while (!_done)
                Thread.Sleep(50);

            _directEve.Dispose();
            Log("GridMon finished.");
        }
예제 #4
0
파일: Program.cs 프로젝트: Rx2/Questor
        static void Main(string[] args)
        {
            if (args.Length == 3 || args.Length == 4)
            {
                _username = args[0];
                _password = args[1];
                _character = args[2];

                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                var started = DateTime.Now;

                // Sleep until we're done
                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);

                    if (DateTime.Now.Subtract(started).TotalSeconds > 180)
                    {
                        Logging.Log("auto login timed out after 3 minutes");
                        break;
                    }
                }

                _directEve.Dispose();

                // If the last parameter is false, then we only auto-login
                if (args.Length == 4 && string.Compare(args[3], "false", true) == 0)
                    return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
예제 #5
0
파일: BuyLPI.cs 프로젝트: karope/Questor
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Logging.Log("BuyLPI", "Syntax:", Logging.white);
                Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]", Logging.white);
                Logging.Log("BuyLPI", "(Quantity is optional)", Logging.white);
                Logging.Log("BuyLPI", "", Logging.white);
                Logging.Log("BuyLPI", "Example:", Logging.white);
                Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10", Logging.white);
                Logging.Log("BuyLPI", "*OR*", Logging.white);
                Logging.Log("BuyLPI", "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("BuyLPI", "Quantity must be an integer, 0 - " + int.MaxValue, Logging.white);
                    return;
                }

                if (dummy < 0)
                {
                    Logging.Log("BuyLPI", "Quantity must be a positive number", Logging.white);
                    return;
                }

                _quantity = dummy;
                _totalquantityoforders = dummy;
            }

            Logging.Log("BuyLPI", "Starting BuyLPI...", Logging.white);
            _cleanup = new Cleanup();
            _directEve = new DirectEve();
            Cache.Instance.DirectEve = _directEve;
            _directEve.OnFrame += OnFrame;

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

            _directEve.Dispose();
            Logging.Log("BuyLPI", "BuyLPI finished.", Logging.white);
        }
예제 #6
0
파일: Program.cs 프로젝트: vega87/questor
        static void Main(string[] args)
        {
            _maxRuntime = Int32.MaxValue;
            var p = new OptionSet() {
                "Usage: questor [OPTIONS]",
                "Run missions and make uber ISK.",
                "",
                "Options:",
                { "u|user="******"the {USER} we are logging in as.",
                v => _username = v },
                { "p|password="******"the user's {PASSWORD}.",
                v => _password = v },
                { "c|character=", "the {CHARACTER} to use.",
                v => _character = v },
                { "s|script=", "a {SCRIPT} file to execute before login.",
                v => _scriptFile = v },
                { "l|login", "login only and exit.",
                v => _loginOnly = v != null },
                { "r|runtime=", "Quit Questor after {RUNTIME} minutes.",
                v => _maxRuntime = Int32.Parse(v) },
                { "h|help", "show this message and exit",
                v => _showHelp = v != null },
                };

            List<string> extra;
            try
            {
                extra = p.Parse(args);
                //Logging.Log(string.Format("questor: extra = {0}", string.Join(" ", extra.ToArray())));
            }
            catch (OptionException e)
            {
                Logging.Log("questor: ");
                Logging.Log(e.Message);
                Logging.Log("Try `questor --help' for more information.");
                return;
            }

            if (_showHelp)
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();
                p.WriteOptionDescriptions(sw);
                Logging.Log(sw.ToString());
                return;
            }

            if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password) && !string.IsNullOrEmpty(_character))
            {
                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                var started = DateTime.Now;

                // Sleep until we're done
                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);

                    if (DateTime.Now.Subtract(started).TotalSeconds > 180)
                    {
                        Logging.Log("auto login timed out after 3 minutes");
                        break;
                    }
                }

                _directEve.Dispose();

                // If the last parameter is false, then we only auto-login
                if (_loginOnly)
                    return;
            }

            _startTime = DateTime.Now;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
예제 #7
0
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                _character = args[0];

                var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

                CharSchedules = new List<CharSchedule>();
                var values = XDocument.Load(Path.Combine(path, "Schedules.xml"));
                foreach (var value in values.Root.Elements("char"))
                    CharSchedules.Add(new CharSchedule(value));

                var _schedule = CharSchedules.FirstOrDefault(v => v.Name == _character);
                if (_schedule == null)
                {
                    Logging.Log("[Startup] Error - character not found!");
                    return;
                }
                else
                {
                    Logging.Log("[Startup] User: "******" PW: " + _schedule.PW + " Name: " + _schedule.Name + " Start: " + _schedule.Start + " Stop: " +
                             _schedule.Stop + " RunTime: " + _schedule.RunTime);
                    if (_schedule.User == null || _schedule.PW == null)
                    {
                        Logging.Log("[Startup] Error - Login details not specified in Schedules.xml!");
                        return;
                    }
                    else
                    {
                        _username = _schedule.User;
                        _password = _schedule.PW;
                    }
                    _startTime = _schedule.Start;
                    if (_schedule.startTimeSpecified )
                        _startTime = _startTime.AddSeconds((double)(_r.Next(0, (_randStartDelay * 60))));
                    _stopTime = _schedule.Stop;

                    if ((DateTime.Now > _startTime))
                    {
                        if ((DateTime.Now.Subtract( _startTime).TotalMinutes < 720 )) //if we're less than 12 hours past start time, start now
                        {
                            _startTime = DateTime.Now;
                            _readyToStarta = true;
                        }
                        else
                            _startTime = _startTime.AddDays(1); //otherwise, start tomorrow at start time
                    }
                    else
                        if ((_startTime.Subtract(DateTime.Now).TotalMinutes > 720)) //if we're more than 12 hours shy of start time, start now
                        {
                            _startTime = DateTime.Now;
                            _readyToStarta = true;
                        }

                    if (_stopTime < _startTime)
                        _stopTime = _stopTime.AddDays(1);

                    if (_schedule.RunTime > 0) //if runtime is specified, overrides stop time
                        _stopTime = _startTime.AddHours(_schedule.RunTime);

                    string _stopTimeText = "No stop time specified";
                    stopTimeSpecified = _schedule.stopTimeSpecified;
                    if (stopTimeSpecified)
                        _stopTimeText = _stopTime.ToString();

                    Logging.Log("[Startup] Start Time: " + _startTime + " - Stop Time: " + _stopTimeText);

                    if (!_readyToStarta)
                    {
                        minutesToStart = _startTime.Subtract(DateTime.Now).TotalMinutes;
                        Logging.Log("[Startup] Starting at " + _startTime + ". " + String.Format("{0:0.##}", minutesToStart) + " minutes to go.");
                        _timer.Elapsed += new ElapsedEventHandler(TimerEventProcessor);
                        if (minutesToStart > 0)
                            _timer.Interval = (int)(minutesToStart * 60000);
                        else
                            _timer.Interval = 1000;
                        _timer.Enabled = true;
                        _timer.Start();

                    }
                    else
                    {
                        _readyToStart = true;
                        Logging.Log("[Startup] Already passed start time.  Starting now.");
                    }
                }

                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                _directEve.Dispose();
            }
            else if (args.Length == 3 || args.Length == 4)
            {
                _username = args[0];
                _password = args[1];
                _character = args[2];
                _readyToStart = true;

                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                var started = DateTime.Now;

                // Sleep until we're done
                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                _directEve.Dispose();

                // If the last parameter is false, then we only auto-login
                if (args.Length == 4 && string.Compare(args[3], "false", true) == 0)
                    return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
예제 #8
0
파일: Program.cs 프로젝트: Chryst/Questor
        private static void Main(string[] args)
        {
            _maxRuntime = Int32.MaxValue;
            var p = new OptionSet {
                "Usage: questor [OPTIONS]",
                "Run missions and make uber ISK.",
                "",
                "Options:",
                {"u|user="******"the {USER} we are logging in as.", v => _username = v},
                {"p|password="******"the user's {PASSWORD}.", v => _password = v},
                {"c|character=", "the {CHARACTER} to use.", v => _character = v},
                {"s|script=", "a {SCRIPT} file to execute before login.", v => _scriptFile = v},
                {"l|login", "login only and exit.", v => _loginOnly = v != null},
                {"x|chantling", "use chantling's scheduler", v => _chantlingScheduler = v != null},
                {"h|help", "show this message and exit", v => _showHelp = v != null}
                };

            List<string> extra;
            try
            {
                extra = p.Parse(args);
                //Logging.Log(string.Format("questor: extra = {0}", string.Join(" ", extra.ToArray())));
            }
            catch (OptionException ex)
            {
                Logging.Log("Startup", "questor: ", Logging.White);
                Logging.Log("Startup", ex.Message, Logging.White);
                Logging.Log("Startup", "Try `questor --help' for more information.", Logging.White);
                return;
            }
            _readyToStart = true;

            if (_showHelp)
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();
                p.WriteOptionDescriptions(sw);
                Logging.Log("Startup", sw.ToString(), Logging.White);
                return;
            }

            if (_chantlingScheduler && string.IsNullOrEmpty(_character))
            {
                Logging.Log("Startup", "Error: to use chantling's scheduler, you also need to provide a character name!", Logging.Red);
                return;
            }

            if (_chantlingScheduler && !string.IsNullOrEmpty(_character))
            {
                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                _character = _character.Replace("\"", "");  // strip quotation marks if any are present

                CharSchedules = new List<CharSchedule>();
                if (path != null)
                {
                    XDocument values = XDocument.Load(Path.Combine(path, "Schedules.xml"));
                    if (values.Root != null)
                        foreach (XElement value in values.Root.Elements("char"))
                            CharSchedules.Add(new CharSchedule(value));
                }
                //
                // chantling scheduler
                //
                CharSchedule schedule = CharSchedules.FirstOrDefault(v => v.Name == _character);
                if (schedule == null)
                {
                    Logging.Log("Startup", "Error - character not found!", Logging.Red);
                    return;
                }

                if (schedule.User == null || schedule.PW == null)
                {
                    Logging.Log("Startup", "Error - Login details not specified in Schedules.xml!", Logging.Red);
                    return;
                }

                _username = schedule.User;
                _password = schedule.PW;
                Logging.Log("Startup", "User: "******" Name: " + schedule.Name, Logging.White);

                if (schedule.StartTimeSpecified)
                {
                    if (schedule.Start1 > schedule.Stop1) schedule.Stop1 = schedule.Stop1.AddDays(1);
                    if (DateTime.Now.AddHours(2) > schedule.Start1 && DateTime.Now < schedule.Stop1)
                    {
                        StartTime = schedule.Start1;
                        StopTime = schedule.Stop1;
                        StopTimeSpecified = true;
                        Logging.Log("Startup", "Schedule1: Start1: " + schedule.Start1 + " Stop1: " + schedule.Stop1, Logging.White);
                    }
                }

                if (schedule.StartTime2Specified)
                {
                    if (DateTime.Now > schedule.Stop1 || DateTime.Now.DayOfYear > schedule.Stop1.DayOfYear) //if after schedule1 stoptime or the next day
                    {
                        if (schedule.Start2 > schedule.Stop2) schedule.Stop2 = schedule.Stop2.AddDays(1);
                        if (DateTime.Now.AddHours(2) > schedule.Start2 && DateTime.Now < schedule.Stop2)
                        {
                            StartTime = schedule.Start2;
                            StopTime = schedule.Stop2;
                            StopTimeSpecified = true;
                            Logging.Log("Startup", "Schedule2: Start2: " + schedule.Start2 + " Stop2: " + schedule.Stop2, Logging.White);
                        }
                    }
                }

                if (schedule.StartTime3Specified)
                {
                    if (DateTime.Now > schedule.Stop2 || DateTime.Now.DayOfYear > schedule.Stop2.DayOfYear) //if after schedule2 stoptime or the next day
                    {
                        if (schedule.Start3 > schedule.Stop3) schedule.Stop3 = schedule.Stop3.AddDays(1);
                        if (DateTime.Now.AddHours(2) > schedule.Start3 && DateTime.Now < schedule.Stop3)
                        {
                            StartTime = schedule.Start3;
                            StopTime = schedule.Stop3;
                            StopTimeSpecified = true;
                            Logging.Log("Startup",
                                        "Schedule3: Start3: " + schedule.Start3 + " Stop3: " + schedule.Stop3,
                                        Logging.White);
                        }
                    }
                }
                //
                // if we havent found a worksable schedule yet assume schedule 1 is correct. what we want.
                //
                if (schedule.StartTimeSpecified && StartTime == DateTime.MaxValue)
                {
                    StartTime = schedule.Start1;
                    StopTime = schedule.Stop1;
                    Logging.Log("Startup", "Forcing Schedule 1 because none of the schedules started within 2 hours", Logging.White);
                    Logging.Log("Startup", "Schedule 1: Start1: " + schedule.Start1 + " Stop1: " + schedule.Stop1, Logging.White);
                }

                if (schedule.StartTimeSpecified || schedule.StartTime2Specified || schedule.StartTime3Specified)
                    StartTime = StartTime.AddSeconds(R.Next(0, (RandStartDelay * 60)));

                if ((DateTime.Now > StartTime))
                {
                    if ((DateTime.Now.Subtract(StartTime).TotalMinutes < 1200)) //if we're less than x hours past start time, start now
                    {
                        StartTime = DateTime.Now;
                        _readyToStarta = true;
                    }
                    else
                        StartTime = StartTime.AddDays(1); //otherwise, start tomorrow at start time
                }
                else if ((StartTime.Subtract(DateTime.Now).TotalMinutes > 1200)) //if we're more than x hours shy of start time, start now
                    {
                        StartTime = DateTime.Now;
                        _readyToStarta = true;
                    }

                if (StopTime < StartTime)
                    StopTime = StopTime.AddDays(1);

                //if (schedule.RunTime > 0) //if runtime is specified, overrides stop time
                //    StopTime = StartTime.AddMinutes(schedule.RunTime); //minutes of runtime

                //if (schedule.RunTime < 18 && schedule.RunTime > 0)     //if runtime is 10 or less, assume they meant hours
                //    StopTime = StartTime.AddHours(schedule.RunTime);   //hours of runtime

                Logging.Log("Startup", " Start Time: " + StartTime + " - Stop Time: " + StopTime, Logging.White);

                if (!_readyToStarta)
                {
                    _minutesToStart = StartTime.Subtract(DateTime.Now).TotalMinutes;
                    Logging.Log("Startup", "Starting at " + StartTime + ". " + String.Format("{0:0.##}", _minutesToStart) + " minutes to go.", Logging.Yellow);
                    Timer.Elapsed += new ElapsedEventHandler(TimerEventProcessor);
                    if (_minutesToStart > 0)
                        Timer.Interval = (int)(_minutesToStart * 60000);
                    else
                        Timer.Interval = 1000;
                    Timer.Enabled = true;
                    Timer.Start();
                }
                else
                {
                    _readyToStart = true;
                    Logging.Log("Startup", "Already passed start time.  Starting in 15 seconds.", Logging.White);
                    System.Threading.Thread.Sleep(15000);
                }
                //
                // chantling scheduler (above)
                //
                try
                {
                    _directEve = new DirectEve();
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange);
                    Logging.Log("Startup", string.Format("DirectEVE: 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 Loading DirectEve, maybe server is down";
                    Cache.Instance.SessionState = "Quitting";
                    Cleanup.CloseQuestor();
                }

                try
                {
                    _directEve.OnFrame += OnFrame;
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White);
                }

                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                try
                {
                    _directEve.Dispose();
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", string.Format("DirectEVE.Dispose: Exception {0}...", ex), Logging.White);
                }
            }

            if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password) && !string.IsNullOrEmpty(_character))
            {
                _readyToStart = true;

                try
                {
                    _directEve = new DirectEve();
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange);
                    Logging.Log("Startup", string.Format("DirectEVE: 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 Loading DirectEve, maybe server is down";
                    Cache.Instance.SessionState = "Quitting";
                    Cleanup.CloseQuestor();
                }

                try
                {
                    _directEve.OnFrame += OnFrame;
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White);
                }

                // Sleep until we're done
                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                try
                {
                    _directEve.Dispose();
                }
                catch (Exception ex)
                {
                    Logging.Log("Startup", string.Format("DirectEVE.Dispose: Exception {0}...", ex), Logging.White);
                }

                // If the last parameter is false, then we only auto-login
                if (_loginOnly)
                    return;
            }

            StartTime = DateTime.Now;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new QuestorfrmMain());
        }
예제 #9
0
파일: Program.cs 프로젝트: ahaw/Questor
        static void Main(string[] args)
        {
            _maxRuntime = Int32.MaxValue;
            var p = new OptionSet() {
                "Usage: questor [OPTIONS]",
                "Run missions and make uber ISK.",
                "",
                "Options:",
                { "u|user="******"the {USER} we are logging in as.",
                v => _username = v },
                { "p|password="******"the user's {PASSWORD}.",
                v => _password = v },
                { "c|character=", "the {CHARACTER} to use.",
                v => _character = v },
                { "s|script=", "a {SCRIPT} file to execute before login.",
                v => _scriptFile = v },
                { "l|login", "login only and exit.",
                v => _loginOnly = v != null },
                { "r|runtime=", "Quit Questor after {RUNTIME} minutes.",
                v => _maxRuntime = Int32.Parse(v) },
                { "x|chantling", "use chantling's scheduler",
                v => _chantlingScheduler = v != null },
                { "h|help", "show this message and exit",
                v => _showHelp = v != null },
                };

            List<string> extra;
            try
            {
                extra = p.Parse(args);
                //Logging.Log(string.Format("questor: extra = {0}", string.Join(" ", extra.ToArray())));
            }
            catch (OptionException e)
            {
                Logging.Log("questor: ");
                Logging.Log(e.Message);
                Logging.Log("Try `questor --help' for more information.");
                return;
            }
                _readyToStart = true;

            if (_showHelp)
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();
                p.WriteOptionDescriptions(sw);
                Logging.Log(sw.ToString());
                return;
            }

            if (_chantlingScheduler && string.IsNullOrEmpty(_character))
            {
                Logging.Log("Error: to use chantling's scheduler, you also need to provide a character name!");
                return;
            }

            if (_chantlingScheduler && !string.IsNullOrEmpty(_character))
            {
                var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                _character = _character.Replace("\"", "");  // strip quotation marks if any are present

                CharSchedules = new List<CharSchedule>();
                var values = XDocument.Load(Path.Combine(path, "Schedules.xml"));
                foreach (var value in values.Root.Elements("char"))
                    CharSchedules.Add(new CharSchedule(value));

                var _schedule = CharSchedules.FirstOrDefault(v => v.Name == _character);
                if (_schedule == null)
                {
                    Logging.Log("[Startup] Error - character not found!");
                    return;
                }
                else
                {
                    Logging.Log("[Startup] User: "******" PW: " + _schedule.PW + " Name: " + _schedule.Name + " Start: " + _schedule.Start + " Stop: " +
                             _schedule.Stop + " RunTime: " + _schedule.RunTime);
                    if (_schedule.User == null || _schedule.PW == null)
                    {
                        Logging.Log("[Startup] Error - Login details not specified in Schedules.xml!");
                        return;
                    }
                    else
                    {
                        _username = _schedule.User;
                        _password = _schedule.PW;
                    }
                    _startTime = _schedule.Start;

                    if (_schedule.startTimeSpecified )
                        _startTime = _startTime.AddSeconds((double)(_r.Next(0, (_randStartDelay * 60))));
                        _scheduledstartTime = _schedule.Start;
                        _scheduledstopTime = _schedule.Stop;
                        _stopTime = _schedule.Stop;

                        //if ((DateTime.Now > _scheduledstopTime))
                        //{
                        //	_startTime = _startTime.AddDays(1); //otherwise, start tomorrow at start time
                        //	_readyToStarta = false;
                        //}
                        if ((DateTime.Now > _startTime))
                        {
                            if ((DateTime.Now.Subtract( _startTime).TotalMinutes < 1200 )) //if we're less than x hours past start time, start now
                            {
                                _startTime = DateTime.Now;
                                _readyToStarta = true;
                            }
                            else
                                _startTime = _startTime.AddDays(1); //otherwise, start tomorrow at start time
                        }
                        else
                            if ((_startTime.Subtract(DateTime.Now).TotalMinutes > 1200)) //if we're more than x hours shy of start time, start now
                            {
                                _startTime = DateTime.Now;
                                _readyToStarta = true;
                            }

                        if (_stopTime < _startTime)
                            _stopTime = _stopTime.AddDays(1);

                        if (_schedule.RunTime > 0) //if runtime is specified, overrides stop time
                            _stopTime = _startTime.AddHours(_schedule.RunTime);

                        string _stopTimeText = "No stop time specified";
                        stopTimeSpecified = _schedule.stopTimeSpecified;
                        if (stopTimeSpecified)
                            _stopTimeText = _stopTime.ToString();

                        Logging.Log("[Startup] Start Time: " + _startTime + " - Stop Time: " + _stopTimeText);

                        if (!_readyToStarta)
                        {
                            minutesToStart = _startTime.Subtract(DateTime.Now).TotalMinutes;
                            Logging.Log("[Startup] Starting at " + _startTime + ". " + String.Format("{0:0.##}", minutesToStart) + " minutes to go.");
                            _timer.Elapsed += new ElapsedEventHandler(TimerEventProcessor);
                            if (minutesToStart > 0)
                                _timer.Interval = (int)(minutesToStart * 60000);
                            else
                                _timer.Interval = 1000;
                            _timer.Enabled = true;
                            _timer.Start();

                        }
                        else
                        {
                            _readyToStart = true;
                            Logging.Log("[Startup] Already passed start time.  Starting in 15 seconds.");
                            System.Threading.Thread.Sleep(15000);
                        }

                }

                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                _directEve.Dispose();
            }

            if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password) && !string.IsNullOrEmpty(_character))
            {
                _readyToStart = true;

                _directEve = new DirectEve();
                _directEve.OnFrame += OnFrame;

                var started = DateTime.Now;

                // Sleep until we're done
                while (!_done)
                {
                    System.Threading.Thread.Sleep(50);
                }

                _directEve.Dispose();

                // If the last parameter is false, then we only auto-login
                if (_loginOnly)
                    return;
            }

            _startTime = DateTime.Now;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());
        }
예제 #10
0
        private static void Main(string[] args)
        {
            _maxRuntime = Int32.MaxValue;
            var p = new OptionSet {
                "Usage: questor [OPTIONS]",
                "Run missions and make uber ISK.",
                "",
                "Options:",
                {"u|user="******"the {USER} we are logging in as.", v => _username = v},
                {"p|password="******"the user's {PASSWORD}.", v => _password = v},
                {"c|character=", "the {CHARACTER} to use.", v => _character = v},
                {"s|script=", "a {SCRIPT} file to execute before login.", v => _scriptFile = v},
                {"t|scriptAfterLogin="******"a {SCRIPT} file to execute after login.", v => _scriptAfterLoginFile = v},
                {"l|loginOnly", "login only and exit.", v => _loginOnly = v != null},
                {"x|chantling", "use chantling's scheduler", v => _chantlingScheduler = v != null},
                {"n|loginNow", "Login using info in scheduler", v => _loginNowIgnoreScheduler = v != null},
                {"h|help", "show this message and exit", v => _showHelp = v != null}
                };

            List<string> extra;
            try
            {
                extra = p.Parse(args);

                //Logging.Log(string.Format("questor: extra = {0}", string.Join(" ", extra.ToArray())));
            }
            catch (OptionException ex)
            {
                Logging.Log("Startup", "questor: ", Logging.White);
                Logging.Log("Startup", ex.Message, Logging.White);
                Logging.Log("Startup", "Try `questor --help' for more information.", Logging.White);
                return;
            }
            _readyToStart = true;

            if (_showHelp)
            {
                System.IO.StringWriter sw = new System.IO.StringWriter();
                p.WriteOptionDescriptions(sw);
                Logging.Log("Startup", sw.ToString(), Logging.White);
                return;
            }

            if (_loginNowIgnoreScheduler && !_chantlingScheduler)
            {
                _chantlingScheduler = true;
            }

            if (_chantlingScheduler && string.IsNullOrEmpty(_character))
            {
                Logging.Log("Startup", "Error: to use chantling's scheduler, you also need to provide a character name!", Logging.Red);
                return;
            }

            //
            // login using info from schedules.xml
            //
            if (_chantlingScheduler && !string.IsNullOrEmpty(_character))
            {
                LoginUsingScheduler();
            }

            //
            // direct login, no schedules.xml
            //
            if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password) && !string.IsNullOrEmpty(_character))
            {
                _readyToStart = true;
            }

            try
            {
                _directEve = new DirectEve();
            }
            catch (Exception ex)
            {
                Logging.Log("Startup", "Error on Loading DirectEve, maybe server is down", Logging.Orange);
                Logging.Log("Startup", string.Format("DirectEVE: 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 Loading DirectEve, maybe server is down";
                Cache.Instance.SessionState = "Quitting";
                Cleanup.CloseQuestor();
            }

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

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

            try
            {
                _directEve.OnFrame += OnFrame;
            }
            catch (Exception ex)
            {
                Logging.Log("Startup", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White);
            }

            // Sleep until we're done
            while (!_done)
            {
                System.Threading.Thread.Sleep(50); //this runs while we wait to login
            }

            try
            {
                _directEve.Dispose();
            }
            catch (Exception ex)
            {
                Logging.Log("Startup", string.Format("DirectEVE.Dispose: Exception {0}...", ex), Logging.White);
            }

            if (_done) //this is just here for clarity, we are really held up in LoginUsingScheduler() or LoginUsingUserNamePassword(); until done == true
            {
                if (!string.IsNullOrEmpty(_scriptAfterLoginFile))
                {
                    Logging.Log("Startup", "Running Script After Login: [ timedcommand 150 runscript " + _scriptAfterLoginFile + "]", Logging.Teal);
                    LavishScript.ExecuteCommand("timedcommand 150 runscript " + _scriptAfterLoginFile);
                }

                // If the last parameter is false, then we only auto-login
                if (_loginOnly)
                {
                    Logging.Log("Startup", "_loginOnly: done and exiting", Logging.Teal);
                    return;
                }
            }

            StartTime = DateTime.Now;

            //
            // We should only get this far if run if we are already logged in...
            // launch questor
            //
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logging.Log("Startup", "We are logged in: Launching Questor", Logging.Teal);
            Application.Run(new QuestorfrmMain());
        }
예제 #11
0
파일: Program.cs 프로젝트: rixim/Questor
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Log("Syntax:");
                Log("DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]");
                Log("(Quantity is optional)");
                Log("");
                Log("Example:");
                Log("DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10");
                Log("*OR*");
                Log("DotNet BuyLPI BuyLPI 27339 10");
                return;
            }

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

            if (args.Length >= 2)
            {
                int dummy;
                if (!int.TryParse(args[1], out dummy))
                {
                    Log("Quantity must be an integer, 0 - {0}", int.MaxValue);
                    return;
                }

                if (dummy < 0)
                {
                    Log("Quantity must be a positive number");
                    return;
                }

                _quantity = dummy;
            }

            Log("Starting BuyLPI...");
            _directEve = new DirectEve();
            _directEve.OnFrame += OnFrame;

            // Sleep until we're done
            while (!_done)
                Thread.Sleep(50);

            _directEve.Dispose();
            Log("BuyLPI finished.");
        }
예제 #12
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("BuyLPI", "Syntax:", Logging.White);
                Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI <TypeName or TypeId> [Quantity]", Logging.White);
                Logging.Log("BuyLPI", "(Quantity is optional)", Logging.White);
                Logging.Log("BuyLPI", "", Logging.White);
                Logging.Log("BuyLPI", "Example:", Logging.White);
                Logging.Log("BuyLPI", "DotNet BuyLPI BuyLPI \"Caldari Navy Mjolnir Torpedo\" 10", Logging.White);
                Logging.Log("BuyLPI", "*OR*", Logging.White);
                Logging.Log("BuyLPI", "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("BuyLPI", "Quantity must be an integer, 0 - " + int.MaxValue, Logging.White);
                    return;
                }

                if (dummy < 0)
                {
                    Logging.Log("BuyLPI", "Quantity must be a positive number", Logging.White);
                    return;
                }

                _quantity = dummy;
                _totalQuantityOfOrders = dummy;
            }

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

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

            _directEve.Dispose();
            Logging.Log("BuyLPI", "BuyLPI finished.", Logging.White);
            //InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTimeForLogs, "BuyLPI: Finished 2"));
        }