* Price.cs:

* Service.cs:
* Price.cs:
* PhysicalProduct.cs: Billing

* SetPrice.cs: Billing


* MyClass.cs:
* ResultPages.cs:
* NpgsqlRoleProvider.cs:
* NpgsqlProfileProvider.cs:
* NpgsqlMembershipProvider.cs: xml doc

* SalesCatalog.csproj: cleanning

* YavscModel.csproj: coding policies
This commit is contained in:
Paul Schneider 2015-02-18 17:34:26 +01:00
commit 7b0dd0c1e2
11 changed files with 457 additions and 54 deletions

View file

@ -15,6 +15,9 @@ using System.Web.Configuration;
namespace Npgsql.Web
{
/// <summary>
/// Npgsql membership provider.
/// </summary>
public sealed class NpgsqlMembershipProvider: MembershipProvider
{
@ -34,7 +37,11 @@ namespace Npgsql.Web
//
// System.Configuration.Provider.ProviderBase.Initialize Method
//
/// <summary>
/// Initialize the specified name and config.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="config">Config.</param>
public override void Initialize (string name, NameValueCollection config)
{
//
@ -134,54 +141,87 @@ namespace Npgsql.Web
private int pMaxInvalidPasswordAttempts;
private int pPasswordAttemptWindow;
private MembershipPasswordFormat pPasswordFormat;
/// <summary>
/// Gets or sets the name of the application.
/// </summary>
/// <value>The name of the application.</value>
public override string ApplicationName {
get { return pApplicationName; }
set { pApplicationName = value; }
}
/// <summary>
/// Gets a value indicating whether this <see cref="Npgsql.Web.NpgsqlMembershipProvider"/> enable password reset.
/// </summary>
/// <value><c>true</c> if enable password reset; otherwise, <c>false</c>.</value>
public override bool EnablePasswordReset {
get { return pEnablePasswordReset; }
}
/// <summary>
/// Gets a value indicating whether this <see cref="Npgsql.Web.NpgsqlMembershipProvider"/> enable password retrieval.
/// </summary>
/// <value><c>true</c> if enable password retrieval; otherwise, <c>false</c>.</value>
public override bool EnablePasswordRetrieval {
get { return pEnablePasswordRetrieval; }
}
/// <summary>
/// Gets a value indicating whether this <see cref="Npgsql.Web.NpgsqlMembershipProvider"/> requires question and answer.
/// </summary>
/// <value><c>true</c> if requires question and answer; otherwise, <c>false</c>.</value>
public override bool RequiresQuestionAndAnswer {
get { return pRequiresQuestionAndAnswer; }
}
/// <summary>
/// Gets a value indicating whether this <see cref="Npgsql.Web.NpgsqlMembershipProvider"/> requires unique email.
/// </summary>
/// <value><c>true</c> if requires unique email; otherwise, <c>false</c>.</value>
public override bool RequiresUniqueEmail {
get { return pRequiresUniqueEmail; }
}
/// <summary>
/// Gets the max invalid password attempts.
/// </summary>
/// <value>The max invalid password attempts.</value>
public override int MaxInvalidPasswordAttempts {
get { return pMaxInvalidPasswordAttempts; }
}
/// <summary>
/// Gets the password attempt window.
/// </summary>
/// <value>The password attempt window.</value>
public override int PasswordAttemptWindow {
get { return pPasswordAttemptWindow; }
}
/// <summary>
/// Gets the password format.
/// </summary>
/// <value>The password format.</value>
public override MembershipPasswordFormat PasswordFormat {
get { return pPasswordFormat; }
}
private int pMinRequiredNonAlphanumericCharacters;
/// <summary>
/// Gets the minimum required non alphanumeric characters.
/// </summary>
/// <value>The minimum required non alphanumeric characters.</value>
public override int MinRequiredNonAlphanumericCharacters {
get { return pMinRequiredNonAlphanumericCharacters; }
}
private int pMinRequiredPasswordLength;
/// <summary>
/// Gets the minimum length of the required password.
/// </summary>
/// <value>The minimum length of the required password.</value>
public override int MinRequiredPasswordLength {
get { return pMinRequiredPasswordLength; }
}
private string pPasswordStrengthRegularExpression;
/// <summary>
/// Gets the password strength regular expression.
/// </summary>
/// <value>The password strength regular expression.</value>
public override string PasswordStrengthRegularExpression {
get { return pPasswordStrengthRegularExpression; }
}
@ -193,7 +233,14 @@ namespace Npgsql.Web
//
// MembershipProvider.ChangePassword
//
/// <Docs>To be added.</Docs>
/// <param name="newPwd">To be added.</param>
/// <summary>
/// Changes the password.
/// </summary>
/// <returns><c>true</c>, if password was changed, <c>false</c> otherwise.</returns>
/// <param name="username">Username.</param>
/// <param name="oldPwd">Old pwd.</param>
public override bool ChangePassword (string username, string oldPwd, string newPwd)
{
if (!ValidateUser (username, oldPwd))
@ -233,7 +280,15 @@ namespace Npgsql.Web
//
// MembershipProvider.ChangePasswordQuestionAndAnswer
//
/// <Docs>To be added.</Docs>
/// <param name="newPwdAnswer">To be added.</param>
/// <summary>
/// Changes the password question and answer.
/// </summary>
/// <returns><c>true</c>, if password question and answer was changed, <c>false</c> otherwise.</returns>
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
/// <param name="newPwdQuestion">New pwd question.</param>
public override bool ChangePasswordQuestionAndAnswer (string username,
string password,
string newPwdQuestion,
@ -268,6 +323,20 @@ namespace Npgsql.Web
// MembershipProvider.CreateUser
//
/// <Docs>Creates an User.</Docs>
/// <summary>
/// To be added.
/// </summary>
/// <remarks>To be added.</remarks>
/// <returns>The user.</returns>
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
/// <param name="email">E-mail.</param>
/// <param name="passwordQuestion">Password question.</param>
/// <param name="passwordAnswer">Password answer.</param>
/// <param name="isApproved">If set to <c>true</c> is approved.</param>
/// <param name="providerUserKey">To be added.</param>
/// <param name="status">Status.</param>
public override MembershipUser CreateUser (string username,
string password,
string email,
@ -397,7 +466,15 @@ namespace Npgsql.Web
//
// MembershipProvider.GetAllUsers
//
/// <Docs>To be added.</Docs>
/// <param name="totalRecords">To be added.</param>
/// <returns>To be added.</returns>
/// <since version=".NET 2.0"></since>
/// <summary>
/// Gets all users.
/// </summary>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
public override MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection users = new MembershipUserCollection ();
@ -448,7 +525,10 @@ namespace Npgsql.Web
//
// MembershipProvider.GetNumberOfUsersOnline
//
/// <summary>
/// Gets the number of users online.
/// </summary>
/// <returns>The number of users online.</returns>
public override int GetNumberOfUsersOnline ()
{
int numOnline = 0;
@ -479,7 +559,13 @@ namespace Npgsql.Web
//
// MembershipProvider.GetPassword
//
/// <Docs>To be added.</Docs>
/// <summary>
/// Gets the password.
/// </summary>
/// <returns>The password.</returns>
/// <param name="username">Username.</param>
/// <param name="answer">Answer.</param>
public override string GetPassword (string username, string answer)
{
string password = "";
@ -592,6 +678,12 @@ namespace Npgsql.Web
//
// MembershipProvider.GetUser(object, bool)
//
/// <summary>
/// Gets the user.
/// </summary>
/// <returns>The user.</returns>
/// <param name="providerUserKey">Provider user key.</param>
/// <param name="userIsOnline">If set to <c>true</c> user is online.</param>
public override MembershipUser GetUser (object providerUserKey, bool userIsOnline)
{
MembershipUser u = null;
@ -686,7 +778,11 @@ namespace Npgsql.Web
//
// MembershipProvider.UnlockUser
//
/// <summary>
/// Unlocks the user.
/// </summary>
/// <returns><c>true</c>, if user was unlocked, <c>false</c> otherwise.</returns>
/// <param name="username">Username.</param>
public override bool UnlockUser (string username)
{
int rowsAffected = 0;
@ -712,7 +808,11 @@ namespace Npgsql.Web
//
// MembershipProvider.GetUserNameByEmail
//
/// <summary>
/// Gets the user name by email.
/// </summary>
/// <returns>The user name by email.</returns>
/// <param name="email">Email.</param>
public override string GetUserNameByEmail (string email)
{
string username = "";
@ -734,7 +834,13 @@ namespace Npgsql.Web
//
// MembershipProvider.ResetPassword
//
/// <Docs>To be added.</Docs>
/// <summary>
/// Resets the password.
/// </summary>
/// <returns>The password.</returns>
/// <param name="username">Username.</param>
/// <param name="answer">Answer.</param>
public override string ResetPassword (string username, string answer)
{
int rowsAffected = 0;
@ -818,7 +924,10 @@ namespace Npgsql.Web
//
// MembershipProvider.UpdateUser
//
/// <summary>
/// Updates the user.
/// </summary>
/// <param name="user">User.</param>
public override void UpdateUser (MembershipUser user)
{
using (NpgsqlConnection conn = new NpgsqlConnection (connectionString)) {
@ -842,7 +951,13 @@ namespace Npgsql.Web
//
// MembershipProvider.ValidateUser
//
/// <Docs>To be added.</Docs>
/// <summary>
/// Validates the user.
/// </summary>
/// <returns><c>true</c>, if user was validated, <c>false</c> otherwise.</returns>
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
public override bool ValidateUser (string username, string password)
{
bool isValid = false;
@ -1022,7 +1137,12 @@ namespace Npgsql.Web
// CheckPassword
// Compares password values based on the MembershipPasswordFormat.
//
/// <summary>
/// Checks the password.
/// </summary>
/// <returns><c>true</c>, if password was checked, <c>false</c> otherwise.</returns>
/// <param name="password">Password.</param>
/// <param name="dbpassword">Dbpassword.</param>
private bool CheckPassword (string password, string dbpassword)
{
string pass1 = password;
@ -1049,7 +1169,11 @@ namespace Npgsql.Web
// EncodePassword
// Encrypts, Hashes, or leaves the password clear based on the PasswordFormat.
//
/// <summary>
/// Encodes the password.
/// </summary>
/// <returns>The password.</returns>
/// <param name="password">Password.</param>
private string EncodePassword (string password)
{
string encodedPassword = password;
@ -1118,7 +1242,16 @@ namespace Npgsql.Web
//
// MembershipProvider.FindUsersByName
//
/// <Docs>To be added.</Docs>
/// <param name="pageSize">To be added.</param>
/// <summary>
/// Finds user by their name.
/// The name can use wilcards : % or ? (used in a Npgsql LIKE clause)
/// </summary>
/// <returns>An user's MembershipUser collection taching that name ...</returns>
/// <param name="usernameToMatch">Username to match.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="totalRecords">Total records.</param>
public override MembershipUserCollection FindUsersByName (string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection users = new MembershipUserCollection ();
@ -1168,6 +1301,16 @@ namespace Npgsql.Web
// MembershipProvider.FindUsersByEmail
//
/// <Docs>To be added.</Docs>
/// <param name="pageSize">To be added.</param>
/// <summary>
/// To be added.
/// </summary>
/// <remarks>To be added.</remarks>
/// <returns>The users by email.</returns>
/// <param name="emailToMatch">Email to match.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="totalRecords">Total records.</param>
public override MembershipUserCollection FindUsersByEmail (string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
MembershipUserCollection users = new MembershipUserCollection ();

View file

@ -5,15 +5,25 @@ using Npgsql;
namespace Npgsql.Web
{
/// <summary>
/// Npgsql profile provider.
/// </summary>
public class NpgsqlProfileProvider: ProfileProvider
{
private string connectionString;
private string applicationName;
/// <summary>
/// Initializes a new instance of the <see cref="Npgsql.Web.NpgsqlProfileProvider"/> class.
/// </summary>
public NpgsqlProfileProvider ()
{
}
/// <summary>
/// Initialize the specified iname and config.
/// </summary>
/// <param name="iname">Iname.</param>
/// <param name="config">Config.</param>
public override void Initialize (string iname, System.Collections.Specialized.NameValueCollection config)
{
// get the
@ -29,27 +39,61 @@ namespace Npgsql.Web
}
#region implemented abstract members of System.Web.Profile.ProfileProvider
/// <summary>
/// Deletes the inactive profiles.
/// </summary>
/// <returns>The inactive profiles.</returns>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="userInactiveSinceDate">User inactive since date.</param>
public override int DeleteInactiveProfiles (ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Deletes the profiles.
/// </summary>
/// <returns>The profiles.</returns>
/// <param name="usernames">Usernames.</param>
public override int DeleteProfiles (string[] usernames)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Deletes the profiles.
/// </summary>
/// <returns>The profiles.</returns>
/// <param name="profiles">Profiles.</param>
public override int DeleteProfiles (ProfileInfoCollection profiles)
{
throw new System.NotImplementedException ();
}
/// <Docs>To be added.</Docs>
/// <param name="userInactiveSinceDate">To be added.</param>
/// <param name="pageSize">To be added.</param>
/// <summary>
/// To be added.
/// </summary>
/// <remarks>To be added.</remarks>
/// <returns>The inactive profiles by user name.</returns>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="usernameToMatch">Username to match.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="totalRecords">Total records.</param>
public override ProfileInfoCollection FindInactiveProfilesByUserName (ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new System.NotImplementedException ();
}
/// <Docs>To be added.</Docs>
/// <param name="pageIndex">To be added.</param>
/// <param name="totalRecords">To be added.</param>
/// <returns>To be added.</returns>
/// <since version=".NET 2.0"></since>
/// <summary>
/// Finds the name of the profiles by user.
/// </summary>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="usernameToMatch">Username to match.</param>
/// <param name="pageSize">Page size.</param>
public override ProfileInfoCollection FindProfilesByUserName (ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
if (pageIndex < 0)
@ -99,17 +143,41 @@ namespace Npgsql.Web
}
return c;
}
/// <Docs>To be added.</Docs>
/// <param name="pageIndex">To be added.</param>
/// <param name="totalRecords">To be added.</param>
/// <returns>To be added.</returns>
/// <since version=".NET 2.0"></since>
/// <summary>
/// Gets all inactive profiles.
/// </summary>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="userInactiveSinceDate">User inactive since date.</param>
/// <param name="pageSize">Page size.</param>
public override ProfileInfoCollection GetAllInactiveProfiles (ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
throw new System.NotImplementedException ();
}
/// <Docs>To be added.</Docs>
/// <param name="pageSize">To be added.</param>
/// <summary>
/// To be added.
/// </summary>
/// <remarks>To be added.</remarks>
/// <returns>The all profiles.</returns>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="totalRecords">Total records.</param>
public override ProfileInfoCollection GetAllProfiles (ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Gets the number of inactive profiles.
/// </summary>
/// <returns>The number of inactive profiles.</returns>
/// <param name="authenticationOption">Authentication option.</param>
/// <param name="userInactiveSinceDate">User inactive since date.</param>
public override int GetNumberOfInactiveProfiles (ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
throw new System.NotImplementedException ();
@ -118,7 +186,12 @@ namespace Npgsql.Web
#endregion
#region implemented abstract members of System.Configuration.SettingsProvider
/// <summary>
/// Gets the property values.
/// </summary>
/// <returns>The property values.</returns>
/// <param name="context">Context.</param>
/// <param name="collection">Collection.</param>
public override SettingsPropertyValueCollection GetPropertyValues (SettingsContext context, SettingsPropertyCollection collection)
{
SettingsPropertyValueCollection c = new SettingsPropertyValueCollection ();
@ -157,7 +230,11 @@ namespace Npgsql.Web
return c;
}
/// <summary>
/// Sets the property values.
/// </summary>
/// <param name="context">Context.</param>
/// <param name="collection">Collection.</param>
public override void SetPropertyValues (SettingsContext context, SettingsPropertyValueCollection collection)
{
// get the unique id of the profile
@ -220,7 +297,10 @@ namespace Npgsql.Web
}
}
}
/// <summary>
/// Gets or sets the name of the application.
/// </summary>
/// <value>The name of the application.</value>
public override string ApplicationName {
get {
return applicationName;

View file

@ -41,13 +41,33 @@ using System.Linq;
namespace Npgsql.Web
{
/// <summary>
/// Npgsql role provider.
/// </summary>
public class NpgsqlRoleProvider: RoleProvider
{
/// <summary>
/// The name.
/// </summary>
protected string name = "NpgsqlRoleProvider";
/// <summary>
/// The name of the connection string.
/// </summary>
protected string connectionStringName = "pgProvider";
/// <summary>
/// The name of the application.
/// </summary>
protected string applicationName = "/";
/// <summary>
/// The connection string.
/// </summary>
protected string connectionString = string.Empty;
/// <summary>
/// Initialize the specified iname and config.
/// </summary>
/// <param name="iname">Iname.</param>
/// <param name="config">Config.</param>
public override void Initialize (string iname, System.Collections.Specialized.NameValueCollection config)
{
try {
@ -82,6 +102,12 @@ namespace Npgsql.Web
}
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Adds the users to roles.
/// </summary>
/// <param name="usernames">Usernames.</param>
/// <param name="roleNames">Role names.</param>
public override void AddUsersToRoles (string[] usernames, string[] roleNames)
{
if (usernames.Any (x => x == null) || roleNames.Any (x => x == null)) {
@ -113,6 +139,10 @@ namespace Npgsql.Web
}
/// <summary>
/// Gets or sets the name of the application.
/// </summary>
/// <value>The name of the application.</value>
public override string ApplicationName {
get {
return applicationName;
@ -122,6 +152,11 @@ namespace Npgsql.Web
}
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Creates the role.
/// </summary>
/// <param name="roleName">Role name.</param>
public override void CreateRole (string roleName)
{
if (roleName == null)
@ -148,6 +183,13 @@ namespace Npgsql.Web
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Deletes the role.
/// </summary>
/// <returns><c>true</c>, if role was deleted, <c>false</c> otherwise.</returns>
/// <param name="roleName">Role name.</param>
/// <param name="throwOnPopulatedRole">If set to <c>true</c> throw on populated role.</param>
public override bool DeleteRole (string roleName, bool throwOnPopulatedRole)
{
if (roleName == null)
@ -173,11 +215,23 @@ namespace Npgsql.Web
return true;
}
/// <summary>
/// Finds the users in role.
/// </summary>
/// <returns>The users in role.</returns>
/// <param name="roleName">Role name.</param>
/// <param name="usernameToMatch">Username to match.</param>
public override string[] FindUsersInRole (string roleName, string usernameToMatch)
{
return GetUsersInRole (roleName, usernameToMatch);
}
/// <summary>
/// Gets the users in role.
/// </summary>
/// <returns>The users in role.</returns>
/// <param name="rolename">Rolename.</param>
/// <param name="usernameToMatch">Username to match.</param>
protected string[] GetUsersInRole (string rolename, string usernameToMatch)
{
if (rolename == null)
@ -206,6 +260,10 @@ namespace Npgsql.Web
}
}
/// <summary>
/// Gets all roles.
/// </summary>
/// <returns>The all roles.</returns>
public override string[] GetAllRoles ()
{
using (var conn = new NpgsqlConnection(connectionString)) {
@ -227,6 +285,11 @@ namespace Npgsql.Web
}
}
/// <summary>
/// Gets the roles for user.
/// </summary>
/// <returns>The roles for user.</returns>
/// <param name="username">Username.</param>
public override string[] GetRolesForUser (string username)
{
if (username == null)
@ -252,6 +315,13 @@ namespace Npgsql.Web
}
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Gets the users in role.
/// </summary>
/// <returns>The users in role.</returns>
/// <param name="roleName">Role name.</param>
public override string[] GetUsersInRole (string roleName)
{
if (string.IsNullOrEmpty (roleName))
@ -277,6 +347,13 @@ namespace Npgsql.Web
}
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Determines whether this instance is user in role the specified username roleName.
/// </summary>
/// <returns><c>true</c> if this instance is user in role the specified username roleName; otherwise, <c>false</c>.</returns>
/// <param name="username">Username.</param>
/// <param name="roleName">Role name.</param>
public override bool IsUserInRole (string username, string roleName)
{
if (username == null || roleName == null)
@ -303,6 +380,12 @@ namespace Npgsql.Web
}
/// <Docs>To be added.</Docs>
/// <summary>
/// Removes the users from roles.
/// </summary>
/// <param name="usernames">Usernames.</param>
/// <param name="roleNames">Role names.</param>
public override void RemoveUsersFromRoles (string[] usernames, string[] roleNames)
{
if (usernames.Any (x => x == null) || roleNames.Any (x => x == null)) {
@ -333,6 +416,12 @@ namespace Npgsql.Web
}
/// <Docs>Tests if a given role name exists.</Docs>
/// <summary>
/// Tests if a given role name exists.
/// </summary>
/// <returns><c>true</c>, if exists was roled, <c>false</c> otherwise.</returns>
/// <param name="roleName">Role name.</param>
public override bool RoleExists (string roleName)
{
using (var conn = new NpgsqlConnection(connectionString)) {
@ -347,13 +436,21 @@ namespace Npgsql.Web
}
}
}
/// <summary>
/// Gets the name of this provider,
/// should correspond to the item key
/// in the configuration collection of providers.
/// </summary>
/// <value>The name.</value>
public override string Name {
get {
return name;
}
}
/// <summary>
/// Gets the description for this provider.
/// </summary>
/// <value>The description.</value>
public override string Description {
get {
return "PostgreSQL ASP.Net Role Provider class";