Mostly a cleanup of old code

This commit is contained in:
Thomas Hounsell 2017-04-17 11:11:45 +01:00
parent 1a89be223d
commit 0a8a4485cc
50 changed files with 774 additions and 3412 deletions

View File

@ -16,8 +16,7 @@ static DatabaseConfig()
? ConfigurationManager.AppSettings["data:MongoHost"]
: "localhost";
int port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out port);
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out int port);
if (!success)
{
port = 27017; // mongo default port

View File

@ -81,6 +81,33 @@ public override void Initialize(string name, NameValueCollection config)
MongoClient dbClient = new MongoClient(settings);
_memberCollection = dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoMember>(MEMBER_COLLECTION_NAME);
#pragma warning disable 4014
SetupIndexes();
#pragma warning restore 4014
}
public async Task SetupIndexes()
{
List<BsonDocument> indexes = await (await _memberCollection.Indexes.ListAsync()).ToListAsync();
if (indexes.All(i => i["name"] != "_idx_username"))
{
await _memberCollection.Indexes.CreateOneAsync(Builders<MongoMember>.IndexKeys.Ascending(b => b.UserName),
new CreateIndexOptions
{
Name = "_idx_username"
});
}
if (indexes.All(i => i["name"] != "_idx_email"))
{
await _memberCollection.Indexes.CreateOneAsync(Builders<MongoMember>.IndexKeys.Ascending(b => b.EmailAddress),
new CreateIndexOptions
{
Name = "_idx_email"
});
}
}
public override bool ChangePassword(string username, string oldPassword, string newPassword)
@ -200,7 +227,7 @@ public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize
{
MembershipUserCollection muc = new MembershipUserCollection();
IFindFluent<MongoMember, MongoMember> users = _memberCollection.Find(new BsonDocument());
IFindFluent<MongoMember, MongoMember> users = _memberCollection.Find(new BsonDocument()).Sort(Builders<MongoMember>.Sort.Ascending(m => m.UserName));
Task<long> totalRecordsTask = users.CountAsync();
totalRecordsTask.Wait();
@ -433,8 +460,7 @@ private static byte[] CalculateHash(string password, ref byte[] salt)
private static bool TryReadBool(string config, bool defaultValue)
{
bool temp;
bool success = bool.TryParse(config, out temp);
bool success = bool.TryParse(config, out bool temp);
return success
? temp
: defaultValue;
@ -442,8 +468,7 @@ private static bool TryReadBool(string config, bool defaultValue)
private static int TryReadInt(string config, int defaultValue)
{
int temp;
bool success = int.TryParse(config, out temp);
bool success = int.TryParse(config, out int temp);
return success
? temp
: defaultValue;

View File

@ -1,32 +0,0 @@
using System.Configuration;
namespace RedisAuth
{
internal static class DatabaseConfig
{
public static string Host { get; private set; }
public static int Port { get; private set; }
public static long Database { get; private set; }
static DatabaseConfig()
{
Host = ConfigurationManager.AppSettings["data:ServerHost"];
int _port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:ServerPort"], out _port);
if (!success)
{
_port = 6379; // redis default port
}
Port = _port;
long _db;
success = long.TryParse(ConfigurationManager.AppSettings["data:ServerDB"], out _db);
if (!success)
{
_db = 0; // redis default db
}
Database = _db;
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Redis Authentication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BuildFeed")]
[assembly: AssemblyCopyright("Copyright © 2015, Thomas Hounsell")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c6a16cf0-41da-4b90-918a-cb84a8c3f1e2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,78 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RedisAuth</RootNamespace>
<AssemblyName>RedisAuth</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>ExtendedDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="NServiceKit.Common, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Common.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Interfaces, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Interfaces.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Redis, Version=1.0.20.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Redis.1.0.20\lib\net35\NServiceKit.Redis.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Text.1.0.10\lib\net35\NServiceKit.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DatabaseConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RedisMembershipProvider.cs" />
<Compile Include="RedisRoleProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,494 +0,0 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web.Security;
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
namespace RedisAuth
{
public class RedisMembershipProvider : MembershipProvider
{
private bool _enablePasswordReset = true;
private int _maxInvalidPasswordAttempts = 3;
private int _minRequiredNonAlphanumericCharacters = 1;
private int _minRequriedPasswordLength = 8;
private int _passwordAttemptWindow = 60;
private bool _requiresUniqueEmail = true;
public override string ApplicationName
{
get { return ""; }
set { }
}
public override bool EnablePasswordReset
{
get { return _enablePasswordReset; }
}
public override bool EnablePasswordRetrieval
{
get { return false; }
}
public override int MaxInvalidPasswordAttempts
{
get { return _maxInvalidPasswordAttempts; }
}
public override int MinRequiredNonAlphanumericCharacters
{
get { return _minRequiredNonAlphanumericCharacters; }
}
public override int MinRequiredPasswordLength
{
get { return _minRequriedPasswordLength; }
}
public override int PasswordAttemptWindow
{
get { return _passwordAttemptWindow; }
}
public override MembershipPasswordFormat PasswordFormat
{
get { return MembershipPasswordFormat.Hashed; }
}
public override string PasswordStrengthRegularExpression
{
get { return ""; }
}
public override bool RequiresQuestionAndAnswer
{
get { return false; }
}
public override bool RequiresUniqueEmail
{
get { return _requiresUniqueEmail; }
}
public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
base.Initialize(name, config);
_enablePasswordReset = tryReadBool(config["enablePasswordReset"], _enablePasswordReset);
_maxInvalidPasswordAttempts = tryReadInt(config["maxInvalidPasswordAttempts"], _maxInvalidPasswordAttempts);
_minRequiredNonAlphanumericCharacters = tryReadInt(config["minRequiredNonAlphanumericCharacters"], _minRequiredNonAlphanumericCharacters);
_minRequriedPasswordLength = tryReadInt(config["minRequriedPasswordLength"], _minRequriedPasswordLength);
_passwordAttemptWindow = tryReadInt(config["passwordAttemptWindow"], _passwordAttemptWindow);
_requiresUniqueEmail = tryReadBool(config["requiresUniqueEmail"], _requiresUniqueEmail);
}
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
bool isAuthenticated = ValidateUser(username, oldPassword);
if (isAuthenticated)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetAll().SingleOrDefault(m => m.UserName.ToLower() == username.ToLower());
byte[] salt = new byte[24];
byte[] hash = calculateHash(newPassword, ref salt);
rm.PassSalt = salt;
rm.PassHash = hash;
client.Store(rm);
return true;
}
}
return false;
}
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
throw new NotImplementedException();
}
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
if (password.Length < MinRequiredPasswordLength)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
MembershipUser mu = null;
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var users = client.GetAll();
if (users.Any(m => m.UserName.ToLower() == username.ToLower()))
{
status = MembershipCreateStatus.DuplicateUserName;
}
else if (users.Any(m => m.EmailAddress.ToLower() == email.ToLower()))
{
status = MembershipCreateStatus.DuplicateEmail;
}
else
{
byte[] salt = new byte[24];
byte[] hash = calculateHash(password, ref salt);
RedisMember rm = new RedisMember()
{
Id = Guid.NewGuid(),
UserName = username,
PassHash = hash,
PassSalt = salt,
EmailAddress = email,
IsApproved = false,
IsLockedOut = false,
CreationDate = DateTime.Now,
LastLoginDate = DateTime.MinValue,
LastActivityDate = DateTime.MinValue,
LastLockoutDate = DateTime.MinValue
};
client.Store(rm);
status = MembershipCreateStatus.Success;
mu = new MembershipUser(this.Name, rm.UserName, rm.Id, rm.EmailAddress, "", "", rm.IsApproved, rm.IsLockedOut, rm.CreationDate, rm.LastLoginDate, rm.LastActivityDate, DateTime.MinValue, rm.LastLockoutDate);
}
}
return mu;
}
private static byte[] calculateHash(string password, ref byte[] salt)
{
if (!salt.Any(v => v != 0))
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(salt);
}
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
byte[] hashPlaintext = new byte[salt.Length + passwordBytes.Length];
passwordBytes.CopyTo(hashPlaintext, 0);
salt.CopyTo(hashPlaintext, passwordBytes.Length);
SHA512CryptoServiceProvider sha = new SHA512CryptoServiceProvider();
byte[] hash = sha.ComputeHash(hashPlaintext);
return hash;
}
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var user = client.GetAll().SingleOrDefault(m => m.UserName.ToLower() == username.ToLower());
if (user != null)
{
client.DeleteById(user.Id);
return true;
}
else
{
return false;
}
}
}
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection muc = new MembershipUserCollection();
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var users = client.GetAll();
totalRecords = users.Count;
var pageItems = users.Skip(pageIndex * pageSize).Take(pageSize);
foreach (var rm in pageItems)
{
muc.Add(new MembershipUser(this.Name, rm.UserName, rm.Id, rm.EmailAddress, "", "", rm.IsApproved, rm.IsLockedOut, rm.CreationDate, rm.LastLoginDate, rm.LastActivityDate, DateTime.MinValue, rm.LastLockoutDate));
}
}
return muc;
}
public override int GetNumberOfUsersOnline()
{
throw new NotImplementedException();
}
public override string GetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetAll().SingleOrDefault(m => m.UserName.ToLower() == username.ToLower());
if (rm == null)
{
return null;
}
else
{
return new MembershipUser(this.Name, rm.UserName, rm.Id, rm.EmailAddress, "", "", rm.IsApproved, rm.IsLockedOut, rm.CreationDate, rm.LastLoginDate, rm.LastActivityDate, DateTime.MinValue, rm.LastLockoutDate);
}
}
}
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetById(providerUserKey);
if (rm == null)
{
return null;
}
else
{
return new MembershipUser(this.Name, rm.UserName, rm.Id, rm.EmailAddress, "", "", rm.IsApproved, rm.IsLockedOut, rm.CreationDate, rm.LastLoginDate, rm.LastActivityDate, DateTime.MinValue, rm.LastLockoutDate);
}
}
}
public override string GetUserNameByEmail(string email)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetAll().SingleOrDefault(m => m.EmailAddress.ToLower() == email.ToLower());
if (rm == null)
{
return "";
}
else
{
return rm.UserName;
}
}
}
public override string ResetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public void ChangeApproval(Guid Id, bool newStatus)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetById(Id);
if (rm != null)
{
rm.IsApproved = newStatus;
client.Store(rm);
}
}
}
public void ChangeLockStatus(Guid Id, bool newStatus)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetById(Id);
if (rm != null)
{
rm.IsLockedOut = newStatus;
if (newStatus)
{
rm.LastLockoutDate = DateTime.Now;
}
else
{
rm.LockoutWindowAttempts = 0;
rm.LockoutWindowStart = DateTime.MinValue;
}
client.Store(rm);
}
}
}
public override bool UnlockUser(string userName)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetAll().SingleOrDefault(m => m.UserName.ToLower() == userName.ToLower());
rm.IsLockedOut = false;
client.Store(rm);
return true;
}
}
public override void UpdateUser(MembershipUser user)
{
throw new NotImplementedException();
}
public override bool ValidateUser(string username, string password)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisMember>();
var rm = client.GetAll().SingleOrDefault(m => m.UserName.ToLower() == username.ToLower());
if (rm == null || !(rm.IsApproved && !rm.IsLockedOut))
{
return false;
}
byte[] salt = rm.PassSalt;
byte[] hash = calculateHash(password, ref salt);
bool isFail = false;
for (int i = 0; i > hash.Length; i++)
{
isFail |= (hash[i] != rm.PassHash[i]);
}
if (isFail)
{
if (rm.LockoutWindowStart == DateTime.MinValue)
{
rm.LockoutWindowStart = DateTime.Now;
rm.LockoutWindowAttempts = 1;
}
else
{
if (rm.LockoutWindowStart.AddMinutes(PasswordAttemptWindow) > DateTime.Now)
{
// still within window
rm.LockoutWindowAttempts++;
if (rm.LockoutWindowAttempts >= MaxInvalidPasswordAttempts)
{
rm.IsLockedOut = true;
}
}
else
{
// outside of window, reset
rm.LockoutWindowStart = DateTime.Now;
rm.LockoutWindowAttempts = 1;
}
}
}
else
{
rm.LastLoginDate = DateTime.Now;
rm.LockoutWindowStart = DateTime.MinValue;
rm.LockoutWindowAttempts = 0;
}
client.Store(rm);
return !isFail;
}
}
private static bool tryReadBool(string config, bool defaultValue)
{
bool temp = false;
bool success = bool.TryParse(config, out temp);
return success ? temp : defaultValue;
}
private static int tryReadInt(string config, int defaultValue)
{
int temp = 0;
bool success = int.TryParse(config, out temp);
return success ? temp : defaultValue;
}
}
[DataObject]
public class RedisMember : IHasId<Guid>
{
[Key]
[Index]
public Guid Id { get; set; }
[@Required]
[DisplayName("Username")]
[Key]
public string UserName { get; set; }
[@Required]
public byte[] PassHash { get; set; }
[@Required]
public byte[] PassSalt { get; set; }
[@Required]
[DisplayName("Email Address")]
[Key]
public string EmailAddress { get; set; }
public bool IsApproved { get; set; }
public bool IsLockedOut { get; set; }
public DateTime CreationDate { get; set; }
public DateTime LastActivityDate { get; set; }
public DateTime LastLockoutDate { get; set; }
public DateTime LastLoginDate { get; set; }
public DateTime LockoutWindowStart { get; set; }
public int LockoutWindowAttempts { get; set; }
}
}

