Esempio n. 1
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="configFile">The name of the file that contains the config data</param>
        /// <param name="exceptionReporter">The optional sink for exceptions</param>
        internal OverridableConfig(string configFile, IExceptionReporter exceptionReporter)
        {
            string fullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configFile);

            if (File.Exists(fullPath))
            {
                try
                {
                    string json = File.ReadAllText(fullPath);
                    if (json.Length > 0)
                    {
                        _settings = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(json);
                        return;
                    }
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
                {
                    if (exceptionReporter != null)
                    {
                        exceptionReporter.ReportException(e);
                    }
                }
#pragma warning restore CA1031 // Do not catch general exception types
            }

            // This is our typical path
            _settings = new Dictionary <string, string>();
        }
Esempio n. 2
0
 public static DialogResult PresentModal(Exception e, IExceptionReporter reporter, string message, bool canCancel)
 {
     using (ErrorDialog dlg = new ErrorDialog())
     {
         return dlg.BindAndShow(e, reporter, message, canCancel);
     }
 }
        public StudentQualificationService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter, IStudentService userService, IAPIService apiService)

            : base(unitOfWork, exceptionReporter)
        {
            _userService = userService;
            _apiService  = apiService;
        }
        public void Initialize(IExceptionReporter reporter)
        {
            var catalogs = new List <ComposablePartCatalog>();

            catalogs.AddRange(GetAssemblies(reporter));

            var aggregateCatalog = new AggregateCatalog(catalogs);

            container = new CompositionContainer(aggregateCatalog);
        }
        /// <summary>
        /// Get the Uri to the release notes, based on the installed version
        /// </summary>
        /// <param name="exceptionReporter">Allows exceptions to get tracked</param>
        /// <returns>The Uri if available, null if not</returns>
        public static Uri GetReleaseNotesUri(IExceptionReporter exceptionReporter)
        {
            string version = GetInstalledProductVersion(exceptionReporter);

            if (!string.IsNullOrEmpty(version))
            {
                return(new Uri(string.Format(CultureInfo.InvariantCulture,
                                             "https://github.com/Microsoft/accessibility-insights-windows/releases/tag/v{0}",
                                             version)));
            }

            return(null);
        }
 private static AssemblyCatalog CreateAssemblyCatalog(string file, IExceptionReporter reporter)
 {
     try
     {
         return(new AssemblyCatalog(file));
     }
     catch (Exception ex)
     {
         if (reporter != null)
         {
             reporter.Report(ex);
         }
         return(null);
     }
 }
Esempio n. 7
0
        private DialogResult BindAndShow(Exception exception, IExceptionReporter reporter, string message, bool canCancel)
        {
            if (exception == null)
                throw new ArgumentNullException("exception");

            this.Exception = exception;
            this.MessageLABEL.Text = message ?? exception.Message;
                       
            PrepareReportLink(exception, reporter);
            DumpException(exception);
            
            CancelBTN.Visible = canCancel;
            OkBTN.Focus();

            return ShowDialog();
        }
        public T[] Compose <T>(IExceptionReporter reporter)
        {
            try
            {
                return(container.GetExportedValues <T>().ToArray());
            }
            catch (Exception ex)
            {
                if (reporter != null)
                {
                    reporter.Report(ex);
                    return(new T[0]);
                }

                throw;
            }
        }
        /// <summary>
        /// Returns the product version of the currently installed
        ///     Microsoft.AccessibilityInsights application
        /// Returns null if the version could not be found
        ///     - could occur if the application has not been installed at all
        ///     - could occur if Windows Installer's cached MSI file is corrupted or deleted
        /// </summary>
        /// <returns></returns>
        public static string GetInstalledProductVersion(IExceptionReporter exceptionReporter)
        {
            if (exceptionReporter == null)
            {
                throw new ArgumentNullException(nameof(exceptionReporter));
            }

            string targetUpgradeCode = UpdateGuid.ToUpperInvariant();

            // Check whether application with target upgrade code is installed on this machine
            IEnumerable <ProductInstallation> installations = ProductInstallation.GetRelatedProducts(targetUpgradeCode);
            bool existingApp;

            try
            {
                existingApp = installations.Any();
            }
            catch (ArgumentException e)
            {
                exceptionReporter.ReportException(e);
                // occurs when the upgrade code is formatted incorrectly
                // exception text: "Parameter is incorrect"
                return(null);
            }
            if (!existingApp)
            {
                // occurs when the upgrade code does not match any existing application
                return(null);
            }
            ProductInstallation existingInstall = installations.FirstOrDefault <ProductInstallation>(i => i.ProductVersion != null);

            if (existingInstall == null)
            {
                return(null);
            }
            string msiFilePath = existingInstall.LocalPackage;

            if (msiFilePath != null)
            {
                return(GetMSIProductVersion(msiFilePath));
            }

            // Should only get here if LocalPackage not set
            return(null);
        }
