RobotStudio event

Export all Logs

Hello everbody, I got a small Problem. I tried to export all log in Categorys from one real Robot.

I treid to do this in C#, but it will not works. I would be need only the messages, Date, and stuff from the Log.

Later i will put this Stuff in a Database.

Any one do something like this?




Comments

  • You need to create an instance of EvetLog class and sign with the controller and EventLog properties of that controller.

    After you need to create a new variable var and assign that newly created instants with GetCategories properties to that variable.

    And use foreach to go through that variable and so on.

    Example:

    class ControllerLocater

        {

            private string outputLine = null;

            public string OutputLine { get { return outputLine; } set { outputLine = value; } } 

            private string errorBody = null;

            public string ErrorBody  { get { return errorBody; } set { errorBody = value; } }

            private string bodyText = null;

            public string BodyText  { get { return BodyText; } }

            public void controllerOutput()

            {

                NetworkScanner ntScann = new NetworkScanner();

                ntScann.Scan();

     

                ControllerInfoCollection controllers = ntScann.Controllers;

     

                Controller ctrl = ControllerFactory.CreateFrom(controllers[0]);

                EventLog log = ctrl.EventLog;

     

                var categories = log.GetCategories();

     

                foreach (var c in categories)

                {

                    for (int p = 0; p < c.Messages.Count; p++)

                    {

                        bodyText = c.Messages[p].Body;

                              

                        // some text editing. Not complited – just as an exampl

                        TextEditor();

     

                        Console.WriteLine($"/nType of Log - {c.Type.ToString()}");

                        Console.WriteLine($"/n{errorBody}");

     

                    }

                   

                    c.Dispose();

                }

     

            } // end of controllerOutput method

     

            public string TextEditor()

            {

                outputLine = Regex.Replace(bodyText, "<.*?>", System.String.Empty);

                //ar = Regex.Split(outputLine, pt);

                //Console.ReadKey();

                outputLine = Regex.Replace(outputLine, @\.(?! |$), ". ");

                outputLine = outputLine.Replace("1)", "\n\n\bActions \n1) ");

                outputLine = outputLine.Replace("2)", "\n2) ");

                outputLine = outputLine.Replace("3)", "\n3) ");

                errorBody = outputLine;

     

                return errorBody;

     

            } // end of TextEditor method

     

        } // end of ControllerLocater class