View File

@ -1,244 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Security;
using Required = System.ComponentModel.DataAnnotations.RequiredAttribute;
namespace RedisAuth
{
public class RedisRoleProvider : RoleProvider
{
public override string ApplicationName
{
get { return ""; }
set { }
}
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
List<RedisRole> roles = new List<RedisRole>();
roles.AddRange(from r in client.GetAll()
where roleNames.Any(n => n == r.RoleName)
select r);
List<RedisMember> users = new List<RedisMember>();
users.AddRange(from u in uClient.GetAll()
where usernames.Any(n => n == u.UserName)
select u);
for (int i = 0; i < roles.Count; i++)
{
List<Guid> newUsers = new List<Guid>();
if(roles[i].Users != null)
{
var usersToAdd = from u in users
where !roles[i].Users.Any(v => v == u.Id)
select u.Id;
newUsers.AddRange(roles[i].Users);
newUsers.AddRange(usersToAdd);
}
roles[i].Users = newUsers.ToArray();
}
client.StoreAll(roles);
}
}
public override void CreateRole(string roleName)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
RedisRole rr = new RedisRole()
{
Id = Guid.NewGuid(),
RoleName = roleName
};
client.Store(rr);
}
}
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var role = client.GetAll().SingleOrDefault(r => r.RoleName == roleName);
if (role.Users.Length > 0 && throwOnPopulatedRole)
{
throw new Exception("This role still has users");
}
client.DeleteById(role.Id);
return true;
}
}
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
var userIds = from r in client.GetAll()
where r.RoleName == roleName
from u in r.Users
select u;
var users = uClient.GetByIds(userIds);
return (from u in users
where u.UserName.ToLower().Contains(usernameToMatch.ToLower())
select u.UserName).ToArray();
}
}
public override string[] GetAllRoles()
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
return (from r in client.GetAll()
select r.RoleName).ToArray();
}
}
public override string[] GetRolesForUser(string username)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
var user = uClient.GetAll().SingleOrDefault(u => u.UserName.ToLower() == username.ToLower());
if (user == null)
{
throw new Exception("Username does not exist");
}
return (from r in client.GetAll()
where r.Users != null
where r.Users.Any(u => u == user.Id)
select r.RoleName).ToArray();
}
}
public override string[] GetUsersInRole(string roleName)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
var userIds = from r in client.GetAll()
where r.RoleName == roleName
from u in r.Users
select u;
var users = uClient.GetByIds(userIds);
return (from u in users
select u.UserName).ToArray();
}
}
public override bool IsUserInRole(string username, string roleName)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
var user = uClient.GetAll().SingleOrDefault(u => u.UserName.ToLower() == username.ToLower());
if (user == null)
{
throw new Exception();
}
var role = client.GetAll().SingleOrDefault(r => r.RoleName == roleName);
if(role.Users == null)
{
return false;
}
return role.Users.Any(u => u == user.Id);
}
}
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
var uClient = rClient.As<RedisMember>();
List<RedisRole> roles = new List<RedisRole>();
roles.AddRange(from r in client.GetAll()
where roleNames.Any(n => n == r.RoleName)
select r);
List<RedisMember> users = new List<RedisMember>();
users.AddRange(from u in uClient.GetAll()
where usernames.Any(n => n == u.UserName)
select u);
for (int i = 0; i < roles.Count; i++)
{
roles[i].Users = (from u in roles[i].Users
where !users.Any(v => v.Id == u)
select u).ToArray();
}
client.StoreAll(roles);
}
}
public override bool RoleExists(string roleName)
{
using (RedisClient rClient = new RedisClient(DatabaseConfig.Host, DatabaseConfig.Port, db: DatabaseConfig.Database))
{
var client = rClient.As<RedisRole>();
return client.GetAll().Any(r => r.RoleName == roleName);
}
}
}
[DataObject]
public class RedisRole : IHasId<Guid>
{
[Key]
[Index]
public Guid Id { get; set; }
[@Required]
[DisplayName("Role name")]
[Key]
public string RoleName { get; set; }
public Guid[] Users { get; set; }
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NServiceKit.Common" version="1.0.43" targetFramework="net46" />
<package id="NServiceKit.Redis" version="1.0.20" targetFramework="net46" />
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net45" />
</packages>

View File

@ -16,13 +16,12 @@ static MongoConfig()
? ConfigurationManager.AppSettings["data:MongoHost"]
: "localhost";
int _port;
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out int port);
if (!success)
{
_port = 27017; // mongo default port
port = 27017; // mongo default port
}
Port = _port;
Port = port;
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
? ConfigurationManager.AppSettings["data:MongoDB"]
@ -35,7 +34,9 @@ static MongoConfig()
public static void SetupIndexes()
{
BuildRepository b = new BuildRepository();
#pragma warning disable 4014
b.SetupIndexes();
#pragma warning restore 4014
}
}
}

