Exemple #1
0
        private void RunReport(string reportName, string path, Action findReport, Action reportParameters, int numRetries = 3)
        {
            if (!EnoughRetries(numRetries))
            {
                return;
            }

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

            findReport.Invoke();
            Input.PressKey(Input.KEY_TAB);
            Thread.Sleep(500);
            Input.PressKey(Input.KEY_ENTER);
            Thread.Sleep(5000);

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Loading " + reportName + ", will save to " + path);

            HwndObject parameters = null;
            HwndObject report     = null;

            if (!InitializeReport(out parameters, out report, reportName))
            {
                Console.ForegroundColor = Colors.Error;
                Console.WriteLine("Trying again...");
                RunReport(reportName, path, findReport, reportParameters, numRetries - 1);
                return;
            }
            Thread.Sleep(5000);

            reportParameters.Invoke();

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Requesting Report");

            Stopwatch watch = Stopwatch.StartNew();

            while (report.GetChildren()[0].GetChildren().Count == 0)
            {
                Console.WriteLine("Waiting... (" + watch.ElapsedMilliseconds + ")");
                Thread.Sleep(3000);
            }
            watch.Stop();

            Console.ForegroundColor = Colors.Success;
            Console.WriteLine("Report Generated");

            SaveReport(path);

            Console.ForegroundColor = Colors.Message;
            Console.WriteLine("Report Processed");

            report.CloseWindow();
        }
Exemple #2
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);
            }
        }