Example #1
0
 public FormBugReportPresenter(BugSubmitter bugSubmitter, IFormBugReport formBugReport)
 {
     _BugSubmitter                   = bugSubmitter;
     _FormBugReport                  = formBugReport;
     _FormBugReport.SendClicked     += Form_SendClicked;
     _FormBugReport.DontSendClicked += Form_DontSendClicked;
 }
Example #2
0
            protected override bool OnInitialize(System.Collections.ObjectModel.ReadOnlyCollection <string> commandLineArgs)
            {
                try
                {
                    ChangeUICulture(Settings.Default.UICulture.Name);

                    // Register skins.
                    DevExpress.UserSkins.BonusSkins.Register();
                    DevExpress.UserSkins.OfficeSkins.Register();

                    // Set user skin.
                    UserLookAndFeel.Default.SetSkinStyle(Settings.Default.SkinName);

                    // Initialize automatic error handling.
                    Application.ThreadException += Application_ThreadException;
                    _BugReportPresenter          = new FormBugReportPresenter(new BugSubmitter(), new FormBugReport());
                }
                catch (Exception ex)
                {
                    // NOTE: Here we can't use FormBugReport because it may not be initialized.
                    MessageBox.Show(
                        "Unfortunally FileWall failed to initialize. Please send us screenshot of this window.\r\n" +
                        BugSubmitter.FormatErrorMessage(ex), "FileWall", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                try
                {
                    _FormMain = new FormMain();

                    _ServiceGateway          = new ServiceGateway(new AdvSC("FileWallService"), new ServiceInterfaceManager());
                    _ServiceGateway.Started += ServiceGateway_Started;

                    _Presenter = new FormMainPresenter(_FormMain,
                                                       _ServiceGateway,
                                                       new LogViewModel(new EventLog("APAccess")));

                    // Start service if it's needed.
                    if (!_Presenter.ServiceGateway.IsStarted)
                    {
                        _Presenter.ServiceGateway.Start();
                    }
                    else
                    {
                        // Subscribing to events.
                        var accessRequestedWrapper = new AccessRequestedWrapper(_ServiceGateway.ServiceInterface);
                        accessRequestedWrapper.AccessRequested += AccessRequested;
                    }
                }
                catch (Exception ex)
                {
                    _BugReportPresenter.Show(ex);
                    return(false);
                }

                return(true);
            }
Example #3
0
            private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
            {
                // Log exception details before showing "error dialog"
                try
                {
                    var submitter = new BugSubmitter();
                    var bugReport = submitter.CollectInfo(e.Exception);

                    EventLog.WriteEntry("APClient", bugReport.GetUserFriendlyText(), EventLogEntryType.Error);
                }
                catch {}

                // Show error dialog.
                _BugReportPresenter.Show(e.Exception);
            }
Example #4
0
        protected override void OnStop()
        {
            try
            {
                AsyncCore.Instance.Stop();

                // Save the ruleset back to file.
                _Ruleset.AcceptChanges();
                _Ruleset.WriteXml(_DefaultRulesetPath);
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("APService", "On stop. " + BugSubmitter.FormatErrorMessage(ex), EventLogEntryType.Error);
                throw;
            }

            EventLog.WriteEntry("APService", "Service successfully stopped.");
        }
Example #5
0
 public void Show(Exception ex)
 {
     try // Yes I know that it's not good practice
     // But still it the solution.
     {
         _BugReport = _BugSubmitter.CollectInfo(ex);
     }
     catch (Exception internalException)
     {
         MessageBox.Show("Error in exception-handling code. Please send us screenshot of this message\r\n" +
                         BugSubmitter.FormatErrorMessage(internalException),
                         "FileWall",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
     _FormBugReport.Details = _BugReport.GetUserFriendlyText();
     _FormBugReport.ShowDialog();
 }
Example #6
0
        private void Form_SendClicked(object sender, EventArgs e)
        {
            _BugReport.UserActions = _FormBugReport.WhatYouDid;
            _BugReport.Email       = _FormBugReport.Email;

            _FormBugReport.Hide();

            try // Yes I know that it's not good practice
                // But still it the solution.
            {
                _BugSubmitter.Submit(_BugReport);
            }
            catch (Exception internalException)
            {
                MessageBox.Show("Error in exception-handling code. Please send us screenshot of this message\r\n" +
                                BugSubmitter.FormatErrorMessage(internalException),
                                "FileWall",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            _BugReport = null;
        }
Example #7
0
        protected override void OnStart(string[] args)
        {
            try
            {
                if (File.Exists(_DefaultRulesetPath) == false)
                {
                    throw new FileNotFoundException("Ruleset file not found (" + _DefaultRulesetPath + ")");
                }

                _Ruleset = new Ruleset();
                _Ruleset.ReadXml(_DefaultRulesetPath);
                _Ruleset.AcceptChanges();

                var serviceInterface = ServiceInterface.Marshal(_Ruleset);

                AsyncCore.Instance.Start(_Ruleset, serviceInterface, new EventLog("APAccess", ".", "APLogger"));
            }
            catch (RemotingException ex)
            {
                var registeredChannels = string.Format("\r\n******Registered channels({0})*****\r\n", ChannelServices.RegisteredChannels.Length);
                foreach (var channel in ChannelServices.RegisteredChannels)
                {
                    registeredChannels += channel.ChannelName + "\r\n";
                }

                EventLog.WriteEntry("APService", "On start. " + BugSubmitter.FormatErrorMessage(ex) + registeredChannels, EventLogEntryType.Error);
                throw;
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("APService", "On start. " + BugSubmitter.FormatErrorMessage(ex), EventLogEntryType.Error);
                throw;
            }

            EventLog.WriteEntry("APService", "Service successfully started.", EventLogEntryType.Information);
        }