public override void Configure(IFunctionsHostBuilder builder)
        {
            var keyVaultName  = Environment.GetEnvironmentVariable("KeyVaultName");
            var configService = new ConfigService(keyVaultName);

            configService.LoadConfigurationAsync().Wait();

            var tableStorageAccount = CloudStorageAccount.Parse(configService.TableStorageAccountConnectionString);
            var tableClient         = tableStorageAccount.CreateCloudTableClient();

            var mediaServiceCallHistoryTable = tableClient.GetTableReference(configService.MediaServiceCallHistoryTableName);

            mediaServiceCallHistoryTable.CreateIfNotExists();
            var mediaServiceCallHistoryTableStorageService = new TableStorageService(mediaServiceCallHistoryTable);

            var provisioningCompletedEventQueue = new QueueClient(configService.StorageAccountConnectionString, configService.ProvisioningCompletedEventQueueName);

            provisioningCompletedEventQueue.CreateIfNotExists();

            var provisioningCompletedEventStorageService = new ProvisioningCompletedEventStorageService(provisioningCompletedEventQueue);
            var mediaServiceCallHistoryStorageService    = new MediaServiceCallHistoryStorageService(mediaServiceCallHistoryTableStorageService);

            var assetDataProvisioningService                 = new AssetDataProvisioningService(new MediaServiceInstanceFactory(mediaServiceCallHistoryStorageService, configService), configService);
            var clearStreamingProvisioningService            = new ClearStreamingProvisioningService(new MediaServiceInstanceFactory(mediaServiceCallHistoryStorageService, configService), configService);
            var outputEncryptionStreamingProvisioningService = new OutputEncryptionStreamingProvisioningService(new MediaServiceInstanceFactory(mediaServiceCallHistoryStorageService, configService), configService);

            // Instantiate the list of provisioning services to run for each provisioning request
            // These services run in the same order as in this list
            // Provisioning logic can be customized by removing any of the services from the list below. Also new services can be created and added to this list.
            var provisioningOrchestrator = new ProvisioningOrchestrator(
                new List <IProvisioningService>
            {
                assetDataProvisioningService,
                clearStreamingProvisioningService,
                outputEncryptionStreamingProvisioningService
            },
                provisioningCompletedEventStorageService);

            builder.Services.AddSingleton <IProvisioningOrchestrator>(provisioningOrchestrator);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(IFormCollection collection, CustomCommands cmd)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrWhiteSpace(collection["Command"]))
                    {
                        var customCommands = new CustomCommands()
                        {
                            PartitionKey = Guid.NewGuid().ToString(),
                            RowKey       = "1",
                            Alias        = collection["Alias"],
                            Command      = collection["Command"],
                            Cooldown     = int.Parse(collection["Cooldown"]),
                            Message      = collection["Message"],
                            Userlevel    = collection["Userlevel"],
                            Description  = collection["Description"],
                            IsEnabled    = bool.Parse(collection["IsEnabled"])
                        };

                        await TableStorageService.InsertEntity(customCommands, Constants.CustomCommandsTableName);

                        return(RedirectToAction("Index", "Commands", new { ac = "The command was successfully added!", type = "success" }));
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception)
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public bool Save(DeviceInput entity)
        {
            //List<Entity.BaseNoSqlEntity> lst = new List<Entity.BaseNoSqlEntity>();
            //entity.RowKey = entity.ID.ToString();
            //entity.PartitionKey = ApartmentConstants.PartitionKey;
            //entity.TableName = "Device";

            //lst.Add(entity);

            //Entity.Address address = entity.Address;
            //address.PartitionKey = ApartmentConstants.PartitionKey;
            //address.TableName = "Address";
            //address.RowKey = address.ID.ToString();


            //lst.Add(address);
            //return SaveBatch(lst);
            TableStorageService <BaseAzureTableStorage> StorageService = new TableStorageService <BaseAzureTableStorage>(DeviceInputDataConstants.TableName);

            StorageService.CreateTable();
            return(StorageService.Insert(entity));
        }
Exemplo n.º 4
0
        // GET: SongsInfo
        public async Task <ActionResult> Index()
        {
            var songsInfo = new SongsInfo();
            var table     = TableStorageService.ConnectToTable(Constants.CurrentSongTableName);
            var queryCS   = await table.ExecuteQuerySegmentedAsync(new TableQuery <AzureTableSong>(), null);

            songsInfo.CurrentSong = queryCS.Results.FirstOrDefault();

            var bytes = await ImageService.DownloadImage(songsInfo.CurrentSong.OriginalGame);

            if (bytes == null)
            {
                bytes = await ImageService.DownloadImage(Constants.DefaultBlobImage);
            }

            songsInfo.GamePicture = bytes;

            var songs = await TableStorageService.RetrieveAllEntities <AzureTableSong>(Constants.QueueTableName);

            songsInfo.SongsQueue = songs.OrderBy(x => x.Position);
            return(View(songsInfo));
        }
