Exemple #1
0
        protected override async Task OnParametersSetAsync()
        {
            Channels = new ChannelsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module  = Constants.VideosModule,
                    Type    = Constants.ChannelType,
                    OrderBy = new string[]
                    {
                        OrderBy.Weight,
                        OrderBy.Latest,
                        OrderBy.Title
                    }
                }
            };
            await Channels.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanAddChannel = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.VideosModule,
                Constants.ChannelType,
                Actions.Add
                );
        }
Exemple #2
0
 private static void InitializeChannels()
 {
     if (Program._client.ConnectionState == ConnectionState.Connected)
     {
         Channels = new Models.ChannelsModel(_client);
     }
 }
Exemple #3
0
        public async Task MainAsync()
        {
            using (ErrorsSavingService = new BackgroundWorker())
            {
                ErrorsSavingService.DoWork       += SaveErrorsData;
                ErrorsSavingServiceTimer          = new System.Timers.Timer(new TimeSpan(0, 60, 0).TotalMilliseconds);
                ErrorsSavingServiceTimer.Elapsed += CheckSaveErrorsProcess;
                ErrorsSavingServiceTimer.Start();
            }

            OpQueue = new List <SpyOpInfo>();

            using (NewOpDetectionService = new BackgroundWorker())
            {
                NewOpDetectionService.DoWork += CheckForNewOps;
                TimeSpan x = new TimeSpan(0, 0, 0, 0, 500);
                NewOpDetectionServiceTimer          = new System.Timers.Timer(x.TotalMilliseconds);
                NewOpDetectionServiceTimer.Elapsed += CheckCheckForNewOpsProcess;
                NewOpDetectionServiceTimer.Start();
                x = new TimeSpan(0, 0, 1);
                ProcessOpQueueServiceTimer          = new System.Timers.Timer(x.TotalMilliseconds);
                ProcessOpQueueServiceTimer.Elapsed += CheckQueueServiceProcess;
                ProcessOpQueueServiceTimer.Start();
                using (ProcessOpQueueService = new BackgroundWorker())
                {
                    ProcessOpQueueService.DoWork += ProcessQueue;
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            _client   = new DiscordSocketClient();
            _commands = new CommandService();

            _services = new ServiceCollection().AddSingleton(_client).AddSingleton(_commands).BuildServiceProvider();

            await InstallCommandsAsync();

            string token = "MzU1MzkwNzg1ODQ1MTk4ODQ4.DRHWOw.e7tUoO4E7pZJgHs8S65eoX-Uk2U"; // Remember to keep this private!
            await _client.LoginAsync(TokenType.Bot, token);

            await _client.StartAsync();

            Thread.Sleep(1500);

            if (_client.ConnectionState == ConnectionState.Connected)
            {
                Channels = new Models.ChannelsModel(_client);
                //_client.UserJoined += Announcements;
            }

            Application.Run(new Form1());
        }
        public async Task <IActionResult> Index()
        {
            var identityConfiguration = await _repositoryService.TryGetIdentityEntityAsync(HttpContext.User.Identity.Name).ConfigureAwait(false);

            var channelsModel = new ChannelsModel
            {
                Channels = identityConfiguration.Channels.Keys.ToList()
            };

            // This controller allows setting the used channel.
            // The list of channels is provided as radio buttons.
            // Direct call will open the window always.
            // Other controllers can redirect to this view if required.
            return(View(nameof(Index), channelsModel));
        }
 public ChannelsModel GetChannelsModel()
 {
     try
     {
         var channelsModel = new ChannelsModel();
         var channels      = from channel
                             in _entityModel.Channels
                             orderby channel.date descending
                             select new Channel {
             Id = channel.channelId, Name = channel.src_Name
         };
         channelsModel.Channels.AddRange(channels);
         return(channelsModel);
     }
     catch (Exception exception)
     {
         return(null);
     }
 }
Exemple #6
0
        protected override async Task OnParametersSetAsync()
        {
            var configSearch = new NodeSearch()
            {
                Module = Constants.VideosModule,
                Type   = Constants.ConfigType
            };
            var configNodes = (await NodeService.GetAsync(configSearch, 0));

            if (configNodes.Length > 0)
            {
                Config = configNodes[0];
            }
            Channels = new ChannelsModel(NodeService)
            {
                NodeSearch = new NodeSearch()
                {
                    Module  = Constants.VideosModule,
                    Type    = Constants.ChannelType,
                    OrderBy = $"{OrderBy.Weight},{OrderBy.Latest},{OrderBy.Title}"
                }
            };
            await Channels.InitAsync();

            var loggedInUserId = (await AuthenticationStateTask).LoggedInUserId();

            CanEditConfig = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.VideosModule,
                Constants.ConfigType,
                Actions.Edit
                );

            CanAddChannel = await SecurityService.AllowedAsync(
                loggedInUserId,
                null,
                Constants.VideosModule,
                Constants.ChannelType,
                Actions.Add
                );
        }
		public ChannelsModel GetChannelsModel()
		{
			var channelsModel = new ChannelsModel();

			using (SqlConnection connection = new SqlConnection(_connectionString))
			{
				SqlCommand command = new SqlCommand("SELECT id,src_Name FROM Channels ORDER By date DESC", connection);
				connection.Open();
				using (SqlDataReader reader = command.ExecuteReader())
				{
					while (reader.Read())
					{
						channelsModel.Channels.Add(
							new Channel
							{
								Id = reader.GetInt32(0),
								Name = reader.GetString(1)
							});
					}
				}
			}
			return channelsModel;
		}