View File

@ -1,22 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26020.0
VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed", "BuildFeed\BuildFeed.csproj", "{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RedisAuth", "Authentication\RedisAuth\RedisAuth.csproj", "{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoAuth", "Authentication\MongoAuth\MongoAuth.csproj", "{7C67BFB9-1B3B-4676-A58D-10573DA82CFE}"
EndProject
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "BuildFeedApp-Westminster", "Mobile\BuildFeedApp-Westminster\BuildFeedApp-Westminster.jsproj", "{5CAADB66-1FC2-4492-B766-36354687120D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RedisMongoMigration", "Tools\RedisMongoMigration\RedisMongoMigration.csproj", "{CD3C08CC-45BF-484B-A878-69614A4EA098}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoTimeFix", "Tools\MongoTimeFix\MongoTimeFix.csproj", "{B7EC3C45-E5CE-4AD5-B303-65D865F12454}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoTimeChecker", "Tools\MongoTimeChecker\MongoTimeChecker.csproj", "{B68C450F-1475-4B9C-B513-43C79CBAA338}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Authentication", "Authentication", "{53344C34-3493-4D0E-8425-FB18C0CC59D0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{938956E0-6FA0-4432-A238-DAE704686F26}"
@ -27,8 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed.Local", "BuildFee
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildFeed.Model", "BuildFeed.Model\BuildFeed.Model.csproj", "{7E2B4F61-1C11-4471-AF80-5480E94C0664}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigrateBuildStrings", "Tools\MigrateBuildStrings\MigrateBuildStrings.csproj", "{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -57,22 +47,6 @@ Global
{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}.Release|x64.Build.0 = Release|Any CPU
{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}.Release|x86.ActiveCfg = Release|Any CPU
{CDDCF754-ECAA-4A66-ADAA-62957A57A51B}.Release|x86.Build.0 = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|ARM.Build.0 = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|x64.ActiveCfg = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|x64.Build.0 = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|x86.ActiveCfg = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Debug|x86.Build.0 = Debug|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|Any CPU.Build.0 = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|ARM.ActiveCfg = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|ARM.Build.0 = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|x64.ActiveCfg = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|x64.Build.0 = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|x86.ActiveCfg = Release|Any CPU
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2}.Release|x86.Build.0 = Release|Any CPU
{7C67BFB9-1B3B-4676-A58D-10573DA82CFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C67BFB9-1B3B-4676-A58D-10573DA82CFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C67BFB9-1B3B-4676-A58D-10573DA82CFE}.Debug|ARM.ActiveCfg = Debug|Any CPU
@ -113,54 +87,6 @@ Global
{5CAADB66-1FC2-4492-B766-36354687120D}.Release|x86.ActiveCfg = Release|x86
{5CAADB66-1FC2-4492-B766-36354687120D}.Release|x86.Build.0 = Release|x86
{5CAADB66-1FC2-4492-B766-36354687120D}.Release|x86.Deploy.0 = Release|x86
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|ARM.ActiveCfg = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|ARM.Build.0 = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|x64.ActiveCfg = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|x64.Build.0 = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Debug|x86.Build.0 = Debug|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|Any CPU.Build.0 = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|ARM.ActiveCfg = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|ARM.Build.0 = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|x64.ActiveCfg = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|x64.Build.0 = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|x86.ActiveCfg = Release|Any CPU
{CD3C08CC-45BF-484B-A878-69614A4EA098}.Release|x86.Build.0 = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|ARM.Build.0 = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|x64.ActiveCfg = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|x64.Build.0 = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|x86.ActiveCfg = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Debug|x86.Build.0 = Debug|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|Any CPU.Build.0 = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|ARM.ActiveCfg = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|ARM.Build.0 = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|x64.ActiveCfg = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|x64.Build.0 = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|x86.ActiveCfg = Release|Any CPU
{B7EC3C45-E5CE-4AD5-B303-65D865F12454}.Release|x86.Build.0 = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|ARM.ActiveCfg = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|ARM.Build.0 = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|x64.ActiveCfg = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|x64.Build.0 = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|x86.ActiveCfg = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Debug|x86.Build.0 = Debug|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|Any CPU.Build.0 = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|ARM.ActiveCfg = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|ARM.Build.0 = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|x64.ActiveCfg = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|x64.Build.0 = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|x86.ActiveCfg = Release|Any CPU
{B68C450F-1475-4B9C-B513-43C79CBAA338}.Release|x86.Build.0 = Release|Any CPU
{3485B33A-6C3A-4535-9D85-4696914AD504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3485B33A-6C3A-4535-9D85-4696914AD504}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3485B33A-6C3A-4535-9D85-4696914AD504}.Debug|ARM.ActiveCfg = Debug|Any CPU
@ -193,33 +119,12 @@ Global
{7E2B4F61-1C11-4471-AF80-5480E94C0664}.Release|x64.Build.0 = Release|Any CPU
{7E2B4F61-1C11-4471-AF80-5480E94C0664}.Release|x86.ActiveCfg = Release|Any CPU
{7E2B4F61-1C11-4471-AF80-5480E94C0664}.Release|x86.Build.0 = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|ARM.Build.0 = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|x64.ActiveCfg = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|x64.Build.0 = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|x86.ActiveCfg = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Debug|x86.Build.0 = Debug|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|Any CPU.Build.0 = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|ARM.ActiveCfg = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|ARM.Build.0 = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x64.ActiveCfg = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x64.Build.0 = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x86.ActiveCfg = Release|Any CPU
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C6A16CF0-41DA-4B90-918A-CB84A8C3F1E2} = {53344C34-3493-4D0E-8425-FB18C0CC59D0}
{7C67BFB9-1B3B-4676-A58D-10573DA82CFE} = {53344C34-3493-4D0E-8425-FB18C0CC59D0}
{5CAADB66-1FC2-4492-B766-36354687120D} = {2B646675-44D1-4722-8A86-8C64876C8FB7}
{CD3C08CC-45BF-484B-A878-69614A4EA098} = {938956E0-6FA0-4432-A238-DAE704686F26}
{B7EC3C45-E5CE-4AD5-B303-65D865F12454} = {938956E0-6FA0-4432-A238-DAE704686F26}
{B68C450F-1475-4B9C-B513-43C79CBAA338} = {938956E0-6FA0-4432-A238-DAE704686F26}
{8C3BD4DC-1DB5-4082-A051-4518AA8250A0} = {938956E0-6FA0-4432-A238-DAE704686F26}
EndGlobalSection
EndGlobal