Exemplo n.º 5
0
        public static void Run([ServiceBusTrigger("myqueue-1", Connection = "ConnectionStringKey")] string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");

            var myValuesRepository = new TableStorageService <MyValue>(log, TableStorageConnectionString, MyValuesTableName);
            var mySumRepository    = new TableStorageService <MyValue>(log, TableStorageConnectionString, MySumTableName);

            var myValue = JsonConvert.DeserializeObject <MyValue>(myQueueItem);

            myValuesRepository.InsertOrUpdateEntry(myValue);

            // this is not memory efficient
            var latestValues = myValuesRepository.GetAllEntries().OrderBy(v => v.Timestamp).TakeLast(10);
            var totalSum     = latestValues.Sum(v => v.Value);

            var myNewestSum = new MyValue()
            {
                Value = totalSum
            };

            mySumRepository.InsertOrUpdateEntry(myNewestSum);
        }
Exemplo n.º 6
0
        public static async Task Initialize(TestContext _)
        {
            // Set the correct keyvault name
            configService = new E2ETestConfigService("<enter keyvault name>");
            await configService.LoadConfigurationAsync().ConfigureAwait(false);

            var storageAccount = CloudStorageAccount.Parse(configService.TableStorageAccountConnectionString);

            // Create a table client for interacting with the table service
            var tableClient = storageAccount.CreateCloudTableClient();

            // Create a table client for interacting with the table service
            var mediaServiceInstanceHealthTable = tableClient.GetTableReference(configService.MediaServiceInstanceHealthTableName);
            await mediaServiceInstanceHealthTable.CreateIfNotExistsAsync().ConfigureAwait(false);

            mediaServiceInstanceHealthTableStorageService = new TableStorageService(mediaServiceInstanceHealthTable);
            await mediaServiceInstanceHealthTableStorageService.DeleteAllAsync <MediaServiceInstanceHealthModelTableEntity>().ConfigureAwait(false);

            var jobOutputStatusTable = tableClient.GetTableReference(configService.JobOutputStatusTableName);
            await jobOutputStatusTable.CreateIfNotExistsAsync().ConfigureAwait(false);

            jobOutputStatusTableStorageService = new TableStorageService(jobOutputStatusTable);
            await jobOutputStatusTableStorageService.DeleteAllAsync <JobOutputStatusModelTableEntity>().ConfigureAwait(false);

            var mediaServiceCallHistoryTable = tableClient.GetTableReference(configService.MediaServiceCallHistoryTableName);

            mediaServiceCallHistoryTable.CreateIfNotExists();
            var mediaServiceCallHistoryTableStorageService = new TableStorageService(mediaServiceCallHistoryTable);

            mediaServiceCallHistoryStorageService = new MediaServiceCallHistoryStorageService(mediaServiceCallHistoryTableStorageService);
            await mediaServiceCallHistoryTableStorageService.DeleteAllAsync <MediaServiceCallHistoryModelTableEntity>().ConfigureAwait(false);

            jobRequestQueue = new QueueClient(configService.StorageAccountConnectionString, configService.JobRequestQueueName);
            await jobRequestQueue.CreateIfNotExistsAsync().ConfigureAwait(false);

            jobVerificationRequestQueue = new QueueClient(configService.StorageAccountConnectionString, configService.JobVerificationRequestQueueName);
            await jobVerificationRequestQueue.CreateIfNotExistsAsync().ConfigureAwait(false);
        }
        public override void Configure(IFunctionsHostBuilder builder)
        {
            var keyVaultName  = Environment.GetEnvironmentVariable("KeyVaultName");
            var configService = new ConfigService(keyVaultName);

            configService.LoadConfigurationAsync().Wait();

            var tableStorageAccount = CloudStorageAccount.Parse(configService.TableStorageAccountConnectionString);
            var tableClient         = tableStorageAccount.CreateCloudTableClient();

            var mediaServiceInstanceHealthTable = tableClient.GetTableReference(configService.MediaServiceInstanceHealthTableName);

            mediaServiceInstanceHealthTable.CreateIfNotExists();
            var mediaServiceInstanceHealthTableStorageService = new TableStorageService(mediaServiceInstanceHealthTable);

            var jobOutputStatusTable = tableClient.GetTableReference(configService.JobOutputStatusTableName);

            jobOutputStatusTable.CreateIfNotExists();
            var jobOutputStatusTableStorageService = new TableStorageService(jobOutputStatusTable);

            var mediaServiceCallHistoryTable = tableClient.GetTableReference(configService.MediaServiceCallHistoryTableName);

            mediaServiceCallHistoryTable.CreateIfNotExists();
            var mediaServiceCallHistoryTableStorageService = new TableStorageService(mediaServiceCallHistoryTable);

            var jobVerificationRequestQueue = new QueueClient(configService.StorageAccountConnectionString, configService.JobVerificationRequestQueueName);

            jobVerificationRequestQueue.CreateIfNotExists();

            var jobOutputStatusStorageService            = new JobOutputStatusStorageService(jobOutputStatusTableStorageService);
            var mediaServiceCallHistoryStorageService    = new MediaServiceCallHistoryStorageService(mediaServiceCallHistoryTableStorageService);
            var mediaServiceInstanceHealthStorageService = new MediaServiceInstanceHealthStorageService(mediaServiceInstanceHealthTableStorageService);
            var mediaServiceInstanceHealthService        = new MediaServiceInstanceHealthService(mediaServiceInstanceHealthStorageService, jobOutputStatusStorageService, mediaServiceCallHistoryStorageService, configService);
            var jobVerificationRequestStorageService     = new JobVerificationRequestStorageService(jobVerificationRequestQueue);
            var jobSchedulingService = new JobSchedulingService(mediaServiceInstanceHealthService, jobVerificationRequestStorageService, jobOutputStatusStorageService, new MediaServiceInstanceFactory(mediaServiceCallHistoryStorageService, configService), configService);

            builder.Services.AddSingleton <IJobSchedulingService>(jobSchedulingService);
        }
