Beispiel #1
0
        public static void Init()
        {
            Toggl.InitialiseLog();

            var configuration = new Configuration("aa13053a88d5133b688db0f25ec103b7");

            configuration.AppVersion = Program.Version();

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

            bugsnag = new Client(configuration);
            bugsnag.BeforeNotify(report =>
            {
                report.Event.User = new User
                {
                    Id = Program.UserId.ToString()
                };
                report.Event.Metadata.Add("Details", new Dictionary <string, string>
                {
                    {
                        "Channel", Toggl.UpdateService.UpdateChannel.Value
                    },
                    {
                        "Bitness", Utils.Bitness()
                    },
Beispiel #2
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();

                bugsnag = new Bugsnag.Clients.BaseClient("2a46aa1157256f759053289f2d687c2f");

#if INVS
                bugsnag.Config.ReleaseStage = "development";
#else
                bugsnag.Config.ReleaseStage = "production";
#endif

                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.Config.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.Default;

                new App().Run();
            }
        }
Beispiel #3
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();
            }
        }