예제 #1
0
        public static async Task StartWithErrorDialogAsync(this ISyncThingManager syncThingManager, IWindowManager windowManager)
        {
            try
            {
                await syncThingManager.StartAsync();
            }
            catch (Win32Exception e)
            {
                if (e.ErrorCode != -2147467259)
                {
                    throw;
                }

                // Possibly "This program is blocked by group policy. For more information, contact your system administrator" caused
                // by e.g. CryptoLocker?
                windowManager.ShowMessageBox(
                    Localizer.Translate("Dialog_SyncthingBlockedByGroupPolicy_Message", e.Message, syncThingManager.ExecutablePath),
                    Localizer.Translate("Dialog_SyncthingBlockedByGroupPolicy_Title"),
                    MessageBoxButton.OK, icon: MessageBoxImage.Error);
            }
            catch (SyncThingDidNotStartCorrectlyException)
            {
                // Haven't translated yet - still debugging
                windowManager.ShowMessageBox(
                    "Syncthing started running, but we were enable to connect to it. Please report this as a bug",
                    "Syncthing didn't start correctly",
                    MessageBoxButton.OK, icon: MessageBoxImage.Error);
            }
        }
        public static async Task StartWithErrorDialogAsync(this ISyncThingManager syncThingManager, IWindowManager windowManager)
        {
            try
            {
                await syncThingManager.StartAsync();
            }
            catch (Win32Exception e)
            {
                if (e.ErrorCode != -2147467259)
                {
                    throw;
                }

                // Possibly "This program is blocked by group policy. For more information, contact your system administrator" caused
                // by e.g. CryptoLocker?
                windowManager.ShowMessageBox(
                    Localizer.F(Resources.Dialog_SyncthingBlockedByGroupPolicy_Message, e.Message, syncThingManager.ExecutablePath),
                    Resources.Dialog_SyncthingBlockedByGroupPolicy_Title,
                    MessageBoxButton.OK, icon: MessageBoxImage.Error);
            }
            catch (SyncThingDidNotStartCorrectlyException e)
            {
                windowManager.ShowMessageBox(
                    Localizer.F(Resources.Dialog_SyncthingDidNotStart_Message, e.Message),
                    Resources.Dialog_SyncthingDidNotStart_Title,
                    MessageBoxButton.OK, icon: MessageBoxImage.Error);
            }
        }