Skip to content

Commit

Permalink
Fixing Compiler Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinselohrkater committed Jul 24, 2017
1 parent a744d98 commit 2e9046b
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 69 deletions.
25 changes: 22 additions & 3 deletions src/Eurofurence.App.Domain.Model/Fragments/LinkFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public enum FragmentTypeEnum

[Required]
[DataMember]
public FragmentTypeEnum FragmentType { get; set; }
public FragmentTypeEnum FragmentType { get; }

[DataMember]
public string Name { get; set; }
public string Name { get; }

/// <summary>
/// * For FragmentType `DealerDetail`: The `Id` of the dealer record the link is referencing to.
Expand All @@ -39,7 +39,14 @@ public enum FragmentTypeEnum
/// </summary>
[Required]
[DataMember]
public string Target { get; set; }
public string Target { get; }

public LinkFragment(FragmentTypeEnum fragmentType, string name, string target)
{
FragmentType = fragmentType;
Name = name;
Target = target;
}

public override bool Equals(object obj)
{
Expand All @@ -53,5 +60,17 @@ public override bool Equals(object obj)
&& f.Name == Name
&& f.Target == Target;
}


public override int GetHashCode()
{
unchecked
{
var hashCode = (int) FragmentType;
hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Target != null ? Target.GetHashCode() : 0);
return hashCode;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,6 @@ private async Task SendRawAsync(IEnumerable<PushNotificationChannelRecord> recip
}
}


private async Task SendToastAsync(IEnumerable<PushNotificationChannelRecord> recipients, string title,
string message)
{
var recipientsList = recipients.ToList();
if (recipientsList.Count == 0) return;

var accessToken = await GetWnsAccessTokenAsync();

foreach (var recipient in recipientsList)
{
#pragma warning disable CS4014
Task.Run(async () =>
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");
client.DefaultRequestHeaders.Add("X-WNS-TYPE", "wns/toast");

var xml =
$"<?xml version=\"1.0\" encoding=\"utf-8\"?><toast><visual><binding template=\"ToastText01\"><text id=\"1\">{message}</text></binding></visual></toast>";
var payload = new StringContent(xml, Encoding.UTF8, "text/xml");

var result = await client.PostAsync(recipient.ChannelUri, payload);

if (!result.IsSuccessStatusCode)
_pushNotificationRepository.DeleteOneAsync(recipient.Id);
}
});
#pragma warning restore CS4014
}
}

