Jump to content

AutoIt and IIS


Milka
 Share

Recommended Posts

Hello everyone,

I am not really a technical person so pardon my vague terminology :)

I am currently creating a monitoring solution for an ERP in C#. The goal is to check when an application is not accessible anymore because some process (unknown) is stopped.
The only way to check is to try to open the application window. If there is an error, the window will not open and an error alert will pop up.

Since various persons across the world will need this information and don't have access to the server where the ERP is hosted (or to the ERP itself), I created a REST webservice that, when called, will try to launch the ERP, check if it reaches the Home page, and closes it.

When I launch my web application code, it works as a charm. But once the webservice is published on the IIS server it does not work anymore. What happens is that the window does not open and the ERP is, apparently, opened in the background (no graphical interface). The IIS server is set to use my user.

Can someone explain me what I did wrong?

Maybe my solution is just not realistic and if so would you have some advice on how to approach this problem? 

Here my code :

private static bool IsDown(this NST nstObject)
        {
            bool L_Break_Loop = false;

            Console.WriteLine("Country being processed : " + nstObject.Trigram);

            int L_Launcher_Handle = AutoItX.RunAs("MYUSERID", "COMPANYDOMAIN", "PASSWORD", AutoItX.SW_SHOW, OutputFileLocation + "//" + nstObject.Trigram + ".cmd", "");

            System.IO.File.WriteAllText(OutputFileLocation + "//ProcessNav.txt", "Worked : " + L_Launcher_Handle.ToString());

            AutoItX.WinGetHandle("Microsoft Dynamics NAV"); // Getting Navision splash screen

            while (AutoItX.WinExists("Microsoft Dynamics NAV") == 0)
            {
                AutoItX.WinGetHandle("Microsoft Dynamics NAV");
            }

            DateTime L_DateTime_Window_Appeared = DateTime.Now;

            while (!L_Break_Loop)
            {
                AutoItX.WinGetHandle("Microsoft Dynamics NAV"); // Getting Navision splash screen

                if (DateTime.Now > L_DateTime_Window_Appeared.AddSeconds(60) && AutoItX.WinExists("Role Center") != 1) // If timeout reached + role center doesn't exist
                {
                    L_Break_Loop = true;
                    break;
                }
                else if (AutoItX.WinExists("Role Center") == 1) // If role center appeared
                {
                    L_Break_Loop = true;
                    break;
                }
            }

            if (AutoItX.WinExists("Role Center") == 1) // Role Center found
            {
                Close_Window("Role Center");

                Console.WriteLine("NST status : UP");
                return false;
            }
            else if (AutoItX.WinExists("Role Center") != 1) // Role Center not found
            {
                Close_Window("Microsoft Dynamics NAV"); // In case of NST restarting while script running => NAV opens last moment but script doesn't catch it.

                Close_Window("Role Center");

                Close_Window("Select Server"); //Closing the select servers page

                Console.WriteLine("NST status : DOWN");
                return true;
            }

            return false;
        }

 

Capture.PNG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...