Ejemplo n.º 1
0
        private static void SetupLogging()
        {
            var basePath = AppFileUtils.GetLogsPath();
            var logs     = new List <FileToLog>
            {
                //ViewModels
                new FileToLog(typeof(MainViewModel), "vm_main"),
                new FileToLog(typeof(DevicesViewModel), "vm_devices"),
                new FileToLog(typeof(SettingsViewModel), "vm_settings"),
                new FileToLog(typeof(PlayListItemViewModel), "vm_playlistitem"),
                new FileToLog(typeof(FileItemViewModel), "vm_fileitem"),
                new FileToLog(typeof(DeviceItemViewModel), "vm_deviceitem"),
                new FileToLog(typeof(DownloadDialogViewModel), "vm_download_dialog"),
                new FileToLog(typeof(SplashViewModel), "vm_splash"),
                //Others
                new FileToLog(typeof(Player), "cast_player"),
            };

            logs.AddRange(Application.DependencyInjection.GetApplicationLogs());
            logs.AddRange(Infrastructure.DependencyInjection.GetInfrastructureLogs());
            logs.AddRange(Server.DependencyInjection.GetServerLogs());

            logs.SetupLogging(basePath);
            var loggerFactory = new LoggerFactory()
                                .AddSerilog();

            //to resolve an ilogger<T> you need a iloggerfactory, thats why whe register both
            Mvx.IoCProvider.RegisterSingleton(loggerFactory);
            Mvx.IoCProvider.RegisterType(typeof(ILogger <>), typeof(Logger <>));
        }
Ejemplo n.º 2
0
 public App()
 {
     //https://docs.devexpress.com/WPF/400286/common-concepts/performance-improvement/reducing-the-application-launch-time
     // Defines where to store JIT profiles
     ProfileOptimization.SetProfileRoot(AppFileUtils.GetBaseAppFolder());
     // Enables Multicore JIT with the specified profile
     ProfileOptimization.StartProfile("Startup.Profile");
 }
Ejemplo n.º 3
0
        public static IServiceCollection AddApplication(this IServiceCollection services, string ffmpegPath, string ffprobePath, string generatedFilesFolderPath = null)
        {
            if (string.IsNullOrWhiteSpace(generatedFilesFolderPath))
            {
                generatedFilesFolderPath = AppFileUtils.GetBaseAppFolder();
            }
            var fileService = new FileService(ffmpegPath, ffprobePath, generatedFilesFolderPath);

            services.AddSingleton <ICommonFileService>(fileService);
            services.AddSingleton <IFileService>(fileService);
            return(services.AddCommonServices().AddFFmpegService());
        }
Ejemplo n.º 4
0
        public AppDataService(IMapper mapper)
        {
            _mapper           = mapper;
            _connectionString = AppFileUtils.GetDbConnectionString();
            _db = new FreeSql.FreeSqlBuilder()
                  .UseConnectionString(FreeSql.DataType.Sqlite, _connectionString)
                  .UseAutoSyncStructure(false)
                  .Build();

            _db.CodeFirst.ConfigEntity <PlayList>(pl => pl.Property(x => x.Id).IsPrimary(true).IsIdentity(true));
            _db.CodeFirst.ConfigEntity <FileItem>(f => f.Property(x => x.Id).IsPrimary(true).IsIdentity(true));
            ApplyMigrations();
        }
Ejemplo n.º 5
0
        public override void Initialize()
        {
            base.Initialize();

            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            SetupLogging();
            SetupMapper();

            //NPI WHY I NEED TO MANUALLY REGISTER THIS ONE
            Mvx.IoCProvider.RegisterSingleton <IMvxMessenger>(new MvxMessengerHub());

            string baseAppFolder = AppFileUtils.GetBaseAppFolder();
            var    fileService   = new FileService(baseAppFolder);

            Mvx.IoCProvider.RegisterSingleton(typeof(IFileService), () => fileService);
            Mvx.IoCProvider.RegisterSingleton(typeof(ICommonFileService), () => fileService);
            Mvx.IoCProvider.ConstructAndRegisterSingleton <ITelemetryService, TelemetryService>();
            Mvx.IoCProvider.ConstructAndRegisterSingleton <IAppSettingsService, AppSettingsService>();
            Mvx.IoCProvider.ConstructAndRegisterSingleton <IAppDataService, AppDataService>();
            Mvx.IoCProvider.ConstructAndRegisterSingleton <IYoutubeUrlDecoder, YoutubeUrlDecoder>();

            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IPlayer>(() =>
            {
                var logger = Mvx.IoCProvider.Resolve <ILogger <Player> >();
                return(new Player(logger, logToConsole: false));
            });

            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IFFmpegService, FFmpegService>();
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <ICastService, CastService>();
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <IFileWatcherService, FileWatcherService>();

            Mvx.IoCProvider.ConstructAndRegisterSingleton <IAppWebServer, AppWebServer>();
            Mvx.IoCProvider.RegisterSingleton(typeof(IBaseWebServer), () => Mvx.IoCProvider.Resolve <IAppWebServer>());

            var messenger    = Mvx.IoCProvider.Resolve <IMvxMessenger>();
            var textProvider = new ResxTextProvider(Resource.ResourceManager, messenger);

            Mvx.IoCProvider.RegisterSingleton <ITextProvider>(textProvider);

            //since im using automapper to resolve this one, i need to explicit register it
            Mvx.IoCProvider.RegisterType <PlayListItemViewModel>();
            Mvx.IoCProvider.RegisterType <FileItemViewModel>();
            Mvx.IoCProvider.RegisterType <DeviceItemViewModel>();
            Mvx.IoCProvider.ConstructAndRegisterSingleton(typeof(SettingsViewModel));

            RegisterAppStart <SplashViewModel>();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            var logs = new List <FileToLog>
            {
                new FileToLog(typeof(MainService), "service_main")
            };

            logs.AddRange(DependencyInjection.GetServerLogs());
            logs.AddRange(Infrastructure.DependencyInjection.GetInfrastructureLogs());
            logs.AddRange(Application.DependencyInjection.GetApplicationLogs());
            logs.SetupLogging(AppFileUtils.GetServerLogsPath());

            Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            CreateHostBuilder(args).Build().Run();
        }
Ejemplo n.º 7
0
 public string CreateDirectory(string baseFolder, string folder)
 {
     return(AppFileUtils.CreateDirectory(baseFolder, folder));
 }
Ejemplo n.º 8
0
 public void DeleteServerLogsAndPreviews()
 {
     DeleteFilesInDirectory(GetPreviewsPath(), DateTime.Now.AddDays(-1));
     DeleteFilesInDirectory(AppFileUtils.GetServerLogsPath(), DateTime.Now.AddDays(-3));
 }