Beispiel #1
0
        public static IList <Delegate> BuildDelegateDictionary(IDictionary <Type, object> reports)
        {
            var projectBuildHierarchyReport   = (ProjectBuildHierarchyReport)GetReport(reports, typeof(ProjectBuildHierarchyReport));
            var warningSummaryReport          = (WarningSummaryReport)GetReport(reports, typeof(WarningSummaryReport));
            var warningByProjectSummaryReport = (WarningByProjectSummaryReport)GetReport(reports, typeof(WarningByProjectSummaryReport));
            var timespanItemsReport           = (TimestampItemsReport)GetReport(reports, typeof(TimestampItemsReport));

            var newDelegates = new List <Delegate>();

            var projectHandler = new ProjectHandler(ref projectBuildHierarchyReport);

            newDelegates.Add((Action <ProjectStarted>)projectHandler.Handle);
            newDelegates.Add((Action <ProjectEnded>)projectHandler.Handle);

            var warningHandler = new WarningHandler(ref warningSummaryReport, ref warningByProjectSummaryReport);

            newDelegates.Add((Action <ProjectStarted>)warningHandler.Handle);
            newDelegates.Add((Action <WarningAdded>)warningHandler.Handle);
            newDelegates.Add((Action <ProjectEnded>)warningHandler.Handle);

            var timespanHandler = new TimespanHandler(ref timespanItemsReport);

            newDelegates.Add((Action <TimestampAdded>)timespanHandler.Handle);

            return(newDelegates);
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var log    = new WarningHandler();
            var savior = new FileSavior();

            Singleton.Add(savior);
            Singleton.Add(log);
            if (e.Args.Length == 1)
            {
                if (e.Args[0] == KillLazuriteProcessCommand)
                {
                    Utils.KillAllLazuriteProcesses();
                    App.Current.Shutdown();
                }
                else if (e.Args[0] == RemoveFromAutorunCommand)
                {
                    TaskSchedulerUtils.RemoveLogonTask();
                    App.Current.Shutdown();
                }
                else
                {
                    new MainWindow(e.Args[0]).Show();
                }
            }
            else
            {
                Lazurite.Windows.Utils.Utils.ExecuteProcess(Lazurite.Windows.Utils.Utils.GetAssemblyPath(typeof(App).Assembly), WindowsIdentity.GetCurrent().Name, true, false);
                App.Current.Shutdown();
            }
        }
Beispiel #3
0
 public LazuriteCore()
 {
     Singleton.Add(Savior                 = new FileSavior());
     Singleton.Add(WarningHandler         = new WarningHandler());
     Singleton.Add(SystemUtils            = new SystemUtils());
     Singleton.Add(AddictionalDataManager = new AddictionalDataManager());
 }
 public LazuriteCore()
 {
     Singleton.Add(WarningHandler = new WarningHandler());
     Singleton.Add(new DataEncryptor());
     Singleton.Add(DataManager = new FileDataManager());
     Singleton.Add(new StoredPropertiesManager());
     Singleton.Add(SystemUtils            = new SystemUtils());
     Singleton.Add(AddictionalDataManager = new AddictionalDataManager());
 }
Beispiel #5
0
 private void HandleUnhandledException(Exception exception)
 {
     WarningHandler.ExtremeLog("Launcher unhandled exception!", exception);
     if (exception != null)
     {
         Log.FatalFormat(exception, "Необработанная ошибка");
     }
     else
     {
         Log.FatalFormat(new Exception("unknown exception"), "Необработанная неизвестная ошибка");
     }
     System.Windows.Application.Current.Shutdown(1);
 }
Beispiel #6
0
        private void HandleUnhandledException(Exception exception)
        {
            WarningHandler.ExtremeLog("Unhandled exception!", exception);

            if (exception != null)
            {
                Core.WarningHandler.FatalFormat(exception, "Необработанная ошибка");
            }
            else
            {
                Core.WarningHandler.FatalFormat(new Exception("unknown exception"), "Необработанная неизвестная ошибка");
            }

            Shutdown(1);
        }
