예제 #1
0
        public HwndObject GetInfoManager() // TODO: make this a retryable action
        {
            foreach (HwndObject o in getMainContainer().GetChildren())
            {
                Console.ForegroundColor = Colors.Message;
                if (o.Title.StartsWith("Info Manager"))
                {
                    Stuff.WriteConsoleMessage("Info Manager already opened");
                    return(o);
                }
            }

            Stuff.WriteConsoleMessage("Info Manager not opened...");
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_A);
            Thread.Sleep(1000);
            Input.PressKey(Input.KEY_I);
            Thread.Sleep(1000);
            HwndObject infoManager = GetInfoManager();

            if (infoManager == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager");
            }
            return(infoManager);
        }
예제 #2
0
        public void RunChairReport(string path, string startDate, string endDate, List <Tuple <string, string> > studentRanges, int numRetries = DEFAULT_RETRIES)
        {
            if (!EnoughRetries(numRetries))
            {
                return;
            }

            CloseInfoManager();
            if (GetInfoManager() == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager...Giving Up");
                return;
            }

            Input.MoveTo(new Point(800, 95)); // Custom Lists
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Input.MoveTo(new Point(300, 220)); // Category
            Thread.Sleep(500);
            Input.RegisterClick();

            Input.MoveTo(new Point(485, 350));
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Stuff.WriteConsoleMessage("Setting student ranges");
            SetStudentRangeParameters(new Point(485, 350), studentRanges);
            Thread.Sleep(500);

            Stuff.WriteConsoleMessage("Setting date range of " + startDate + " to " + endDate);
            SetDateFieldParameters(new Point(710, 350), startDate, endDate);
            Thread.Sleep(500);

            if (!new RetryableAction(() => ExecuteQuery(), "Executing Query").Execute())
            {
                Stuff.WriteConsoleError("Unable to execute query to gather appointments");
                return;
            }
            Thread.Sleep(5000);

            GetInfoManager().Activate();
            if (!new RetryableAction(() => ExportQuery(), "Exporting Query Results").Execute())
            {
                Stuff.WriteConsoleError("Unable to export query results");
                return;
            }
            Thread.Sleep(5000);

            if (!new RetryableAction(() => SaveExcel(path), "Saving Generated Excel File").Execute())
            {
                Stuff.WriteConsoleError("Unable to save excel file");
                return;
            }
            Thread.Sleep(5000);
        }
예제 #3
0
        private void ExecuteQuery()
        {
            HwndObject startWindow = HwndObject.GetForegroundWindow();

            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S);
            Stopwatch watch = Stopwatch.StartNew();

            Thread.Sleep(500);

            HwndObject fetching = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                List <HwndObject> list = o.GetChildren();
                if (list.Count != 3)
                {
                    continue;
                }

                if (list[1].Title.Equals("Please wait...") || list[1].Title.Equals("Fetching Data..."))
                {
                    Stuff.WriteConsoleMessage("Parent: " + Stuff.GetHwndInfoString(o.GetParent()));
                    fetching = list[0];
                    break;
                }
            }

            while (HwndObject.GetForegroundWindow() != startWindow)
            {
                Console.Write("Waiting... (" + watch.ElapsedMilliseconds + ")");
                if (fetching != null)
                {
                    Console.WriteLine(fetching.Text);
                }
                else
                {
                    Console.WriteLine();
                }
                Thread.Sleep(5000);
            }
            watch.Stop();

            Stuff.WriteConsoleSuccess("Report Generated");
        }
예제 #4
0
        public bool Execute(int numRetries = DEFAULT_RETRIES)
        {
            if (numRetries == 0)
            {
                return(false);
            }

            try
            {
                Stuff.WriteConsoleMessage("Running " + actionName);
                action.Invoke();
                return(true);
            }
            catch (Exception ex)
            {
                Stuff.WriteConsoleError(ex.ToString());
                Stuff.WriteConsoleError("Unable to complete " + actionName + "; trying again...");
                return(Execute(numRetries - 1));
            }
        }
