private async Task ProcessMissions(IImageProvider imageProvider, DeveloperHelper helper, StringBuilder sb) { var missionReference = helper.GetTableReference(AzureTableName.Missions); var missions = await missionReference.ExecuteQueryAsync(new TableQuery <MissionAzure>()); var missionsForUpdate = missions.Where( m => m.RowKey == AzureTableConstants.MissionRowKey && BlobInfo.GetInfoByUrl(m.PhotoUrl).Kind == BlobKind.External); foreach (var missionAzure in missionsForUpdate) { var imageResult = await imageProvider.SaveImageByUrl(missionAzure.PhotoUrl, BlobContainer.MissionImages); if (imageResult.Status != OperationResultStatus.Success) { sb.AppendLine(string.Format(MissionTemplate, missionAzure.Name, missionAzure.Id, imageResult.Description)); continue; } missionAzure.PhotoUrl = imageResult.Description; TableOperation updateOperation = TableOperation.Replace(missionAzure); var result = await missionReference.ExecuteAsync(updateOperation); if (!result.HttpStatusCode.EnsureSuccessStatusCode()) { sb.AppendLine(string.Format(MissionTemplate, missionAzure.Name, missionAzure.Id, result.HttpStatusCode)); } } }
public void GetDeveloperAttributesEmptyResultTest() { List <Developer> expected = new List <Developer>(); var actual = DeveloperHelper.GetDeveloperAttributes(typeof(TestCustomType))?.ToList(); CollectionAssert.AreEqual(expected, actual); }
public async Task ChangeNick(CommandContext ctx, [Description("Nowy pseudonim.")][RemainingText] string name) { if (DeveloperHelper.IsDeveloper(ctx.User.Id)) { await ctx.Guild.CurrentMember.ModifyAsync(p => p.Nickname = name); } else { await ctx.RespondAsync("You aren't my father."); } }
public async Task ChangeName(CommandContext ctx, [Description("Nowa nazwa bota.")][RemainingText] string name = null) { if (DeveloperHelper.IsDeveloper(ctx.User.Id)) { await Bot.DiscordClient.UpdateCurrentUserAsync(name); } else { await ctx.RespondAsync("You aren't my father."); } }
public async Task RemoveNick(CommandContext ctx) { if (DeveloperHelper.IsDeveloper(ctx.User.Id)) { await ctx.Guild.CurrentMember.ModifyAsync(p => p.Nickname = null); } else { await ctx.RespondAsync("You aren't my father."); } }
public async Task Czesc(CommandContext ctx) { await ctx.TriggerTypingAsync(); if (DeveloperHelper.IsDeveloper(ctx.User.Id)) { await ctx.RespondAsync("Cześć mój programisto " + ctx.User.Mention); } else { await ctx.RespondAsync("Cześć " + ctx.User.Mention); } }
private static void Main(string[] args) { var developers = DeveloperHelper.GetDeveloperAttributes(typeof(TestHelper))?.ToList(); if (developers != null && developers.Any()) { developers.ForEach(x => Console.WriteLine($"Name: {x.Name}, Email: {x.Email}")); } else { Console.WriteLine($"There aren't any developer attributes related to {typeof(TestHelper)}."); } Console.ReadKey(); }
/// <summary> /// Excecutes the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>OperationResult.</returns> public async Task <OperationResult> Excecute(params object[] args) { var sb = new StringBuilder(); var helper = new DeveloperHelper(); var imageProvider = IocConfig.GetConfiguredContainer().Resolve <IImageProvider>(); await ProcessMissions(imageProvider, helper, sb); await ProcessMissionDrafts(imageProvider, helper, sb); if (sb.Length > 0) { return(new OperationResult(OperationResultStatus.Warning, sb.ToString())); } return(new OperationResult(OperationResultStatus.Success)); }
private static async Task ProcessCloudTables(DeveloperHelper helper) { var tableClient = helper.CloudTableClient; var tables = tableClient.ListTables(); foreach (var cloudTable in tables) { var items = cloudTable.ExecuteQuery(new TableQuery()); foreach (var dynamicTableEntity in items) { var deleteOperation = TableOperation.Delete(dynamicTableEntity); await cloudTable.ExecuteAsync(deleteOperation); } /*await cloudTable.DeleteIfExistsAsync();*/ } }
/// <summary> /// Excecutes the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>OperationResult.</returns> public async Task <OperationResult> Excecute(params object[] args) { var helper = new DeveloperHelper(); try { await ProcessCloudTables(helper); await ProcessBlobs(helper); return(new OperationResult(OperationResultStatus.Success)); } catch (Exception ex) { var message = string.Format("Exception on deleting: \n{0}", ex.ToStringExtended()); return(new OperationResult(OperationResultStatus.Error, message)); } }
private static async Task ProcessBlobs(DeveloperHelper helper) { var blobClient = helper.CloudBlobClient; var containers = blobClient.ListContainers(); foreach (var cloudBlobContainer in containers) { var blobs = cloudBlobContainer.ListBlobs(); foreach (var listBlobItem in blobs) { var blob = listBlobItem as CloudBlockBlob; if (blob != null) { await blob.DeleteAsync(); } } } }
public void GetDeveloperAttributesTest() { List <Developer> expected = new List <Developer> { new Developer { Name = "Katsiaryna Tsmyh", Email = "dede" }, new Developer { Name = "Developer Name", Email = "*****@*****.**" }, new Developer { Name = "Another Developer Name", Email = "*****@*****.**" } }; var actual = DeveloperHelper.GetDeveloperAttributes(typeof(TestHelper))?.ToList(); CollectionAssert.AreEqual(expected, actual); }
public async Task Description(CommandContext ctx, [Description("Nowy opis.")][RemainingText] string message = null) { if (DeveloperHelper.IsDeveloper(ctx.User.Id)) { _description = message; try { await ctx.Client.UpdateStatusAsync(new DiscordActivity(message)); } catch (Exception ie) { Console.WriteLine("Error: Can't set status."); Console.WriteLine("Exception: " + ie.Message); Console.WriteLine("Inner Exception: " + ie?.InnerException?.Message); Console.WriteLine("Stack trace: " + ie.StackTrace); } } else { await ctx.RespondAsync("You aren't my father."); } }
/// <summary> /// Excecutes the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns>OperationResult.</returns> public async Task <OperationResult> Excecute(params object[] args) { try { var helper = new DeveloperHelper(); var container = helper.GetBlobContainer(BlobContainer.TempStorage); var blobs = container.ListBlobs(); foreach (var listBlobItem in blobs) { var blob = listBlobItem as CloudBlockBlob; if (blob != null) { await blob.DeleteAsync(); } } return(new OperationResult(OperationResultStatus.Success)); } catch (Exception ex) { return(new OperationResult(OperationResultStatus.Error, ex.ToStringExtended())); } }
public bool Authorize([NotNull] DashboardContext context) { var httpContext = context.GetHttpContext(); return(DeveloperHelper.IsCanAccess(httpContext, ConfigurationRoot)); }
public void GetDeveloperAttributesNullResultTest() { var actual = DeveloperHelper.GetDeveloperAttributes(null)?.ToList(); Assert.AreEqual(null, actual); }
private bool IsValidDeveloperRequest(HttpContext context) { return(DeveloperHelper.IsCanAccess(context, Core.SystemConfigs.Developers.AccessKey)); }
private static bool IsCanAccessSwagger(HttpContext httpContext) { return(DeveloperHelper.IsCanAccess(httpContext, ConfigurationRoot)); }