View File

@ -13,7 +13,7 @@
<li>@Html.ActionLink("Return to admin panel", "index", "base")</li>
</ul>
<table>
<table id="user-table">
<thead>
<tr>
<th>
@ -43,7 +43,7 @@
@mu.UserName
</td>
<td>
<a href="mailto:@mu.Email">@mu.Email</a>
<a href="mailto:@mu.Email" title="@mu.Email">@mu.Email</a>
</td>
<td>
@mu.CreationDate.Humanize()

View File

@ -10,8 +10,7 @@ public override object BindModel(ControllerContext controllerContext, ModelBindi
{
ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
DateTime retValue;
bool success = DateTime.TryParse(value.AttemptedValue, CultureInfo.CurrentUICulture.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces, out retValue);
bool success = DateTime.TryParse(value.AttemptedValue, CultureInfo.CurrentUICulture.DateTimeFormat, DateTimeStyles.AllowWhiteSpaces, out DateTime retValue);
if (!success)
{

View File

@ -98,8 +98,7 @@ public async Task<ActionResult> Register(RegistrationUser ru)
{
if (ModelState.IsValid)
{
MembershipCreateStatus status;
MembershipUser mu = Membership.CreateUser(ru.UserName, ru.Password, ru.EmailAddress, "{IGNORE}", "{IGNORE}", false, out status);
MembershipUser mu = Membership.CreateUser(ru.UserName, ru.Password, ru.EmailAddress, "{IGNORE}", "{IGNORE}", false, out MembershipCreateStatus status);
switch (status)
{

View File

@ -1 +1 @@
{"version":3,"sources":["dark.scss","dark.css"],"names":[],"mappings":"AAAA,KAEI,iBAAA,QACA,MAAA,QAGJ,EAEI,MAAA,KCAJ,eDGA,KAGI,MAAA,QAGJ,eAEI,oBAAA,QAGJ,cAEI,iBAAA,QACA,MAAA,QAHJ,iBAOQ,oBAAA,KAIR,iBAEI,iBAAA,QACA,MAAA,QACA,oBAAA,QAJJ,wBAQQ,MAAA,QARR,6CAiBgB,MAAA,QAjBhB,kDCJE,mDD2Bc,iBAAA,QAMhB,eAEI,iBAAA,QACA,aAAA,QACA,WAAA,EAAA,IAAA,KAAA,gBC5BF,wBADA,uBDyBF,uBAUQ,iBAAA,QAIR,QAEI,WAAA,EAAA,IAAA,KAAA,gBAAA,MAFJ,WAAA,WAMQ,MAAA,QCnCN,kCD6BF,0BC9BE,oBD2CM,MAAA,QAIR,0BAIQ,WAAA,QACA,MAAA,kBC1CR,yCADA,wCDsCA,wCAYQ,WAAA,QACA,MAAA,kBAIR,oCAEI,iBAAA,QAFJ,uCAMQ,MAAA,QCnDN,2ED6CF,0EAYQ,iBAAA,QACA,MAAA,QACA,aAAA","file":"dark.css","sourcesContent":["body\r\n{\r\n background-color: #f6f5f3;\r\n color: #373736;\r\n}\r\n\r\na\r\n{\r\n color: #fff;\r\n}\r\n\r\nh1 > a,\r\n#page-footer a\r\n{\r\n color: #373736;\r\n}\r\n\r\ntable thead th\r\n{\r\n border-bottom-color: #f6f5f3;\r\n}\r\n\r\n#page-content\r\n{\r\n background-color: #373736;\r\n color: #f6f5f3;\r\n\r\n h3\r\n {\r\n border-bottom-color: #ccc;\r\n }\r\n}\r\n\r\n#page-navigation\r\n{\r\n background-color: #242423;\r\n color: #f6f5f3;\r\n border-bottom-color: #f6f5f3;\r\n\r\n button\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n #page-navigation-links\r\n {\r\n > li\r\n {\r\n a\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n &.open > a,\r\n > a:hover\r\n {\r\n background-color: #373736;\r\n }\r\n }\r\n }\r\n}\r\n\r\n.dropdown-menu\r\n{\r\n background-color: #242423;\r\n border-color: #f6f5f3;\r\n box-shadow: 0 5px 10px rgba(0,0,0,0.15);\r\n\r\n a:hover,\r\n a:focus,\r\n a:active\r\n {\r\n background-color: #373736;\r\n }\r\n}\r\n\r\narticle\r\n{\r\n box-shadow: 0 5px 10px rgba(0,0,0,0.15) inset;\r\n\r\n h1, h3\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n .build-group > h3 > a,\r\n a.more-link,\r\n .build-details-comments a\r\n {\r\n color: #d6d5d3;\r\n }\r\n}\r\n\r\nul.pagination\r\n{\r\n > li.active > a\r\n {\r\n background: #f6f5f3;\r\n color: #242423 !important;\r\n }\r\n\r\n > li:hover:not(.disabled) > a,\r\n > li:focus:not(.disabled) > a,\r\n > li:active:not(.disabled) > a\r\n {\r\n background: #d6d5d3;\r\n color: #373736 !important;\r\n }\r\n}\r\n\r\n#modal-search-overlay #modal-search\r\n{\r\n background-color: #242423;\r\n\r\n h3\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n > #modal-search-box > #modal-search-input,\r\n > #modal-search-box > #modal-search-button\r\n {\r\n background-color: #373736;\r\n color: #f6f5f3;\r\n border-color: #d6d5d3;\r\n }\r\n}\r\n","body{background-color:#f6f5f3;color:#373736}a{color:#fff}#page-footer a,h1>a{color:#373736}table thead th{border-bottom-color:#f6f5f3}#page-content{background-color:#373736;color:#f6f5f3}#page-content h3{border-bottom-color:#ccc}#page-navigation{background-color:#242423;color:#f6f5f3;border-bottom-color:#f6f5f3}#page-navigation button{color:#f6f5f3}#page-navigation #page-navigation-links>li a{color:#f6f5f3}#page-navigation #page-navigation-links>li.open>a,#page-navigation #page-navigation-links>li>a:hover{background-color:#373736}.dropdown-menu{background-color:#242423;border-color:#f6f5f3;box-shadow:0 5px 10px rgba(0,0,0,.15)}.dropdown-menu a:active,.dropdown-menu a:focus,.dropdown-menu a:hover{background-color:#373736}article{box-shadow:0 5px 10px rgba(0,0,0,.15) inset}article h1,article h3{color:#f6f5f3}article .build-details-comments a,article .build-group>h3>a,article a.more-link{color:#d6d5d3}ul.pagination>li.active>a{background:#f6f5f3;color:#242423!important}ul.pagination>li:active:not(.disabled)>a,ul.pagination>li:focus:not(.disabled)>a,ul.pagination>li:hover:not(.disabled)>a{background:#d6d5d3;color:#373736!important}#modal-search-overlay #modal-search{background-color:#242423}#modal-search-overlay #modal-search h3{color:#f6f5f3}#modal-search-overlay #modal-search>#modal-search-box>#modal-search-button,#modal-search-overlay #modal-search>#modal-search-box>#modal-search-input{background-color:#373736;color:#f6f5f3;border-color:#d6d5d3}\n/*# sourceMappingURL=dark.css.map */\n"]}
{"version":3,"sources":["dark.scss","dark.css"],"names":[],"mappings":"AAAA,KAEG,iBAAA,QACA,MAAA,QAGH,EAEG,MAAA,KCAH,eDGA,KAGG,MAAA,QAGH,eAEG,oBAAA,QAGH,cAEG,iBAAA,QACA,MAAA,QAHH,iBAOM,oBAAA,KAIN,iBAEG,iBAAA,QACA,MAAA,QACA,oBAAA,QAJH,wBAQM,MAAA,QARN,6CAiBY,MAAA,QAjBZ,kDCJE,mDD2BU,iBAAA,QAMZ,eAEG,iBAAA,QACA,aAAA,QACA,WAAA,EAAA,IAAA,KAAA,gBC5BD,wBADA,uBDyBF,uBAUM,iBAAA,QAIN,QAEG,WAAA,EAAA,IAAA,KAAA,gBAAA,MAFH,WAAA,WAMM,MAAA,QCnCJ,kCD6BF,0BC9BE,oBD2CI,MAAA,QAIN,0BAIM,WAAA,QACA,MAAA,kBC1CN,yCADA,wCDsCA,wCAYM,WAAA,QACA,MAAA,kBAIN,oCAEG,iBAAA,QAFH,uCAMM,MAAA,QCnDJ,2ED6CF,0EAYM,iBAAA,QACA,MAAA,QACA,aAAA","file":"dark.css","sourcesContent":["body\r\n{\r\n background-color: #f6f5f3;\r\n color: #373736;\r\n}\r\n\r\na\r\n{\r\n color: #fff;\r\n}\r\n\r\nh1 > a,\r\n#page-footer a\r\n{\r\n color: #373736;\r\n}\r\n\r\ntable thead th\r\n{\r\n border-bottom-color: #f6f5f3;\r\n}\r\n\r\n#page-content\r\n{\r\n background-color: #373736;\r\n color: #f6f5f3;\r\n\r\n h3\r\n {\r\n border-bottom-color: #ccc;\r\n }\r\n}\r\n\r\n#page-navigation\r\n{\r\n background-color: #242423;\r\n color: #f6f5f3;\r\n border-bottom-color: #f6f5f3;\r\n\r\n button\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n #page-navigation-links\r\n {\r\n > li\r\n {\r\n a\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n &.open > a,\r\n > a:hover\r\n {\r\n background-color: #373736;\r\n }\r\n }\r\n }\r\n}\r\n\r\n.dropdown-menu\r\n{\r\n background-color: #242423;\r\n border-color: #f6f5f3;\r\n box-shadow: 0 5px 10px rgba(0,0,0,0.15);\r\n\r\n a:hover,\r\n a:focus,\r\n a:active\r\n {\r\n background-color: #373736;\r\n }\r\n}\r\n\r\narticle\r\n{\r\n box-shadow: 0 5px 10px rgba(0,0,0,0.15) inset;\r\n\r\n h1, h3\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n .build-group > h3 > a,\r\n a.more-link,\r\n .build-details-comments a\r\n {\r\n color: #d6d5d3;\r\n }\r\n}\r\n\r\nul.pagination\r\n{\r\n > li.active > a\r\n {\r\n background: #f6f5f3;\r\n color: #242423 !important;\r\n }\r\n\r\n > li:hover:not(.disabled) > a,\r\n > li:focus:not(.disabled) > a,\r\n > li:active:not(.disabled) > a\r\n {\r\n background: #d6d5d3;\r\n color: #373736 !important;\r\n }\r\n}\r\n\r\n#modal-search-overlay #modal-search\r\n{\r\n background-color: #242423;\r\n\r\n h3\r\n {\r\n color: #f6f5f3;\r\n }\r\n\r\n > #modal-search-box > #modal-search-input,\r\n > #modal-search-box > #modal-search-button\r\n {\r\n background-color: #373736;\r\n color: #f6f5f3;\r\n border-color: #d6d5d3;\r\n }\r\n}\r\n","body{background-color:#f6f5f3;color:#373736}a{color:#fff}#page-footer a,h1>a{color:#373736}table thead th{border-bottom-color:#f6f5f3}#page-content{background-color:#373736;color:#f6f5f3}#page-content h3{border-bottom-color:#ccc}#page-navigation{background-color:#242423;color:#f6f5f3;border-bottom-color:#f6f5f3}#page-navigation button{color:#f6f5f3}#page-navigation #page-navigation-links>li a{color:#f6f5f3}#page-navigation #page-navigation-links>li.open>a,#page-navigation #page-navigation-links>li>a:hover{background-color:#373736}.dropdown-menu{background-color:#242423;border-color:#f6f5f3;box-shadow:0 5px 10px rgba(0,0,0,.15)}.dropdown-menu a:active,.dropdown-menu a:focus,.dropdown-menu a:hover{background-color:#373736}article{box-shadow:0 5px 10px rgba(0,0,0,.15) inset}article h1,article h3{color:#f6f5f3}article .build-details-comments a,article .build-group>h3>a,article a.more-link{color:#d6d5d3}ul.pagination>li.active>a{background:#f6f5f3;color:#242423!important}ul.pagination>li:active:not(.disabled)>a,ul.pagination>li:focus:not(.disabled)>a,ul.pagination>li:hover:not(.disabled)>a{background:#d6d5d3;color:#373736!important}#modal-search-overlay #modal-search{background-color:#242423}#modal-search-overlay #modal-search h3{color:#f6f5f3}#modal-search-overlay #modal-search>#modal-search-box>#modal-search-button,#modal-search-overlay #modal-search>#modal-search-box>#modal-search-input{background-color:#373736;color:#f6f5f3;border-color:#d6d5d3}\n/*# sourceMappingURL=dark.css.map */\n"]}

View File

@ -1,127 +1,127 @@
body
{
background-color: #f6f5f3;
color: #373736;
background-color: #f6f5f3;
color: #373736;
}
a
{
color: #fff;
color: #fff;
}
h1 > a,
#page-footer a
{
color: #373736;
color: #373736;
}
table thead th
{
border-bottom-color: #f6f5f3;
border-bottom-color: #f6f5f3;
}
#page-content
{
background-color: #373736;
color: #f6f5f3;
background-color: #373736;
color: #f6f5f3;
h3
{
border-bottom-color: #ccc;
}
h3
{
border-bottom-color: #ccc;
}
}
#page-navigation
{
background-color: #242423;
color: #f6f5f3;
border-bottom-color: #f6f5f3;
background-color: #242423;
color: #f6f5f3;
border-bottom-color: #f6f5f3;
button
{
color: #f6f5f3;
}
button
{
color: #f6f5f3;
}
#page-navigation-links
{
> li
{
a
{
color: #f6f5f3;
}
#page-navigation-links
{
> li
{
a
{
color: #f6f5f3;
}
&.open > a,
> a:hover
{
background-color: #373736;
}
}
}
&.open > a,
> a:hover
{
background-color: #373736;
}
}
}
}
.dropdown-menu
{
background-color: #242423;
border-color: #f6f5f3;
box-shadow: 0 5px 10px rgba(0,0,0,0.15);
background-color: #242423;
border-color: #f6f5f3;
box-shadow: 0 5px 10px rgba(0,0,0,0.15);
a:hover,
a:focus,
a:active
{
background-color: #373736;
}
a:hover,
a:focus,
a:active
{
background-color: #373736;
}
}
article
{
box-shadow: 0 5px 10px rgba(0,0,0,0.15) inset;
box-shadow: 0 5px 10px rgba(0,0,0,0.15) inset;
h1, h3
{
color: #f6f5f3;
}
h1, h3
{
color: #f6f5f3;
}
.build-group > h3 > a,
a.more-link,
.build-details-comments a
{
color: #d6d5d3;
}
.build-group > h3 > a,
a.more-link,
.build-details-comments a
{
color: #d6d5d3;
}
}
ul.pagination
{
> li.active > a
{
background: #f6f5f3;
color: #242423 !important;
}
> li.active > a
{
background: #f6f5f3;
color: #242423 !important;
}
> li:hover:not(.disabled) > a,
> li:focus:not(.disabled) > a,
> li:active:not(.disabled) > a
{
background: #d6d5d3;
color: #373736 !important;
}
> li:hover:not(.disabled) > a,
> li:focus:not(.disabled) > a,
> li:active:not(.disabled) > a
{
background: #d6d5d3;
color: #373736 !important;
}
}
#modal-search-overlay #modal-search
{
background-color: #242423;
background-color: #242423;
h3
{
color: #f6f5f3;
}
h3
{
color: #f6f5f3;
}
> #modal-search-box > #modal-search-input,
> #modal-search-box > #modal-search-button
{
background-color: #373736;
color: #f6f5f3;
border-color: #d6d5d3;
}
> #modal-search-box > #modal-search-input,
> #modal-search-box > #modal-search-button
{
background-color: #373736;
color: #f6f5f3;
border-color: #d6d5d3;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="data:MongoDB" value="BuildFeed" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C3BD4DC-1DB5-4082-A051-4518AA8250A0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MigrateBuildStrings</RootNamespace>
<AssemblyName>MigrateBuildStrings</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BuildFeed.Model\BuildFeed.Model.csproj">
<Project>{7e2b4f61-1c11-4471-af80-5480e94c0664}</Project>
<Name>BuildFeed.Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,20 +0,0 @@
using System.Threading.Tasks;
using BuildFeed.Model;
namespace MigrateBuildStrings
{
internal class Program
{
private static void Main(string[] args)
{
Task.Run(async () =>
{
BuildRepository bModel = new BuildRepository();
foreach (Build build in await bModel.SelectBuildsByOrder())
{
await bModel.Update(build);
}
}).Wait();
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MigrateBuildStrings")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MigrateBuildStrings")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8c3bd4dc-1db5-4082-a051-4518aa8250a0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration
{
public enum TypeOfSource
{
PublicRelease,
InternalLeak,
UpdateGDR,
UpdateLDR,
AppPackage,
BuildTools,
Documentation,
Logging,
PrivateLeak
}
}

View File

@ -1,137 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Text;
namespace RedisMongoMigration.Mongo
{
public class BuildModel
{
[BsonId]
public Guid Id { get; set; }
public long? LegacyId { get; set; }
public byte MajorVersion { get; set; }
public byte MinorVersion { get; set; }
public ushort Number { get; set; }
public ushort? Revision { get; set; }
public string Lab { get; set; }
public DateTime? BuildTime { get; set; }
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
public TypeOfSource SourceType { get; set; }
public string SourceDetails { get; set; }
public DateTime? LeakDate { get; set; }
public MongoLevelOfFlight FlightLevel { get; set; }
public string LabUrl { get; set; }
public bool IsLeaked
{
get
{
switch (SourceType)
{
case TypeOfSource.PublicRelease:
case TypeOfSource.InternalLeak:
case TypeOfSource.UpdateGDR:
case TypeOfSource.UpdateLDR:
return true;
default:
return false;
}
}
}
public string FullBuildString
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
{
sb.AppendFormat(".{0}", Revision);
}
if (!string.IsNullOrWhiteSpace(Lab))
{
sb.AppendFormat(".{0}", Lab);
}
if (BuildTime.HasValue)
{
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
}
return sb.ToString();
}
}
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
}
public class Build
{
private const string _buildCollectionName = "builds";
private MongoClient _dbClient;
private IMongoCollection<BuildModel> _buildCollection;
public Build()
{
_dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<BuildModel>(_buildCollectionName);
}
public List<BuildModel> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
}
public BuildModel SelectByLegacyId(long id)
{
var task = _buildCollection.Find(b => b.LegacyId == id).SingleOrDefaultAsync();
task.Wait();
return task.Result;
}
public void UpdateDateOfLegacy(long id, DateTime? leak)
{
var task = _buildCollection.UpdateOneAsync(f => f.LegacyId == id, Builders<BuildModel>.Update.Set(f => f.BuildTime, leak));
task.Wait();
}
public void Insert(BuildModel item)
{
item.Id = Guid.NewGuid();
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
}
public void InsertAll(IEnumerable<BuildModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
}
}
public enum MongoLevelOfFlight
{
None = 0,
WIS = 1,
WIF = 2,
OSG = 3,
MSIT = 4,
Canary = 5
}
}

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B68C450F-1475-4B9C-B513-43C79CBAA338}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MongoTimeChecker</RootNamespace>
<AssemblyName>MongoTimeChecker</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Bson.2.4.1\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.2.4.1\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.Core.2.4.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Common, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Common.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Interfaces, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Interfaces.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Redis, Version=1.0.20.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Redis.1.0.20\lib\net35\NServiceKit.Redis.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Text.1.0.10\lib\net35\NServiceKit.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Build.cs" />
<Compile Include="Mongo\Build.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Redis\Build.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MBuildModel = RedisMongoMigration.Mongo.BuildModel;
using MBuild = RedisMongoMigration.Mongo.Build;
using RBuild = RedisMongoMigration.Redis.Build;
namespace MongoTimeChecker
{
class Program
{
static void Main(string[] args)
{
var builds = RBuild.Select();
MBuild mBuildObj = new MBuild();
foreach (var build in builds)
{
var mBuild = mBuildObj.SelectByLegacyId(build.Id);
if(mBuild != null)
{
bool isSame = mBuild.BuildTime == build.BuildTime;
if(!isSame)
{
Console.WriteLine($"{build.FullBuildString}: {build.BuildTime} != {mBuild.BuildTime}");
DateTime dt = DateTime.SpecifyKind(build.BuildTime.Value, DateTimeKind.Utc);
mBuildObj.UpdateDateOfLegacy(build.Id, dt);
}
}
}
Console.ReadKey();
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MongoTimeChecker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MongoTimeChecker")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b68c450f-1475-4b9c-b513-43c79cbaa338")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,94 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace RedisMongoMigration.Redis
{
[DataObject]
public class Build : IHasId<long>
{
[Key]
[AutoIncrement]
[Index]
public long Id { get; set; }
public byte MajorVersion { get; set; }
public byte MinorVersion { get; set; }
public ushort Number { get; set; }
public ushort? Revision { get; set; }
public string Lab { get; set; }
public DateTime? BuildTime { get; set; }
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
public TypeOfSource SourceType { get; set; }
public string SourceDetails { get; set; }
public DateTime? LeakDate { get; set; }
public RedisLevelOfFlight FlightLevel { get; set; }
public bool IsLeaked
{
get
{
switch (SourceType)
{
case TypeOfSource.PublicRelease:
case TypeOfSource.InternalLeak:
case TypeOfSource.UpdateGDR:
return true;
default:
return false;
}
}
}
public string FullBuildString
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
{
sb.AppendFormat(".{0}", Revision);
}
if (!string.IsNullOrWhiteSpace(Lab))
{
sb.AppendFormat(".{0}", Lab);
}
if (BuildTime.HasValue)
{
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
}
return sb.ToString();
}
}
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
public static IEnumerable<Build> Select()
{
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
{
var client = rClient.As<Build>();
return client.GetAll();
}
}
}
public enum RedisLevelOfFlight
{
None = 0,
Low = 1,
Medium = 2,
High = 3
}
}

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MongoDB.Bson" version="2.4.1" targetFramework="net46" />
<package id="MongoDB.Driver" version="2.4.1" targetFramework="net46" />
<package id="MongoDB.Driver.Core" version="2.4.1" targetFramework="net46" />
<package id="NServiceKit.Common" version="1.0.43" targetFramework="net46" />
<package id="NServiceKit.Redis" version="1.0.20" targetFramework="net46" />
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net46" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net46" />
</packages>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7EC3C45-E5CE-4AD5-B303-65D865F12454}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MongoTimeFix</RootNamespace>
<AssemblyName>MongoTimeFix</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Bson.2.4.1\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.2.4.1\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.Core.2.4.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,133 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MongoTimeFix
{
class Program
{
static void Main(string[] args)
{
const string _buildCollectionName = "builds";
MongoClient _dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
IMongoCollection<BuildModel> _buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<BuildModel>(_buildCollectionName);
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
foreach(var b in task.Result)
{
if (b.BuildTime.HasValue)
{
b.BuildTime = DateTime.SpecifyKind(b.BuildTime.Value.AddHours(1), DateTimeKind.Utc);
}
if (b.LeakDate.HasValue)
{
b.LeakDate = DateTime.SpecifyKind(b.LeakDate.Value.AddHours(1), DateTimeKind.Utc);
}
_buildCollection.ReplaceOneAsync(f => f.Id == b.Id, b);
}
}
}
public class BuildModel
{
[BsonId]
public Guid Id { get; set; }
public long? LegacyId { get; set; }
public byte MajorVersion { get; set; }
public byte MinorVersion { get; set; }
public ushort Number { get; set; }
public ushort? Revision { get; set; }
public string Lab { get; set; }
public DateTime? BuildTime { get; set; }
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
public TypeOfSource SourceType { get; set; }
public string SourceDetails { get; set; }
public DateTime? LeakDate { get; set; }
public LevelOfFlight FlightLevel { get; set; }
public string LabUrl { get; set; }
public bool IsLeaked
{
get
{
switch (SourceType)
{
case TypeOfSource.PublicRelease:
case TypeOfSource.InternalLeak:
case TypeOfSource.UpdateGDR:
case TypeOfSource.UpdateLDR:
return true;
default:
return false;
}
}
}
public string FullBuildString
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
{
sb.AppendFormat(".{0}", Revision);
}
if (!string.IsNullOrWhiteSpace(Lab))
{
sb.AppendFormat(".{0}", Lab);
}
if (BuildTime.HasValue)
{
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
}
return sb.ToString();
}
}
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
}
public enum LevelOfFlight
{
None = 0,
WIS = 1,
WIF = 2,
OSG = 3,
MSIT = 4,
Canary = 5
}
public enum TypeOfSource
{
PublicRelease,
InternalLeak,
UpdateGDR,
UpdateLDR,
AppPackage,
BuildTools,
Documentation,
Logging,
PrivateLeak
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MongoTimeFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MongoTimeFix")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b7ec3c45-e5ce-4ad5-b303-65d865f12454")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MongoDB.Bson" version="2.4.1" targetFramework="net452" />
<package id="MongoDB.Driver" version="2.4.1" targetFramework="net452" />
<package id="MongoDB.Driver.Core" version="2.4.1" targetFramework="net452" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" />
</packages>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration
{
public enum TypeOfSource
{
PublicRelease,
InternalLeak,
UpdateGDR,
UpdateLDR,
AppPackage,
BuildTools,
Documentation,
Logging,
PrivateLeak
}
}

View File

@ -1,39 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration
{
public class MetaItemKey
{
public string Value { get; set; }
public MetaType Type { get; set; }
public MetaItemKey()
{
}
public MetaItemKey(string id)
{
var items = id.Split(':');
Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]);
Value = items[1];
}
public override string ToString()
{
return $"{Type}:{Value}";
}
}
public enum MetaType
{
Lab,
Version,
Source,
Year
}
}

View File

@ -1,124 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Text;
namespace RedisMongoMigration.Mongo
{
public class BuildModel
{
[BsonId]
public Guid Id { get; set; }
public long? LegacyId { get; set; }
public byte MajorVersion { get; set; }
public byte MinorVersion { get; set; }
public ushort Number { get; set; }
public ushort? Revision { get; set; }
public string Lab { get; set; }
public DateTime? BuildTime { get; set; }
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
public TypeOfSource SourceType { get; set; }
public string SourceDetails { get; set; }
public DateTime? LeakDate { get; set; }
public MongoLevelOfFlight FlightLevel { get; set; }
public string LabUrl { get; set; }
public bool IsLeaked
{
get
{
switch (SourceType)
{
case TypeOfSource.PublicRelease:
case TypeOfSource.InternalLeak:
case TypeOfSource.UpdateGDR:
case TypeOfSource.UpdateLDR:
return true;
default:
return false;
}
}
}
public string FullBuildString
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
{
sb.AppendFormat(".{0}", Revision);
}
if (!string.IsNullOrWhiteSpace(Lab))
{
sb.AppendFormat(".{0}", Lab);
}
if (BuildTime.HasValue)
{
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
}
return sb.ToString();
}
}
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
}
public class Build
{
private const string _buildCollectionName = "builds";
private MongoClient _dbClient;
private IMongoCollection<BuildModel> _buildCollection;
public Build()
{
_dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<BuildModel>(_buildCollectionName);
}
public List<BuildModel> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
}
public void Insert(BuildModel item)
{
item.Id = Guid.NewGuid();
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
}
public void InsertAll(IEnumerable<BuildModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
}
}
public enum MongoLevelOfFlight
{
None = 0,
WIS = 1,
WIF = 2,
OSG = 3,
MSIT = 4,
Canary = 5
}
}

