public static ProjectDatabaseModel ConvertCwsToWorksOSProject(ProjectDetailResponseModel project, ILogger log) { log.LogInformation($"{nameof(ConvertCwsToWorksOSProject)} project {JsonConvert.SerializeObject(project)}"); var extractedCalibrationFileOk = false; var coordinateSystemFileName = string.Empty; DateTime?coordinateSystemLastActionedUtc = null; if (project.ProjectSettings?.Config != null && project.ProjectSettings.Config.Any()) { extractedCalibrationFileOk = ExtractCalibrationFileDetails(project.ProjectSettings.Config, out coordinateSystemFileName, out coordinateSystemLastActionedUtc); } if (project.ProjectSettings?.Boundary == null || project.ProjectSettings?.TimeZone == null) { log.LogInformation($"{nameof(ConvertCwsToWorksOSProject)} contains no boundary or timezone"); } if (!extractedCalibrationFileOk) { log.LogInformation($"{nameof(ConvertCwsToWorksOSProject)} contains no calibrationFile."); } var projectDatabaseModel = new ProjectDatabaseModel() { ProjectUID = project.ProjectId, CustomerUID = project.AccountId, Name = project.ProjectName, ProjectType = project.ProjectType, UserProjectRole = project.UserProjectRole, ProjectTimeZone = project.ProjectSettings != null?PreferencesTimeZones.IanaToWindows(project.ProjectSettings.TimeZone) : string.Empty, ProjectTimeZoneIana = project.ProjectSettings?.TimeZone, Boundary = project.ProjectSettings?.Boundary != null?GeometryConversion.ProjectBoundaryToWKT(project.ProjectSettings.Boundary) : string.Empty, CoordinateSystemFileName = coordinateSystemFileName, CoordinateSystemLastActionedUTC = coordinateSystemLastActionedUtc, IsArchived = project.Status == ProjectStatus.Archived, LastActionedUTC = project.LastUpdate ?? DateTime.UtcNow }; return(projectDatabaseModel); }
public void IanaToWindows_ValidIanaTimeZone() { Assert.Equal("New Zealand Standard Time", PreferencesTimeZones.IanaToWindows("Pacific/Auckland")); }
public void IanaToWindows_InvalidIanaTimeZone() { Assert.Null(PreferencesTimeZones.IanaToWindows("Pacific/Wellington")); }
public void IanaToWindows_MissingIanaTimeZone() { Assert.Equal(string.Empty, PreferencesTimeZones.IanaToWindows(null)); }