public DeploymentEventLog(
     AppConfig config,
     TelemetryClient telemetry,
     ApplicationInsightsHelper applicationInsightsHelper)
     : base(config, telemetry, applicationInsightsHelper)
 {
 }
        public IContainer Setup(IServiceCollection services, IConfiguration configuration)
        {
            var builder   = new ContainerBuilder();
            var appConfig = new AppConfig();

            configuration.Bind(appConfig);
            builder.RegisterInstance(appConfig).SingleInstance();
            var applicationInsightHelper = new ApplicationInsightsHelper();

            configuration.Bind(applicationInsightHelper);
            builder.RegisterInstance(applicationInsightHelper).SingleInstance();
            builder.Populate(services);
            builder.RegisterGeneric(typeof(Logger <>)).As(typeof(ILogger <>));
            this.AutowireAssemblies(builder);
            builder.RegisterType <UserManagementClient>().As <IUserManagementClient>().SingleInstance();
            builder.RegisterType <AppConfigurationClient>().As <IAppConfigurationClient>().SingleInstance();
            builder.RegisterType <StorageAdapterClient>().As <IStorageAdapterClient>().SingleInstance();
            builder.RegisterType <ExternalRequestHelper>().As <IExternalRequestHelper>().SingleInstance();
            builder.RegisterType <CustomEventLogHelper>().As <ICustomEventLogHelper>().SingleInstance();
            builder.RegisterType <GuidKeyGenerator>().As <IKeyGenerator>().SingleInstance();
            builder.RegisterType <HttpClient>().As <IHttpClient>().SingleInstance();
            builder.Register(context => GetOpenIdConnectManager(context.Resolve <AppConfig>())).As <IConfigurationManager <OpenIdConnectConfiguration> >().SingleInstance();
            builder.RegisterType <CorsSetup>().As <ICorsSetup>().SingleInstance();
            builder.RegisterType <StorageClient>().As <IStorageClient>().SingleInstance();
            builder.RegisterType <AsaManagerClient>().As <IAsaManagerClient>().SingleInstance();
            builder.RegisterType <TimeSeriesClient>().As <ITimeSeriesClient>().SingleInstance();
            builder.RegisterType <CloudTableClientFactory>().As <ICloudTableClientFactory>().SingleInstance();
            builder.RegisterType <TableStorageClient>().As <ITableStorageClient>().SingleInstance();
            builder.RegisterType <BlobStorageClient>().As <IBlobStorageClient>().SingleInstance();
            this.SetupCustomRules(builder);
            var container = builder.Build();

            Factory.RegisterContainer(container);
            return(container);
        }
Beispiel #3
0
        /// <summary>
        /// On startup, register synchronization context
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnStartup(StartupEventArgs e)
        {
            TelemetryConfiguration.Active.TelemetryInitializers.Add(new PopcornApplicationInsightsInitializer());
            var builder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;

            builder.UseAdaptiveSampling(1);
            builder.Build();
            await ApplicationInsightsHelper.Initialize();

            base.OnStartup(e);
            WatchStart = Stopwatch.StartNew();
            Logger.Info(
                "Popcorn starting...");
            Unosquare.FFME.MediaElement.FFmpegDirectory = Constants.FFmpegPath;

            try
            {
                var userService = SimpleIoc.Default.GetInstance <IUserService>();
                await userService.GetUser();

                await Task.Run(async() =>
                {
                    var netsh        = new NetSH(new Utils.CommandLineHarness());
                    var showResponse = netsh.Http.Show.UrlAcl(Constants.ServerUrl);
                    if (showResponse.ResponseObject.Count == 0)
                    {
                        if (!Helper.IsAdministrator())
                        {
                            RestartAsAdmin();
                        }
                        else
                        {
                            RegisterUrlAcl();
                        }
                    }

                    if (!await FirewallRuleExists("Popcorn Server"))
                    {
                        if (!Helper.IsAdministrator())
                        {
                            RestartAsAdmin();
                        }
                        else
                        {
                            await RegisterFirewallRule();
                        }
                    }

                    _localServer = WebApp.Start <Startup>(Constants.ServerUrl);
                });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Beispiel #4
0
            public WhenPackageAndToolStatisticsInLogFile(ITestOutputHelper testOutputHelper)
            {
                var loggerFactory = new LoggerFactory();

                loggerFactory.AddProvider(new XunitLoggerProvider(testOutputHelper));
                _loggerFactory = loggerFactory;

                _leasedLogFile             = GetLeasedLogFileMock(_logFileName);
                _applicationInsightsHelper = new ApplicationInsightsHelper(TelemetryConfiguration.CreateDefault());
            }
Beispiel #5
0
        /// <summary>
        /// On startup, register synchronization context
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            var config = TelemetryConfiguration.CreateDefault();

            config.TelemetryInitializers.Add(new PopcornApplicationInsightsInitializer());
            ApplicationInsightsHelper.Initialize(config);
            base.OnStartup(e);
            WatchStart = Stopwatch.StartNew();
            Logger.Info(
                "Popcorn starting...");
            Unosquare.FFME.Library.FFmpegDirectory = Constants.FFmpegPath;
        }
Beispiel #6
0
 /// <summary>
 /// On startup, register synchronization context
 /// </summary>
 /// <param name="e"></param>
 protected override async void OnStartup(StartupEventArgs e)
 {
     TelemetryConfiguration.Active.TelemetryInitializers.Add(new PopcornApplicationInsightsInitializer());
     ApplicationInsightsHelper.Initialize();
     base.OnStartup(e);
     WatchStart = Stopwatch.StartNew();
     Logger.Info(
         "Popcorn starting...");
     Unosquare.FFME.Library.FFmpegDirectory = Constants.FFmpegPath;
     try
     {
         SQLitePCL.Batteries.Init();
         var userService = SimpleIoc.Default.GetInstance <IUserService>();
         await userService.GetUser();
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
        public async Task <ActionResult> ProcessDocument()
        {
            var watch = new Stopwatch();

            watch.Start();

            Vision.Models.Document document = new Vision.Models.Document();
            OcrResults             results;

            // Get File
            try
            {
                document.FileLocation = GetPostedFile();
            }
            catch (Exception ex)
            {
                return(Json("Upload Failed: " + ex.Message));
            }

            if (string.IsNullOrEmpty(document.LanguageCode))
            {
                document.LanguageCode = "unk";
            }

            try
            {
                FileStream stream   = new FileStream(path: document.FileLocation, mode: FileMode.Open, access: FileAccess.Read);
                var        FileInfo = new FileInfo(document.FileLocation);

                VisionServiceClient visionService = new VisionServiceClient(configuration.GetValue <string>("VisionApiSubscriptionKey"), configuration.GetValue <string>("VisionApiEndpoint"));

                results = await visionService.RecognizeTextAsync(imageStream : stream, languageCode : document.LanguageCode);



                stream.Close();
                stream.Dispose();

                watch.Stop();


                ApplicationInsightsHelper aiHelper = new ApplicationInsightsHelper(configuration);

                var metric = new Dictionary <string, double>
                {
                    ["ProcessTime(ms)"]     = watch.ElapsedMilliseconds,
                    ["DocumentSize(bytes)"] = FileInfo.Length
                };

                var properties = new Dictionary <string, string>()
                {
                    ["FileType"] = FileInfo.Extension
                };

                aiHelper.TrackEvent("OCRProcessing", properties, metric);
            }
            catch (Exception ex)
            {
                return(Json("Processing Failed: " + ex.Message));

                throw;
            }


            return(Json(results));
        }