Esempio n. 10
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="exceptionReporter">Mechanism for reporting recoverable exceptions from the config</param>
        public GitHubWrapper(IExceptionReporter exceptionReporter)
        {
            const double      defaultTimeout = 60.0;
            OverridableConfig config         = new OverridableConfig("GitHubWrapper.settings", exceptionReporter);

            _productionConfigFileUri = GetConfiguredUri(config, "ProductionConfigFileUrl", DefaultProductionConfigFileUrl);
            _insiderConfigFileUri    = GetConfiguredUri(config, "InsiderConfigFileUrl", DefaultInsiderConfigFileUrl);
            _canaryConfigFileUri     = GetConfiguredUri(config, "CanaryConfigFileUrl", DefaultCanaryConfigFileUrl);

            string configTimeout = config.GetConfigSetting("TimeoutInSeconds", string.Empty);

            if (!double.TryParse(configTimeout, NumberStyles.Number, CultureInfo.InvariantCulture, out double timeoutInSeconds) || timeoutInSeconds <= 0)
            {
                timeoutInSeconds = defaultTimeout;
            }

            _timeout = TimeSpan.FromSeconds(timeoutInSeconds);
        }
        private IEnumerable <AssemblyCatalog> GetAssemblies(IExceptionReporter reporter)
        {
            IEnumerable <AssemblyCatalog> assemblyCatalogs = RetrieveFileList()
                                                             .Select(f => CreateAssemblyCatalog(f, reporter))
                                                             .Where(ac => ac != null);

            foreach (AssemblyCatalog assemblyCatalog in assemblyCatalogs)
            {
                try
                {
                    bool dummy = assemblyCatalog.Parts.Any();
                }
                catch (Exception ex)
                {
                    if (reporter != null)
                    {
                        reporter.Report(ex);
                    }
                    continue;
                }

                yield return(assemblyCatalog);
            }
        }
Esempio n. 12
0
 public QualificationService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter, ICacheProvider cacheService, IAPIService apiService)
     : base(unitOfWork, exceptionReporter)
 {
     _cacheService = cacheService;
     _apiService   = apiService;
 }
Esempio n. 13
0
 public QuestionBankService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter) : base(unitOfWork, exceptionReporter)
 {
 }
Esempio n. 14
0
 private void PrepareReportLink(Exception exception, IExceptionReporter reporter)
 {
     if (reporter == null)
     {
         SendReportLBTN.Enabled = false;
     }
     else
     {
         this.Reporter = reporter;
     }
 }
Esempio n. 15
0
 public static DialogResult PresentModal(Exception e, IExceptionReporter reporter)
 {
     return PresentModal(e, reporter, null, false);
 }
Esempio n. 16
0
		public EventReporter(IDataServiceLogger logger, IExceptionReporter exceptionReporter)
		{
			this.Logger = logger;
			this.ExceptionReporter = exceptionReporter;
		}
Esempio n. 17
0
 public EventReporter(IDataServiceLogger logger, IExceptionReporter exceptionReporter)
 {
     this.Logger            = logger;
     this.ExceptionReporter = exceptionReporter;
 }
Esempio n. 18
0
 public StudentService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter, IAPIService apiService)
     : base(unitOfWork, exceptionReporter)
 {
     _apiService = apiService;
 }
Esempio n. 19
0
        /// <summary>
        /// Given a ReleaseChannel and a keyName, attempt to load the corresponding ChannelInfo objecvt
        /// </summary>
        /// <param name="releaseChannel">The ReleaseChannel being queried</param>
        /// <param name="channelInfo">Returns the ChannelInfo here</param>
        /// <param name="gitHubWrapper">An optional wrapper to the GitHub data</param>
        /// <param name="keyName">An optional override of the key to use when reading the ChannelInfo data</param>
        /// <param name="exceptionReporter">An optional IExceptionReporter if you want exception details</param>
        /// <returns>true if we found data</returns>
        public static bool TryGetChannelInfo(ReleaseChannel releaseChannel, out ChannelInfo channelInfo, IGitHubWrapper gitHubWrapper, string keyName = "default", IExceptionReporter exceptionReporter = null)
        {
            try
            {
                IGitHubWrapper wrapper = gitHubWrapper ?? new GitHubWrapper(exceptionReporter);
                using (Stream stream = new MemoryStream())
                {
                    wrapper.LoadChannelInfoIntoStream(releaseChannel, stream);
                    channelInfo = GetChannelFromStream(stream, keyName);
                    return(true);
                }
            }
            catch (Exception e)
            {
                if (exceptionReporter != null)
                {
                    exceptionReporter.ReportException(e);
                }
            }

            // Default values
            channelInfo = null;
            return(false);
        }
 public Task <T[]> ComposeAsync <T>(IExceptionReporter errorReporter)
 {
     return(Task.Factory.StartNew(() => Compose <T>(errorReporter)));
 }
 public Task InitializeAsync(IExceptionReporter reporter)
 {
     return(Task.Run(() => Initialize(reporter)));
 }
Esempio n. 22
0
 public SurveyService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter)
     : base(unitOfWork, exceptionReporter)
 {
 }
Esempio n. 23
0
 public ExceptionScanner(IExceptionReporter reporter)
 {
     _reporter = reporter;
 }
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="gitHubWrapper">Provides access to GitHub</param>
 /// <param name="exceptionReporter">Provides a way to report exceptions</param>
 public ProductionChannelInfoProvider(IGitHubWrapper gitHubWrapper, IExceptionReporter exceptionReporter)
 {
     _gitHubWrapper     = gitHubWrapper;
     _exceptionReporter = exceptionReporter;
 }
Esempio n. 25
0
 public void DisplayException(Exception e, IExceptionReporter exceptionReporter=null, string[] tokenNames=null)
     {
     MiscUtil.DisplayException(e, exceptionReporter, tokenNames);
     NoteException();
     }
 public ActiveDirectoryService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter, IStudentService studentService, IQualificationService qualificationService)
     : base(unitOfWork, exceptionReporter)
 {
     _studentService       = studentService;
     _qualificationService = qualificationService;
 }
Esempio n. 27
0
 /// <summary>
 /// </summary>
 /// <param name="unitOfWork"></param>
 /// <param name="exceptionReporter"></param>
 protected BaseService(IUnitOfWork unitOfWork, IExceptionReporter exceptionReporter)
 {
     UnitOfWork        = unitOfWork;
     ExceptionReporter = exceptionReporter;
 }