View File

@ -1,58 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration.Mongo
{
public class MetaItemModel
{
[BsonId]
public MetaItemKey Id { get; set; }
public string PageContent { get; set; }
public string MetaDescription { get; set; }
}
public class MetaItem
{
private const string _buildCollectionName = "metaitem";
private MongoClient _dbClient;
private IMongoCollection<MetaItemModel> _buildCollection;
public MetaItem()
{
_dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<MetaItemModel>(_buildCollectionName);
}
public List<MetaItemModel> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
}
public void Insert(MetaItemModel item)
{
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
}
public void InsertAll(IEnumerable<MetaItemModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
}
}
}

View File

@ -1,71 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration.Mongo
{
public class MemberModel
{
[BsonId]
public Guid Id { get; set; }
public string UserName { get; set; }
public byte[] PassHash { get; set; }
public byte[] PassSalt { get; set; }
public string EmailAddress { get; set; }
public bool IsApproved { get; set; }
public bool IsLockedOut { get; set; }
public DateTime CreationDate { get; set; }
public DateTime LastActivityDate { get; set; }
public DateTime LastLockoutDate { get; set; }
public DateTime LastLoginDate { get; set; }
public DateTime LockoutWindowStart { get; set; }
public int LockoutWindowAttempts { get; set; }
}
public class MongoMember
{
private const string _buildCollectionName = "members";
private MongoClient _dbClient;
private IMongoCollection<MemberModel> _buildCollection;
public MongoMember()
{
_dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<MemberModel>(_buildCollectionName);
}
public List<MemberModel> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
}
public void Insert(MemberModel item)
{
item.Id = Guid.NewGuid();
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
}
public void InsertAll(IEnumerable<MemberModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
}
}
}

