mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Code style updates
This commit is contained in:
parent
0f614d258b
commit
1088aa7898
|
@ -10,9 +10,9 @@ internal static class DatabaseConfig
|
||||||
|
|
||||||
static DatabaseConfig()
|
static DatabaseConfig()
|
||||||
{
|
{
|
||||||
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"]) ?
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
|
||||||
ConfigurationManager.AppSettings["data:MongoHost"] :
|
? ConfigurationManager.AppSettings["data:MongoHost"]
|
||||||
"localhost";
|
: "localhost";
|
||||||
|
|
||||||
int _port;
|
int _port;
|
||||||
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
||||||
|
@ -22,9 +22,9 @@ static DatabaseConfig()
|
||||||
}
|
}
|
||||||
Port = _port;
|
Port = _port;
|
||||||
|
|
||||||
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"]) ?
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
|
||||||
ConfigurationManager.AppSettings["data:MongoDB"] :
|
? ConfigurationManager.AppSettings["data:MongoDB"]
|
||||||
"MongoAuth";
|
: "MongoAuth";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,4 @@
|
||||||
using MongoDB.Bson;
|
using System;
|
||||||
using MongoDB.Bson.Serialization.Attributes;
|
|
||||||
using MongoDB.Driver;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -9,12 +6,15 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web.Security;
|
using System.Web.Security;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
|
||||||
namespace MongoAuth
|
namespace MongoAuth
|
||||||
{
|
{
|
||||||
public class MongoMembershipProvider : MembershipProvider
|
public class MongoMembershipProvider : MembershipProvider
|
||||||
{
|
{
|
||||||
private const string _memberCollectionName = "members";
|
private const string MEMBER_COLLECTION_NAME = "members";
|
||||||
|
|
||||||
private bool _enablePasswordReset = true;
|
private bool _enablePasswordReset = true;
|
||||||
private int _maxInvalidPasswordAttempts = 5;
|
private int _maxInvalidPasswordAttempts = 5;
|
||||||
|
@ -57,18 +57,18 @@ public override void Initialize(string name, NameValueCollection config)
|
||||||
|
|
||||||
base.Initialize(name, config);
|
base.Initialize(name, config);
|
||||||
|
|
||||||
_enablePasswordReset = tryReadBool(config["enablePasswordReset"], _enablePasswordReset);
|
_enablePasswordReset = TryReadBool(config["enablePasswordReset"], _enablePasswordReset);
|
||||||
_maxInvalidPasswordAttempts = tryReadInt(config["maxInvalidPasswordAttempts"], _maxInvalidPasswordAttempts);
|
_maxInvalidPasswordAttempts = TryReadInt(config["maxInvalidPasswordAttempts"], _maxInvalidPasswordAttempts);
|
||||||
_minRequiredNonAlphanumericCharacters = tryReadInt(config["minRequiredNonAlphanumericCharacters"], _minRequiredNonAlphanumericCharacters);
|
_minRequiredNonAlphanumericCharacters = TryReadInt(config["minRequiredNonAlphanumericCharacters"], _minRequiredNonAlphanumericCharacters);
|
||||||
_minRequriedPasswordLength = tryReadInt(config["minRequriedPasswordLength"], _minRequriedPasswordLength);
|
_minRequriedPasswordLength = TryReadInt(config["minRequriedPasswordLength"], _minRequriedPasswordLength);
|
||||||
_passwordAttemptWindow = tryReadInt(config["passwordAttemptWindow"], _passwordAttemptWindow);
|
_passwordAttemptWindow = TryReadInt(config["passwordAttemptWindow"], _passwordAttemptWindow);
|
||||||
_requiresUniqueEmail = tryReadBool(config["requiresUniqueEmail"], _requiresUniqueEmail);
|
_requiresUniqueEmail = TryReadBool(config["requiresUniqueEmail"], _requiresUniqueEmail);
|
||||||
|
|
||||||
_dbClient = new MongoClient(new MongoClientSettings()
|
_dbClient = new MongoClient(new MongoClientSettings
|
||||||
{
|
{
|
||||||
Server = new MongoServerAddress(DatabaseConfig.Host, DatabaseConfig.Port)
|
Server = new MongoServerAddress(DatabaseConfig.Host, DatabaseConfig.Port)
|
||||||
});
|
});
|
||||||
_memberCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoMember>(_memberCollectionName);
|
_memberCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoMember>(MEMBER_COLLECTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ChangePassword(string username, string oldPassword, string newPassword)
|
public override bool ChangePassword(string username, string oldPassword, string newPassword)
|
||||||
|
@ -77,11 +77,9 @@ public override bool ChangePassword(string username, string oldPassword, string
|
||||||
|
|
||||||
if (isAuthenticated)
|
if (isAuthenticated)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<MongoMember> task = _memberCollection.Find(m => m.UserName.ToLower() == username.ToLower()).SingleOrDefaultAsync();
|
||||||
.Find(m => m.UserName.ToLower() == username.ToLower())
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
var mm = task.Result;
|
MongoMember mm = task.Result;
|
||||||
|
|
||||||
if (mm == null)
|
if (mm == null)
|
||||||
{
|
{
|
||||||
|
@ -89,13 +87,12 @@ public override bool ChangePassword(string username, string oldPassword, string
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] salt = new byte[24];
|
byte[] salt = new byte[24];
|
||||||
byte[] hash = calculateHash(newPassword, ref salt);
|
byte[] hash = CalculateHash(newPassword, ref salt);
|
||||||
|
|
||||||
mm.PassSalt = salt;
|
mm.PassSalt = salt;
|
||||||
mm.PassHash = hash;
|
mm.PassHash = hash;
|
||||||
|
|
||||||
var replaceTask = _memberCollection
|
Task<ReplaceOneResult> replaceTask = _memberCollection.ReplaceOneAsync(m => m.Id == mm.Id, mm);
|
||||||
.ReplaceOneAsync(m => m.Id == mm.Id, mm);
|
|
||||||
replaceTask.Wait();
|
replaceTask.Wait();
|
||||||
|
|
||||||
return replaceTask.IsCompleted;
|
return replaceTask.IsCompleted;
|
||||||
|
@ -104,10 +101,7 @@ public override bool ChangePassword(string username, string oldPassword, string
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
|
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
|
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
|
||||||
{
|
{
|
||||||
|
@ -119,12 +113,8 @@ public override MembershipUser CreateUser(string username, string password, stri
|
||||||
|
|
||||||
MembershipUser mu = null;
|
MembershipUser mu = null;
|
||||||
|
|
||||||
var dupeUsers = _memberCollection
|
Task<long> dupeUsers = _memberCollection.Find(m => m.UserName.ToLower() == username.ToLower()).CountAsync();
|
||||||
.Find(m => m.UserName.ToLower() == username.ToLower())
|
Task<long> dupeEmails = _memberCollection.Find(m => m.EmailAddress.ToLower() == email.ToLower()).CountAsync();
|
||||||
.CountAsync();
|
|
||||||
var dupeEmails = _memberCollection
|
|
||||||
.Find(m => m.EmailAddress.ToLower() == email.ToLower())
|
|
||||||
.CountAsync();
|
|
||||||
dupeUsers.Wait();
|
dupeUsers.Wait();
|
||||||
dupeEmails.Wait();
|
dupeEmails.Wait();
|
||||||
|
|
||||||
|
@ -139,34 +129,30 @@ public override MembershipUser CreateUser(string username, string password, stri
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] salt = new byte[24];
|
byte[] salt = new byte[24];
|
||||||
byte[] hash = calculateHash(password, ref salt);
|
byte[] hash = CalculateHash(password, ref salt);
|
||||||
|
|
||||||
MongoMember mm = new MongoMember()
|
MongoMember mm = new MongoMember
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
UserName = username,
|
UserName = username,
|
||||||
PassHash = hash,
|
PassHash = hash,
|
||||||
PassSalt = salt,
|
PassSalt = salt,
|
||||||
EmailAddress = email,
|
EmailAddress = email,
|
||||||
|
|
||||||
IsApproved = false,
|
IsApproved = false,
|
||||||
IsLockedOut = false,
|
IsLockedOut = false,
|
||||||
|
|
||||||
CreationDate = DateTime.Now,
|
CreationDate = DateTime.Now,
|
||||||
LastLoginDate = DateTime.MinValue,
|
LastLoginDate = DateTime.MinValue,
|
||||||
LastActivityDate = DateTime.MinValue,
|
LastActivityDate = DateTime.MinValue,
|
||||||
LastLockoutDate = DateTime.MinValue
|
LastLockoutDate = DateTime.MinValue
|
||||||
};
|
};
|
||||||
|
|
||||||
var insertTask = _memberCollection
|
Task insertTask = _memberCollection.InsertOneAsync(mm);
|
||||||
.InsertOneAsync(mm);
|
|
||||||
insertTask.Wait();
|
insertTask.Wait();
|
||||||
|
|
||||||
if (insertTask.Status == TaskStatus.RanToCompletion)
|
if (insertTask.Status == TaskStatus.RanToCompletion)
|
||||||
{
|
{
|
||||||
|
|
||||||
status = MembershipCreateStatus.Success;
|
status = MembershipCreateStatus.Success;
|
||||||
mu = new MembershipUser(this.Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
mu = new MembershipUser(Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -179,110 +165,85 @@ public override MembershipUser CreateUser(string username, string password, stri
|
||||||
|
|
||||||
public override bool DeleteUser(string username, bool deleteAllRelatedData)
|
public override bool DeleteUser(string username, bool deleteAllRelatedData)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<DeleteResult> task = _memberCollection.DeleteOneAsync(m => m.UserName.ToLower() == username.ToLower());
|
||||||
.DeleteOneAsync(m => m.UserName.ToLower() == username.ToLower());
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
return task.Result.IsAcknowledged && task.Result.DeletedCount == 1;
|
return task.Result.IsAcknowledged && task.Result.DeletedCount == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
|
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
|
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
|
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
|
||||||
{
|
{
|
||||||
MembershipUserCollection muc = new MembershipUserCollection();
|
MembershipUserCollection muc = new MembershipUserCollection();
|
||||||
|
|
||||||
var users = _memberCollection
|
IFindFluent<MongoMember, MongoMember> users = _memberCollection.Find(new BsonDocument());
|
||||||
.Find(new BsonDocument());
|
|
||||||
|
|
||||||
var totalRecordsTask = users
|
Task<long> totalRecordsTask = users.CountAsync();
|
||||||
.CountAsync();
|
|
||||||
totalRecordsTask.Wait();
|
totalRecordsTask.Wait();
|
||||||
totalRecords = Convert.ToInt32(totalRecordsTask.Result);
|
totalRecords = Convert.ToInt32(totalRecordsTask.Result);
|
||||||
|
|
||||||
users = users
|
users = users.Skip(pageIndex * pageSize).Limit(pageSize);
|
||||||
.Skip(pageIndex * pageSize)
|
Task<List<MongoMember>> pageItemsTask = users.ToListAsync();
|
||||||
.Limit(pageSize);
|
|
||||||
var pageItemsTask = users.ToListAsync();
|
|
||||||
pageItemsTask.Wait();
|
pageItemsTask.Wait();
|
||||||
|
|
||||||
foreach (var mm in pageItemsTask.Result)
|
foreach (MongoMember mm in pageItemsTask.Result)
|
||||||
{
|
{
|
||||||
muc.Add(new MembershipUser(this.Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate));
|
muc.Add(new MembershipUser(Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
return muc;
|
return muc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetNumberOfUsersOnline()
|
public override int GetNumberOfUsersOnline() { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string GetPassword(string username, string answer)
|
public override string GetPassword(string username, string answer) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override MembershipUser GetUser(string username, bool userIsOnline)
|
public override MembershipUser GetUser(string username, bool userIsOnline)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<MongoMember> task = _memberCollection.Find(f => f.UserName.ToLower() == username.ToLower()).FirstOrDefaultAsync();
|
||||||
.Find(f => f.UserName.ToLower() == username.ToLower())
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
var mm = task.Result;
|
MongoMember mm = task.Result;
|
||||||
|
|
||||||
return mm == null ? null : new MembershipUser(this.Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
return mm == null
|
||||||
|
? null
|
||||||
|
: new MembershipUser(Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
|
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<MongoMember> task = _memberCollection.Find(f => f.Id == (Guid)providerUserKey).FirstOrDefaultAsync();
|
||||||
.Find(f => f.Id == (Guid)providerUserKey)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
var mm = task.Result;
|
MongoMember mm = task.Result;
|
||||||
|
|
||||||
return mm == null ? null : new MembershipUser(this.Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
return mm == null
|
||||||
|
? null
|
||||||
|
: new MembershipUser(Name, mm.UserName, mm.Id, mm.EmailAddress, "", "", mm.IsApproved, mm.IsLockedOut, mm.CreationDate, mm.LastLoginDate, mm.LastActivityDate, DateTime.MinValue, mm.LastLockoutDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetUserNameByEmail(string email)
|
public override string GetUserNameByEmail(string email)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<MongoMember> task = _memberCollection.Find(f => f.EmailAddress.ToLower() == email.ToLower()).FirstOrDefaultAsync();
|
||||||
.Find(f => f.EmailAddress.ToLower() == email.ToLower())
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
return task.Result.UserName;
|
return task.Result.UserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ResetPassword(string username, string answer)
|
public override string ResetPassword(string username, string answer) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeApproval(Guid Id, bool newStatus)
|
public void ChangeApproval(Guid id, bool newStatus)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<UpdateResult> task = _memberCollection.UpdateOneAsync(Builders<MongoMember>.Filter.Eq(u => u.Id, id), Builders<MongoMember>.Update.Set(u => u.IsApproved, newStatus));
|
||||||
.UpdateOneAsync(
|
|
||||||
Builders<MongoMember>.Filter.Eq(u => u.Id, Id),
|
|
||||||
Builders<MongoMember>.Update.Set(u => u.IsApproved, newStatus));
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeLockStatus(Guid Id, bool newStatus)
|
public void ChangeLockStatus(Guid id, bool newStatus)
|
||||||
{
|
{
|
||||||
var updateDefinition = new List<UpdateDefinition<MongoMember>>();
|
List<UpdateDefinition<MongoMember>> updateDefinition = new List<UpdateDefinition<MongoMember>>();
|
||||||
updateDefinition.Add(Builders<MongoMember>.Update.Set(u => u.IsLockedOut, newStatus));
|
updateDefinition.Add(Builders<MongoMember>.Update.Set(u => u.IsLockedOut, newStatus));
|
||||||
|
|
||||||
if (newStatus)
|
if (newStatus)
|
||||||
|
@ -295,50 +256,40 @@ public void ChangeLockStatus(Guid Id, bool newStatus)
|
||||||
updateDefinition.Add(Builders<MongoMember>.Update.Set(u => u.LastLockoutDate, DateTime.MinValue));
|
updateDefinition.Add(Builders<MongoMember>.Update.Set(u => u.LastLockoutDate, DateTime.MinValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
var task = _memberCollection
|
Task<UpdateResult> task = _memberCollection.UpdateOneAsync(Builders<MongoMember>.Filter.Eq(u => u.Id, id), Builders<MongoMember>.Update.Combine(updateDefinition));
|
||||||
.UpdateOneAsync(
|
|
||||||
Builders<MongoMember>.Filter.Eq(u => u.Id, Id),
|
|
||||||
Builders<MongoMember>.Update.Combine(updateDefinition));
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool UnlockUser(string userName)
|
public override bool UnlockUser(string userName)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<UpdateResult> task = _memberCollection.UpdateOneAsync(Builders<MongoMember>.Filter.Eq(m => m.UserName.ToLower(), userName.ToLower()), Builders<MongoMember>.Update.Set(m => m.IsLockedOut, false));
|
||||||
.UpdateOneAsync(
|
|
||||||
Builders<MongoMember>.Filter.Eq(m => m.UserName.ToLower(), userName.ToLower()),
|
|
||||||
Builders<MongoMember>.Update.Set(m => m.IsLockedOut, false));
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
return task.Result.IsAcknowledged && task.Result.ModifiedCount == 1;
|
return task.Result.IsAcknowledged && task.Result.ModifiedCount == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UpdateUser(MembershipUser user)
|
public override void UpdateUser(MembershipUser user) { throw new NotImplementedException(); }
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool ValidateUser(string username, string password)
|
public override bool ValidateUser(string username, string password)
|
||||||
{
|
{
|
||||||
var task = _memberCollection
|
Task<MongoMember> task = _memberCollection.Find(f => f.UserName.ToLower() == username.ToLower()).FirstOrDefaultAsync();
|
||||||
.Find(f => f.UserName.ToLower() == username.ToLower())
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
var mm = task.Result;
|
MongoMember mm = task.Result;
|
||||||
|
|
||||||
if (mm == null || !(mm.IsApproved && !mm.IsLockedOut))
|
if (mm == null
|
||||||
|
|| !(mm.IsApproved && !mm.IsLockedOut))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] salt = mm.PassSalt;
|
byte[] salt = mm.PassSalt;
|
||||||
byte[] hash = calculateHash(password, ref salt);
|
byte[] hash = CalculateHash(password, ref salt);
|
||||||
|
|
||||||
bool isFail = false;
|
bool isFail = false;
|
||||||
|
|
||||||
for (int i = 0; i > hash.Length; i++)
|
for (int i = 0; i > hash.Length; i++)
|
||||||
{
|
{
|
||||||
isFail |= (hash[i] != mm.PassHash[i]);
|
isFail |= hash[i] != mm.PassHash[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,16 +326,13 @@ public override bool ValidateUser(string username, string password)
|
||||||
mm.LockoutWindowAttempts = 0;
|
mm.LockoutWindowAttempts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var updTask = _memberCollection
|
Task<ReplaceOneResult> updTask = _memberCollection.ReplaceOneAsync(Builders<MongoMember>.Filter.Eq(u => u.Id, mm.Id), mm);
|
||||||
.ReplaceOneAsync(
|
|
||||||
Builders<MongoMember>.Filter.Eq(u => u.Id, mm.Id),
|
|
||||||
mm);
|
|
||||||
updTask.Wait();
|
updTask.Wait();
|
||||||
|
|
||||||
return !isFail;
|
return !isFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] calculateHash(string password, ref byte[] salt)
|
private static byte[] CalculateHash(string password, ref byte[] salt)
|
||||||
{
|
{
|
||||||
if (!salt.Any(v => v != 0))
|
if (!salt.Any(v => v != 0))
|
||||||
{
|
{
|
||||||
|
@ -405,18 +353,22 @@ private static byte[] calculateHash(string password, ref byte[] salt)
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool tryReadBool(string config, bool defaultValue)
|
private static bool TryReadBool(string config, bool defaultValue)
|
||||||
{
|
{
|
||||||
bool temp = false;
|
bool temp;
|
||||||
bool success = bool.TryParse(config, out temp);
|
bool success = bool.TryParse(config, out temp);
|
||||||
return success ? temp : defaultValue;
|
return success
|
||||||
|
? temp
|
||||||
|
: defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int tryReadInt(string config, int defaultValue)
|
private static int TryReadInt(string config, int defaultValue)
|
||||||
{
|
{
|
||||||
int temp = 0;
|
int temp;
|
||||||
bool success = int.TryParse(config, out temp);
|
bool success = int.TryParse(config, out temp);
|
||||||
return success ? temp : defaultValue;
|
return success
|
||||||
|
? temp
|
||||||
|
: defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,5 +393,4 @@ public class MongoMember
|
||||||
public DateTime LockoutWindowStart { get; set; }
|
public DateTime LockoutWindowStart { get; set; }
|
||||||
public int LockoutWindowAttempts { get; set; }
|
public int LockoutWindowAttempts { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,20 +1,22 @@
|
||||||
using MongoDB.Bson;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Configuration.Provider;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Security;
|
||||||
|
using MongoAuth.Properties;
|
||||||
|
using MongoDB.Bson;
|
||||||
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web.Security;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Configuration.Provider;
|
|
||||||
|
|
||||||
namespace MongoAuth
|
namespace MongoAuth
|
||||||
{
|
{
|
||||||
public class MongoRoleProvider : RoleProvider
|
public class MongoRoleProvider : RoleProvider
|
||||||
{
|
{
|
||||||
private const string _roleCollectionName = "roles";
|
private const string MEMBER_COLLECTION_NAME = "members";
|
||||||
private const string _memberCollectionName = "members";
|
private const string ROLE_COLLECTION_NAME = "roles";
|
||||||
private MongoClient _dbClient;
|
private MongoClient _dbClient;
|
||||||
private IMongoCollection<MongoRole> _roleCollection;
|
private IMongoCollection<MongoRole> _roleCollection;
|
||||||
private IMongoCollection<MongoMember> _memberCollection;
|
private IMongoCollection<MongoMember> _memberCollection;
|
||||||
|
@ -29,26 +31,22 @@ public override void Initialize(string name, NameValueCollection config)
|
||||||
{
|
{
|
||||||
base.Initialize(name, config);
|
base.Initialize(name, config);
|
||||||
|
|
||||||
_dbClient = new MongoClient(new MongoClientSettings()
|
_dbClient = new MongoClient(new MongoClientSettings
|
||||||
{
|
{
|
||||||
Server = new MongoServerAddress(DatabaseConfig.Host, DatabaseConfig.Port)
|
Server = new MongoServerAddress(DatabaseConfig.Host, DatabaseConfig.Port)
|
||||||
});
|
});
|
||||||
|
|
||||||
_roleCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoRole>(_roleCollectionName);
|
_roleCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoRole>(ROLE_COLLECTION_NAME);
|
||||||
_memberCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoMember>(_memberCollectionName);
|
_memberCollection = _dbClient.GetDatabase(DatabaseConfig.Database).GetCollection<MongoMember>(MEMBER_COLLECTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
||||||
{
|
{
|
||||||
var roleTask = _roleCollection
|
Task<List<MongoRole>> roleTask = _roleCollection.Find(r => roleNames.Contains(r.RoleName)).ToListAsync();
|
||||||
.Find(r => roleNames.Contains(r.RoleName))
|
|
||||||
.ToListAsync();
|
|
||||||
roleTask.Wait();
|
roleTask.Wait();
|
||||||
List<MongoRole> roles = roleTask.Result;
|
List<MongoRole> roles = roleTask.Result;
|
||||||
|
|
||||||
var userTask = _memberCollection
|
Task<List<MongoMember>> userTask = _memberCollection.Find(u => usernames.Contains(u.UserName)).ToListAsync();
|
||||||
.Find(u => usernames.Contains(u.UserName))
|
|
||||||
.ToListAsync();
|
|
||||||
userTask.Wait();
|
userTask.Wait();
|
||||||
List<MongoMember> users = userTask.Result;
|
List<MongoMember> users = userTask.Result;
|
||||||
|
|
||||||
|
@ -61,47 +59,44 @@ public override void AddUsersToRoles(string[] usernames, string[] roleNames)
|
||||||
newUsers.AddRange(roles[i].Users);
|
newUsers.AddRange(roles[i].Users);
|
||||||
}
|
}
|
||||||
|
|
||||||
var usersToAdd = from u in users
|
IEnumerable<Guid> usersToAdd = from u in users
|
||||||
where !newUsers.Any(v => v == u.Id)
|
where newUsers.All(v => v != u.Id)
|
||||||
select u.Id;
|
select u.Id;
|
||||||
|
|
||||||
newUsers.AddRange(usersToAdd);
|
newUsers.AddRange(usersToAdd);
|
||||||
|
|
||||||
roles[i].Users = newUsers.ToArray();
|
roles[i].Users = newUsers.ToArray();
|
||||||
|
|
||||||
var update = _roleCollection
|
Task<ReplaceOneResult> update = _roleCollection.ReplaceOneAsync(Builders<MongoRole>.Filter.Eq(r => r.Id, roles[i].Id), roles[i]);
|
||||||
.ReplaceOneAsync(Builders<MongoRole>.Filter.Eq(r => r.Id, roles[i].Id), roles[i]);
|
|
||||||
update.Wait();
|
update.Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CreateRole(string roleName)
|
public override void CreateRole(string roleName)
|
||||||
{
|
{
|
||||||
MongoRole r = new MongoRole()
|
MongoRole r = new MongoRole
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
RoleName = roleName
|
RoleName = roleName
|
||||||
};
|
};
|
||||||
|
|
||||||
var task = _roleCollection
|
Task task = _roleCollection.InsertOneAsync(r);
|
||||||
.InsertOneAsync(r);
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
||||||
{
|
{
|
||||||
var role = _roleCollection
|
Task<MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();
|
||||||
.Find(r => r.RoleName == roleName)
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
if (role.Result != null && role.Result.Users.Length > 0 && throwOnPopulatedRole)
|
if (role.Result != null
|
||||||
|
&& role.Result.Users.Length > 0
|
||||||
|
&& throwOnPopulatedRole)
|
||||||
{
|
{
|
||||||
throw new ProviderException(Properties.Resources.RoleNotEmpty);
|
throw new ProviderException(Resources.RoleNotEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
var task = _roleCollection
|
Task<DeleteResult> task = _roleCollection.DeleteOneAsync(r => r.RoleName == roleName);
|
||||||
.DeleteOneAsync(r => r.RoleName == roleName);
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -109,94 +104,69 @@ public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
|
||||||
|
|
||||||
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
|
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
|
||||||
{
|
{
|
||||||
var role = _roleCollection
|
Task<MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();
|
||||||
.Find(r => r.RoleName == roleName)
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
if (role == null)
|
if (role.Result == null)
|
||||||
{
|
{
|
||||||
return Array.Empty<string>();
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = _memberCollection
|
Task<List<MongoMember>> users = _memberCollection.Find(u => role.Result.Users.Contains(u.Id) && u.UserName.ToLower().Contains(usernameToMatch.ToLower())).ToListAsync();
|
||||||
.Find(u => role.Result.Users.Contains(u.Id) && u.UserName.ToLower().Contains(usernameToMatch.ToLower()))
|
|
||||||
.ToListAsync();
|
|
||||||
users.Wait();
|
users.Wait();
|
||||||
|
|
||||||
return users.Result
|
return users.Result.Select(r => r.UserName).ToArray();
|
||||||
.Select(r => r.UserName)
|
|
||||||
.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string[] GetAllRoles()
|
public override string[] GetAllRoles()
|
||||||
{
|
{
|
||||||
var roles = _roleCollection
|
Task<List<MongoRole>> roles = _roleCollection.Find(new BsonDocument()).ToListAsync();
|
||||||
.Find(new BsonDocument())
|
|
||||||
.ToListAsync();
|
|
||||||
roles.Wait();
|
roles.Wait();
|
||||||
|
|
||||||
return roles.Result
|
return roles.Result.Select(r => r.RoleName).ToArray();
|
||||||
.Select(r => r.RoleName)
|
|
||||||
.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string[] GetRolesForUser(string username)
|
public override string[] GetRolesForUser(string username)
|
||||||
{
|
{
|
||||||
var user = _memberCollection
|
Task<MongoMember> user = _memberCollection.Find(u => u.UserName.ToLower() == username.ToLower()).SingleOrDefaultAsync();
|
||||||
.Find(u => u.UserName.ToLower() == username.ToLower())
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
user.Wait();
|
user.Wait();
|
||||||
|
|
||||||
if (user == null)
|
if (user.Result == null)
|
||||||
{
|
{
|
||||||
return Array.Empty<string>();
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var role = _roleCollection
|
Task<List<MongoRole>> role = _roleCollection.Find(r => r.Users != null && r.Users.Contains(user.Result.Id)).ToListAsync();
|
||||||
.Find(r => r.Users != null && r.Users.Contains(user.Result.Id))
|
|
||||||
.ToListAsync();
|
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
return role.Result
|
return role.Result.Select(r => r.RoleName).ToArray();
|
||||||
.Select(r => r.RoleName)
|
|
||||||
.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string[] GetUsersInRole(string roleName)
|
public override string[] GetUsersInRole(string roleName)
|
||||||
{
|
{
|
||||||
var role = _roleCollection
|
Task<MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();
|
||||||
.Find(r => r.RoleName == roleName)
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
if (role == null)
|
if (role.Result == null)
|
||||||
{
|
{
|
||||||
return Array.Empty<string>();
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var users = _memberCollection
|
Task<List<MongoMember>> users = _memberCollection.Find(u => role.Result.Users.Contains(u.Id)).ToListAsync();
|
||||||
.Find(u => role.Result.Users.Contains(u.Id))
|
|
||||||
.ToListAsync();
|
|
||||||
users.Wait();
|
users.Wait();
|
||||||
|
|
||||||
return users.Result
|
return users.Result.Select(u => u.UserName).ToArray();
|
||||||
.Select(u => u.UserName)
|
|
||||||
.ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsUserInRole(string username, string roleName)
|
public override bool IsUserInRole(string username, string roleName)
|
||||||
{
|
{
|
||||||
var user = _memberCollection
|
Task<MongoMember> user = _memberCollection.Find(u => u.UserName.ToLower() == username.ToLower()).SingleOrDefaultAsync();
|
||||||
.Find(u => u.UserName.ToLower() == username.ToLower())
|
Task<MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
var role = _roleCollection
|
|
||||||
.Find(r => r.RoleName == roleName)
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
user.Wait();
|
user.Wait();
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
if (user.Result == null || role.Result == null || role.Result.Users == null)
|
if (user.Result == null
|
||||||
|
|| role.Result?.Users == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -206,35 +176,28 @@ public override bool IsUserInRole(string username, string roleName)
|
||||||
|
|
||||||
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
|
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
|
||||||
{
|
{
|
||||||
var roleTask = _roleCollection
|
Task<List<MongoRole>> roleTask = _roleCollection.Find(r => roleNames.Contains(r.RoleName)).ToListAsync();
|
||||||
.Find(r => roleNames.Contains(r.RoleName))
|
|
||||||
.ToListAsync();
|
|
||||||
roleTask.Wait();
|
roleTask.Wait();
|
||||||
List<MongoRole> roles = roleTask.Result;
|
List<MongoRole> roles = roleTask.Result;
|
||||||
|
|
||||||
var userTask = _memberCollection
|
Task<List<MongoMember>> userTask = _memberCollection.Find(u => usernames.Contains(u.UserName)).ToListAsync();
|
||||||
.Find(u => usernames.Contains(u.UserName))
|
|
||||||
.ToListAsync();
|
|
||||||
userTask.Wait();
|
userTask.Wait();
|
||||||
List<MongoMember> users = userTask.Result;
|
List<MongoMember> users = userTask.Result;
|
||||||
|
|
||||||
for (int i = 0; i < roles.Count; i++)
|
foreach (MongoRole t in roles)
|
||||||
{
|
{
|
||||||
roles[i].Users = (from u in roles[i].Users
|
t.Users = (from u in t.Users
|
||||||
where !users.Any(v => v.Id == u)
|
where users.All(v => v.Id != u)
|
||||||
select u).ToArray();
|
select u).ToArray();
|
||||||
|
|
||||||
var update = _roleCollection
|
Task<ReplaceOneResult> update = _roleCollection.ReplaceOneAsync(Builders<MongoRole>.Filter.Eq(r => r.Id, t.Id), t);
|
||||||
.ReplaceOneAsync(Builders<MongoRole>.Filter.Eq(r => r.Id, roles[i].Id), roles[i]);
|
|
||||||
update.Wait();
|
update.Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool RoleExists(string roleName)
|
public override bool RoleExists(string roleName)
|
||||||
{
|
{
|
||||||
var role = _roleCollection
|
Task<MongoRole> role = _roleCollection.Find(r => r.RoleName == roleName).SingleOrDefaultAsync();
|
||||||
.Find(r => r.RoleName == roleName)
|
|
||||||
.SingleOrDefaultAsync();
|
|
||||||
role.Wait();
|
role.Wait();
|
||||||
|
|
||||||
return role.Result != null;
|
return role.Result != null;
|
||||||
|
|
|
@ -4,9 +4,6 @@ namespace BuildFeed
|
||||||
{
|
{
|
||||||
public class FilterConfig
|
public class FilterConfig
|
||||||
{
|
{
|
||||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); }
|
||||||
{
|
|
||||||
filters.Add(new HandleErrorAttribute());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
using BuildFeed.Models;
|
using System.Configuration;
|
||||||
using System.Configuration;
|
using BuildFeed.Models;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BuildFeed
|
namespace BuildFeed
|
||||||
{
|
{
|
||||||
|
@ -12,9 +11,9 @@ internal static class MongoConfig
|
||||||
|
|
||||||
static MongoConfig()
|
static MongoConfig()
|
||||||
{
|
{
|
||||||
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"]) ?
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
|
||||||
ConfigurationManager.AppSettings["data:MongoHost"] :
|
? ConfigurationManager.AppSettings["data:MongoHost"]
|
||||||
"localhost";
|
: "localhost";
|
||||||
|
|
||||||
int _port;
|
int _port;
|
||||||
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
||||||
|
@ -24,9 +23,9 @@ static MongoConfig()
|
||||||
}
|
}
|
||||||
Port = _port;
|
Port = _port;
|
||||||
|
|
||||||
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"]) ?
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
|
||||||
ConfigurationManager.AppSettings["data:MongoDB"] :
|
? ConfigurationManager.AppSettings["data:MongoDB"]
|
||||||
"MongoAuth";
|
: "MongoAuth";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetupIndexes()
|
public static void SetupIndexes()
|
||||||
|
|
|
@ -11,7 +11,9 @@ public static void RegisterRoutes(RouteCollection routes)
|
||||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||||
|
|
||||||
routes.AppendTrailingSlash = true;
|
routes.AppendTrailingSlash = true;
|
||||||
routes.MapHttpRoute("API", "api/{action}/{id}", new
|
routes.MapHttpRoute("API",
|
||||||
|
"api/{action}/{id}",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "api",
|
controller = "api",
|
||||||
action = "GetBuilds",
|
action = "GetBuilds",
|
||||||
|
|
|
@ -82,7 +82,8 @@ public async Task<ActionResult> create(MetaItemModel meta)
|
||||||
|
|
||||||
public async Task<ActionResult> edit(MetaType type, string value)
|
public async Task<ActionResult> edit(MetaType type, string value)
|
||||||
{
|
{
|
||||||
return View("create", await _mModel.SelectById(new MetaItemKey
|
return View("create",
|
||||||
|
await _mModel.SelectById(new MetaItemKey
|
||||||
{
|
{
|
||||||
Type = type,
|
Type = type,
|
||||||
Value = value
|
Value = value
|
||||||
|
|
|
@ -67,7 +67,8 @@ public ActionResult cleanup()
|
||||||
|
|
||||||
foreach (MembershipUser user in users)
|
foreach (MembershipUser user in users)
|
||||||
{
|
{
|
||||||
if (!user.IsApproved && (user.CreationDate.AddDays(30) < DateTime.Now))
|
if (!user.IsApproved
|
||||||
|
&& (user.CreationDate.AddDays(30) < DateTime.Now))
|
||||||
{
|
{
|
||||||
Membership.DeleteUser(user.UserName);
|
Membership.DeleteUser(user.UserName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
@model BuildFeed.Models.MetaItemModel
|
@model BuildFeed.Models.MetaItemModel
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = string.Format("Add metadata for {0} | BuildFeed", Model.Id.Value);
|
ViewBag.Title = $"Add metadata for {Model.Id.Value} | BuildFeed";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@string.Format("Add metadata for {0}", Model.Id.Value)</h2>
|
<h2>@($"Add metadata for {Model.Id.Value}") </h2>
|
||||||
|
|
||||||
|
|
||||||
@using (Html.BeginForm())
|
@using (Html.BeginForm())
|
||||||
|
@ -15,9 +15,16 @@
|
||||||
|
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(model => model.MetaDescription, htmlAttributes: new { @class = "control-label" })
|
@Html.LabelFor(model => model.MetaDescription, new
|
||||||
|
{
|
||||||
|
@class = "control-label"
|
||||||
|
})
|
||||||
<div class="wide-group">
|
<div class="wide-group">
|
||||||
@Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" })
|
@Html.TextAreaFor(model => model.MetaDescription, new
|
||||||
|
{
|
||||||
|
@class = "form-control",
|
||||||
|
rows = "2"
|
||||||
|
})
|
||||||
<div class="help-block">
|
<div class="help-block">
|
||||||
<span id="meta-count">0</span> characters
|
<span id="meta-count">0</span> characters
|
||||||
@Html.ValidationMessageFor(model => model.MetaDescription)
|
@Html.ValidationMessageFor(model => model.MetaDescription)
|
||||||
|
@ -26,9 +33,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@Html.LabelFor(model => model.PageContent, new { @class = "control-label" })
|
@Html.LabelFor(model => model.PageContent, new
|
||||||
|
{
|
||||||
|
@class = "control-label"
|
||||||
|
})
|
||||||
<div class="wide-group">
|
<div class="wide-group">
|
||||||
@Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" })
|
@Html.TextAreaFor(model => model.PageContent, new
|
||||||
|
{
|
||||||
|
@class = "form-control"
|
||||||
|
})
|
||||||
<div class="help-block">
|
<div class="help-block">
|
||||||
@Html.ValidationMessageFor(model => model.PageContent)
|
@Html.ValidationMessageFor(model => model.PageContent)
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,16 +66,20 @@
|
||||||
<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
|
<script type="text/javascript" src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function updateMetaCount() {
|
function updateMetaCount()
|
||||||
|
{
|
||||||
var count = document.getElementById("@Html.IdFor(model => model.MetaDescription)").value.length;
|
var count = document.getElementById("@Html.IdFor(model => model.MetaDescription)").value.length;
|
||||||
$("#meta-count").text(count.toFixed(0));
|
$("#meta-count").text(count.toFixed(0));
|
||||||
if (count === 0) {
|
if (count === 0)
|
||||||
|
{
|
||||||
$("#meta-count").attr("class", "");
|
$("#meta-count").attr("class", "");
|
||||||
}
|
}
|
||||||
else if (count < 160) {
|
else if (count < 160)
|
||||||
|
{
|
||||||
$("#meta-count").attr("class", "text-success");
|
$("#meta-count").attr("class", "text-success");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$("#meta-count").attr("class", "text-danger");
|
$("#meta-count").attr("class", "text-danger");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,17 +87,21 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
var btnsGrps = $.trumbowyg.btnsGrps;
|
var btnsGrps = $.trumbowyg.btnsGrps;
|
||||||
|
|
||||||
$("#@Html.IdFor(model => model.PageContent)").trumbowyg({
|
$("#@Html.IdFor(model => model.PageContent)")
|
||||||
|
.trumbowyg({
|
||||||
semantic: true,
|
semantic: true,
|
||||||
autogrow: true,
|
autogrow: true,
|
||||||
btns: ['viewHTML',
|
btns: [
|
||||||
|
'viewHTML',
|
||||||
'|', 'strong', 'em',
|
'|', 'strong', 'em',
|
||||||
'|', 'link',
|
'|', 'link',
|
||||||
'|', btnsGrps.justify,
|
'|', btnsGrps.justify,
|
||||||
'|', btnsGrps.lists]
|
'|', btnsGrps.lists
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#@Html.IdFor(model => model.MetaDescription)").keyup(function () {
|
$("#@Html.IdFor(model => model.MetaDescription)")
|
||||||
|
.keyup(function() {
|
||||||
updateMetaCount();
|
updateMetaCount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@model BuildFeed.Areas.admin.Models.ViewModel.MetaListing
|
@using BuildFeed.Models
|
||||||
|
@model BuildFeed.Areas.admin.Models.ViewModel.MetaListing
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Metadata | BuildFeed";
|
ViewBag.Title = "Metadata | BuildFeed";
|
||||||
|
@ -18,16 +19,27 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var group in Model.CurrentItems)
|
@foreach (IGrouping<MetaType, MetaItemModel> group in Model.CurrentItems)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"><h4>@group.Key</h4></td>
|
<td colspan="3">
|
||||||
|
<h4>@group.Key</h4>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
foreach (var item in group)
|
foreach (MetaItemModel item in group)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@item.Id.Value</td>
|
<td>@item.Id.Value</td>
|
||||||
<td>@Html.ActionLink("Edit", "edit", new { type = item.Id.Type, value = item.Id.Value }, new { @class = "button", style = "width:50px" })</td>
|
<td>
|
||||||
|
@Html.ActionLink("Edit", "edit", new
|
||||||
|
{
|
||||||
|
type = item.Id.Type,
|
||||||
|
value = item.Id.Value
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button",
|
||||||
|
style = "width:50px"
|
||||||
|
})</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,16 +54,27 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var group in Model.NewItems)
|
@foreach (IGrouping<MetaType, MetaItemModel> group in Model.NewItems)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"><h4>@group.Key</h4></td>
|
<td colspan="3">
|
||||||
|
<h4>@group.Key</h4>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
foreach (var item in group)
|
foreach (MetaItemModel item in group)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@item.Id.Value</td>
|
<td>@item.Id.Value</td>
|
||||||
<td>@Html.ActionLink("Create", "create", new { type = item.Id.Type, value = item.Id.Value }, new { @class = "button", style = "width:50px" })</td>
|
<td>
|
||||||
|
@Html.ActionLink("Create", "create", new
|
||||||
|
{
|
||||||
|
type = item.Id.Type,
|
||||||
|
value = item.Id.Value
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button",
|
||||||
|
style = "width:50px"
|
||||||
|
})</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
<a href="mailto:@mu.Email">@mu.Email</a>
|
<a href="mailto:@mu.Email">@mu.Email</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@(mu.LastLoginDate == default(DateTime) ? "Never" : mu.LastLoginDate.Humanize())
|
@(mu.LastLoginDate == default(DateTime)
|
||||||
|
? "Never"
|
||||||
|
: mu.LastLoginDate.Humanize())
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,26 +46,60 @@
|
||||||
<a href="mailto:@mu.Email">@mu.Email</a>
|
<a href="mailto:@mu.Email">@mu.Email</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@(mu.CreationDate == default(DateTime) ? "Never" : mu.CreationDate.Humanize())
|
@(mu.CreationDate == default(DateTime)
|
||||||
|
? "Never"
|
||||||
|
: mu.CreationDate.Humanize())
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@(mu.LastLoginDate == default(DateTime) ? "Never" : mu.LastLoginDate.Humanize())
|
@(mu.LastLoginDate == default(DateTime)
|
||||||
|
? "Never"
|
||||||
|
: mu.LastLoginDate.Humanize())
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@(mu.LastLockoutDate == default(DateTime) ? "Never" : mu.LastLockoutDate.Humanize())
|
@(mu.LastLockoutDate == default(DateTime)
|
||||||
|
? "Never"
|
||||||
|
: mu.LastLockoutDate.Humanize())
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@(
|
@(
|
||||||
mu.IsApproved ?
|
mu.IsApproved
|
||||||
Html.ActionLink("Unapprove", "unapprove", new { id = mu.ProviderUserKey }, new { @class = "button delete-button", style = "width:70px;" }) :
|
? Html.ActionLink("Unapprove", "unapprove", new
|
||||||
Html.ActionLink("Approve", "approve", new { id = mu.ProviderUserKey }, new { @class = "button add-button", style = "width:70px;" })
|
{
|
||||||
|
id = mu.ProviderUserKey
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button delete-button",
|
||||||
|
style = "width:70px;"
|
||||||
|
})
|
||||||
|
: Html.ActionLink("Approve", "approve", new
|
||||||
|
{
|
||||||
|
id = mu.ProviderUserKey
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button add-button",
|
||||||
|
style = "width:70px;"
|
||||||
|
})
|
||||||
)
|
)
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@(
|
@(
|
||||||
!mu.IsLockedOut ?
|
!mu.IsLockedOut
|
||||||
Html.ActionLink("Lock", "lock", new { id = mu.ProviderUserKey }, new { @class = "button delete-button", style = "width:70px;" }) :
|
? Html.ActionLink("Lock", "lock", new
|
||||||
Html.ActionLink("Unlock", "unlock", new { id = mu.ProviderUserKey }, new { @class = "button add-button", style = "width:70px;" })
|
{
|
||||||
|
id = mu.ProviderUserKey
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button delete-button",
|
||||||
|
style = "width:70px;"
|
||||||
|
})
|
||||||
|
: Html.ActionLink("Unlock", "unlock", new
|
||||||
|
{
|
||||||
|
id = mu.ProviderUserKey
|
||||||
|
}, new
|
||||||
|
{
|
||||||
|
@class = "button add-button",
|
||||||
|
style = "width:70px;"
|
||||||
|
})
|
||||||
)
|
)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -8,17 +8,22 @@ public class AdminAreaRegistration : AreaRegistration
|
||||||
|
|
||||||
public override void RegisterArea(AreaRegistrationContext context)
|
public override void RegisterArea(AreaRegistrationContext context)
|
||||||
{
|
{
|
||||||
context.MapRoute(
|
context.MapRoute("Meta",
|
||||||
"Meta",
|
|
||||||
"admin/{controller}/{action}/{type}/{value}",
|
"admin/{controller}/{action}/{type}/{value}",
|
||||||
new { action = "index", controller = "meta" }
|
new
|
||||||
);
|
{
|
||||||
|
action = "index",
|
||||||
|
controller = "meta"
|
||||||
|
});
|
||||||
|
|
||||||
context.MapRoute(
|
context.MapRoute("Admin (Default)",
|
||||||
"Admin (Default)",
|
|
||||||
"admin/{controller}/{action}/{id}",
|
"admin/{controller}/{action}/{id}",
|
||||||
new { action = "index", controller = "base", id = UrlParameter.Optional }
|
new
|
||||||
);
|
{
|
||||||
|
action = "index",
|
||||||
|
controller = "base",
|
||||||
|
id = UrlParameter.Optional
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -104,7 +104,8 @@ where s.Text.ToLower().Contains(id.ToLower())
|
||||||
orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending
|
orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending
|
||||||
select new SearchResult
|
select new SearchResult
|
||||||
{
|
{
|
||||||
Url = Url.Route("Source Root", new
|
Url = Url.Route("Source Root",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "Front",
|
controller = "Front",
|
||||||
action = "ViewSource",
|
action = "ViewSource",
|
||||||
|
@ -123,7 +124,8 @@ orderby s.Text.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascendi
|
||||||
orderby v.Major descending, v.Minor descending
|
orderby v.Major descending, v.Minor descending
|
||||||
select new SearchResult
|
select new SearchResult
|
||||||
{
|
{
|
||||||
Url = Url.Route("Version Root", new
|
Url = Url.Route("Version Root",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "Front",
|
controller = "Front",
|
||||||
action = "ViewVersion",
|
action = "ViewVersion",
|
||||||
|
@ -143,7 +145,8 @@ where y.ToString().Contains(id)
|
||||||
orderby y descending
|
orderby y descending
|
||||||
select new SearchResult
|
select new SearchResult
|
||||||
{
|
{
|
||||||
Url = Url.Route("Year Root", new
|
Url = Url.Route("Year Root",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "Front",
|
controller = "Front",
|
||||||
action = "ViewYear",
|
action = "ViewYear",
|
||||||
|
@ -160,7 +163,8 @@ orderby y descending
|
||||||
IEnumerable<SearchResult> labResults = from l in await _bModel.SearchLabs(id)
|
IEnumerable<SearchResult> labResults = from l in await _bModel.SearchLabs(id)
|
||||||
select new SearchResult
|
select new SearchResult
|
||||||
{
|
{
|
||||||
Url = Url.Route("Lab Root", new
|
Url = Url.Route("Lab Root",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "Front",
|
controller = "Front",
|
||||||
action = "ViewLab",
|
action = "ViewLab",
|
||||||
|
@ -179,7 +183,8 @@ where b.FullBuildString.ToLower().Contains(id.ToLower())
|
||||||
orderby b.FullBuildString.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending, b.BuildTime descending
|
orderby b.FullBuildString.ToLower().IndexOf(id.ToLower(), StringComparison.Ordinal) ascending, b.BuildTime descending
|
||||||
select new SearchResult
|
select new SearchResult
|
||||||
{
|
{
|
||||||
Url = Url.Route("Build", new
|
Url = Url.Route("Build",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
controller = "Front",
|
controller = "Front",
|
||||||
action = "ViewBuild",
|
action = "ViewBuild",
|
||||||
|
|
|
@ -74,7 +74,8 @@ public async Task<ActionResult> ViewGroup(uint major, uint minor, uint number, u
|
||||||
List<BuildModel> builds = await _bModel.SelectGroup(bg);
|
List<BuildModel> builds = await _bModel.SelectGroup(bg);
|
||||||
|
|
||||||
return builds.Count() == 1
|
return builds.Count() == 1
|
||||||
? RedirectToAction(nameof(ViewBuild), new
|
? RedirectToAction(nameof(ViewBuild),
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = builds.Single().Id
|
id = builds.Single().Id
|
||||||
}) as ActionResult
|
}) as ActionResult
|
||||||
|
@ -103,7 +104,8 @@ public async Task<ActionResult> ViewBuild(long id)
|
||||||
{
|
{
|
||||||
return new HttpNotFoundResult();
|
return new HttpNotFoundResult();
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(ViewBuild), new
|
return RedirectToAction(nameof(ViewBuild),
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = b.Id
|
id = b.Id
|
||||||
});
|
});
|
||||||
|
@ -149,7 +151,12 @@ public async Task<ActionResult> TwitterCard(Guid id)
|
||||||
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 280, new Point(32, 96), StringFormat.GenericTypographic);
|
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 280, new Point(32, 96), StringFormat.GenericTypographic);
|
||||||
gp.AddString(b.BuildTime.HasValue
|
gp.AddString(b.BuildTime.HasValue
|
||||||
? $"{b.Lab}\r\n{b.BuildTime.Value:yyyy/MM/dd HH:mm}"
|
? $"{b.Lab}\r\n{b.BuildTime.Value:yyyy/MM/dd HH:mm}"
|
||||||
: $"{b.Lab}", new FontFamily("Segoe UI"), 0, 44, new Point(40, 440), StringFormat.GenericTypographic);
|
: $"{b.Lab}",
|
||||||
|
new FontFamily("Segoe UI"),
|
||||||
|
0,
|
||||||
|
44,
|
||||||
|
new Point(40, 440),
|
||||||
|
StringFormat.GenericTypographic);
|
||||||
gr.FillPath(Brushes.White, gp);
|
gr.FillPath(Brushes.White, gp);
|
||||||
|
|
||||||
Response.ContentType = "image/png";
|
Response.ContentType = "image/png";
|
||||||
|
@ -168,7 +175,8 @@ public async Task<ActionResult> TwitterCard(long id)
|
||||||
{
|
{
|
||||||
return new HttpNotFoundResult();
|
return new HttpNotFoundResult();
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(TwitterCard), new
|
return RedirectToAction(nameof(TwitterCard),
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = b.Id
|
id = b.Id
|
||||||
});
|
});
|
||||||
|
@ -178,7 +186,10 @@ public async Task<ActionResult> TwitterCard(long id)
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
||||||
#endif
|
#endif
|
||||||
public async Task<ActionResult> ViewLab(string lab) { return await ViewLabPage(lab, 1); }
|
public async Task<ActionResult> ViewLab(string lab)
|
||||||
|
{
|
||||||
|
return await ViewLabPage(lab, 1);
|
||||||
|
}
|
||||||
|
|
||||||
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
|
[Route("lab/{lab}/page-{page:int:min(2)}/", Order = 0)]
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
@ -210,7 +221,10 @@ public async Task<ActionResult> ViewLabPage(string lab, int page)
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
||||||
#endif
|
#endif
|
||||||
public async Task<ActionResult> ViewSource(TypeOfSource source) { return await ViewSourcePage(source, 1); }
|
public async Task<ActionResult> ViewSource(TypeOfSource source)
|
||||||
|
{
|
||||||
|
return await ViewSourcePage(source, 1);
|
||||||
|
}
|
||||||
|
|
||||||
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
|
[Route("source/{source}/page-{page:int:min(2)}/", Order = 0)]
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
@ -242,7 +256,10 @@ public async Task<ActionResult> ViewSourcePage(TypeOfSource source, int page)
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
||||||
#endif
|
#endif
|
||||||
public async Task<ActionResult> ViewYear(int year) { return await ViewYearPage(year, 1); }
|
public async Task<ActionResult> ViewYear(int year)
|
||||||
|
{
|
||||||
|
return await ViewYearPage(year, 1);
|
||||||
|
}
|
||||||
|
|
||||||
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
|
[Route("year/{year}/page-{page:int:min(2)}/", Order = 0)]
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
@ -274,7 +291,10 @@ public async Task<ActionResult> ViewYearPage(int year, int page)
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
// [OutputCache(Duration = 600, VaryByParam = "none", VaryByCustom = "userName")]
|
||||||
#endif
|
#endif
|
||||||
public async Task<ActionResult> ViewVersion(uint major, uint minor) { return await ViewVersionPage(major, minor, 1); }
|
public async Task<ActionResult> ViewVersion(uint major, uint minor)
|
||||||
|
{
|
||||||
|
return await ViewVersionPage(major, minor, 1);
|
||||||
|
}
|
||||||
|
|
||||||
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
|
[Route("version/{major}.{minor}/page-{page:int:min(2)}/", Order = 0)]
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
|
@ -336,7 +356,8 @@ public async Task<ActionResult> AddBuild(BuildModel build)
|
||||||
{
|
{
|
||||||
return View("EditBuild", build);
|
return View("EditBuild", build);
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(ViewBuild), new
|
return RedirectToAction(nameof(ViewBuild),
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = build.Id
|
id = build.Id
|
||||||
});
|
});
|
||||||
|
@ -373,7 +394,8 @@ public async Task<ActionResult> EditBuild(Guid id, BuildModel build)
|
||||||
return View(build);
|
return View(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction(nameof(ViewBuild), new
|
return RedirectToAction(nameof(ViewBuild),
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = build.Id
|
id = build.Id
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using BuildFeed.Code;
|
|
||||||
using BuildFeed.Models;
|
using BuildFeed.Models;
|
||||||
using WilderMinds.RssSyndication;
|
using WilderMinds.RssSyndication;
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,8 @@ public async Task<ActionResult> Sitemap()
|
||||||
List<BuildModel> builds = await _bModel.SelectBuildsByOrder();
|
List<BuildModel> builds = await _bModel.SelectBuildsByOrder();
|
||||||
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>
|
Dictionary<string, SitemapPagedAction[]> actions = new Dictionary<string, SitemapPagedAction[]>
|
||||||
{
|
{
|
||||||
{ "Pages", new[]
|
{
|
||||||
|
"Pages", new[]
|
||||||
{
|
{
|
||||||
new SitemapPagedAction
|
new SitemapPagedAction
|
||||||
{
|
{
|
||||||
|
@ -153,8 +154,10 @@ public async Task<ActionResult> Sitemap()
|
||||||
}),
|
}),
|
||||||
Pages = (builds.Count + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
Pages = (builds.Count + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
||||||
}
|
}
|
||||||
} },
|
}
|
||||||
{ "Versions", (from b in builds
|
},
|
||||||
|
{
|
||||||
|
"Versions", (from b in builds
|
||||||
group b by new BuildVersion
|
group b by new BuildVersion
|
||||||
{
|
{
|
||||||
Major = b.MajorVersion,
|
Major = b.MajorVersion,
|
||||||
|
@ -174,8 +177,10 @@ into bv
|
||||||
page = 1
|
page = 1
|
||||||
}),
|
}),
|
||||||
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
||||||
}).ToArray() },
|
}).ToArray()
|
||||||
{ "Labs", (from b in builds
|
},
|
||||||
|
{
|
||||||
|
"Labs", (from b in builds
|
||||||
where !string.IsNullOrEmpty(b.Lab)
|
where !string.IsNullOrEmpty(b.Lab)
|
||||||
group b by b.Lab
|
group b by b.Lab
|
||||||
into bv
|
into bv
|
||||||
|
@ -191,8 +196,10 @@ orderby bv.Key
|
||||||
page = 1
|
page = 1
|
||||||
}),
|
}),
|
||||||
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
||||||
}).ToArray() },
|
}).ToArray()
|
||||||
{ "Years", (from b in builds
|
},
|
||||||
|
{
|
||||||
|
"Years", (from b in builds
|
||||||
where b.BuildTime.HasValue
|
where b.BuildTime.HasValue
|
||||||
group b by b.BuildTime.Value.Year
|
group b by b.BuildTime.Value.Year
|
||||||
into bv
|
into bv
|
||||||
|
@ -208,8 +215,10 @@ orderby bv.Key descending
|
||||||
page = 1
|
page = 1
|
||||||
}),
|
}),
|
||||||
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
||||||
}).ToArray() },
|
}).ToArray()
|
||||||
{ "Sources", (from b in builds
|
},
|
||||||
|
{
|
||||||
|
"Sources", (from b in builds
|
||||||
group b by b.SourceType
|
group b by b.SourceType
|
||||||
into bv
|
into bv
|
||||||
orderby bv.Key
|
orderby bv.Key
|
||||||
|
@ -224,7 +233,8 @@ orderby bv.Key
|
||||||
page = 1
|
page = 1
|
||||||
}),
|
}),
|
||||||
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
Pages = (bv.Count() + (FrontController.PAGE_SIZE - 1)) / FrontController.PAGE_SIZE
|
||||||
}).ToArray() }
|
}).ToArray()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +294,10 @@ public async Task<ActionResult> XmlSitemap()
|
||||||
foreach (BuildModel b in await _bModel.Select())
|
foreach (BuildModel b in await _bModel.Select())
|
||||||
{
|
{
|
||||||
XElement url = new XElement(xn + "url");
|
XElement url = new XElement(xn + "url");
|
||||||
url.Add(new XElement(xn + "loc", Request.Url?.GetLeftPart(UriPartial.Authority) + Url.Action("ViewBuild", "Front", new
|
url.Add(new XElement(xn + "loc",
|
||||||
|
Request.Url?.GetLeftPart(UriPartial.Authority) + Url.Action("ViewBuild",
|
||||||
|
"Front",
|
||||||
|
new
|
||||||
{
|
{
|
||||||
id = b.Id
|
id = b.Id
|
||||||
})));
|
})));
|
||||||
|
|
|
@ -13,7 +13,8 @@ public async Task<FrontBuildGroup[]> SelectAllGroups(int limit = -1, int skip =
|
||||||
{
|
{
|
||||||
IAggregateFluent<BsonDocument> query = _buildCollection.Aggregate().Group(new BsonDocument
|
IAggregateFluent<BsonDocument> query = _buildCollection.Aggregate().Group(new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement("_id", new BsonDocument
|
new BsonElement("_id",
|
||||||
|
new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
||||||
new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
|
new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
|
||||||
|
@ -56,7 +57,8 @@ public async Task<long> SelectAllGroupsCount()
|
||||||
{
|
{
|
||||||
List<BsonDocument> grouping = await _buildCollection.Aggregate().Group(new BsonDocument
|
List<BsonDocument> grouping = await _buildCollection.Aggregate().Group(new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement("_id", new BsonDocument
|
new BsonElement("_id",
|
||||||
|
new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
new BsonElement(nameof(BuildGroup.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
||||||
new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
|
new BsonElement(nameof(BuildGroup.Minor), $"${nameof(BuildModel.MinorVersion)}"),
|
||||||
|
@ -88,15 +90,12 @@ public async Task<List<BuildModel>> SelectGroup(BuildGroup group, int limit = -1
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> SelectGroupCount(BuildGroup group)
|
public async Task<long> SelectGroupCount(BuildGroup group) => await _buildCollection.CountAsync(new BsonDocument
|
||||||
{
|
{
|
||||||
return await _buildCollection.CountAsync(new BsonDocument
|
new BsonElement(nameof(BuildModel.MajorVersion), @group.Major),
|
||||||
{
|
new BsonElement(nameof(BuildModel.MinorVersion), @group.Minor),
|
||||||
new BsonElement(nameof(BuildModel.MajorVersion), group.Major),
|
new BsonElement(nameof(BuildModel.Number), @group.Build),
|
||||||
new BsonElement(nameof(BuildModel.MinorVersion), group.Minor),
|
new BsonElement(nameof(BuildModel.Revision), @group.Revision)
|
||||||
new BsonElement(nameof(BuildModel.Number), group.Build),
|
|
||||||
new BsonElement(nameof(BuildModel.Revision), group.Revision)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -71,6 +71,6 @@ public async Task<List<BuildModel>> SelectLab(string lab, int limit = -1, int sk
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> SelectLabCount(string lab) { return await _buildCollection.CountAsync(new BsonDocument(nameof(BuildModel.LabUrl), lab)); }
|
public async Task<long> SelectLabCount(string lab) => await _buildCollection.CountAsync(new BsonDocument(nameof(BuildModel.LabUrl), lab));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ namespace BuildFeed.Models
|
||||||
{
|
{
|
||||||
public partial class Build
|
public partial class Build
|
||||||
{
|
{
|
||||||
public Task<TypeOfSource[]> SelectAllSources(int limit = -1, int skip = 0) { return Task.Run(() => Enum.GetValues(typeof(TypeOfSource)) as TypeOfSource[]); }
|
public Task<TypeOfSource[]> SelectAllSources(int limit = -1, int skip = 0) => Task.Run(() => Enum.GetValues(typeof(TypeOfSource)) as TypeOfSource[]);
|
||||||
|
|
||||||
public Task<long> SelectAllSourcesCount() { return Task.Run(() => Enum.GetValues(typeof(TypeOfSource)).LongLength); }
|
public Task<long> SelectAllSourcesCount() => Task.Run(() => Enum.GetValues(typeof(TypeOfSource)).LongLength);
|
||||||
|
|
||||||
public async Task<List<BuildModel>> SelectSource(TypeOfSource source, int limit = -1, int skip = 0)
|
public async Task<List<BuildModel>> SelectSource(TypeOfSource source, int limit = -1, int skip = 0)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,6 @@ public async Task<List<BuildModel>> SelectSource(TypeOfSource source, int limit
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> SelectSourceCount(TypeOfSource source) { return await _buildCollection.CountAsync(new BsonDocument(nameof(BuildModel.SourceType), source)); }
|
public async Task<long> SelectSourceCount(TypeOfSource source) => await _buildCollection.CountAsync(new BsonDocument(nameof(BuildModel.SourceType), source));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,7 +10,8 @@ public partial class Build
|
||||||
{
|
{
|
||||||
public async Task<BuildVersion[]> SelectAllVersions(int limit = -1, int skip = 0)
|
public async Task<BuildVersion[]> SelectAllVersions(int limit = -1, int skip = 0)
|
||||||
{
|
{
|
||||||
IAggregateFluent<BsonDocument> query = _buildCollection.Aggregate().Group(new BsonDocument("_id", new BsonDocument
|
IAggregateFluent<BsonDocument> query = _buildCollection.Aggregate().Group(new BsonDocument("_id",
|
||||||
|
new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement(nameof(BuildVersion.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
new BsonElement(nameof(BuildVersion.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
||||||
new BsonElement(nameof(BuildVersion.Minor), $"${nameof(BuildModel.MinorVersion)}")
|
new BsonElement(nameof(BuildVersion.Minor), $"${nameof(BuildModel.MinorVersion)}")
|
||||||
|
@ -37,7 +38,8 @@ public async Task<BuildVersion[]> SelectAllVersions(int limit = -1, int skip = 0
|
||||||
|
|
||||||
public async Task<long> SelectAllVersionsCount()
|
public async Task<long> SelectAllVersionsCount()
|
||||||
{
|
{
|
||||||
List<BsonDocument> query = await _buildCollection.Aggregate().Group(new BsonDocument("_id", new BsonDocument
|
List<BsonDocument> query = await _buildCollection.Aggregate().Group(new BsonDocument("_id",
|
||||||
|
new BsonDocument
|
||||||
{
|
{
|
||||||
new BsonElement(nameof(BuildVersion.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
new BsonElement(nameof(BuildVersion.Major), $"${nameof(BuildModel.MajorVersion)}"),
|
||||||
new BsonElement(nameof(BuildVersion.Minor), $"${nameof(BuildModel.MinorVersion)}")
|
new BsonElement(nameof(BuildVersion.Minor), $"${nameof(BuildModel.MinorVersion)}")
|
||||||
|
@ -61,13 +63,10 @@ public async Task<List<BuildModel>> SelectVersion(uint major, uint minor, int li
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> SelectVersionCount(uint major, uint minor)
|
public async Task<long> SelectVersionCount(uint major, uint minor) => await _buildCollection.CountAsync(new BsonDocument
|
||||||
{
|
|
||||||
return await _buildCollection.CountAsync(new BsonDocument
|
|
||||||
{
|
{
|
||||||
new BsonElement(nameof(BuildModel.MajorVersion), major),
|
new BsonElement(nameof(BuildModel.MajorVersion), major),
|
||||||
new BsonElement(nameof(BuildModel.MinorVersion), minor)
|
new BsonElement(nameof(BuildModel.MinorVersion), minor)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -11,7 +11,12 @@ public partial class Build
|
||||||
{
|
{
|
||||||
public async Task<int[]> SelectAllYears(int limit = -1, int skip = 0)
|
public async Task<int[]> SelectAllYears(int limit = -1, int skip = 0)
|
||||||
{
|
{
|
||||||
IAggregateFluent<BsonDocument> query = _buildCollection.Aggregate().Match(Builders<BuildModel>.Filter.Ne(b => b.BuildTime, null)).Group(new BsonDocument("_id", new BsonDocument("$year", $"${nameof(BuildModel.BuildTime)}"))).Sort(new BsonDocument("_id", -1)).Skip(skip);
|
IAggregateFluent<BsonDocument> query =
|
||||||
|
_buildCollection.Aggregate()
|
||||||
|
.Match(Builders<BuildModel>.Filter.Ne(b => b.BuildTime, null))
|
||||||
|
.Group(new BsonDocument("_id", new BsonDocument("$year", $"${nameof(BuildModel.BuildTime)}")))
|
||||||
|
.Sort(new BsonDocument("_id", -1))
|
||||||
|
.Skip(skip);
|
||||||
|
|
||||||
if (limit > 0)
|
if (limit > 0)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +39,9 @@ public async Task<long> SelectAllYearsCount()
|
||||||
|
|
||||||
public async Task<List<BuildModel>> SelectYear(int year, int limit = -1, int skip = 0)
|
public async Task<List<BuildModel>> SelectYear(int year, int limit = -1, int skip = 0)
|
||||||
{
|
{
|
||||||
IFindFluent<BuildModel, BuildModel> query = _buildCollection.Find(Builders<BuildModel>.Filter.And(Builders<BuildModel>.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)), Builders<BuildModel>.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc)))).Sort(sortByCompileDate).Skip(skip);
|
IFindFluent<BuildModel, BuildModel> query =
|
||||||
|
_buildCollection.Find(Builders<BuildModel>.Filter.And(Builders<BuildModel>.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)),
|
||||||
|
Builders<BuildModel>.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc)))).Sort(sortByCompileDate).Skip(skip);
|
||||||
|
|
||||||
if (limit > 0)
|
if (limit > 0)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +51,10 @@ public async Task<List<BuildModel>> SelectYear(int year, int limit = -1, int ski
|
||||||
return await query.ToListAsync();
|
return await query.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<long> SelectYearCount(int year) { return await _buildCollection.CountAsync(Builders<BuildModel>.Filter.And(Builders<BuildModel>.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)), Builders<BuildModel>.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc)))); }
|
public async Task<long> SelectYearCount(int year)
|
||||||
|
=>
|
||||||
|
await
|
||||||
|
_buildCollection.CountAsync(Builders<BuildModel>.Filter.And(Builders<BuildModel>.Filter.Gte(b => b.BuildTime, new DateTime(year, 1, 1, 0, 0, 0, DateTimeKind.Utc)),
|
||||||
|
Builders<BuildModel>.Filter.Lte(b => b.BuildTime, new DateTime(year, 12, 31, 23, 59, 59, DateTimeKind.Utc))));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,13 @@ public async Task SetupIndexes()
|
||||||
List<BsonDocument> indexes = await (await _buildCollection.Indexes.ListAsync()).ToListAsync();
|
List<BsonDocument> indexes = await (await _buildCollection.Indexes.ListAsync()).ToListAsync();
|
||||||
if (indexes.All(i => i["name"] != "_idx_group"))
|
if (indexes.All(i => i["name"] != "_idx_group"))
|
||||||
{
|
{
|
||||||
await _buildCollection.Indexes.CreateOneAsync(Builders<BuildModel>.IndexKeys.Combine(Builders<BuildModel>.IndexKeys.Descending(b => b.MajorVersion), Builders<BuildModel>.IndexKeys.Descending(b => b.MinorVersion), Builders<BuildModel>.IndexKeys.Descending(b => b.Number), Builders<BuildModel>.IndexKeys.Descending(b => b.Revision)), new CreateIndexOptions
|
await
|
||||||
|
_buildCollection.Indexes.CreateOneAsync(
|
||||||
|
Builders<BuildModel>.IndexKeys.Combine(Builders<BuildModel>.IndexKeys.Descending(b => b.MajorVersion),
|
||||||
|
Builders<BuildModel>.IndexKeys.Descending(b => b.MinorVersion),
|
||||||
|
Builders<BuildModel>.IndexKeys.Descending(b => b.Number),
|
||||||
|
Builders<BuildModel>.IndexKeys.Descending(b => b.Revision)),
|
||||||
|
new CreateIndexOptions
|
||||||
{
|
{
|
||||||
Name = "_idx_group"
|
Name = "_idx_group"
|
||||||
});
|
});
|
||||||
|
@ -54,7 +60,8 @@ public async Task SetupIndexes()
|
||||||
|
|
||||||
if (indexes.All(i => i["name"] != "_idx_legacy"))
|
if (indexes.All(i => i["name"] != "_idx_legacy"))
|
||||||
{
|
{
|
||||||
await _buildCollection.Indexes.CreateOneAsync(Builders<BuildModel>.IndexKeys.Ascending(b => b.LegacyId), new CreateIndexOptions
|
await _buildCollection.Indexes.CreateOneAsync(Builders<BuildModel>.IndexKeys.Ascending(b => b.LegacyId),
|
||||||
|
new CreateIndexOptions
|
||||||
{
|
{
|
||||||
Name = "_idx_legacy"
|
Name = "_idx_legacy"
|
||||||
});
|
});
|
||||||
|
@ -62,7 +69,8 @@ public async Task SetupIndexes()
|
||||||
|
|
||||||
if (indexes.All(i => i["name"] != "_idx_lab"))
|
if (indexes.All(i => i["name"] != "_idx_lab"))
|
||||||
{
|
{
|
||||||
await _buildCollection.Indexes.CreateOneAsync(Builders<BuildModel>.IndexKeys.Ascending(b => b.Lab), new CreateIndexOptions
|
await _buildCollection.Indexes.CreateOneAsync(Builders<BuildModel>.IndexKeys.Ascending(b => b.Lab),
|
||||||
|
new CreateIndexOptions
|
||||||
{
|
{
|
||||||
Name = "_idx_lab"
|
Name = "_idx_lab"
|
||||||
});
|
});
|
||||||
|
@ -98,44 +106,60 @@ public async Task<FrontPage> SelectFrontPage()
|
||||||
|
|
||||||
IFindFluent<BuildModel, BuildModel> query = _buildCollection.Find(new BsonDocument
|
IFindFluent<BuildModel, BuildModel> query = _buildCollection.Find(new BsonDocument
|
||||||
{
|
{
|
||||||
{ nameof(BuildModel.LabUrl), new BsonDocument
|
{
|
||||||
|
nameof(BuildModel.LabUrl), new BsonDocument
|
||||||
{
|
{
|
||||||
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:OSGLab"].Split(';')) }
|
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:OSGLab"].Split(';')) }
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
}).Sort(sortByCompileDate).Limit(1);
|
}).Sort(sortByCompileDate).Limit(1);
|
||||||
|
|
||||||
fp.CurrentCanary = (await query.ToListAsync())[0];
|
fp.CurrentCanary = (await query.ToListAsync())[0];
|
||||||
|
|
||||||
query = _buildCollection.Find(new BsonDocument
|
query = _buildCollection.Find(new BsonDocument
|
||||||
{
|
{
|
||||||
{ nameof(BuildModel.LabUrl), new BsonDocument
|
{
|
||||||
|
nameof(BuildModel.LabUrl), new BsonDocument
|
||||||
{
|
{
|
||||||
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:InsiderLab"].Split(';')) }
|
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:InsiderLab"].Split(';')) }
|
||||||
} },
|
}
|
||||||
{ nameof(BuildModel.SourceType), new BsonDocument
|
},
|
||||||
{
|
{
|
||||||
{ "$in", new BsonArray()
|
nameof(BuildModel.SourceType), new BsonDocument
|
||||||
{
|
{
|
||||||
TypeOfSource.PublicRelease, TypeOfSource.UpdateGDR
|
{
|
||||||
} }
|
"$in", new BsonArray
|
||||||
} }
|
{
|
||||||
|
TypeOfSource.PublicRelease,
|
||||||
|
TypeOfSource.UpdateGDR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}).Sort(sortByCompileDate).Limit(1);
|
}).Sort(sortByCompileDate).Limit(1);
|
||||||
|
|
||||||
fp.CurrentInsider = (await query.ToListAsync())[0];
|
fp.CurrentInsider = (await query.ToListAsync())[0];
|
||||||
|
|
||||||
query = _buildCollection.Find(new BsonDocument
|
query = _buildCollection.Find(new BsonDocument
|
||||||
{
|
{
|
||||||
{ nameof(BuildModel.LabUrl), new BsonDocument
|
{
|
||||||
|
nameof(BuildModel.LabUrl), new BsonDocument
|
||||||
{
|
{
|
||||||
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:ReleaseLab"].Split(';')) }
|
{ "$in", new BsonArray(ConfigurationManager.AppSettings["site:ReleaseLab"].Split(';')) }
|
||||||
} },
|
}
|
||||||
{ nameof(BuildModel.SourceType), new BsonDocument
|
},
|
||||||
{
|
{
|
||||||
{ "$in", new BsonArray()
|
nameof(BuildModel.SourceType), new BsonDocument
|
||||||
{
|
{
|
||||||
TypeOfSource.PublicRelease, TypeOfSource.UpdateGDR
|
{
|
||||||
} }
|
"$in", new BsonArray
|
||||||
} }
|
{
|
||||||
|
TypeOfSource.PublicRelease,
|
||||||
|
TypeOfSource.UpdateGDR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}).Sort(sortByCompileDate).Limit(1);
|
}).Sort(sortByCompileDate).Limit(1);
|
||||||
|
|
||||||
fp.CurrentRelease = (await query.ToListAsync())[0];
|
fp.CurrentRelease = (await query.ToListAsync())[0];
|
||||||
|
@ -217,6 +241,9 @@ public async Task Update(BuildModel item)
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataObjectMethod(DataObjectMethodType.Delete, true)]
|
[DataObjectMethod(DataObjectMethodType.Delete, true)]
|
||||||
public async Task DeleteById(Guid id) { await _buildCollection.DeleteOneAsync(Builders<BuildModel>.Filter.Eq(b => b.Id, id)); }
|
public async Task DeleteById(Guid id)
|
||||||
|
{
|
||||||
|
await _buildCollection.DeleteOneAsync(Builders<BuildModel>.Filter.Eq(b => b.Id, id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -141,7 +141,8 @@ public ProjectFamily Family
|
||||||
{
|
{
|
||||||
return ProjectFamily.Windows7;
|
return ProjectFamily.Windows7;
|
||||||
}
|
}
|
||||||
if (MajorVersion == 6 && Number >= 5000)
|
if (MajorVersion == 6
|
||||||
|
&& Number >= 5000)
|
||||||
{
|
{
|
||||||
return ProjectFamily.WindowsVista;
|
return ProjectFamily.WindowsVista;
|
||||||
}
|
}
|
||||||
|
@ -149,15 +150,18 @@ public ProjectFamily Family
|
||||||
{
|
{
|
||||||
return ProjectFamily.Longhorn;
|
return ProjectFamily.Longhorn;
|
||||||
}
|
}
|
||||||
if (MajorVersion == 5 && Number >= 3000)
|
if (MajorVersion == 5
|
||||||
|
&& Number >= 3000)
|
||||||
{
|
{
|
||||||
return ProjectFamily.Server2003;
|
return ProjectFamily.Server2003;
|
||||||
}
|
}
|
||||||
if (MajorVersion == 5 && Number >= 2205)
|
if (MajorVersion == 5
|
||||||
|
&& Number >= 2205)
|
||||||
{
|
{
|
||||||
return ProjectFamily.WindowsXP;
|
return ProjectFamily.WindowsXP;
|
||||||
}
|
}
|
||||||
if (MajorVersion == 5 && MinorVersion == 50)
|
if (MajorVersion == 5
|
||||||
|
&& MinorVersion == 50)
|
||||||
{
|
{
|
||||||
return ProjectFamily.Neptune;
|
return ProjectFamily.Neptune;
|
||||||
}
|
}
|
||||||
|
@ -169,9 +173,6 @@ public ProjectFamily Family
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-')
|
|
||||||
.ToLower();
|
|
||||||
|
|
||||||
public string SourceDetailsFiltered
|
public string SourceDetailsFiltered
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -190,5 +191,7 @@ public string SourceDetailsFiltered
|
||||||
return SourceDetails;
|
return SourceDetails;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,10 +6,8 @@ namespace BuildFeed.Models.ViewModel
|
||||||
public class RegistrationUser
|
public class RegistrationUser
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[MinLength(8)]
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Support_UserName))]
|
||||||
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Support_ConfirmPassword))]
|
public string UserName { get; set; }
|
||||||
[Compare("Password")]
|
|
||||||
public string ConfirmPassword { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[EmailAddress]
|
[EmailAddress]
|
||||||
|
@ -22,7 +20,9 @@ public class RegistrationUser
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Support_UserName))]
|
[MinLength(8)]
|
||||||
public string UserName { get; set; }
|
[Display(ResourceType = typeof(VariantTerms), Name = nameof(VariantTerms.Support_ConfirmPassword))]
|
||||||
|
[Compare(nameof(Password))]
|
||||||
|
public string ConfirmPassword { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user