Ejemplo n.º 1
0
        public async Task InitializeAsync()
        {
            var server = new TestServer();

            server.Start();

            var client = new Bugsnag.Client(new Bugsnag.Configuration("123456")
            {
                Endpoint = server.Endpoint
            });

            try
            {
                throw new NotImplementedException();
            }
            catch (Exception e)
            {
                var context = new BugsnagHttpContext();
                client.Notify(e, report => {
                    report.Event.Request = context.ToRequest();
                });
            }

            var requests = await server.Requests(1);

            _request = requests.Single();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            bugsnagClient = new Bugsnag.Client(new Bugsnag.Configuration
            {
                ApiKey     = "fa43381b116de659fcf1cfda14884d98",
                AppVersion = Application.ProductVersion,
                AutoNotify = false
            });

            // install custom handler for fatal exceptions
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            // route UI thread exceptions to the fatal exception handler
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);

            RemoveOldVersionSettings();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var mainForm              = new MainForm();
            var tileCache             = new BitmapCache();
            var dialogService         = new DialogService(mainForm);
            var featureService        = new FeatureService();
            var sectionsService       = new SectionService();
            var sectionFactory        = new SectionFactory(tileCache);
            var sectionBitmapService  = new SectionBitmapService(sectionFactory);
            var mapModelFactory       = new MapModelFactory(tileCache);
            var mapLoadingService     = new MapLoadingService(sectionFactory, mapModelFactory);
            var imageImportingService = new ImageImportService(tileCache);
            var model = new CoreModel();

            // Unsure if I should get the SectionViews to register themselves, or pass the dispatcher the SectionViews as params
            mainForm.SectionView.SetModel(new SectionViewViewModel(sectionsService));
            mainForm.FeatureView.SetModel(new FeatureViewViewModel(featureService));

            var dispatcher = new Dispatcher(
                model,
                dialogService,
                sectionsService,
                sectionBitmapService,
                featureService,
                mapLoadingService,
                imageImportingService,
                tileCache,
                mainForm);

            mainForm.SetModel(new MainFormViewModel(model, dispatcher));

            mainForm.MapViewPanel.SetModel(new MapViewViewModel(model, dispatcher, featureService));

            var minimapForm = new MinimapForm();

            minimapForm.Owner = mainForm;
            minimapForm.SetModel(new MinimapFormViewModel(model, dispatcher));

            Application.Run(mainForm);
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var configuration = new Bugsnag.Configuration("aa13053a88d5133b688db0f25ec103b7");

            configuration.AppVersion   = Application.ProductVersion;
            configuration.ReleaseStage = "production";
            bugsnag = new Bugsnag.Client(configuration);

            Application.Run(new MainForm());
        }
Ejemplo n.º 4
0
        public static void SetupConsumer <T, V>(IEnumerable <Dictionary <string, string> > configs, Bugsnag.Client bugsnag) where V : Answerable
        {
            var consumer = Activator.CreateInstance <T>();

            var transport = Activator.CreateInstance <V>();

            foreach (var config in configs)
            {
                foreach (var type in Assembly.Load("SharedArea").GetTypes().Where(t =>
                                                                                  t.Namespace.StartsWith("SharedArea.Commands")).ToArray())
                {
                    Task.Run(() =>
                    {
                        using (var c = new ConsumerBuilder <Ignore, MessageWrapper <object> >(config).Build())
                        {
                            c.Subscribe(type.FullName);
                            while (true)
                            {
                                try
                                {
                                    var cr = c.Consume();

                                    switch (cr.Value.MessageType)
                                    {
                                    case MessageWrapper <object> .WrapperType.Question:
                                        {
                                            var methodInfo = consumer.GetType().GetMethod("AnswerQuestion");
                                            var answer     = methodInfo.Invoke(consumer, new [] { cr.Value.Message });
                                            transport.SendAnswerToQuestionaire(cr.Value.SrcClusterCode, cr.Value.SrcPeerCode, cr.Value.QuestionId, answer);
                                            break;
                                        }

                                    case MessageWrapper <object> .WrapperType.Answer:
                                        transport.NotifyAnswerReceived(cr.Value.QuestionId, cr.Value.Message);
                                        break;

                                    case MessageWrapper <object> .WrapperType.Notification:
                                        {
                                            var methodInfo = consumer.GetType().GetMethod("Consume");
                                            methodInfo.Invoke(consumer, new [] { cr.Value.Message });
                                            break;
                                        }
                                    }
                                }
                                catch (ConsumeException e)
                                {
                                    Logger.Log("Error", $"Error occured: {e.Error.Reason}");
                                    bugsnag?.Notify(e);
                                }
                                catch (Exception e)
                                {
                                    Logger.Log("Error", $"Error occured: {e.Message}");
                                    bugsnag?.Notify(e);
                                }
                            }
                        }
                    });
                }
            }
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Win32.AttachConsole(Win32.ATTACH_PARENT_PROCESS);

            using (Mutex mutex = new Mutex(false, "Global\\" + Environment.UserName + "_" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    // See if we get hold of the other process.
                    // If we do, activate it's window and exit.
                    Process   current   = Process.GetCurrentProcess();
                    Process[] instances = Process.GetProcessesByName(current.ProcessName);
                    foreach (Process p in instances)
                    {
                        if (p.Id != current.Id)
                        {
                            // gotcha
                            IntPtr hWnd = p.MainWindowHandle;
                            if (hWnd == IntPtr.Zero)
                            {
                                hWnd = Win32.SearchForWindow(current.ProcessName, "Toggl Desktop");
                            }

                            Win32.ShowWindow(hWnd, Win32.SW_RESTORE);
                            Win32.SetForegroundWindow(hWnd);

                            return;
                        }
                    }

                    // If not, print an error message and exit.
                    System.Windows.MessageBox.Show("Another copy of Toggl Desktop is already running." +
                                                   Environment.NewLine + "This copy will now quit.");
                    return;
                }

                Toggl.InitialiseLog();

                var configuration = new Bugsnag.Configuration("aa13053a88d5133b688db0f25ec103b7");
                configuration.AppVersion = Version();

#if TOGGL_PRODUCTION_BUILD
                configuration.ReleaseStage = "production";
#else
                configuration.ReleaseStage = "development";
#endif

                bugsnag = new Bugsnag.Client(configuration);
                bugsnag.BeforeNotify(report =>
                {
                    report.Event.User = new Bugsnag.Payload.User {
                        Id = uid.ToString()
                    };
                    report.Event.Metadata.Add("Details", new Dictionary <string, string>
                    {
                        { "Channel", Toggl.UpdateChannel() }
                    });
                });

                Toggl.OnLogin += delegate(bool open, UInt64 user_id)
                {
                    uid = user_id;
                };

                Toggl.OnError += delegate(string errmsg, bool user_error)
                {
                    Toggl.Debug(errmsg);
                    try
                    {
                        if (!user_error && bugsnag.Configuration.ReleaseStage != "development")
                        {
                            notifyBugsnag(new Exception(errmsg));
                        }
                    }
                    catch (Exception ex)
                    {
                        Toggl.Debug("Could not check if can notify bugsnag: " + ex);
                    }
                };

                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

                new App().Run();
            }
        }