private async Task<string> GetWnsAccessTokenAsync()
{
using (var client = new HttpClient())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Eurofurence.App.Common.ExtensionMethods;
using Eurofurence.App.Domain.Model.Abstractions;
using Eurofurence.App.Domain.Model.Security;
using Eurofurence.App.Server.Services.Abstractions;
Expand All @@ -20,9 +18,6 @@ public class AuthenticationHandler : IAuthenticationHandler
private readonly IEntityRepository<RegSysIdentityRecord> _regSysIdentityRepository;
private readonly ITokenFactory _tokenFactory;

private readonly RegSysCredentialsAuthenticationProvider _regSysCredentialsAuthenticationProvider;
private readonly RegSysAlternativePinAuthenticationProvider _regSysAlternativePinAuthenticationProvider;

private readonly IAuthenticationProvider[] _authenticationProviders;

public AuthenticationHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ public RegSysAlternativePinAuthenticationProvider(IEntityRepository<RegSysAltern

private string GeneratePin()
{
var validLetters = "ABCDEFGHJKLNPQRSTUVWXYZ";
var r = new Random();

return $"{r.Next(100000, 999999)}";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ILoggerFactory loggerFactory

public async Task CommandFursuitBadge()
{
Func<Task> c1 = null, c2 = null, c3 = null;
Func<Task> c1 = null;
var title = "Fursuit Badge";

c1 = () => AskAsync($"*{title} - Step 1 of 1*\nType in the fursuit badge number.",
Expand Down Expand Up @@ -189,7 +189,7 @@ await ReplyAsync(

public async Task CommandBadgeChecksum()
{
Func<Task> c1 = null, c2 = null, c3 = null;
Func<Task> c1 = null;
var title = "Badge Checksum";

c1 = () => AskAsync($"*{title} - Step 1 of 1*\nWhat's the _registration number_?",
Expand Down Expand Up @@ -287,7 +287,7 @@ await _privateMessageService.SendPrivateMessageAsync(new SendPrivateMessageReque

public async Task CommandLocate()
{
Func<Task> c1 = null, c2 = null, c3 = null;
Func<Task> c1 = null;
var title = "Locate User";

c1 = () => AskAsync($"*{title} - Step 1 of 1*\nWhat's the attendees _registration number (including the letter at the end)_ on the badge?",
Expand Down Expand Up @@ -498,7 +498,7 @@ public async Task ReplyAsync(string message, params string[] commandOptions)

private async Task CommandPinInfo()
{
Func<Task> c1 = null, c2 = null, c3 = null;
Func<Task> c1 = null;
var title = "PIN Info";

c1 = () => AskAsync($"*{title} - Step 1 of 1*\nWhat's the attendees _registration number (including the letter at the end)_ on the badge?",
Expand Down Expand Up @@ -685,8 +685,10 @@ private Task ClearLastAskResponseOptions()
{
if (_lastAskMessage != null) return ClearInlineResponseOptions(_lastAskMessage.MessageId);
}
catch (Exception e)
catch (Exception ex)
{
_logger.LogError("ClearLastAskResponseOptions failed: {Message} {StackTrace}",
ex.Message, ex.StackTrace);
}

return Task.CompletedTask;
Expand Down
12 changes: 9 additions & 3 deletions src/Eurofurence.App.Server.Services/Telegram/BotManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ await _botClient.AnswerInlineQueryAsync(
results,
cacheTime: 0);
}
catch (Exception e)
catch (Exception ex)
{
_logger.LogError("BotClientOnOnInlineQuery failed: {Message} {StackTrace}",
ex.Message, ex.StackTrace);
}
}

Expand Down Expand Up @@ -283,8 +285,10 @@ private async void BotClientOnOnCallbackQuery(object sender, CallbackQueryEventA

await _conversationManager[e.CallbackQuery.From.Id].OnCallbackQueryAsync(e);
}
catch (Exception exception)
catch (Exception ex)
{
_logger.LogError("BotClientOnOnCallbackQuery failed: {Message} {StackTrace}",
ex.Message, ex.StackTrace);
}
}

Expand All @@ -294,8 +298,10 @@ private async void BotClientOnOnMessage(object sender, MessageEventArgs e)
{
await _conversationManager[e.Message.From.Id].OnMessageAsync(e);
}
catch (Exception exception)
catch (Exception ex)
{
_logger.LogError("BotClientOnOnMessage failed: {Message} {StackTrace}",
ex.Message, ex.StackTrace);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Eurofurence.App.Server.Web/Controllers/MapsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public async Task<ActionResult> DeleteSingleMapEntryAsync([FromRoute] Guid Id, [
/// </summary>
/// <remarks>If you can generate guids client-side, you can also use the PUT variant for both create and update.</remarks>
/// <param name="Record">Do not specify the "Id" property. It will be auto-assigned and returned in the response.</param>
/// <param name="Id">"Id" of the map</param>
/// <returns>The id of the new map entry (guid)</returns>
/// <response code="400">
/// * Unable to parse `Record` or `Id`
Expand All @@ -159,7 +160,8 @@ public async Task<ActionResult> PostSingleMapEntryAsync([FromBody] MapEntryRecor
/// model (request body) must match the {EntryId} part of the uri.
/// </remarks>
/// <param name="Record">"Id" property must match the {EntryId} part of the uri</param>
/// <param>FindMeAgain</param>
/// <param name="Id">"Id" of the map.</param>
/// <param name="EntryId">"Id" of the entry that gets inserted.</param>
/// <response code="400">
/// * Unable to parse `Record`, `Id` or `EntryId`
/// * `Record.Id` does not match `EntryId` from uri.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class SyncController
private readonly IEventConferenceRoomService _eventConferenceRoomService;
private readonly IEventConferenceTrackService _eventConferenceTrackService;
private readonly IEventService _eventService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IImageService _imageService;
private readonly IKnowledgeEntryService _knowledgeEntryService;
private readonly IKnowledgeGroupService _knowledgeGroupService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,8 @@ private void ImportLinks(DealerRecord dealerRecord, string websiteUrls)
assumedUri = $"http://{part}";

if (Uri.IsWellFormedUriString(assumedUri, UriKind.Absolute))
linkFragments.Add(new LinkFragment
{
FragmentType = LinkFragment.FragmentTypeEnum.WebExternal,
Target = assumedUri
});
linkFragments.Add(new LinkFragment(LinkFragment.FragmentTypeEnum.WebExternal, string.Empty,
assumedUri));
}

dealerRecord.Links = linkFragments.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ private async Task<int> CleanUpImagesAsync(List<KnowledgeEntryRecord> knowledgeE
int modifiedRecords = 0;
var usedImageIds = knowledgeEntries.SelectMany(a => a.ImageIds).Distinct().ToList();

#pragma warning disable RECS0063 // Warns when a culture-aware 'StartsWith' call is used by default.
var knowledgeImages =
await _imageService.FindAllAsync(a => a.IsDeleted == 0 &&
a.InternalReference.StartsWith("knowledge:"));
#pragma warning restore RECS0063 // Warns when a culture-aware 'StartsWith' call is used by default.

foreach (var image in knowledgeImages)
{
Expand Down Expand Up @@ -149,12 +151,10 @@ private async Task ProcessLinksAsync(KnowledgeEntryRecord knowledgeEntry, string

if (Uri.IsWellFormedUriString(target, UriKind.Absolute))
{
linkFragments.Add(new LinkFragment()
{
FragmentType = LinkFragment.FragmentTypeEnum.WebExternal,
Name = name,
Target = target,
});
linkFragments.Add(new LinkFragment(
LinkFragment.FragmentTypeEnum.WebExternal,
name,
target));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,8 @@ private void ImportLinks(DealerRecord dealerRecord, string websiteUrls)
assumedUri = $"http://{part}";

if (Uri.IsWellFormedUriString(assumedUri, UriKind.Absolute))
linkFragments.Add(new LinkFragment
{
FragmentType = LinkFragment.FragmentTypeEnum.WebExternal,
Target = assumedUri
});
linkFragments.Add(new LinkFragment(LinkFragment.FragmentTypeEnum.WebExternal,string.Empty,
assumedUri));
}

dealerRecord.Links = linkFragments.ToArray();
Expand Down

0 comments on commit 2e9046b

Please sign in to comment.