Exemplo n.º 8
0
        private async void DeleteSong(object sender, EventArgs e)
        {
            try
            {
                if (await DisplayAlert("Warning!", "Do you really want to delete it?", "Yes", "No"))
                {
                    if (await TableStorageService.DeleteSong(song))
                    {
                        await DisplayAlert("Success!", "Song deleted!", "OK");

                        await Navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlert("Error!", "Song NOT deleted!", "OK");
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error!", "There was an error!", "OK");
            }
        }
Exemplo n.º 9
0
        public async Task <ActionResult> Edit(string pk, string rk, IFormCollection collection)
        {
            try
            {
                var command = await TableStorageService.RetrieveEntity <CustomCommands>(pk, rk, Constants.CustomCommandsTableName);

                command.Alias       = collection["Alias"];
                command.Command     = collection["Command"];
                command.Cooldown    = int.Parse(collection["Cooldown"]);
                command.Message     = collection["Message"];
                command.Userlevel   = collection["Userlevel"];
                command.Description = collection["Description"];
                command.IsEnabled   = bool.Parse(collection["IsEnabled"]);

                await TableStorageService.ReplaceEntity(command, Constants.CustomCommandsTableName);

                return(RedirectToAction("Index", "Commands", new { ac = "The command was successfully edited!", type = "success" }));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 10
0
        public static void Run([TimerTrigger("0 * * * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            var bankTransactionRepository           = new TableStorageService <BankTransaction>(log, ConnectionString, $"{My_Name}BankTransaction");
            var bankTransactionStatisticsRepository = new TableStorageService <BankTransactionStatistics>(log, ConnectionString, $"{My_Name}BankTransactionStatistics");

            SeedData(bankTransactionRepository);

            // Generate BankTransactionStatistics from all senders by aggregating the total sum of their transactions

            var entities = bankTransactionRepository.GetAllEntries();
            var senders  = entities.Select(e => e.PartitionKey).Distinct();

            foreach (var sender in senders)
            {
                var transactions = bankTransactionRepository.GetByPartitionId(sender);
                var totalAmmount = transactions.Sum(t => t.Ammount);

                var existingBankTransactionStatistics = bankTransactionStatisticsRepository.GetByPartitionId(sender).FirstOrDefault();

                if (existingBankTransactionStatistics != null)
                {
                    existingBankTransactionStatistics.Ammount = totalAmmount;
                }
                else
                {
                    existingBankTransactionStatistics = new BankTransactionStatistics(Guid.NewGuid().ToString(), sender)
                    {
                        Ammount = totalAmmount
                    };
                }

                bankTransactionStatisticsRepository.InsertOrUpdateEntry(existingBankTransactionStatistics);
            }
        }
Exemplo n.º 11
0
        public async Task <ActionResult> Create(IFormCollection collection, Tags tag)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrWhiteSpace(collection["Name"]))
                    {
                        var tags = new Tags()
                        {
                            PartitionKey = Guid.NewGuid().ToString(),
                            RowKey       = "1",
                            Name         = collection["Name"],
                            Emoji        = collection["Emoji"],
                            Description  = collection["Description"]
                        };

                        await TableStorageService.InsertEntity(tags, Constants.TagsTableName);

                        return(RedirectToAction("Index", "Tags", new { ac = "The tag was successfully added!", type = "success" }));
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception)
            {
                return(View());
            }
        }
        public static async Task ReceiveFeedbackAsync(string terraConnString)
        {
            IHelper _helper = new Helper(ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"].ToString());
            ITableStorageService _cloudTableManager = new TableStorageService();
            ServiceClient        serviceClient      = ServiceClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IoTHubConnectionString"].ToString());
            var feedbackReceiver = serviceClient.GetFeedbackReceiver();

            DateTime time     = DateTime.Now;
            string   feedback = String.Empty;

            try
            {
                while (true)
                {
                    var feedbackBatch = await feedbackReceiver.ReceiveAsync();

                    if (feedbackBatch != null)
                    {
                        _helper.WriteInformation("Inside while loop " + DateTime.Now);
                        foreach (FeedbackRecord feedbackBatchRecord in feedbackBatch.Records)
                        {
                            string temp = $"Device Id:{feedbackBatchRecord.DeviceId}-Status:{feedbackBatchRecord.StatusCode} - Message Id :{feedbackBatchRecord.OriginalMessageId}";

                            feedback += $"|{temp}|";

                            var messageToTerra =
                                new
                            {
                                statusCode  = (int)feedbackBatchRecord.StatusCode,
                                description = feedbackBatchRecord.Description
                            };
                            // var eventData = new EventData(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageToTerra)));

                            IDictionary <string, string> appValues = new Dictionary <string, string>();
                            appValues.Add("DeviceId", feedbackBatchRecord.DeviceId);
                            appValues.Add("DeviceGeneratedId", feedbackBatchRecord.DeviceGenerationId);
                            appValues.Add("MessageId", feedbackBatchRecord.OriginalMessageId);
                            appValues.Add("EnqueuedTimeUtc", feedbackBatchRecord.EnqueuedTimeUtc.ToString());

                            //eventData.Properties.Add("DeviceId", feedbackBatchRecord.DeviceId);
                            //eventData.Properties.Add("DeviceGeneratedId", feedbackBatchRecord.DeviceGenerationId);
                            //eventData.Properties.Add("MessageId", feedbackBatchRecord.OriginalMessageId);
                            //eventData.Properties.Add("EnqueuedTimeUtc", feedbackBatchRecord.EnqueuedTimeUtc.ToString());

                            //Sending to Terra
                            //  var hubClient = EventHubClient.CreateFromConnectionString(terraConnString);
                            // await hubClient.SendAsync(eventData);


                            // store in table
                            await _cloudTableManager.Insert <WOADeviceFeedbackEntity>("DeviceFeedbacks", feedbackBatchRecord.DeviceId, feedbackBatchRecord.OriginalMessageId, new WOADeviceFeedbackEntity()
                            {
                                DeviceStatus = feedbackBatchRecord.Description
                            });
                        }
                        await feedbackReceiver.CompleteAsync(feedbackBatch);
                    }
                }
            }
            catch (Exception ex)
            {
                _helper.SendException(ex);
                _helper.WriteInformation("Feedback process unsuccessful..");
            }
        }
Exemplo n.º 13
0
 public ValuesController(ILogger <ValuesController> logger)
 {
     this._logger     = logger;
     valuesRepository = new TableStorageService <MyValue>(logger, TableStorageConnectionString, TableName);
 }
Exemplo n.º 14
0
 public PBITrackRepos(IOptions <OAuthOptions> options, GitHubService gitHubService, TableStorageService tableService, BlobStorageService blobService)
 {
     _tableService  = tableService;
     _gitHubService = gitHubService;
     _blobService   = blobService;
 }
 public DownloaderLogic(BlobStorageService blobStorageService, TableStorageService tableStorageService, SyncStatusRepository syncStatusRepository)
 {
     _blobStorageService   = blobStorageService;
     _tableStorageService  = tableStorageService;
     _syncStatusRepository = syncStatusRepository;
 }
 public RetrieveAllGameSettingsSinceLastSync(BlobStorageService blobStorageService, TableStorageService tableStorageService)
 {
     _blobStorageService  = blobStorageService;
     _tableStorageService = tableStorageService;
     _downloadDir         = $@"{Directory.GetCurrentDirectory()}\DownloadedGameSettings\";
 }
        public async Task <ActionResult> RequestSong(string pk, string rk)
        {
            var tableSong = TableStorageService.ConnectToTable("CurrentSong");
            var queryCS   = await tableSong.ExecuteQuerySegmentedAsync(new TableQuery <AzureTableSong>(), null);

            var currentSong = queryCS.Results.FirstOrDefault();

            if (currentSong.RowKey != rk)
            {
                var song = await TableStorageService.RetrieveEntity <AllSongs>(pk, rk, Constants.AllSongsTableName);

                if (song != null)
                {
                    var position = 1;

                    var channel = CookieService.Get(Request, Constants.ChannelCookieName);

                    var user = await userManager.GetUserAsync(User);

                    var userName = user.UserName;

                    var isModOwner = await userManager.IsInRoleAsync(user, "Moderator") ||
                                     await userManager.IsInRoleAsync(user, "Owner");

                    var queueSongs = await TableStorageService.RetrieveAllEntities <AzureTableSong>(Constants.QueueTableName);

                    if (queueSongs.Count > 0)
                    {
                        if (!isModOwner)
                        {
                            var friend = await TableStorageService.RetrieveEntity <Friends>(channel, "1", Constants.FriendsTableName);

                            if (friend != null)
                            {
                                var friendRequests = queueSongs.Count(x => x.RequestedById == channel);
                                if (friendRequests > 1)
                                {
                                    return(RedirectToAction("Index", "Playlist", new { ac = "Error. You already have two song requests on the queue.", type = "danger" }));
                                }
                            }
                            else
                            {
                                var userExists = queueSongs.Any(x => x.RequestedById == channel);
                                if (userExists)
                                {
                                    return(RedirectToAction("Index", "Playlist", new { ac = "Error. You already have a song request on the queue.", type = "danger" }));
                                }
                            }
                        }

                        var songExists = queueSongs.Any(x => x.RowKey == rk);
                        if (songExists)
                        {
                            return(RedirectToAction("Index", "Playlist", new { ac = $"Error. That song is already on the queue.", type = "danger" }));
                        }

                        queueSongs = queueSongs.OrderBy(x => x.Position).ToList();
                        position   = queueSongs.Last().Position + 1;
                    }

                    var lastRequest = (song.LastTimeRequested.HasValue)
                        ? MathFunctions.GetCooldownMinutes(song.LastTimeRequested.Value) : 100;

                    if (isModOwner || lastRequest > 60)
                    {
                        var updateSong = new AllSongs()
                        {
                            PartitionKey      = song.PartitionKey,
                            RowKey            = song.RowKey,
                            Counter           = song.Counter0 + 1,
                            LastTimeRequested = DateTime.UtcNow
                        };

                        await TableStorageService.MergeEntity(updateSong, Constants.AllSongsTableName);

                        var newSongQueue = new AzureTableSong()
                        {
                            PartitionKey      = song.PartitionKey,
                            RowKey            = song.RowKey,
                            Title             = song.OriginalTitle,
                            OriginalGame      = song.OriginalGame,
                            LowerCaseTitle    = song.Title,
                            Channel           = song.Channel,
                            VideoId           = song.YouTubeLink.Replace("https://youtu.be/", string.Empty),
                            YouTubeLink       = song.YouTubeLink,
                            Duration          = song.Duration,
                            TotalTime         = 0,
                            RecentlyAdded     = song.RecentlyAdded,
                            RequestedBy       = userName,
                            RequestedById     = channel,
                            Counter           = song.Counter0 + 1,
                            Likes             = song.Likes0,
                            Position          = position,
                            LastTimeRequested = song.LastTimeRequested
                        };

                        await TableStorageService.InsertEntity(newSongQueue, Constants.QueueTableName);

                        return(RedirectToAction("Index", "SongsQueue", new { ac = $"The song was added to the queue in position {position}.", type = "success" }));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Playlist", new { ac = $"Error. That song is in cooldown. Please wait {60 - lastRequest} minutes to request it again.", type = "danger" }));
                    }
                }

                return(RedirectToAction("Index", "Playlist", new { ac = "Error. The song does not exist.", type = "danger" }));
            }
            else
            {
                return(RedirectToAction("Index", "Playlist", new { ac = "Error. The song is currently playing.", type = "danger" }));
            }
        }
        public async Task <ActionResult> Create(IFormCollection collection, AllSongs song)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var youTubeLink = collection["YouTubeLink"].ToString();

                    if (!string.IsNullOrWhiteSpace(youTubeLink))
                    {
                        var table = TableStorageService.ConnectToTable(Constants.AllSongsTableName);
                        TableContinuationToken tableContinuationToken = null;
                        int maxKey     = 0;
                        var songExists = false;

                        do
                        {
                            var tableQuerySegment = await table.ExecuteQuerySegmentedAsync(new TableQuery <AllSongs>(), tableContinuationToken);

                            var songs = tableQuerySegment.Results;

                            var max = songs.Max(x => x.RowKey);
                            maxKey = Math.Max(maxKey, int.Parse(max));

                            tableContinuationToken = tableQuerySegment.ContinuationToken;
                            songExists             = songs.Any(x => x.YouTubeLink == youTubeLink);
                        }while (tableContinuationToken != null && !songExists);

                        if (!songExists)
                        {
                            var    i     = (maxKey + 1).ToString("D4");
                            string title = collection["OriginalTitle"];
                            string game  = collection["OriginalGame"];

                            var newSong = new AllSongs()
                            {
                                RowKey            = i,
                                OriginalGame      = game,
                                Game              = game.ToLower(),
                                OriginalTitle     = title,
                                PartitionKey      = StringFunctions.ReplaceChars(game.ToLower()),
                                Title             = StringFunctions.ReplaceChars(title.ToLower()),
                                Channel           = collection["Channel"],
                                Duration          = collection["Duration"],
                                YouTubeLink       = youTubeLink,
                                LastTimeRequested = null,
                                RecentlyAdded     = "✓",
                                Counter           = 0,
                                Likes             = 0
                            };

                            await TableStorageService.InsertEntity(newSong, Constants.AllSongsTableName);

                            //TODO: add tags from webpage

                            return(RedirectToAction("Index", "Playlist", new { ac = "The song was successfully added!", type = "success" }));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Playlist", new { ac = "The YouTube video URL already exists in the playlist!", type = "danger" }));
                        }
                    }
                    else
                    {
                        return(View());
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception)
            {
                return(View());
            }
        }
Exemplo n.º 19
0
 protected override async void OnAppearing()
 {
     base.OnAppearing();
     SongList.ItemsSource = await TableStorageService.GetSongs();
 }
 public PreLoadPaymentsSteps()
 {
     _tableStorageService = ParentContainer.GetInstance <TableStorageService>();
     _settings            = ParentContainer.GetInstance <Config>();
 }
Exemplo n.º 21
0
        public async Task <ViewResult> Index(string sortOrder, string currentFilter, string searchString, int?page, int?pageSize, string currentSort)
        {
            ViewBag.CurrentSort = sortOrder ?? currentSort;
            sortOrder           = ViewBag.CurrentSort;

            ViewBag.SortName        = (string.IsNullOrEmpty(sortOrder) ? "name_desc" : "");
            ViewBag.SortEmoji       = ((sortOrder == "emoji") ? "emoji_desc" : "emoji");
            ViewBag.SortDescription = ((sortOrder == "description") ? "description_desc" : "description");

            var currentPageSize = pageSize.HasValue ? pageSize.Value : 10;

            ViewBag.CurrentPageSize = currentPageSize;

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var tags = await TableStorageService.RetrieveAllEntities <Tags>(Constants.TagsTableName);

            var source = string.IsNullOrWhiteSpace(searchString)
                ? tags
                : tags.Where(x => x.Name.Contains(searchString) || x.Description.Contains(searchString));

            switch (sortOrder)
            {
            case "name_desc":
                source = source.OrderByDescending(x => x.Name);
                break;

            case "emoji":
                source = source.OrderBy(x => x.Emoji).ThenBy(x => x.Name);
                break;

            case "emoji_desc":
                source = source.OrderByDescending(x => x.Emoji).ThenBy(x => x.Name);
                break;

            case "description":
                source = source.OrderBy(x => x.Description).ThenBy(x => x.Name);
                break;

            case "description_desc":
                source = source.OrderByDescending(x => x.Description).ThenBy(x => x.Name);
                break;

            default:
                source = source.OrderBy(x => x.Name);
                break;
            }

            int pageNumber = page ?? 1;

            return(View(new PageTags()
            {
                Tags = source.ToPagedList(pageNumber, currentPageSize)
            }));
        }
Exemplo n.º 22
0
        public async Task <ViewResult> Index(string sortOrder, string currentFilter, string searchString, int?page, int?pageSize, string currentSort)
        {
            ViewBag.CurrentSort = sortOrder ?? currentSort;
            sortOrder           = ViewBag.CurrentSort;

            ViewBag.SortCommand   = (string.IsNullOrEmpty(sortOrder) ? "command_desc" : "");
            ViewBag.SortStatus    = ((sortOrder == "status") ? "status_desc" : "status");
            ViewBag.SortMessage   = ((sortOrder == "message") ? "message_desc" : "message");
            ViewBag.SortUserlevel = ((sortOrder == "userlevel") ? "userlevel_desc" : "userlevel");

            var currentPageSize = pageSize.HasValue ? pageSize.Value : 10;

            ViewBag.CurrentPageSize = currentPageSize;

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var commands       = FileService.ReadCommands();
            var customCommands = await TableStorageService.RetrieveAllEntities <CustomCommands>(Constants.CustomCommandsTableName);

            commands = commands.Union(customCommands).ToList();

            var source = string.IsNullOrWhiteSpace(searchString)
                ? commands
                : commands.Where(x => x.Command.Contains(searchString) || x.Message.Contains(searchString));

            switch (sortOrder)
            {
            case "command_desc":
                source = source.OrderByDescending(x => x.Command);
                break;

            case "status":
                source = source.OrderBy(x => x.IsEnabled).ThenBy(x => x.Command);
                break;

            case "status_desc":
                source = source.OrderByDescending(x => x.IsEnabled).ThenBy(x => x.Command);
                break;

            case "message":
                source = source.OrderBy(x => x.Message).ThenBy(x => x.Command);
                break;

            case "message_desc":
                source = source.OrderByDescending(x => x.Message).ThenBy(x => x.Command);
                break;

            case "userlevel":
                source = source.OrderBy(x => x.Userlevel).ThenBy(x => x.Command);
                break;

            case "userlevel_desc":
                source = source.OrderByDescending(x => x.Userlevel).ThenBy(x => x.Command);
                break;

            default:
                source = source.OrderBy(x => x.Command);
                break;
            }

            int pageNumber = page ?? 1;

            return(View(new PageCommands()
            {
                Commands = source.ToPagedList(pageNumber, currentPageSize)
            }));
        }
Exemplo n.º 23
0
        public async Task <ViewResult> Index(string sortOrder, string currentFilter, string searchString, int?page, int?pageSize, string currentSort)
        {
            ViewBag.CurrentSort = sortOrder ?? currentSort;
            sortOrder           = ViewBag.CurrentSort;

            ViewBag.SortTitle    = (string.IsNullOrEmpty(sortOrder) ? "title_desc" : "");
            ViewBag.SortDuration = ((sortOrder == "duration") ? "duration_desc" : "duration");
            ViewBag.SortArtist   = ((sortOrder == "artist") ? "artist_desc" : "artist");

            var currentPageSize = pageSize.HasValue ? pageSize.Value : 10;

            ViewBag.CurrentPageSize = currentPageSize;

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var playlist = new List <MySongs>();

            var table = TableStorageService.ConnectToTable(Constants.MySongsTableName);
            TableContinuationToken tableContinuationToken = null;

            var channel = CookieService.Get(Request, Constants.ChannelCookieName);

            var filter = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, channel);
            var query  = new TableQuery <MySongs>().Where(filter);

            do
            {
                var tableQuerySegment = await table.ExecuteQuerySegmentedAsync(query, tableContinuationToken);

                playlist.AddRange(tableQuerySegment.Results);
                tableContinuationToken = tableQuerySegment.ContinuationToken;
            }while (tableContinuationToken != null);

            var source = string.IsNullOrWhiteSpace(searchString)
                ? playlist
                         //: playlist.Where(x => x.Title.Contains(searchString));
                : EasyCustomSearch.SearchSong(searchString, playlist);

            switch (sortOrder)
            {
            case "title_desc":
                source = source.OrderByDescending(x => x.Title);
                break;

            case "duration":
                source = source.OrderBy(x => x.Duration).ThenBy(x => x.Title);
                break;

            case "duration_desc":
                source = source.OrderByDescending(x => x.Duration).ThenBy(x => x.Title);
                break;

            case "artist":
                source = source.OrderBy(x => x.Channel).ThenBy(x => x.Title);
                break;

            case "artist_desc":
                source = source.OrderByDescending(x => x.Channel).ThenBy(x => x.Title);
                break;

            default:
                source = source.OrderBy(x => x.Title);
                break;
            }

            var pageNumber = page ?? 1;

            return(View(new MyPageSongs()
            {
                MySongs = source.ToPagedList(pageNumber, currentPageSize)
            }));
        }
 public AzureUserStore(TAzureStorageContext context, ILookupNormalizer normalizer)
 {
     this.userTable   = new TableStorageService <TUser>(context, "Users");
     this._normalizer = normalizer;
 }
        public async Task <ViewResult> Index(string sortOrder, string currentFilter, string searchString, int?page, int?pageSize, string currentSort, bool?checkNew)
        {
            ViewBag.CurrentSort = sortOrder ?? currentSort;
            sortOrder           = ViewBag.CurrentSort;

            ViewBag.SortTitle    = (string.IsNullOrEmpty(sortOrder) ? "title_desc" : "");
            ViewBag.SortDuration = ((sortOrder == "duration") ? "duration_desc" : "duration");
            ViewBag.SortCounter  = ((sortOrder == "counter") ? "counter_desc" : "counter");
            ViewBag.SortArtist   = ((sortOrder == "artist") ? "artist_desc" : "artist");
            ViewBag.SortNumber   = ((sortOrder == "number") ? "number_desc" : "number");

            var currentPageSize = pageSize.HasValue ? pageSize.Value : 10;

            ViewBag.CurrentPageSize = currentPageSize;

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            ViewBag.CheckNew = checkNew;

            var playlist = await TableStorageService.RetrieveAllEntities <AllSongs>(Constants.AllSongsTableName);

            var source = string.IsNullOrWhiteSpace(searchString)
                ? playlist
                : EasyCustomSearch.SearchSong(searchString, playlist);

            if (!string.IsNullOrWhiteSpace(searchString))
            {
                var num = -1;

                if (int.TryParse(searchString, out num))
                {
                    var song = playlist.Where(x => x.RowKey == searchString || x.RowKey == num.ToString("D4"));
                    if (song != null)
                    {
                        if (!source.Any(x => x.RowKey == searchString || x.RowKey == num.ToString("D4")))
                        {
                            source = source.Union(song);
                        }
                    }
                }
            }

            if (checkNew.HasValue)
            {
                if (checkNew.Value)
                {
                    source = source.Where(x => x.Game == "NEW" || x.RecentlyAdded == "✓");
                }
            }

            switch (sortOrder)
            {
            case "title_desc":
                source = source.OrderByDescending(x => x.OriginalTitle);
                break;

            case "duration":
                source = source.OrderBy(x => x.Duration).ThenBy(x => x.OriginalTitle);
                break;

            case "duration_desc":
                source = source.OrderByDescending(x => x.Duration).ThenBy(x => x.OriginalTitle);
                break;

            case "counter":
                source = source.OrderBy(x => x.Counter).ThenBy(x => x.OriginalTitle);
                break;

            case "counter_desc":
                source = source.OrderByDescending(x => x.Counter).ThenBy(x => x.OriginalTitle);
                break;

            case "artist":
                source = source.OrderBy(x => x.Channel).ThenBy(x => x.OriginalTitle);
                break;

            case "artist_desc":
                source = source.OrderByDescending(x => x.Channel).ThenBy(x => x.OriginalTitle);
                break;

            case "number":
                source = source.OrderBy(x => x.RowKey);
                break;

            case "number_desc":
                source = source.OrderByDescending(x => x.RowKey);
                break;

            default:
                // no va para respetar la busqueda source = source.OrderBy(x => x.OriginalTitle);
                break;
            }

            var pageNumber = page ?? 1;

            return(View(new PageSongs()
            {
                AllSongs = source.ToPagedList(pageNumber, currentPageSize)
            }));
        }
Exemplo n.º 26
0
 public GHSTTrackRepos(IOptions <OAuthOptions> options, GitHubService gitHubService, TableStorageService tableService)
 {
     _tableService  = tableService;
     _gitHubService = gitHubService;
 }
Exemplo n.º 27
0
 public void GetCoursesTest()
 {
     TableStorageService service = new TableStorageService(_endPoint, _sasToken);
     string json = service.GetCourses();
 }
Exemplo n.º 28
0
        private static void SeedData(TableStorageService <BankTransaction> tableStorageService)
        {
            var transactions = new BankTransaction[]
            {
                new BankTransaction("1", "John Smith")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Amanda"
                },
                new BankTransaction("2", "John Smith")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Elton"
                },
                new BankTransaction("3", "Elton James")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Amanda"
                },
                new BankTransaction("4", "John Smith")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Elton"
                },
                new BankTransaction("5", "Elton James")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Amanda"
                },
                new BankTransaction("6", "Amanda Jefferson")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "John"
                },
                new BankTransaction("7", "Amanda Jefferson")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Elton"
                },
                new BankTransaction("8", "John Smith")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Elton"
                },
                new BankTransaction("9", "Amanda Jefferson")
                {
                    Ammount            = new Random().Next(1, 100),
                    DestinationAccount = Guid.NewGuid().ToString(),
                    DestinationName    = "Elton"
                },
            };

            foreach (var transaction in transactions)
            {
                tableStorageService.InsertOrUpdateEntry(transaction);
            }
        }
Exemplo n.º 29
0
 public void GetEnrollmentTest()
 {
     string email = "*****@*****.**";
     TableStorageService service = new TableStorageService(_endPoint, _sasToken);
     string json = service.GetEnrollment(email);
 }