Beispiel #7
0
        public static async Task <Course> GetCourse(string courseName, string termID)
        {
            Course ret;
            URL    url = new URL(courseName, termID);

            var    httpClient = new HttpClient();
            string html       = await httpClient.GetStringAsync(url);

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            string fullName;

            List <HtmlNode> divs = null;

            divs = htmlDocument
                   .DocumentNode
                   .Descendants("div")
                   .Where(node => node.GetAttributeValue("id", "") == courseName)
                   .First()
                   .Descendants("div")
                   .Where(node => node.GetAttributeValue("class", "").Contains("section delivery"))
                   .ToList();

            fullName = htmlDocument
                       .DocumentNode
                       .Descendants("span")
                       .Where(node => node.GetAttributeValue("class", "") == "course-title")
                       .First()
                       .InnerText;
            List <Section> sections = new List <Section>();

            // Enumerate through each section
            foreach (var div in divs)
            {
                string name = div
                              .Descendants("input").First()
                              .ChildAttributes("value").First()
                              .Value;

                var rows = div
                           .Descendants("div")
                           .Single(node => node.GetAttributeValue("class", "") == "class-days-container")
                           .Elements("div").ToList();

                var span = div.Descendants("span");

                var instructors = span
                                  .Where(node => node.GetAttributeValue("class", "") == "section-instructor")
                                  .Select(node => node.InnerText)
                                  .ToList();

                int openSeats = int.Parse(span
                                          .Single(node => node.GetAttributeValue("class", "") == "open-seats-count")
                                          .InnerText);
                int waitlist = int.Parse(span
                                         .Where(node => node.GetAttributeValue("class", "") == "waitlist-count")
                                         .First()
                                         .InnerText);

                string instructor = instructors[0];
                for (int i = 1; i < instructors.Count(); i++)
                {
                    instructor += ", ";
                    instructor += instructors[i];
                }

                List <ClassSequence> classes = new List <ClassSequence>();
                // Enumerate through each class of the section
                foreach (var row in rows)
                {
                    HtmlNode dayTimeGroup = row.Descendants("div").FirstOrDefault(n => n.Attributes["class"].Value.Contains("section-day-time-group"));
                    if (dayTimeGroup == null)
                    {
                        WarningHandler?.Invoke("Warning", "Some class times are inaccessible, please contact department or instructor for details");
                        break;
                    }

                    var enumerator = dayTimeGroup.Descendants("span").GetEnumerator();
                    if (!enumerator.MoveNext())
                    {
                        break;
                    }

                    if (enumerator.Current.GetAttributeValue("class", "") == "elms-class-message")
                    {
                        WarningHandler?.Invoke("Warning", "Part of the class times are only accessible through ELMS, which are skipped by the scheduler");
                        break;
                    }

                    var    positions = row.Descendants("span");
                    string building  = positions
                                       .Where(node => node.GetAttributeValue("class", "") == "building-code")
                                       .FirstOrDefault()?.InnerText ?? string.Empty;
                    string room = positions
                                  .Where(node => node.GetAttributeValue("class", "") == "class-room")
                                  .FirstOrDefault()?.InnerText ?? string.Empty;
                    Location location = new Location(building, room);

                    List <DayOfWeek> days = enumerator.Current.InnerText.ToDayOfWeek();

                    enumerator.MoveNext();
                    Time start = enumerator.Current.InnerText;

                    enumerator.MoveNext();
                    Time end = enumerator.Current.InnerText;

                    List <Weekday> weekdays = new List <Weekday>();
                    foreach (var day in days)
                    {
                        weekdays.Add(new Weekday(day, new ClassSpan(start, end)));
                    }

                    classes.Add(new ClassSequence(instructor, location, weekdays.ToArray()));
                }

                sections.Add(new Section(courseName, name, openSeats, waitlist, classes.ToArray()));
            }

            ret = new Course(courseName, fullName, sections.ToArray());
            return(ret);
        }
Beispiel #8
0
 internal TransactionWrapper()
 {
     handler = new WarningHandler(this);
     Handle  = new TransactionHandle(this);
 }
