Skip to content

Commit

Permalink
Merge pull request #176 from openimis/feature/OP-940
Browse files Browse the repository at this point in the history
OP-940 Test mobiles apps on release server (22.10 Release)
  • Loading branch information
delcroip authored Nov 10, 2022
2 parents 90d5d93 + 01dd563 commit 338c051
Show file tree
Hide file tree
Showing 34 changed files with 78 additions and 168 deletions.
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/ClaimModule/Models/ClaimOutPut.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand Down
20 changes: 6 additions & 14 deletions OpenImis.ModulesV3/ClaimModule/Models/ClaimsModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers.Validators;
using OpenImis.ModulesV3.Utils;
using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand All @@ -14,17 +10,13 @@ public class ClaimsModel
[Required]
public string claim_administrator_code { get; set; }
public ClaimStatus status_claim { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid visit_date_from")]
public DateTime? visit_date_from { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid visit_date_to")]
public DateTime? visit_date_to { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid processed_date_from")]
public DateTime? processed_date_from { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid processed_date_to")]
public DateTime? processed_date_to { get; set; }
}

Expand Down
7 changes: 1 addition & 6 deletions OpenImis.ModulesV3/ClaimModule/Models/DsiInputModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@

using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers.Validators;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;

Expand Down
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/FeedbackModule/Models/Feedback.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.FeedbackModule.Models
{
Expand Down
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/FeedbackModule/Models/FeedbackRequest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.FeedbackModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace OpenImis.RestApi.Util.ErrorHandling
namespace OpenImis.ModulesV3.Helpers
{
/// <summary>
/// Exception for business related errors. It's error message will be included in the payload.
Expand Down
13 changes: 13 additions & 0 deletions OpenImis.ModulesV3/Helpers/DateTimeFormats.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.Helpers
{
public static class DateTimeFormats
{
public const string IsoDateFormat = "yyyy-MM-dd";
public const string IsoDateTimeFormat = "yyyy-MM-ddTHH:mm:ss";
public const string FileNameDateTimeFormat = "yyyy-MM-ddTHH-mm-ss";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,42 @@
using System.Text;
using System.Xml;

namespace OpenImis.ModulesV3.Utils
namespace OpenImis.ModulesV3.Helpers
{
public static class DateTimeFormats
{
public static CultureInfo cultureInfo = CultureInfo.InvariantCulture;
public const string IsoDateFormat = "yyyy-MM-dd";
public const string IsoDateTimeFormat = "yyyy-MM-ddTHH:mm:ss";
public const string FileNameDateTimeFormat = "yyyy-MM-ddTHH-mm-ss";

}

public class CustomFormatDatetimeSerializer : JsonConverter<DateTime>
public class CustomFormatDatetimeSerializer : JsonConverter<DateTime?>
{
protected string format;
protected string errorMessage;

public CustomFormatDatetimeSerializer(string format)
{
this.format = format;
this.errorMessage = "Invalid datetime field";
}

public CustomFormatDatetimeSerializer(string format, string errorMessage)
{
this.format = format;
this.errorMessage = errorMessage;
}

public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue, JsonSerializer serializer)
public override DateTime? ReadJson(JsonReader reader, Type objectType, DateTime? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
return DateTime.ParseExact(reader.Value.ToString(), this.format, DateTimeFormats.cultureInfo);
if (DateTime.TryParseExact(reader.Value.ToString(), format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dt))
{
return dt;
}
else
{
throw new BusinessException(errorMessage);
}
}

public override void WriteJson(JsonWriter writer, DateTime value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, DateTime? value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString(this.format, DateTimeFormats.cultureInfo));
DateTime dt = value ?? new DateTime();
writer.WriteValue(dt.ToString(format, CultureInfo.InvariantCulture));

}
}

Expand All @@ -41,11 +49,16 @@ public class IsoDateSerializer : CustomFormatDatetimeSerializer
public IsoDateSerializer() : base(DateTimeFormats.IsoDateFormat)
{
}

public IsoDateSerializer(string errorMessage) : base(DateTimeFormats.IsoDateFormat, errorMessage)
{
}
}

public class ImisSPXmlWriter : XmlTextWriter
{
public ImisSPXmlWriter(TextWriter writer) : base(writer) {
public ImisSPXmlWriter(TextWriter writer) : base(writer)
{
}
public ImisSPXmlWriter(Stream stream, Encoding encoding) : base(stream, encoding) { }
public ImisSPXmlWriter(string filename, Encoding encoding) : base(filename, encoding) { }
Expand All @@ -55,7 +68,7 @@ public override void WriteRaw(string data)
DateTime dt;

if (DateTime.TryParse(data, out dt))
base.WriteRaw(dt.ToString(DateTimeFormats.IsoDateFormat, DateTimeFormats.cultureInfo));
base.WriteRaw(dt.ToString(DateTimeFormats.IsoDateFormat, CultureInfo.InvariantCulture));
else
base.WriteRaw(data);
}
Expand Down
46 changes: 0 additions & 46 deletions OpenImis.ModulesV3/Helpers/Validators/ValidDateAttribute.cs

This file was deleted.

4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/InsureeModule/Models/DetailModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.InsureeModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.InsureeModule.Models.EnrollFamilyModels
{
Expand Down
5 changes: 1 addition & 4 deletions OpenImis.ModulesV3/InsureeModule/Models/GetInsureeModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;

namespace OpenImis.ModulesV3.InsureeModule.Models
{
Expand All @@ -17,6 +15,5 @@ public class GetInsureeModel
public string PhotoBase64 { get; set; }
public string OtherNames { get; set; }
public string LastName { get; set; }

}
}
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/InsureeModule/Models/InsureeModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Newtonsoft.Json;
using OpenImis.DB.SqlServer;
using OpenImis.ModulesV3.Helpers;
using OpenImis.ModulesV3.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace OpenImis.ModulesV3.InsureeModule.Models
{
Expand Down
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/MasterDataModule/Models/OfficerModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.MasterDataModule.Models
{
Expand Down
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/MasterDataModule/Models/ProductModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.MasterDataModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.PolicyModule.Models
{
Expand Down
7 changes: 1 addition & 6 deletions OpenImis.ModulesV3/PolicyModule/Models/PolicyRenewalModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.PolicyModule.Models
{
Expand All @@ -14,15 +12,12 @@ public class PolicyRenewalModel
public string ReceiptNo { get; set; }
public string ProductCode { get; set; }
public float Amount { get; set; }

[JsonConverter(typeof(IsoDateSerializer))]
public DateTime Date { get; set; }
public bool Discontinue { get; set; }
public int PayerId { get; set; }

public string ControlNumber { get; set; }


public Policy GetPolicy()
{
return new Policy()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.ReportModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenImis.ModulesV3.ReportModule.Models
{
Expand Down
1 change: 0 additions & 1 deletion OpenImis.ModulesV3/Utils/LinqExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpenImis.ModulesV3.Utils
{
Expand Down
2 changes: 0 additions & 2 deletions OpenImis.ModulesV3/Utils/PhotoUtils.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Extensions.Logging;

namespace OpenImis.ModulesV3.Utils
Expand Down
2 changes: 0 additions & 2 deletions OpenImis.ModulesV3/Utils/Repository.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using OpenImis.DB.SqlServer;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace OpenImis.ModulesV3.Utils
{
Expand Down
Loading

0 comments on commit 338c051

Please sign in to comment.