Skip to content

Commit

Permalink
added spouse mobile number, improved data parsing, bump assembly vers…
Browse files Browse the repository at this point in the history
…ion to 1.2
  • Loading branch information
monemihir committed Oct 8, 2018
1 parent 0baa7a9 commit 445f216
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/MMVICReportGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<AssemblyVersion>1.1.2.6626</AssemblyVersion>
<AssemblyVersion>1.2.18.6855</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
16 changes: 14 additions & 2 deletions src/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public MainForm()
m_dataProcessor = new DataProcessor();
m_dataProcessor.RegisterObserver(this);

mdReportHeader.Text = "MMVIC Members Directory " + DateTime.Now.Year;

if (!Settings.Default.EnableTestMode)
return;

Expand All @@ -65,8 +67,6 @@ public MainForm()
// set defaults for member directory tab
mdInputFile.Text = Path.Combine(Constants.Paths.CacheDirectory, Constants.SampleMembershipDataFileName);
mdOutputFolder.Text = GetDownloadsPath();
mdReportHeader.Text = "MMVIC Members Directory " + DateTime.Now.Year;


Random rand = new Random(DateTime.Now.Millisecond);

Expand Down Expand Up @@ -119,6 +119,12 @@ private void btnSelectXLSConvertInputFile_Click(object sender, EventArgs e)
selectFileDialog.ShowDialog();

xlsConvertInputFile.Text = selectFileDialog.FileName;

if (!string.IsNullOrEmpty(xlsConvertOutputFolder.Text))
return;

string directory = Path.GetDirectoryName(xlsConvertInputFile.Text);
xlsConvertOutputFolder.Text = directory;
}

private void btnSelectXLSConvertOutputFolder_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -184,6 +190,12 @@ private void btnSelectMDInputFile_Click(object sender, EventArgs e)
selectFileDialog.ShowDialog();

mdInputFile.Text = selectFileDialog.FileName;

if (!string.IsNullOrEmpty(mdOutputFolder.Text))
return;

string directory = Path.GetDirectoryName(mdInputFile.Text);
mdOutputFolder.Text = directory;
}

private void btnSelectMDOutputFolder_Click(object sender, EventArgs e)
Expand Down
45 changes: 38 additions & 7 deletions src/Models/Membership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using WebExtras.Core;
using WebExtras.FontAwesome;
using WebExtras.Html;
Expand All @@ -44,6 +45,7 @@ public class Membership
public int PostCode { get; set; }
public string TelNo { get; set; }
public string MobileNo { get; set; }
public string SpouseMobileNo { get; set; }
public string Email1 { get; set; }
public string Email2 { get; set; }
public DateTime PaymentDate { get; set; }
Expand All @@ -59,7 +61,7 @@ public Membership()

public override int GetHashCode()
{
List<string> current = new List<string>(Children) {LastName, FirstName, SpouseName};
List<string> current = new List<string>(Children) { LastName, FirstName, SpouseName };

return string.Join("", current).GetHashCode();
}
Expand All @@ -70,8 +72,8 @@ public override bool Equals(object obj)
if (casted == null)
return false;

List<string> left = new List<string>(Children) {LastName, FirstName, SpouseName};
List<string> right = new List<string>(casted.Children) {casted.LastName, casted.FirstName, casted.SpouseName};
List<string> left = new List<string>(Children) { LastName, FirstName, SpouseName };
List<string> right = new List<string>(casted.Children) { casted.LastName, casted.FirstName, casted.SpouseName };

return string.Join("", left) == string.Join("", right);
}
Expand Down Expand Up @@ -109,7 +111,7 @@ public static Membership[] ProcessFile(string membershipPsvFilePath)

if (prop.PropertyType.IsArray)
{
string[] data = buff[i].Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries);
string[] data = buff[i].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

prop.SetValue(order, data);
}
Expand Down Expand Up @@ -144,6 +146,7 @@ public string ToPsvRow()
PostCode.ToString(),
TelNo,
MobileNo,
SpouseMobileNo,
Email1,
Email2,
PaymentDate.ToString(Constants.DateTimeIsoFormat),
Expand All @@ -160,10 +163,18 @@ public string ToPsvRow()
/// <returns>Sanitized name</returns>
private string SanitizeName(string name)
{
string[] lookup = {LastName, FirstName, "and", "&"};
string[] lookup = { LastName, FirstName, "&", "/", "\\" };

Array.ForEach(lookup, str => { name = name.Replace(str, string.Empty).Trim(); });

name = Regex.Replace(name, @"[\d-]", string.Empty);

if (name.Equals("na", StringComparison.OrdinalIgnoreCase))
name = string.Empty;

if (name.Equals("and", StringComparison.OrdinalIgnoreCase))
name = string.Empty;

return name.ToTitleCase();
}

Expand Down Expand Up @@ -216,9 +227,14 @@ public HtmlDiv ToHtmlComponent()

if (Children.Any())
{
HtmlDiv children = new HtmlDiv(string.Join(", ", Children.Select(c => string.Join(", ", SanitizeName(c).Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)))));
string childrenNames = string.Join(", ", Children.Select(c => string.Join(", ", SanitizeName(c).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))));

HtmlDiv children = new HtmlDiv(childrenNames);
children.CssClasses.Add("strong");
div.AppendTags.Add(children);

if (string.IsNullOrEmpty(childrenNames))
div.AppendTags.Add(br);
}
else
div.AppendTags.Add(br);
Expand All @@ -230,7 +246,22 @@ public HtmlDiv ToHtmlComponent()

div.AppendTags.Add(br);

HtmlDiv phone = new HtmlDiv("Tel: " + TelNo + "<br>" + "Mobile: " + MobileNo);
if (TelNo == MobileNo || TelNo == SpouseMobileNo)
TelNo = string.Empty;

if (!MobileNo.StartsWith("+61") && !MobileNo.StartsWith("0"))
MobileNo = "0" + MobileNo;

string numbers = "Tel: " + TelNo + "<br>" + "Mobile: " + MobileNo;
if (!string.IsNullOrEmpty(SpouseMobileNo))
{
if (!SpouseMobileNo.StartsWith("+61") && !SpouseMobileNo.StartsWith("0"))
SpouseMobileNo = "0" + SpouseMobileNo;
if (MobileNo != SpouseMobileNo)
numbers += ", " + SpouseMobileNo;
}

HtmlDiv phone = new HtmlDiv(numbers);
div.AppendTags.Add(phone);

return div;
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2.6626")]
[assembly: AssemblyFileVersion("1.1.2.6626")]
[assembly: AssemblyVersion("1.2.18.6855")]
[assembly: AssemblyFileVersion("1.2.18.6855")]

0 comments on commit 445f216

Please sign in to comment.