Beispiel #9
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("usage logging.exe mw-id=<middleware ID>");
            return(-1);
        }

        //o Load the command-line input into a GMSEC Config object
        // A Config object is basically a key-value pair map which is used to
        // pass configuration options into objects such as Connections,
        // ConnectionManagers, Subscribe and Publish function calls, Messages,
        // etc.
        Config config = new Config(args);

        ErrorHandler   errorHandler   = new ErrorHandler();
        WarningHandler warningHandler = new WarningHandler();
        InfoHandler    infoHandler    = new InfoHandler();
        VerboseHandler verboseHandler = new VerboseHandler();
        DebugHandler   debugHandler   = new DebugHandler();
        AnyHandler     anyHandler     = new AnyHandler();

        Log.RegisterHandler(LoggingLevel.ERROR, errorHandler);
        Log.RegisterHandler(LoggingLevel.WARNING, warningHandler);
        Log.RegisterHandler(LoggingLevel.INFO, infoHandler);
        Log.RegisterHandler(LoggingLevel.VERBOSE, verboseHandler);
        Log.RegisterHandler(LoggingLevel.DEBUG, debugHandler);

        //o Set logging reporting level
        Log.SetReportingLevel(LoggingLevel.VERBOSE);
        Log.Verbose("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Print the GMSEC API version number using the GMSEC Logging
        // interface
        // This is useful for determining which version of the API is
        // configured within the environment
        // TODO: Once available, replace this statement with usage of
        // ConnectionManager::getAPIVersion (See RTC 4798)
        Log.Info(Connection.GetAPIVersion());

        try
        {
            //o Create the ConnectionManager
            ConnectionManager connMgr = new ConnectionManager(config);

            //o Connect
            Log.Info("Opening the connection to the middleware server");
            connMgr.Initialize();

            //o Output middleware client/wrapper version
            Log.Info(connMgr.GetLibraryVersion());

            //o Publish a message
            PublishTestMessage(connMgr, "GMSEC.TEST.PUBLISH");

            //o Disconnect from the middleware and clean up the Connection
            connMgr.Cleanup();
        }
        catch (Exception e)
        {
            Log.Error(e.ToString());
            return(-1);
        }

        //o Unregister log handlers
        Log.RegisterHandler(null);

        //o Set log stream to stderr
        config.AddValue("LOGFILE", "STDERR");

        Log.Info("This message should go to stderr, not stdout.  " +
                 "For example, in bash test by running as:\n" +
                 "./logging mw-id=bolt 2> testfile.txt\n" +
                 "... and then check the contents of testfile.txt");

        //o Reset log stream to stdout
        config.AddValue("LOGFILE", "STDOUT");

        Log.Error("This is an example error message.");
        Log.Warning("This is an example warning message.");
        Log.Verbose("This is an example \"verbose\" message.");
        Log.Debug("This is an example debug message which should not show.");

        // This last message cannot be shown right now because
        // Log::setReportingLevel(logVERBOSE), used above, does not
        // allow DEBUG messages to come out.
        Log.Verbose("This is another example \"verbose\" message.");

        Log.SetReportingLevel(LoggingLevel.DEBUG);
        if (Log.GetReportingLevel() == LoggingLevel.DEBUG)
        {
            Log.Info("Changed reporting level to logDEBUG");
        }
        else
        {
            Log.Error("Failed to change reporting level to logDEBUG");
        }

        // The DEBUG message below will be shown successfully, unlike the last
        // debug message.
        Log.Debug("This is an example debug message which should show.");

        Log.Debug("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Debug("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Debug("SECURE reporting level, numerically, is " + Log.LevelFromString("SECURE"));
        Log.Debug("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Debug("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Debug("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Register general-purpose handler and test
        Log.RegisterHandler(anyHandler);

        Log.Error("NONE reporting level, numerically, is " + Log.LevelFromString("NONE"));
        Log.Error("ERROR reporting level, numerically, is " + Log.LevelFromString("ERROR"));
        Log.Warning("WARNING reporting level, numerically, is " + Log.LevelFromString("WARNING"));
        Log.Info("INFO reporting level, numerically, is " + Log.LevelFromString("INFO"));
        Log.Verbose("VERBOSE reporting level, numerically, is " + Log.LevelFromString("VERBOSE"));
        Log.Debug("DEBUG reporting level, numerically, is " + Log.LevelFromString("DEBUG"));

        //o Unregister log handlers
        Log.RegisterHandler(null);

        return(0);
    }
Beispiel #10
0
 internal TransactionWrapper()
 {
     handler = new WarningHandler(this);
     Handle = new TransactionHandle(this);
 }
Beispiel #11
0
 public static void Warning(string message) => WarningHandler?.Invoke(message);
Beispiel #12
0
 /// <summary>
 /// By default if an error returned by the TPM is not the same as the
 /// that expected (set by _ExpectError) then this is translated into 
 /// an exception by this library.  
 /// If a non-null warning handler is installed then this handler is 
 /// invoked INSTEAD and processing is as if the error was the one
 /// expected.
 /// </summary>
 /// <param name="theWarningHandler"></param>
 public void _SetWarningHandler(WarningHandler theWarningHandler)
 {
     TheWarningHandler = theWarningHandler;
 }
Beispiel #13
0
 void Awake()
 {
     instance    = this;
     warningSign = Instantiate((GameObject)Resources.Load("Prefab/Predator/Predator Warning", typeof(GameObject)));
 }
Beispiel #14
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("Error: Missing arg.\n");
            Console.WriteLine("Usage: ./logging mw-id=<middleware>");
            return(-1);
        }

        Config config = new Config(args);

        //o Create and register custom log handlers
        ErrorHandler   eh = new ErrorHandler();
        WarningHandler wh = new WarningHandler();
        InfoHandler    ih = new InfoHandler();
        VerboseHandler vh = new VerboseHandler();
        DebugHandler   dh = new DebugHandler();
        GeneralHandler gh = new GeneralHandler();

        //  Note: Registration of VERBOSE and DEBUG custom log handlers will
        //        be ignored at the Core API level.
        //
        Log.Info("**** Registering all custom log handlers ****");
        Log.RegisterHandler(LogLevel.logERROR, eh);
        Log.RegisterHandler(LogLevel.logWARNING, wh);
        Log.RegisterHandler(LogLevel.logINFO, ih);
        Log.RegisterHandler(LogLevel.logVERBOSE, vh);
        Log.RegisterHandler(LogLevel.logDEBUG, dh);

        //o Set log reporting level
        Log.SetReportingLevel(LogLevel.logINFO);
        Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());

        //o Display the GMSEC API version
        Log.Info("API version: " + ConnectionManager.GetAPIVersion());

        try
        {
            //o Create a ConnectionManager
            using (ConnectionManager connMgr = new ConnectionManager(config))
            {
                //o Connect to the GMSEC Bus
                connMgr.Initialize();

                //o Disconnect from the GMSEC Bus
                connMgr.Cleanup();
            }
        }
        catch (GmsecException e)
        {
            Log.Error("Exception: " + e.ToString());
            return(-1);
        }

        //o Unregister all custom log handlers
        Log.Info("**** Un-registering all custom log handlers ****");
        Log.RegisterHandler(null);

        //o Examples of logging messages
        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");
        Log.Debug("This is a DEBUG message");              // This message will not be displayed

        //o Reset log reporting level so that all log message are displayed
        Log.SetReportingLevel(LogLevel.logDEBUG);

        //o Confirm logging level
        if (Log.GetReportingLevel() == LogLevel.logDEBUG)
        {
            Log.Info("The log reporting level is now set to: " + Log.GetReportingLevel());
        }
        else
        {
            Log.Error("The log reporting level was NOT changed to logDEBUG");
        }
        Log.Debug("A DEBUG message can now be displayed");

        //o Convert log level names to LogLevel enumerated values
        Log.Error("ERROR reporting level as enum value: " + Log.FromString("ERROR"));
        Log.Warning("WARNING reporting level as enum value: " + Log.FromString("WARNING"));
        Log.Info("INFO reporting level as enum value: " + Log.FromString("INFO"));
        Log.Verbose("VERBOSE reporting level as enum value: " + Log.FromString("VERBOSE"));
        Log.Debug("DEBUG reporting level as enum value: " + Log.FromString("DEBUG"));

        //o Reset log reporting level so that only INFO and below are displayed
        Log.SetReportingLevel(LogLevel.logINFO);

        //o Replace all custom log handlers with a general purpose custom log handler
        Log.Info("**** Registering all general purpose custom log handler ****");
        Log.RegisterHandler(gh);

        Log.Error("ERROR reporting level as string: " + Log.ToString(LogLevel.logERROR));
        Log.Warning("WARNING reporting level as string: " + Log.ToString(LogLevel.logWARNING));
        Log.Info("INFO reporting level as string: " + Log.ToString(LogLevel.logINFO));
        Log.Verbose("VERBOSE reporting level as string: " + Log.ToString(LogLevel.logVERBOSE));           // Not displayed
        Log.Debug("DEBUG reporting level as string: " + Log.ToString(LogLevel.logDEBUG));                 // Not displayed

        //o Unregister (all) custom log handler(s)
        Log.Info("**** Un-registering custom log handler ****");
        Log.RegisterHandler(null);

        Log.Error("This is an ERROR message");
        Log.Warning("This is a WARNING message");
        Log.Info("This is an INFO message");
        Log.Verbose("This is a VERBOSE message");          // Not displayed
        Log.Debug("This is a DEBUG message");              // Not displayed

        return(0);
    }