예제 #5
0
        public void SaveExcel(string path)
        {
            HwndObject window = HwndObject.GetForegroundWindow();

            if (!window.Title.Contains("Excel") && !window.Title.StartsWith("Book"))
            {
                foreach (HwndObject o in HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")))
                {
                    if (o.Title.StartsWith("Book"))
                    {
                        if (window == null)
                        {
                            window = o;
                        }
                        else if (Int32.TryParse(o.Title.Substring(4), out int number))
                        {
                            if (number > Int32.Parse(window.Title.Substring(4)))
                            {
                                window = o;
                            }
                        }
                    }
                }
            }

            if (window == null)
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Unable to export report from Axium");
                return;
            }
            else
            {
                Console.ForegroundColor = Colors.Success;
                Console.WriteLine("Excel file opened: " + window.Title);
            }

            window.Activate();
            Thread.Sleep(2000);
            window.Maximize();
            Thread.Sleep(2000);
            Input.PressKeyCombo(Input.KEY_CONTROL, Input.KEY_S);
            Thread.Sleep(2000);

            Input.MoveTo(new Point(800, 635));
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Input.MoveTo(new Point(570, 195));
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            HwndObject saveDialog = HwndObject.GetWindows().Find(e => e.Title.Contains("Save As"));

            Stuff.WriteConsoleMessage("Save dialog found!");
            saveDialog.Activate();
            Thread.Sleep(500);
            Input.KeyboardWrite(path, 100);
            Thread.Sleep(100);
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S);
            Thread.Sleep(2000);

            if (!File.Exists(path + ".xlsx"))
            {
                Stuff.WriteConsoleError("File was not saved...trying again");
            }
            else
            {
                window.CloseWindow();
                Stuff.WriteConsoleSuccess("File was saved to " + path);
            }
        }
예제 #6
0
        private void ExportQuery()
        {
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_A);
            Thread.Sleep(5000);

            HwndObject startWindow = HwndObject.GetForegroundWindow();

            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_E);
            Thread.Sleep(1000);

            Input.MoveTo(new Point(870, 405));
            Input.RegisterClick();
            Thread.Sleep(500);
            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_O);

            Stopwatch watch = Stopwatch.StartNew();

            Thread.Sleep(10000);

            HwndObject progress = null;

            foreach (HwndObject o in HwndObject.GetWindows())
            {
                List <HwndObject> list = o.GetChildren();
                if (list.Count <= 1)
                {
                    continue;
                }

                if (list[1].Title.Equals("Processing"))
                {
                    Stuff.WriteConsoleMessage(Stuff.GetHwndInfoString(list[0]));
                    progress = list[0];
                    break;
                }
            }

            int excelWindowCount = HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")).Count;

            while (true)
            {
                HwndObject window = HwndObject.GetForegroundWindow();
                if (window.Title.Contains("Excel") && window.Title.StartsWith("Book"))
                {
                    Stuff.WriteConsoleMessage("Found opened window");
                    break;
                }
                else if (HwndObject.GetWindows().FindAll(e => e.Title.Contains("Excel")).Count == (excelWindowCount + 1))
                {
                    Stuff.WriteConsoleMessage("Detected change in excel window counts");
                    break;
                }

                Console.Write("Waiting... (" + watch.ElapsedMilliseconds + ")");
                if (progress != null)
                {
                    Console.WriteLine(" " + progress.Text);
                }
                else
                {
                    Console.WriteLine();
                }
                Thread.Sleep(5000);
            }
            watch.Stop();

            Stuff.WriteConsoleSuccess("Data exported");
        }
예제 #7
0
        public void RunAppointmentReport(string path, string startDate, string endDate, List <Tuple <string, string> > studentRanges, int numRetries = DEFAULT_RETRIES)
        {
            if (!EnoughRetries(numRetries))
            {
                return;
            }

            CloseInfoManager();
            if (GetInfoManager() == null)
            {
                Stuff.WriteConsoleError("Unable to open info manager...Giving Up");
                return;
            }

            Input.MoveTo(new Point(480, 95)); // Appointment Tab
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(500);

            Input.MoveTo(new Point(1060, 170)); // Pre-Defined Button
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(1000);

            Input.MoveTo(new Point(845, 500)); // Michael's Appointment List
            Thread.Sleep(500);
            Input.RegisterClick();
            Thread.Sleep(1000);

            Input.PressKeyCombo(Input.KEY_ALT, Input.KEY_S); // Select the report

            Stuff.WriteConsoleMessage("Setting date range of " + startDate + " to " + endDate);
            SetDateFieldParameters(new Point(335, 350), startDate, endDate);
            Thread.Sleep(500);

            Stuff.WriteConsoleMessage("Setting student ranges");
            studentRanges.Add(Tuple.Create("D106", "D106")); //NPE
            studentRanges.Add(Tuple.Create("D099", "D099")); //ER
            SetStudentRangeParameters(new Point(560, 350), studentRanges);
            Thread.Sleep(500);

            if (!new RetryableAction(() => ExecuteQuery(), "Executing Query").Execute())
            {
                Stuff.WriteConsoleError("Unable to execute query to gather appointments");
                return;
            }
            Thread.Sleep(5000);

            GetInfoManager().Activate();
            if (!new RetryableAction(() => ExportQuery(), "Exporting Query Results").Execute())
            {
                Stuff.WriteConsoleError("Unable to export query results");
                return;
            }
            Thread.Sleep(5000);

            if (!new RetryableAction(() => SaveExcel(path), "Saving Generated Excel File").Execute())
            {
                Stuff.WriteConsoleError("Unable to save excel file");
                return;
            }
            Thread.Sleep(5000);
        }