Exemplo n.º 1
0
        public async Task <HttpResultModel <CommandsModel> > PerformResponseUptime(CommandsReadModel commandsReadModel)
        {
            var resultCommandResponse = new HttpResultModel <CommandsModel>();
            var resultStreamInfo      = await GetStreamInformations();

            if (resultStreamInfo.Result && resultStreamInfo.Model.Stream != null)
            {
                var stream        = resultStreamInfo.Model.Stream;
                var nowEuw        = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, TZConvert.WindowsToIana("Romance Standard Time"));
                var createdAtEuw  = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Convert.ToDateTime(stream.Created_at), TZConvert.WindowsToIana("Romance Standard Time"));
                var timeStampDiff = nowEuw - createdAtEuw;
                var message       = $"{timeStampDiff.Hours}h:{timeStampDiff.Minutes}m:{timeStampDiff.Seconds}s";

                var model = new CommandsModel()
                {
                    Response = commandsReadModel.Response.Replace("{uptime}", message)
                };

                resultCommandResponse.PerformResult(true, "", _localizer["Uptime calculé."], model);
                return(resultCommandResponse);
            }
            else
            {
                resultCommandResponse.PerformResult(false, _localizer["Impossible de calculer l'uptime."], "", null);
                return(resultCommandResponse);
            }
        }
Exemplo n.º 2
0
        public static CommandsModel ReadCommands()
        {
            var commands = ReadConfig <CommandsModel>("commands.json", new CommandsModel());

            if (commands == null)
            {
                commands = new CommandsModel();
            }
            return(commands);
        }
        private HttpResultModel <CommandsModel> PerformResponseModel(CommandsReadModel commandsReadModel)
        {
            var resultCommandResponse = new HttpResultModel <CommandsModel>();

            var commandsModel = new CommandsModel()
            {
                Response = commandsReadModel.Response
            };

            resultCommandResponse.PerformResult(true, "", _localizer["Réponse trouvée."], commandsModel);
            return(resultCommandResponse);
        }
Exemplo n.º 4
0
 public QTCommandsManager()
 {
     this.rawCommands = ConfigManager.ReadCommands();
     // Populate commands loop up with aliases
     foreach (var command in this.rawCommands.Commands)
     {
         this.commandsLookup.Add(command.Keyword, command);
         foreach (var alias in command.Aliases)
         {
             this.commandsLookup.Add(alias, command);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            DataContext           = this;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            applicationSettingsModel = new ApplicationSettingsModel();              // create the ApplicationSettingsModel once
            commandsModel            = new CommandsModel(applicationSettingsModel); // create the command model for the simulator
            infoModel = new InfoModel(applicationSettingsModel);                    // create the info model for the simulator
            // add the models to the views for creating the view models
            auto.Model        = commandsModel;
            joystick.Model    = commandsModel;
            flightBoard.Model = infoModel;
        }
        public async Task <HttpResultModel <CommandsModel> > PerformResponseSpotify(CommandsReadModel commandsReadModel, int spotifyType)
        {
            var resultCommandResponse         = new HttpResultModel <CommandsModel>();
            var resultSpotifyCurrentlyPlaying = await SpotifyCurrentlyPlaing();

            if (resultSpotifyCurrentlyPlaying.Result)
            {
                var model = new CommandsModel();

                if (resultSpotifyCurrentlyPlaying.Model != null && resultSpotifyCurrentlyPlaying.Model.IsPlaying)
                {
                    if (spotifyType == (int)SpotifyTypeEnum.MUSIC)
                    {
                        model.Response = commandsReadModel.Response.Replace("{music}", resultSpotifyCurrentlyPlaying.Model.Item.Name).Replace("{artist}", resultSpotifyCurrentlyPlaying.Model.Item.Artists[0].Name);
                    }
                    else if (spotifyType == (int)SpotifyTypeEnum.PLAYLIST)
                    {
                        if (resultSpotifyCurrentlyPlaying.Model.Context != null && resultSpotifyCurrentlyPlaying.Model.Context.ExternalUrls.Spotify != string.Empty)
                        {
                            model.Response = commandsReadModel.Response.Replace("{playlist}", resultSpotifyCurrentlyPlaying.Model.Context.ExternalUrls.Spotify);
                        }
                        else
                        {
                            model.Response = _localizer["Pas de playlist associée au titre en cours."];
                        }
                    }
                }
                else
                {
                    model.Response = _localizer["Pas d'écoute Spotify en cours."];
                }

                resultCommandResponse.PerformResult(true, "", _localizer["Commande music récupérée."], model);
                return(resultCommandResponse);
            }
            else
            {
                resultCommandResponse.PerformResult(false, _localizer["Impossible de récupérer les infos de la musique Spotify."], "", null);
                return(resultCommandResponse);
            }
        }
Exemplo n.º 7
0
 public void Dispose()
 {
     CommandsModel?.Dispose();
 }
Exemplo n.º 8
0
        private void MergeNewValuesWithOriginal(CommandsModel modelFromView)
        {
            //***************************The values that are display only will not be posted back so need to get them from session**************************

            CommandsModel OriginalValuesFromSession = SessionManager.CurrentCommands;
        }
Exemplo n.º 9
0
 public static bool SaveCommands(CommandsModel commands)
 {
     return(SaveConfig <CommandsModel>("commands.json", commands));
 }