Skip to content

Commit

Permalink
PMN-2023.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
PopMedNet-Team committed Jan 23, 2023
1 parent 216bfeb commit bc147ca
Show file tree
Hide file tree
Showing 42 changed files with 889 additions and 210 deletions.
8 changes: 4 additions & 4 deletions Build/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

[assembly: AssemblyCompany("Harvard Pilgrim Health Care Institute")]
[assembly: AssemblyProduct("Distributed Network Solution")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2022")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2023")]
[assembly: ComVisible(false)]
//Please Also update The Click Once version under Lpp.Dns.DataMartClient Properties > publish > Version Number
[assembly: AssemblyVersion( /*<VERSION>*/ "7.7.0.0" /*</VERSION>*/ )]
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.7.0.0" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2022.3")]
[assembly: AssemblyVersion( /*<VERSION>*/ "7.9.0.0" /*</VERSION>*/ )]
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.9.0.0" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2023.1")]
8 changes: 4 additions & 4 deletions Build/DataMartClientCommonAssemlbyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

[assembly: AssemblyCompany("Harvard Pilgrim Health Care Institute")]
[assembly: AssemblyProduct("Distributed Network Solution")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2022")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2023")]
[assembly: ComVisible(false)]
//Please Also update The Click Once version under Lpp.Dns.DataMartClient Properties > publish > Version Number
[assembly: AssemblyVersion( /*<VERSION>*/ "7.7.0.0" /*</VERSION>*/ )]
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.7.0.0" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2022.3")]
[assembly: AssemblyVersion( /*<VERSION>*/ "7.9.0.0" /*</VERSION>*/ )]
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.9.0.0" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2023.1")]
8 changes: 4 additions & 4 deletions Build/DomainManagerCommonAssemlbyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using System.Runtime.InteropServices;

[assembly: AssemblyProduct("Distributed Network Solution")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2022")]
[assembly: AssemblyCopyright("Copyright © PopMedNet 2011-2023")]
[assembly: ComVisible(false)]

[assembly: AssemblyVersion( /*<VERSION>*/ "7.7.0.*" /*</VERSION>*/ )]
[assembly: AssemblyVersion( /*<VERSION>*/ "7.9.0.*" /*</VERSION>*/ )]

//Need to keep the file private part equal to 3000 or above for RavenDB as Embedded usage in adapter packages.
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.7.0.3000" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2022.3")]
[assembly: AssemblyFileVersion( /*<VERSION>*/ "7.9.0.3000" /*</VERSION>*/ )]
[assembly: AssemblyInformationalVersion("2023.1")]
Binary file not shown.
71 changes: 56 additions & 15 deletions Lpp.Dns.Api/Projects/ProjectActivitiesUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Lpp.Dns.Data;
using Lpp.Dns.DTO;
using Lpp.Utilities;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand Down Expand Up @@ -93,9 +96,13 @@ public async Task DoUpdate(Guid projectID)
{
List<DTO.TaskOrderImportDTO> importList = await LoadImport();

if (importList.Count == 0)
if (importList==null || importList.Count==0)
{
return;
var msg = $"Empty or null import list returned during sync with {serviceUrl}";
Logger.Error(msg);
Debug.WriteLine(msg);
// TODO: Notify PMN admins that no items were imported.
throw new NullReferenceException(msg);
}

Logger.Debug("Loading existing activities and determining if each activity is associated with one or more requests.");
Expand Down Expand Up @@ -143,7 +150,9 @@ public async Task DoUpdate(Guid projectID)
//determine the ones that need to be deleted
IEnumerable<Activity> activitiesToDelete = (from a in existingActivities
where a.ParentActivityID == taskOrder.ID && a.TaskLevel == 2
&& !taskOrderToImport.Activities.Any(aa => string.Equals((string.IsNullOrWhiteSpace(aa.Name) ? aa.Acronym : aa.Name), a.Name, StringComparison.OrdinalIgnoreCase))
&& !taskOrderToImport.Activities
.Any(aa => string.Equals((string.IsNullOrWhiteSpace(aa.Name) ? aa.Acronym : aa.Name)
, a.Name, StringComparison.OrdinalIgnoreCase))
select a).ToArray();

DeleteActivities(activitiesToDelete, existingActivities, hasRequests, toDelete.Add, null);
Expand Down Expand Up @@ -183,7 +192,9 @@ public async Task DoUpdate(Guid projectID)
//remove the sub-activities that do not exist in the update.
IEnumerable<Activity> activityProjectsToDelete = (from a in existingActivities
where a.ParentActivityID == childActivity.ID && a.TaskLevel == 3
&& !activityToImport.Activities.Any(aa => string.Equals((string.IsNullOrWhiteSpace(aa.Name) ? aa.Acronym : aa.Name), a.Name, StringComparison.OrdinalIgnoreCase))
&& !activityToImport.Activities
.Any(aa => string.Equals((string.IsNullOrWhiteSpace(aa.Name) ? aa.Acronym : aa.Name)
, a.Name, StringComparison.OrdinalIgnoreCase))
select a).ToArray();

DeleteActivityProjects(activityProjectsToDelete, existingActivities, hasRequests, toDelete.Add, null);
Expand Down Expand Up @@ -238,32 +249,62 @@ public async Task DoUpdate(Guid projectID)

async Task<List<DTO.TaskOrderImportDTO>> LoadImport()
{
var errors = new List<string>();
try
{
using (var web = new HttpClient())
{
web.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(serviceUsername + ":" + servicePassword)));
web.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic",
Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(serviceUsername + ":" + servicePassword)));

