Small fixes.
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using MileageTraker.Web.Utility;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Web.Tests.DAL
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CityNameCleaner
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
[Ignore]
|
||||||
|
public void Clean()
|
||||||
|
{
|
||||||
|
const string cityFilename = @"C:\Temp\cities.csv";
|
||||||
|
const string unknownCityFilename = @"C:\Temp\cities_unknown.csv";
|
||||||
|
var unknownCities =
|
||||||
|
from line in File.ReadAllLines(unknownCityFilename)
|
||||||
|
select new {CityName = line, First = (line.Split(',')).FirstOrDefault()};
|
||||||
|
var cities =
|
||||||
|
File.ReadAllLines(cityFilename);
|
||||||
|
|
||||||
|
var b =
|
||||||
|
from uc in unknownCities
|
||||||
|
let topMatch = (
|
||||||
|
from c in cities
|
||||||
|
let s = Algorithms.Similarity(uc.First, c)
|
||||||
|
orderby s descending
|
||||||
|
select new { c, s }).First()
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
uc.CityName, topMatch.c, topMatch.s
|
||||||
|
};
|
||||||
|
foreach (var l in b)
|
||||||
|
{
|
||||||
|
Console.WriteLine(
|
||||||
|
"UPDATE Log SET Notes=LEFT(CASE WHEN Notes IS NULL THEN CityName ELSE Notes + ', ' + CityName END, 64)" +
|
||||||
|
", CityName='{1}' " +
|
||||||
|
"WHERE CityName='{0}'",
|
||||||
|
l.CityName.Replace("'", "''"), l.c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -92,6 +92,7 @@
|
|||||||
</CodeAnalysisDependentAssemblyPaths>
|
</CodeAnalysisDependentAssemblyPaths>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="DAL\CityNameCleaner.cs" />
|
||||||
<Compile Include="DAL\LogImporterTests.cs" />
|
<Compile Include="DAL\LogImporterTests.cs" />
|
||||||
<Compile Include="DAL\LogImportTemplateWriterTests.cs" />
|
<Compile Include="DAL\LogImportTemplateWriterTests.cs" />
|
||||||
<Compile Include="DAL\UserImporterTests.cs" />
|
<Compile Include="DAL\UserImporterTests.cs" />
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace MileageTraker.Web.Models
|
|||||||
[InputSize("medium")]
|
[InputSize("medium")]
|
||||||
[Required]
|
[Required]
|
||||||
[Remote("CityNameAvailable", "City", ErrorMessage = "City name already in use")]
|
[Remote("CityNameAvailable", "City", ErrorMessage = "City name already in use")]
|
||||||
|
[FormatHint("Use correct capitalization")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string County { get; set; }
|
public string County { get; set; }
|
||||||
|
|||||||
@@ -12,16 +12,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend></legend>
|
<legend></legend>
|
||||||
@Html.DisplayFor(m => m.County)
|
@Html.DisplayFor(m => m.County)
|
||||||
@* <div class="control-group">
|
|
||||||
<div class="control-label">
|
|
||||||
@Html.DisplayNameFor(m => m.County)
|
|
||||||
</div>
|
|
||||||
<div class="controls">
|
|
||||||
@Html.DisplayTextFor(m => m.County)
|
|
||||||
</div>
|
|
||||||
</div>*@
|
|
||||||
@Html.HiddenFor(m => m.County)
|
@Html.HiddenFor(m => m.County)
|
||||||
|
|
||||||
@Html.EditorFor(m => m.Name)
|
@Html.EditorFor(m => m.Name)
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" value="Create" class="btn btn-primary" />
|
<input type="submit" value="Create" class="btn btn-primary" />
|
||||||
|
|||||||
Reference in New Issue
Block a user