2015-08-05 07:23:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2015-09-10 06:48:29 +08:00
|
|
|
|
using MBuildModel = RedisMongoMigration.Mongo.BuildModel;
|
|
|
|
|
using MBuild = RedisMongoMigration.Mongo.Build;
|
|
|
|
|
using RBuild = RedisMongoMigration.Redis.Build;
|
2015-10-14 03:24:39 +08:00
|
|
|
|
using MMetaItemModel = RedisMongoMigration.Mongo.MetaItemModel;
|
|
|
|
|
using MMetaItem = RedisMongoMigration.Mongo.MetaItem;
|
|
|
|
|
using RMetaItem = RedisMongoMigration.Redis.MetaItem;
|
2015-09-12 22:23:13 +08:00
|
|
|
|
using MongoLevelOfFlight = RedisMongoMigration.Mongo.MongoLevelOfFlight;
|
|
|
|
|
using RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight;
|
2015-10-07 03:54:14 +08:00
|
|
|
|
using MMemberModel = RedisMongoMigration.Mongo.MemberModel;
|
2015-09-22 21:34:52 +08:00
|
|
|
|
using RMember = RedisMongoMigration.Redis.RedisMember;
|
2015-10-07 03:54:14 +08:00
|
|
|
|
using MMember = RedisMongoMigration.Mongo.MongoMember;
|
|
|
|
|
using MRoleModel = RedisMongoMigration.Mongo.RoleModel;
|
2015-09-22 21:34:52 +08:00
|
|
|
|
using RRole = RedisMongoMigration.Redis.RedisRole;
|
|
|
|
|
using MRole = RedisMongoMigration.Mongo.MongoRole;
|
2015-09-10 06:48:29 +08:00
|
|
|
|
|
2015-08-05 07:23:20 +08:00
|
|
|
|
namespace RedisMongoMigration
|
|
|
|
|
{
|
2015-09-10 06:48:29 +08:00
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2015-09-22 21:34:52 +08:00
|
|
|
|
var builds = from b in RBuild.Select()
|
|
|
|
|
select new MBuildModel()
|
|
|
|
|
{
|
|
|
|
|
Id = Guid.NewGuid(),
|
|
|
|
|
LegacyId = b.Id,
|
|
|
|
|
|
|
|
|
|
MajorVersion = b.MajorVersion,
|
|
|
|
|
MinorVersion = b.MinorVersion,
|
|
|
|
|
Number = b.Number,
|
|
|
|
|
Revision = b.Revision,
|
|
|
|
|
Lab = b.Lab,
|
2015-10-14 21:06:23 +08:00
|
|
|
|
BuildTime = b.BuildTime.HasValue ? DateTime.SpecifyKind(b.BuildTime.Value, DateTimeKind.Utc) as DateTime? : null as DateTime?,
|
2015-09-22 21:34:52 +08:00
|
|
|
|
|
2015-10-14 21:06:23 +08:00
|
|
|
|
Added = DateTime.SpecifyKind(b.Added, DateTimeKind.Utc),
|
|
|
|
|
Modified = DateTime.SpecifyKind(b.Modified, DateTimeKind.Utc),
|
2015-09-22 21:34:52 +08:00
|
|
|
|
SourceType = b.SourceType,
|
|
|
|
|
SourceDetails = b.SourceDetails,
|
2015-10-14 21:06:23 +08:00
|
|
|
|
LeakDate = b.LeakDate.HasValue ? DateTime.SpecifyKind(b.LeakDate.Value, DateTimeKind.Utc) as DateTime? : null as DateTime?,
|
2015-10-07 03:54:14 +08:00
|
|
|
|
FlightLevel = ExchangeFlights(b.FlightLevel),
|
|
|
|
|
|
|
|
|
|
LabUrl = b.GenerateLabUrl()
|
2015-09-22 21:34:52 +08:00
|
|
|
|
};
|
2015-10-07 03:54:14 +08:00
|
|
|
|
MBuild mb = new MBuild();
|
|
|
|
|
mb.InsertAll(builds);
|
2015-09-10 06:48:29 +08:00
|
|
|
|
Console.WriteLine("Builds: Complete");
|
2015-09-22 21:34:52 +08:00
|
|
|
|
|
2015-10-14 03:24:39 +08:00
|
|
|
|
var metas = from b in RMetaItem.Select()
|
|
|
|
|
select new MMetaItemModel()
|
|
|
|
|
{
|
|
|
|
|
Id = new MetaItemKey()
|
|
|
|
|
{
|
|
|
|
|
Type = b.Id.Type,
|
|
|
|
|
Value = b.Id.Value
|
|
|
|
|
},
|
|
|
|
|
MetaDescription = b.MetaDescription,
|
|
|
|
|
PageContent = b.PageContent
|
|
|
|
|
};
|
|
|
|
|
MMetaItem mmi = new MMetaItem();
|
|
|
|
|
mmi.InsertAll(metas);
|
|
|
|
|
Console.WriteLine("Meta Item: Complete");
|
|
|
|
|
|
2015-09-22 21:34:52 +08:00
|
|
|
|
var members = from r in RMember.Select()
|
2015-10-07 03:54:14 +08:00
|
|
|
|
select new MMemberModel()
|
2015-09-22 21:34:52 +08:00
|
|
|
|
{
|
|
|
|
|
CreationDate = r.CreationDate,
|
|
|
|
|
EmailAddress = r.EmailAddress,
|
|
|
|
|
Id = r.Id,
|
|
|
|
|
IsApproved = r.IsApproved,
|
|
|
|
|
IsLockedOut = r.IsLockedOut,
|
|
|
|
|
LastActivityDate = r.LastActivityDate,
|
|
|
|
|
LastLockoutDate = r.LastLockoutDate,
|
|
|
|
|
LastLoginDate = r.LastLoginDate,
|
|
|
|
|
LockoutWindowAttempts = r.LockoutWindowAttempts,
|
|
|
|
|
LockoutWindowStart = r.LockoutWindowStart,
|
|
|
|
|
PassHash = r.PassHash,
|
|
|
|
|
PassSalt = r.PassSalt,
|
|
|
|
|
UserName = r.UserName
|
|
|
|
|
};
|
2015-10-07 03:54:14 +08:00
|
|
|
|
MMember mm = new MMember();
|
|
|
|
|
mm.InsertAll(members);
|
2015-09-22 21:34:52 +08:00
|
|
|
|
Console.WriteLine("Members: Complete");
|
|
|
|
|
|
|
|
|
|
var roles = from r in RRole.Select()
|
2015-10-07 03:54:14 +08:00
|
|
|
|
select new MRoleModel()
|
2015-09-22 21:34:52 +08:00
|
|
|
|
{
|
|
|
|
|
Id = r.Id,
|
|
|
|
|
RoleName = r.RoleName,
|
|
|
|
|
Users = r.Users
|
|
|
|
|
};
|
2015-10-07 03:54:14 +08:00
|
|
|
|
MRole mr = new MRole();
|
|
|
|
|
mr.InsertAll(roles);
|
2015-09-22 21:34:52 +08:00
|
|
|
|
Console.WriteLine("Roles: Complete");
|
|
|
|
|
|
2015-09-10 06:48:29 +08:00
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
2015-09-12 22:23:13 +08:00
|
|
|
|
|
|
|
|
|
static MongoLevelOfFlight ExchangeFlights(RedisLevelOfFlight flight)
|
|
|
|
|
{
|
|
|
|
|
switch (flight)
|
|
|
|
|
{
|
|
|
|
|
case RedisLevelOfFlight.Low:
|
|
|
|
|
return MongoLevelOfFlight.WIS;
|
|
|
|
|
case RedisLevelOfFlight.High:
|
|
|
|
|
return MongoLevelOfFlight.OSG;
|
|
|
|
|
default:
|
|
|
|
|
return MongoLevelOfFlight.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-10 06:48:29 +08:00
|
|
|
|
}
|
2015-08-05 07:23:20 +08:00
|
|
|
|
}
|