public MainForm()
 {
     InitializeComponent();
     _displayService = new DisplayService();
 }
示例#2
0
 public void EndTests()
 {
     _displayService = null;
 }
示例#3
0
 public void Initialize()
 {
     _displayService = new DisplayService();
 }
示例#4
0
 public MainViewModel(DisplayService displayService, PanelGeneratorService panelGeneratorService)
 {
     _displayService        = displayService;
     _panelGeneratorService = panelGeneratorService;
 }
示例#5
0
        private void RegisterServices()
        {
            serverService = new ServerService(AppSettings.Endpoint);
            templateService = new TemplateService(AppSettings.Endpoint);
            displayService = new DisplayService(HubSettings.Endpoint);
            queuePlanService = new QueuePlanService(AppSettings.Endpoint);

            UnityContainer.RegisterInstance(serverService)
                         .RegisterInstance(templateService)
                         .RegisterInstance(displayService)
                         .RegisterInstance(queuePlanService);
        }
示例#6
0
        static void Main(string[] args)
        {
            var provider = RegisterServicesAndGetServiceProvider();

            var _authenticationService         = provider.GetService <IAuthenticationService>();
            var _parsingService                = provider.GetService <IParsingService>();
            var _metaFileInfoSerializerService = provider.GetService <IMetaFileInfoSerializerService>();
            var _fileLoggerService             = provider.GetService <ILoggerService>();


            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
                         .AddJsonFile("appsettings.json", false)
                         .Build();

            var metaFileInfoSettings  = config.GetSection("MetaFileInfoSettings").Get <MetaFileInfoSettings>();
            var exceptionInfoSettings = config.GetSection("Logger").Get <ExceptionInfoSettings>();

            #region Authentication

            bool isAuthenticated = false;

            while (true && !isAuthenticated)
            {
                Console.WriteLine("Введите логин: ");
                var login = Console.ReadLine();

                Console.WriteLine("Введите пароль: ");
                var password = Console.ReadLine();
                if (_authenticationService.Authenticate(login, password))
                {
                    isAuthenticated = true;
                    Console.WriteLine("Регистрация прошла успешно");
                }
                else
                {
                    Console.WriteLine("Неверный логин или пароль. Повторите попытку.");
                }
            }
            #endregion

            #region Create Meta File
            if (!File.Exists(metaFileInfoSettings.FullPath))
            {
                File.Create(metaFileInfoSettings.FullPath);
            }
            #endregion

            #region Show Menu
            var messages = new List <string>()
            {
                $"Введите команду из списка:",
                "user_info",
                "file_upload <path to file>",
                "file_download <file name> <destination path>",
                "file_move <source file name> <destination file name>",
                "file_remove <file name>",
                "file_info <file name>",
                "file_find <file name>"
            };
            DisplayService.DisplayMessages(messages);

            #endregion

            while (true)
            {
                string input = Console.ReadLine();
                var    containerForCommand = _parsingService.ParseCommand(input);

                var storageServices = new List <BaseStorageService>()
                {
                    new FileStorageService(containerForCommand, metaFileInfoSettings),
                    new MetaFileStorageService(containerForCommand, metaFileInfoSettings, _metaFileInfoSerializerService, _authenticationService)
                };

                try
                {
                    foreach (var service in storageServices)
                    {
                        switch (containerForCommand.FileOperation)
                        {
                        case FileOperation.file_upload:
                            service.FileUpload();
                            break;

                        case FileOperation.file_download:
                            service.FileDownload();
                            break;

                        case FileOperation.file_move:
                            service.FileMove();
                            break;

                        case FileOperation.file_remove:
                            service.FileRemove();
                            break;

                        case FileOperation.file_info:
                            service.FileInfo();
                            break;

                        case FileOperation.file_find:
                            service.FileFind();
                            break;

                        case FileOperation.user_info:
                            service.UserInfo();
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (!File.Exists(exceptionInfoSettings.FullLogPath))
                    {
                        File.Create(exceptionInfoSettings.FullLogPath);
                    }

                    _fileLoggerService.Log(ex.Message, exceptionInfoSettings.FullLogPath);
                }
            }
        }