Replace Log.EmployeeName with Log.User, drop from database

This commit is contained in:
2013-01-06 14:33:49 -05:00
parent d5d58c1649
commit 0b4c7914b3
15 changed files with 140 additions and 54 deletions
+8 -4
View File
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Web;
using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
@@ -92,12 +91,11 @@ namespace MileageTraker.Web.Migrations
,'Driver'
,'Driver')");
//var folder = AppDomain.CurrentDomain.GetData("App_Data").ToString();
var existingUsers = new [] {"dsloan", "ccecil"};
var appDomain = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data");
var users = UserImporter.Import(Path.Combine(appDomain, "UserEmails.xls"));
users = (from u in users
where u.Username != "dsloan" &&
u.Username != "ccecil"
where !existingUsers.Contains(u.Username)
select u).ToList();
foreach (var user in users)
{
@@ -105,6 +103,12 @@ namespace MileageTraker.Web.Migrations
Sql(GetUserInsertSql(user));
Sql(GetUserInsertRoleDriverSql(user));
}
Sql(@"UPDATE [Log]
SET [Log].User_UserId = [User].UserId
FROM [Log]
INNER JOIN [User] ON
[User].FullName = [Log].EmployeeName");
}
public override void Down()