View File

@ -1,59 +0,0 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RedisMongoMigration.Mongo
{
public class RoleModel
{
[BsonId]
public Guid Id { get; set; }
public string RoleName { get; set; }
public Guid[] Users { get; set; }
}
public class MongoRole
{
private const string _buildCollectionName = "roles";
private MongoClient _dbClient;
private IMongoCollection<RoleModel> _buildCollection;
public MongoRole()
{
_dbClient = new MongoClient(new MongoClientSettings()
{
Server = new MongoServerAddress("localhost", 27017)
});
_buildCollection = _dbClient.GetDatabase("BuildFeed").GetCollection<RoleModel>(_buildCollectionName);
}
public List<RoleModel> Select()
{
var task = _buildCollection.Find(new BsonDocument()).ToListAsync();
task.Wait();
return task.Result;
}
public void Insert(RoleModel item)
{
item.Id = Guid.NewGuid();
var task = _buildCollection.InsertOneAsync(item);
task.Wait();
}
public void InsertAll(IEnumerable<RoleModel> items)
{
var task = _buildCollection.InsertManyAsync(items);
task.Wait();
}
}
}

View File

@ -1,117 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MBuildModel = RedisMongoMigration.Mongo.BuildModel;
using MBuild = RedisMongoMigration.Mongo.Build;
using RBuild = RedisMongoMigration.Redis.Build;
using MMetaItemModel = RedisMongoMigration.Mongo.MetaItemModel;
using MMetaItem = RedisMongoMigration.Mongo.MetaItem;
using RMetaItem = RedisMongoMigration.Redis.MetaItem;
using MongoLevelOfFlight = RedisMongoMigration.Mongo.MongoLevelOfFlight;
using RedisLevelOfFlight = RedisMongoMigration.Redis.RedisLevelOfFlight;
using MMemberModel = RedisMongoMigration.Mongo.MemberModel;
using RMember = RedisMongoMigration.Redis.RedisMember;
using MMember = RedisMongoMigration.Mongo.MongoMember;
using MRoleModel = RedisMongoMigration.Mongo.RoleModel;
using RRole = RedisMongoMigration.Redis.RedisRole;
using MRole = RedisMongoMigration.Mongo.MongoRole;
namespace RedisMongoMigration
{
class Program
{
static void Main(string[] args)
{
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,
BuildTime = b.BuildTime.HasValue ? DateTime.SpecifyKind(b.BuildTime.Value, DateTimeKind.Utc) as DateTime? : null as DateTime?,
Added = DateTime.SpecifyKind(b.Added, DateTimeKind.Utc),
Modified = DateTime.SpecifyKind(b.Modified, DateTimeKind.Utc),
SourceType = b.SourceType,
SourceDetails = b.SourceDetails,
LeakDate = b.LeakDate.HasValue ? DateTime.SpecifyKind(b.LeakDate.Value, DateTimeKind.Utc) as DateTime? : null as DateTime?,
FlightLevel = ExchangeFlights(b.FlightLevel),
LabUrl = b.GenerateLabUrl()
};
MBuild mb = new MBuild();
mb.InsertAll(builds);
Console.WriteLine("Builds: Complete");
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");
var members = from r in RMember.Select()
select new MMemberModel()
{
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
};
MMember mm = new MMember();
mm.InsertAll(members);
Console.WriteLine("Members: Complete");
var roles = from r in RRole.Select()
select new MRoleModel()
{
Id = r.Id,
RoleName = r.RoleName,
Users = r.Users
};
MRole mr = new MRole();
mr.InsertAll(roles);
Console.WriteLine("Roles: Complete");
Console.ReadKey();
}
static MongoLevelOfFlight ExchangeFlights(RedisLevelOfFlight flight)
{
switch (flight)
{
case RedisLevelOfFlight.Low:
return MongoLevelOfFlight.WIS;
case RedisLevelOfFlight.High:
return MongoLevelOfFlight.OSG;
default:
return MongoLevelOfFlight.None;
}
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RedisMongoMigration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RedisMongoMigration")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("cd3c08cc-45bf-484b-a878-69614a4ea098")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,94 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace RedisMongoMigration.Redis
{
[DataObject]
public class Build : IHasId<long>
{
[Key]
[AutoIncrement]
[Index]
public long Id { get; set; }
public byte MajorVersion { get; set; }
public byte MinorVersion { get; set; }
public ushort Number { get; set; }
public ushort? Revision { get; set; }
public string Lab { get; set; }
public DateTime? BuildTime { get; set; }
public DateTime Added { get; set; }
public DateTime Modified { get; set; }
public TypeOfSource SourceType { get; set; }
public string SourceDetails { get; set; }
public DateTime? LeakDate { get; set; }
public RedisLevelOfFlight FlightLevel { get; set; }
public bool IsLeaked
{
get
{
switch (SourceType)
{
case TypeOfSource.PublicRelease:
case TypeOfSource.InternalLeak:
case TypeOfSource.UpdateGDR:
return true;
default:
return false;
}
}
}
public string FullBuildString
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{0}.{1}.{2}", MajorVersion, MinorVersion, Number);
if (Revision.HasValue)
{
sb.AppendFormat(".{0}", Revision);
}
if (!string.IsNullOrWhiteSpace(Lab))
{
sb.AppendFormat(".{0}", Lab);
}
if (BuildTime.HasValue)
{
sb.AppendFormat(".{0:yyMMdd-HHmm}", BuildTime);
}
return sb.ToString();
}
}
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
public static IEnumerable<Build> Select()
{
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
{
var client = rClient.As<Build>();
return client.GetAll();
}
}
}
public enum RedisLevelOfFlight
{
None = 0,
Low = 1,
Medium = 2,
High = 3
}
}