Logger.Debug("Beginning request of import list from: " + serviceUrl);

using (var stream = await web.GetStreamAsync(serviceUrl))
using (var jReader = new Newtonsoft.Json.JsonTextReader(new System.IO.StreamReader(stream)))
using (var streamReader = new StreamReader(stream))
{
var serializer = Newtonsoft.Json.JsonSerializer.CreateDefault();
var serializer = new JsonSerializer();
var errorHandler = new JsonSerializerSettings()
{
Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
{
if (args.CurrentObject == args.ErrorContext.OriginalObject)
{
errors.Add(args.ErrorContext.Error.Message);
Debug.WriteLine($"Error thrown deserializing object.");
}
}
};

Logger.Debug("Deserializing import list from: " + serviceUrl);
return serializer.Deserialize<List<DTO.TaskOrderImportDTO>>(jReader);
Logger.Debug($"Deserializing import list from: {serviceUrl}");
Debug.WriteLine($"Deserializing import list from: {serviceUrl}");
var stringResult = await streamReader.ReadToEndAsync();
Debug.Write(stringResult);

return JsonConvert.DeserializeObject<List<DTO.TaskOrderImportDTO>>(stringResult, errorHandler);
//return serializer.Deserialize<List<DTO.TaskOrderImportDTO>>(jReader);
}
}
}
catch (HttpRequestException httpex)
catch (JsonSerializationException ex)
{
Logger.Error("Error getting activities from external service: " + serviceUrl, httpex);

StatusCode = HttpStatusCode.ServiceUnavailable;
StatusMessage = "There was an error communicating with the external service.";
var msg = $"There was an issue deserializing the JSON received from {serviceUrl}: {ex.Message}";
Logger.Error(ex.UnwindException());
Debug.WriteLine(msg);
throw;
}
catch (HttpRequestException ex) // Should handle NotFound and Unauthorized
{
var msg = $"There was an issue getting information from {serviceUrl}.";
Debug.Write($"{msg}... \n{ex.UnwindException()}");
Logger.Error($"{msg}... \n{ex.UnwindException()}");
throw;
}

return new List<DTO.TaskOrderImportDTO>();
catch (Exception ex)
{
Logger.Error($"Error... {ex.UnwindException()}");
Debug.WriteLine(ex.UnwindException());
throw;
}
}

Expand Down
7 changes: 5 additions & 2 deletions Lpp.Dns.Api/Projects/ProjectsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,17 @@ public async Task<HttpResponseMessage> UpdateActivities(Guid ID, string username

if (string.IsNullOrEmpty(serviceUrl) || string.IsNullOrEmpty(serviceUser) || string.IsNullOrEmpty(servicePassword))
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "External service configuration is incomplete, make sure the service url and credentials have been configured correctly.");
return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
"External service configuration is incomplete, make sure the service url and credentials have been configured correctly.");
}

var updater = new ProjectActivitiesUpdater(DataContext, serviceUrl, serviceUser, servicePassword);

if (!await updater.CanUpdate(userID.Value, ID))
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Unable to determine project, confirm that the specified project ID is correct for an Active project and that the user has permission to Update Activities for the project.");
return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
$"Unable to determine project. " +
$"confirm that the specified project ID is correct for an Active project and that the user {username} has permission to Update Activities for the project.");
}

await updater.DoUpdate(ID);
Expand Down

0 comments on commit bc147ca

Please sign in to comment.