Пример #1
0
        public async Task <IActionResult> UpdateWindowsSettings([FromBody] WindowsSettings settings)
        {
            string accessToken = await HttpContext.GetToken();

            var session = await sessionService.GetSession(accessToken);

            if (session == null)
            {
                return(Unauthorized(new { message = "Session expired. Please login again." }));
            }
            try
            {
                if (settings == null)
                {
                    throw new ArgumentNullException("Settings cannot be null");
                }
                if (settings.UserId != session.UserId)
                {
                    throw new NotSupportedException("You are not allowed to change other user's settings");
                }

                var existing = (await userRepository.GetSettings(session.UserId)).ToDto <UserSettings>();
                existing.WindowsSettings = settings.ToJson();
                var updated = await userRepository.UpdateSettings(existing);

                await log.InfoAsync("User Windows Settings updated", context : session.UserId);

                return(Ok(settings));
            }
            catch (Exception ex)
            {
                await log.ErrorAsync("Error in userRepository.GetSettings()", ex);

                return(BadRequest(new { title = ex.GetType().ToString(), details = ex.StackTrace, message = ex.Message }));
            }
        }
Пример #2
0
 public Settings(FFmpegSettings FFmpeg, WindowsSettings WindowsSettings)
 {
     this.FFmpeg          = FFmpeg;
     this.WindowsSettings = WindowsSettings;
 }
Пример #3
0
 public Settings(WindowsSettings WindowsSettings)
 {
     this.WindowsSettings = WindowsSettings;
 }
        public CommandContext(string appPath)
        {
            EnsureArgument.NotNullOrWhiteSpace(appPath, nameof(appPath));

            ApplicationPath = appPath;
            Streams         = new StandardStreams();
            Trace           = new Trace();

            if (PlatformUtils.IsWindows())
            {
                FileSystem     = new WindowsFileSystem();
                SessionManager = new WindowsSessionManager();
                SystemPrompts  = new WindowsSystemPrompts();
                Environment    = new WindowsEnvironment(FileSystem);
                Terminal       = new WindowsTerminal(Trace);
                string gitPath = GetGitPath(Environment, FileSystem, Trace);
                Git = new GitProcess(
                    Trace,
                    Environment,
                    gitPath,
                    FileSystem.GetCurrentDirectory()
                    );
                Settings = new WindowsSettings(Environment, Git, Trace);
            }
            else if (PlatformUtils.IsMacOS())
            {
                FileSystem     = new MacOSFileSystem();
                SessionManager = new MacOSSessionManager();
                SystemPrompts  = new MacOSSystemPrompts();
                Environment    = new PosixEnvironment(FileSystem);
                Terminal       = new MacOSTerminal(Trace);
                string gitPath = GetGitPath(Environment, FileSystem, Trace);
                Git = new GitProcess(
                    Trace,
                    Environment,
                    gitPath,
                    FileSystem.GetCurrentDirectory()
                    );
                Settings = new Settings(Environment, Git);
            }
            else if (PlatformUtils.IsLinux())
            {
                FileSystem = new LinuxFileSystem();
                // TODO: support more than just 'Posix' or X11
                SessionManager = new PosixSessionManager();
                SystemPrompts  = new LinuxSystemPrompts();
                Environment    = new PosixEnvironment(FileSystem);
                Terminal       = new LinuxTerminal(Trace);
                string gitPath = GetGitPath(Environment, FileSystem, Trace);
                Git = new GitProcess(
                    Trace,
                    Environment,
                    gitPath,
                    FileSystem.GetCurrentDirectory()
                    );
                Settings = new Settings(Environment, Git);
            }
            else
            {
                throw new PlatformNotSupportedException();
            }

            HttpClientFactory = new HttpClientFactory(FileSystem, Trace, Settings, Streams);
            CredentialStore   = new CredentialStore(this);

            // Set the parent window handle/ID
            SystemPrompts.ParentWindowId = Settings.ParentWindowId;
        }