View File

@ -1,50 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace RedisMongoMigration.Redis
{
[DataObject]
public class MetaItem : IHasId<MetaItemKey>
{
[Key]
[Index]
public MetaItemKey Id { get; set; }
public string PageContent { get; set; }
public string MetaDescription { get; set; }
public static IEnumerable<MetaItem> Select()
{
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
{
var client = rClient.As<MetaItem>();
return client.GetAll();
}
}
}
public struct MetaItemKey
{
public string Value { get; set; }
public MetaType Type { get; set; }
public MetaItemKey(string id)
{
var items = id.Split(':');
Type = (MetaType)Enum.Parse(typeof(MetaType), items[0]);
Value = items[1];
}
public override string ToString()
{
return $"{Type}:{Value}";
}
}
}

View File

@ -1,48 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace RedisMongoMigration.Redis
{
[DataObject]
public class RedisMember : IHasId<Guid>
{
[Key]
[Index]
public Guid Id { get; set; }
[Key]
public string UserName { get; set; }
public byte[] PassHash { get; set; }
public byte[] PassSalt { get; set; }
[Key]
public string EmailAddress { get; set; }
public bool IsApproved { get; set; }
public bool IsLockedOut { get; set; }
public DateTime CreationDate { get; set; }
public DateTime LastActivityDate { get; set; }
public DateTime LastLockoutDate { get; set; }
public DateTime LastLoginDate { get; set; }
public DateTime LockoutWindowStart { get; set; }
public int LockoutWindowAttempts { get; set; }
public static IEnumerable<RedisMember> Select()
{
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
{
var client = rClient.As<RedisMember>();
return client.GetAll();
}
}
}
}

