Skip to content

Commit

Permalink
Merge pull request #12 from bb-io/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bohdanm-bb authored May 15, 2024
2 parents 9ce3617 + e5db727 commit a2a92b8
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Apps.BWX/Apps.BWX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Product>Bureau Works</Product>
<Version>1.0.9</Version>
<Version>1.0.10</Version>
<Description>Bureau Works is cutting edge translation software that helps its users translate at greater speeds and with an increased sense of authorship.</Description>
<AssemblyName>Apps.BWX</AssemblyName>
</PropertyGroup>
Expand Down
29 changes: 29 additions & 0 deletions Apps.BWX/Converters/DateTimeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apps.BWX.Converters
{
public class DateTimeConverter : JsonConverter<DateTime>
{
public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Integer)
{
DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return start.AddMilliseconds(long.Parse(reader.Value.ToString())).ToLocalTime();
}

throw new JsonException("The JSON value could not be converted to DateTime.");
}

public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString());
}
}
}
10 changes: 6 additions & 4 deletions Apps.BWX/Webhooks/Payload/NewProjectEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blackbird.Applications.Sdk.Common;
using Apps.BWX.Converters;
using Blackbird.Applications.Sdk.Common;
using Newtonsoft.Json;

namespace Apps.BWX.Webhooks.Payload;
Expand All @@ -9,9 +10,10 @@ public class NewProjectEvent
[JsonProperty("uuid")]
public string Uuid { get; set; }

//[Display("Creation timestamp")]
//[JsonProperty("creation_timestamp")]
//public long CreationTimestamp { get; set; }
[Display("Creation date")]
[JsonProperty("creation_timestamp")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime CreationTimestamp { get; set; }

[JsonProperty("creator")]
public string Creator { get; set; }
Expand Down
10 changes: 6 additions & 4 deletions Apps.BWX/Webhooks/Payload/ProjectStatusChangedPayload.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blackbird.Applications.Sdk.Common;
using Apps.BWX.Converters;
using Blackbird.Applications.Sdk.Common;
using Newtonsoft.Json;

namespace Apps.BWX.Webhooks.Payload;
Expand All @@ -9,9 +10,10 @@ public class ProjectStatusChangedPayload
[JsonProperty("uuid")]
public string Uuid { get; set; }

//[Display("Creation timestamp")]
//[JsonProperty("creation_timestamp")]
//public long CreationTimestamp { get; set; }
[Display("Creation date")]
[JsonProperty("creation_timestamp")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime CreationTimestamp { get; set; }
public string Creator { get; set; }

[Display("Creator email")]
Expand Down
52 changes: 30 additions & 22 deletions Apps.BWX/Webhooks/Payload/TaskAssignedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Blackbird.Applications.Sdk.Common;
using Apps.BWX.Converters;
using Blackbird.Applications.Sdk.Common;
using Newtonsoft.Json;

namespace Apps.BWX.Webhooks.Payload;
Expand All @@ -9,13 +10,15 @@ public class TaskAssignedEvent
[JsonProperty("uuid")]
public string Uuid { get; set; }

//[Display("Acceptance date")]
//[JsonProperty("acceptance_date")]
//public long AcceptanceDate { get; set; }
[Display("Acceptance date")]
[JsonProperty("acceptance_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime AcceptanceDate { get; set; }

//[Display("Assign date")]
//[JsonProperty("assign_date")]
//public long AssignDate { get; set; }
[Display("Assign date")]
[JsonProperty("assign_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime AssignDate { get; set; }

[Display("Assigned by email")]
[JsonProperty("assigned_by_email")]
Expand All @@ -40,9 +43,10 @@ public class TaskAssignedEvent
[JsonProperty("begin_index", NullValueHandling = NullValueHandling.Ignore)]
public long BeginIndex { get; set; }

//[Display("Creation timestamp")]
//[JsonProperty("creation_timestamp")]
//public long CreationTimestamp { get; set; }
[Display("Creation date")]
[JsonProperty("creation_timestamp")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime CreationTimestamp { get; set; }

[JsonProperty("creator")]
public string Creator { get; set; }
Expand All @@ -51,13 +55,15 @@ public class TaskAssignedEvent
[JsonProperty("creator_email")]
public string CreatorEmail { get; set; }

//[Display("Delivery date")]
//[JsonProperty("delivery_date")]
//public long DeliveryDate { get; set; }
[Display("Delivery date")]
[JsonProperty("delivery_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime DeliveryDate { get; set; }

//[Display("Due date")]
//[JsonProperty("due_date")]
//public long DueDate { get; set; }
[Display("Due date")]
[JsonProperty("due_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime DueDate { get; set; }

//[Display("End index")]
//[JsonProperty("end_index")]
Expand Down Expand Up @@ -88,13 +94,15 @@ public class TaskAssignedEvent
[JsonProperty("reference_files")]
public List<string> ReferenceFiles { get; set; }

//[Display("Scheduled date")]
//[JsonProperty("scheduled_date")]
//public long ScheduledDate { get; set; }
[Display("Scheduled date")]
[JsonProperty("scheduled_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime ScheduledDate { get; set; }

//[Display("Skip date")]
//[JsonProperty("skip_date")]
//public long SkipDate { get; set; }
[Display("Skip date")]
[JsonProperty("skip_date")]
[JsonConverter(typeof(DateTimeConverter))]
public DateTime SkipDate { get; set; }

[JsonProperty("status")]
public string Status { get; set; }
Expand Down

0 comments on commit a2a92b8

Please sign in to comment.