View File

@ -1,32 +0,0 @@
using NServiceKit.DataAnnotations;
using NServiceKit.DesignPatterns.Model;
using NServiceKit.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace RedisMongoMigration.Redis
{
[DataObject]
public class RedisRole : IHasId<Guid>
{
[Key]
[Index]
public Guid Id { get; set; }
[Key]
public string RoleName { get; set; }
public Guid[] Users { get; set; }
public static IEnumerable<RedisRole> Select()
{
using (RedisClient rClient = new RedisClient("localhost", 6379, db: 1))
{
var client = rClient.As<RedisRole>();
return client.GetAll();
}
}
}
}

View File

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD3C08CC-45BF-484B-A878-69614A4EA098}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RedisMongoMigration</RootNamespace>
<AssemblyName>RedisMongoMigration</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Bson.2.4.1\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.2.4.1\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.4.1.18, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\MongoDB.Driver.Core.2.4.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Common, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Common.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Interfaces, Version=1.0.43.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Common.1.0.43\lib\net35\NServiceKit.Interfaces.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Redis, Version=1.0.20.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\NServiceKit.Redis.1.0.20\lib\net35\NServiceKit.Redis.dll</HintPath>
</Reference>
<Reference Include="NServiceKit.Text, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NServiceKit.Text.1.0.10\lib\net35\NServiceKit.Text.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Build.cs" />
<Compile Include="MetaItem.cs" />
<Compile Include="Mongo\Build.cs" />
<Compile Include="Mongo\MetaItem.cs" />
<Compile Include="Mongo\MongoMember.cs" />
<Compile Include="Mongo\MongoRole.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Redis\Build.cs" />
<Compile Include="Redis\MetaItem.cs" />
<Compile Include="Redis\RedisMember.cs" />
<Compile Include="Redis\RedisRole.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MongoDB.Bson" version="2.4.1" targetFramework="net46" />
<package id="MongoDB.Driver" version="2.4.1" targetFramework="net46" />
<package id="MongoDB.Driver.Core" version="2.4.1" targetFramework="net46" />
<package id="NServiceKit.Common" version="1.0.43" targetFramework="net46" />
<package id="NServiceKit.Redis" version="1.0.20" targetFramework="net46" />
<package id="NServiceKit.Text" version="1.0.10" targetFramework="net46" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net46" />
</packages>