From: <mar...@us...> - 2010-02-06 23:11:13
|
Revision: 17 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=17&view=rev Author: marioarce Date: 2010-02-06 23:11:07 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Ticket #4 Setting Manager class Implemented a class that manages an application configuration XML file Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/ source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/Settings/ source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/Settings/SettingManager.cs Added: source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/Settings/SettingManager.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/Settings/SettingManager.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Configuration/Settings/SettingManager.cs 2010-02-06 23:11:07 UTC (rev 17) @@ -0,0 +1,575 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.IO; +using System.Xml; +using System.Linq; +using System.Text; +using System.Threading; +using System.Configuration; +using System.Collections.Generic; + +namespace CronosControl.BusinessLogic.Configuration.Settings +{ + /// <summary> + /// Setting manager + /// Manages an application configuration XML file + /// </summary> + /// <example> + /// <strong>SettingManager.Current["mail/smtpPort"]</strong><br /> + /// <strong>SettingManager.Current["viewport/width"] = "800"</strong> + /// <strong>SettingManager.Current["viewport/background@red_element"] = "F6"</strong> + /// </example> + /// <remarks> + /// Setting values to non-existing nodes in xml configuration file is not supported + /// </remarks> + /// <seealso href="http://www.w3.org/TR/xpath"/> + public partial class SettingManager + { + #region Constants + /// <summary> + /// Name of the default configuration file to read if not specified in constructor + /// </summary> + private const string DEFAULT_CONFIGURATION_FILENAME = "Config.xml"; + + /// <summary> + /// Name of the default XML element which acts as the configuration root + /// </summary> + private const string DEFAULT_CONFIG_ROOT = "/configuration"; + + /// <summary> + /// Indicates a default value to determine if the configuration is cached or not + /// </summary> + private const bool DEFAULT_IS_CONFIG_CACHEABLE = true; + + /// <summary> + /// Indicates a default value to determine if setting values automatically flush the config to disk + /// </summary> + private const bool DEFAULT_AUTO_FLUSH_ON_SET = true; + + /// <summary> + /// Indicates a default value to use in case NULL replacement was set to 'true' + /// </summary> + private const string DEFAULT_VALUE_IF_NOT_EXISTS = null; + + /// <summary> + /// Indicates if non-existent nodes should return a custom value (e.g.: null, "") + /// </summary> + private const bool DEFAULT_USE_REPLACEMENT_IF_NULL = false; + #endregion + + #region Constructors + /// <summary> + /// Initializes a new instance of the <see cref="SettingManager"/> class. + /// </summary> + private SettingManager() + : this(null, null) + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManager"/> class. + /// </summary> + /// <param name="configurationFilePath">The configuration file path.</param> + private SettingManager(string configurationFilePath) + : this(configurationFilePath, null) + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManager"/> class. + /// </summary> + /// <param name="configurationFilePath">The configuration file path.</param> + /// <param name="rootElement">The root element.</param> + private SettingManager(string configurationFilePath, string rootElement) + { + if (configurationFilePath == null) + { + // Determines if to use configuration-specified SettingManager fileName, or use default + string fileName = DEFAULT_CONFIGURATION_FILENAME; + if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CronosControl.Web.Configuration.FileName"])) + { + fileName = ConfigurationManager.AppSettings["CronosControl.Web.Configuration.FileName"]; + } + + // Determines the base dir to construct the full path + string baseDir = Thread.GetDomain().BaseDirectory; + if (System.Web.HttpContext.Current != null) + { + try + { + baseDir = System.Web.HttpContext.Current.Request.PhysicalApplicationPath; + } + catch + { + // sometimes during the executing HttpContext.Current.Request would not be initialized, + // not even going to be null, but trying to get this value + // the application raise an exception, this is reason of this try-catch + } + } + baseDir = baseDir.Replace("/", "\\"); + configurationFilePath = _ConfigurationFileName = Path.Combine(baseDir, fileName); + } + + this._ConfigurationFileName = configurationFilePath; + + if (rootElement == null) + { + // Determines if to use configuration-specified SettingManager rootElement, or use default + if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CronosControl.Web.Configuration.RootElement"])) + { + rootElement = ConfigurationManager.AppSettings["CronosControl.Web.Configuration.RootElement"]; + } + else + { + rootElement = DEFAULT_CONFIG_ROOT; + } + } + this._ConfigurationRoot = rootElement; + + // Determines if configuration is going to be cached in ram, or load it from disk upon each access + if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["CronosControl.Web.Configuration.UseCache"])) + { + _UseCache = ConfigurationManager.AppSettings["CronosControl.Web.Configuration.RootElement"] == "true"; + } + else + { + _UseCache = DEFAULT_IS_CONFIG_CACHEABLE; + } + } + #endregion + + #region Properties + private static SettingManager _Current = null; + /// <summary> + /// Gets the singleton instance of configuration. + /// </summary> + /// <value>The current.</value> + public static SettingManager Current + { + get + { + if (_Current == null) + { + //NOTE: Not using 'lock' or 'Syncronized' since static variables in .NET now are thread-safe + if (_Current == null) + { + _Current = new SettingManager(); + } + } + return _Current; + } + } + + private bool _UseCache = DEFAULT_IS_CONFIG_CACHEABLE; + /// <summary> + /// Gets or sets a value indicating whether [use cache]. + /// </summary> + /// <value><c>true</c> if [use cache]; otherwise, <c>false</c>.</value> + private bool UseCache + { + get + { + return _UseCache; + } + set + { + _UseCache = value; + } + } + + private bool _FlushOnSet = DEFAULT_AUTO_FLUSH_ON_SET; + /// <summary> + /// Gets or sets a value indicating whether [to flush] when setting values. + /// </summary> + /// <value><c>true</c> if [flush on set]; otherwise, <c>false</c>.</value> + public bool FlushOnSet + { + get + { + return _FlushOnSet; + } + set + { + _FlushOnSet = value; + } + } + + private bool _UseValueIfNotExists = DEFAULT_USE_REPLACEMENT_IF_NULL; + /// <summary> + /// Gets or sets a value indicating whether [use value if not exists], instead of throwing an exception. + /// </summary> + /// <value> + /// <c>true</c> if [use value if not exists]; otherwise, <c>false</c>. + /// </value> + public bool UseValueIfNotExists + { + get + { + return _UseValueIfNotExists; + } + set + { + _UseValueIfNotExists = value; + } + } + + private string _ValueIfNotExists = DEFAULT_VALUE_IF_NOT_EXISTS; + /// <summary> + /// Gets or sets the value that is used if <strong>UseValueIfNotExists</strong> is [true] and a non-existent node was found + /// </summary> + /// <value>The value if not exists.</value> + public string ValueIfNotExists + { + get + { + return _ValueIfNotExists; + } + set + { + _ValueIfNotExists = value; + } + } + + private XmlDocument _ConfigurationDocument = null; + /// <summary> + /// Gets the configuration document. + /// </summary> + /// <value>The configuration document.</value> + private XmlDocument ConfigurationDocument + { + get + { + if (_ConfigurationDocument == null) + { + Reload(); + } + return _ConfigurationDocument; + } + } + + private string _ConfigurationRoot; + /// <summary> + /// Gets the configuration root. + /// </summary> + /// <value>The configuration root.</value> + private string ConfigurationRoot + { + get + { + if (String.IsNullOrEmpty(_ConfigurationRoot)) + { + _ConfigurationRoot = DEFAULT_CONFIG_ROOT; + } + return _ConfigurationRoot; + } + } + + private string _ConfigurationFileName = null; + /// <summary> + /// Gets the name of the configuration file. + /// </summary> + /// <value>The name of the configuration file.</value> + internal string ConfigurationFileName + { + get + { + return _ConfigurationFileName; + } + } + + /// <summary> + /// Gets or sets the <see cref="System.String"/> with the specified branch. + /// </summary> + /// <value></value> + public string this[string branch, string key] + { + get + { + return GetValue(branch + "/" + key); + } + set + { + SetValue(branch + "/" + key, value); + } + } + + /// <summary> + /// Gets or sets the <see cref="System.String"/> with the specified expression. + /// </summary> + /// <value></value> + public string this[string expression] + { + get + { + return GetValue(expression); + } + set + { + SetValue(expression, value); + } + } + #endregion + + #region Methods + /// <summary> + /// Gets the configuration for a specific filename + /// </summary> + /// <param name="filename">The filename.</param> + /// <returns></returns> + public static SettingManager GetConfiguration(string filename) + { + return new SettingManager(filename); + } + + /// <summary> + /// Gets the configuration for a specific file and root name + /// </summary> + /// <param name="filename">The filename.</param> + /// <param name="rootElement">The root element.</param> + /// <returns></returns> + public static SettingManager GetConfiguration(string filename, string rootElement) + { + return new SettingManager(filename, rootElement); + } + + /// <summary> + /// Gets the configuration from the current file name, but for a particular node + /// </summary> + /// <param name="rootElement">The root element.</param> + /// <returns></returns> + public static SettingManager GetConfigurationFromCurrent(string rootElement) + { + return new SettingManager(Current.ConfigurationFileName, rootElement); + } + + /// <summary> + /// Reloads configuration + /// </summary> + public void Reload() + { + try + { + _ConfigurationDocument = new XmlDocument(); + _ConfigurationDocument.Load(ConfigurationFileName); + } + catch (Exception ex) + { + throw new SettingManagerException("Unable to load configuration", ex, this); + } + } + + /// <summary> + /// Gets the value. + /// </summary> + /// <param name="expression">The expression.</param> + /// <returns></returns> + public string GetValue(string expression) + { + if (!UseCache) + { + Reload(); + } + + XmlNode node = ConfigurationDocument.SelectSingleNode(ConfigurationRoot + "/" + expression); + if (node == null) + { + if (UseValueIfNotExists) + { + return ValueIfNotExists; + } + + throw new SettingManagerException( + "Configuration node '" + expression + "' was not found", + this + ); + } + else if (node is XmlElement) + { + return node.InnerText; + } + else if (node is XmlAttribute) + { + return node.Value; + } + else + { + return node.InnerXml; + } + } + + /// <summary> + /// Sets the value. + /// </summary> + /// <param name="expression">The expression.</param> + /// <param name="value">The value.</param> + public void SetValue(string expression, string value) + { + XmlNode selectedNode = ConfigurationDocument.SelectSingleNode(ConfigurationRoot + "/" + expression); + if (selectedNode == null) + { + throw new SettingManagerException("Selected node not found. Setting values on non-existent nodes is not supported yet", this); + } + else if (selectedNode is XmlElement) + { + (selectedNode as XmlElement).InnerText = value; + } + else if (selectedNode is XmlAttribute) + { + (selectedNode as XmlAttribute).Value = value; + } + else + { + throw new SettingManagerException("The type of configuration node specified is not supported", this); + } + + if (FlushOnSet) + { + try + { + Flush(); + } + catch (Exception ex) + { + throw new SettingManagerException( + "Unable to save changes to disk. Check the configuration file exists and write access is allowed", + ex, this + ); + } + } + } + + /// <summary> + /// Flushes current configuration to disk. + /// </summary> + public void Flush() + { + + try + { + ConfigurationDocument.Save(ConfigurationFileName); + } + catch (Exception ex) + { + throw new SettingManagerException( + "Unable to save changes to disk. Check the configuration file exists and write access is allowed", + ex, this + ); + } + } + + /// <summary> + /// Gets a value specifying a branch and key name, where the branch is the parent element of the key element + /// </summary> + /// <param name="branch">The branch.</param> + /// <param name="nodeName">Name of the node.</param> + /// <returns></returns> + [Obsolete( + "Use instead" + + " 'SettingManager.Current[\"xpathExpression\"]' or " + + " 'SettingManager.Current[\"branch\", \"key\"]'", false + )] + public string GetNodeValue(string branch, string nodeName) + { + return GetValue(branch + "/" + nodeName); + } + + /// <summary> + /// Gets the node value. + /// </summary> + /// <param name="branch">The branch.</param> + /// <param name="nodeName">Name of the node.</param> + /// <param name="handleException">if set to <c>true</c> [handle exception].</param> + /// <returns></returns> + [Obsolete( + "Use instead" + + " 'SettingManager.Current[\"xpathExpression\"]' or " + + " 'SettingManager.Current[\"branch\", \"key\"]'", false + )] + public string GetNodeValue(string branch, string nodeName, bool handleException) + { + try + { + return GetValue(branch + "/" + nodeName); + } + catch (Exception e) + { + if (handleException) + { + e.Data.Add("branch", branch); + } + else + { + throw new SettingManagerException( + "Unable to get configuration value for key '" + nodeName + "'", + e, this + ); + } + return null; + } + } + #endregion + } + + /// <summary> + /// Wraps configuration exceptions + /// </summary> + public class SettingManagerException : ApplicationException + { + private SettingManager targetConfiguration = null; + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManagerException"/> class. + /// </summary> + /// <param name="message">The message.</param> + public SettingManagerException(string message) + : base(message) + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManagerException"/> class. + /// </summary> + /// <param name="message">The message.</param> + /// <param name="ex">The ex.</param> + public SettingManagerException(string message, Exception ex) + : base(message) + { + } + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManagerException"/> class. + /// </summary> + /// <param name="message">The message.</param> + /// <param name="cfg">The CFG.</param> + public SettingManagerException(string message, SettingManager cfg) + : base(message) + { + targetConfiguration = cfg; + } + + /// <summary> + /// Initializes a new instance of the <see cref="SettingManagerException"/> class. + /// </summary> + /// <param name="message">The message.</param> + /// <param name="ex">The exception.</param> + /// <param name="configuration">The configuration.</param> + public SettingManagerException(string message, Exception ex, SettingManager configuration) + : base(message, ex) + { + targetConfiguration = configuration; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-02-06 23:19:54
|
Revision: 18 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=18&view=rev Author: marioarce Date: 2010-02-06 23:19:47 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Ticket #3 Custom Membership Provider for CronosControl Implements the methods of MembershipProvider to provide the ASP.NET membership services for CronosControl TrackerManager.cs This class implements the methods necessary for maintaining users with rol 'Tracker' in CronosControl using the database schema, mdf file and entity mappings of CronosControl. Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/ source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/ source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs Added: source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs 2010-02-06 23:19:47 UTC (rev 18) @@ -0,0 +1,477 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Web; +using System.Web.Security; +using System.Text.RegularExpressions; +using System.Configuration.Provider; +using System.Collections.Generic; +using System.Collections.Specialized; +using CronosControl.Common.Utils; +using CronosControl.BusinessLogic.Tracker; +using CronosControl.Model; + +namespace CronosControl.BusinessLogic.Profile +{ + public class CronosControlMembershipProvider : MembershipProvider + { + #region Fields + private string _AppName; + private bool _EnablePasswordReset; + private bool _EnablePasswordRetrieval; + private int _MaxInvalidPasswordAttempts; + private int _MinRequiredNonalphanumericCharacters; + private int _MinRequiredPasswordLength; + private int _PasswordAttemptWindow; + private string _PasswordStrengthRegularExpression; + private bool _RequiresQuestionAndAnswer; + private bool _RequiresUniqueEmail; + #endregion + + #region Methods + /// <summary> + /// Processes a request to update the password for a membership user. + /// </summary> + /// <param name="username">The user to update the password for. </param> + /// <param name="oldPassword">The current password for the specified user.</param> + /// <param name="newPassword">The new password for the specified user.</param> + /// <returns>true if the password was updated successfully; otherwise, false.</returns> + public override bool ChangePassword(string username, string oldPassword, string newPassword) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Processes a request to update the password question and answer for a membership user. + /// </summary> + /// <param name="username">The user to change the password question and answer for.</param> + /// <param name="password">The password for the specified user.</param> + /// <param name="newPasswordQuestion">The new password question for the specified user.</param> + /// <param name="newPasswordAnswer">The new password answer for the specified user.</param> + /// <returns>true if the password question and answer are updated successfully; otherwise, false.</returns> + public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Adds a new membership user to the data source. + /// </summary> + /// <param name="username">The user name for the new user.</param> + /// <param name="password">The password for the new user.</param> + /// <param name="email">The e-mail address for the new user.</param> + /// <param name="passwordQuestion">The password question for the new user.</param> + /// <param name="passwordAnswer">The password answer for the new user.</param> + /// <param name="isApproved">Whether or not the new user is approved to be validated.</param> + /// <param name="providerUserKey">The unique identifier from the membership data source for the user.</param> + /// <param name="status">A MembershipCreateStatus enumeration value indicating whether the user was created successfully.</param> + /// <returns>A MembershipUser object populated with the information for the newly created user.</returns> + public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) + { + MembershipUser user = null; + + // add tracker + TrackerManager.AddTracker(email, username, password, username, "-", isApproved, out status); + + // user key + string userKey = string.Empty; + if (providerUserKey == null) + { + userKey = Guid.NewGuid().ToString(); + } + else + { + userKey = providerUserKey.ToString(); + } + + if (status == MembershipCreateStatus.Success) + { + // create membership user + DateTime dt = DateTimeHelper.ConvertToUtcTime(DateTime.Now); + user = new MembershipUser(this.Name, username, null, email, string.Empty, null, true, false, dt, dt, dt, dt, dt); + } + return user; + } + + /// <summary> + /// Removes a user from the membership data source. + /// </summary> + /// <param name="username">The name of the user to delete.</param> + /// <param name="deleteAllRelatedData">true to delete data related to the user from the database; false to leave data related to the user in the database.</param> + /// <returns>true if the user was successfully deleted; otherwise, false.</returns> + public override bool DeleteUser(string username, bool deleteAllRelatedData) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a collection of membership users where the e-mail address contains the specified e-mail address to match. + /// </summary> + /// <param name="EmailToMatch">The e-mail address to search for.</param> + /// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param> + /// <param name="pageSize">The size of the page of results to return.</param> + /// <param name="totalRecords">The total number of matched users.</param> + /// <returns>A MembershipUserCollection collection that contains a page of pageSizeMembershipUser objects beginning at the page specified by pageIndex.</returns> + public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a collection of membership users where the user name contains the specified user name to match. + /// </summary> + /// <param name="usernameToMatch">The user name to search for.</param> + /// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param> + /// <param name="pageSize">The size of the page of results to return.</param> + /// <param name="totalRecords">The total number of matched users.</param> + /// <returns>A MembershipUserCollection collection that contains a page of pageSizeMembershipUser objects beginning at the page specified by pageIndex.</returns> + public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a collection of all the users in the data source in pages of data. + /// </summary> + /// <param name="pageIndex">The index of the page of results to return. pageIndex is zero-based.</param> + /// <param name="pageSize">The size of the page of results to return.</param> + /// <param name="totalRecords">The total number of matched users.</param> + /// <returns>A MembershipUserCollection collection that contains a page of pageSizeMembershipUser objects beginning at the page specified by pageIndex.</returns> + public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets the number of users currently accessing the application. + /// </summary> + /// <returns>The number of users currently accessing the application.</returns> + public override int GetNumberOfUsersOnline() + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets the password for the specified user name from the data source. + /// </summary> + /// <param name="username">The user to retrieve the password for.</param> + /// <param name="answer">The password answer for the user.</param> + /// <returns>The password for the specified user name.</returns> + public override string GetPassword(string username, string answer) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user. + /// </summary> + /// <param name="username">The name of the user to get information for.</param> + /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param> + /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns> + public override MembershipUser GetUser(string username, bool userIsOnline) + { + User user = TrackerManager.GetTrackerByUsername(username); + + if (user == null) + return null; + DateTime dt = DateTimeHelper.ConvertToUtcTime(DateTime.Now); + + return new MembershipUser(this.Name, username, user.IdUser, user.Email, string.Empty, null, true, false, dt, dt, dt, dt, dt); + } + + /// <summary> + /// Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user. + /// </summary> + /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param> + /// <param name="userIsOnline">true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.</param> + /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns> + public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets the user name associated with the specified e-mail address. + /// </summary> + /// <param name="email">The e-mail address to search for.</param> + /// <returns>The user name associated with the specified e-mail address. If no match is found, return null.</returns> + public override string GetUserNameByEmail(string email) + { + User user = TrackerManager.GetTrackerByEmail(email); + if (user == null) + return null; + return user.Username; + } + + /// <summary> + /// Initializes the provider. + /// </summary> + /// <param name="name">The friendly name of the provider.</param> + /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> + public override void Initialize(string name, NameValueCollection config) + { + if (config == null) + { + throw new ArgumentNullException("config"); + } + if (string.IsNullOrEmpty(name)) + { + name = "CronosControlMembershipProvider"; + } + if (string.IsNullOrEmpty(config["description"])) + { + config.Remove("description"); + config.Add("description", "Membership Provider for CronosControl"); + } + base.Initialize(name, config); + this._EnablePasswordReset = CommonHelper.ConfigGetBooleanValue(config, "enablePasswordReset", true); + this._EnablePasswordRetrieval = CommonHelper.ConfigGetBooleanValue(config, "enablePasswordRetrieval", true); + this._RequiresQuestionAndAnswer = CommonHelper.ConfigGetBooleanValue(config, "requiresQuestionAndAnswer", true); + this._RequiresUniqueEmail = CommonHelper.ConfigGetBooleanValue(config, "requiresUniqueEmail", true); + this._MaxInvalidPasswordAttempts = CommonHelper.ConfigGetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0); + this._PasswordAttemptWindow = CommonHelper.ConfigGetIntValue(config, "passwordAttemptWindow", 10, false, 0); + this._MinRequiredPasswordLength = CommonHelper.ConfigGetIntValue(config, "minRequiredPasswordLength", 7, false, 0x80); + this._MinRequiredNonalphanumericCharacters = CommonHelper.ConfigGetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 0x80); + this._PasswordStrengthRegularExpression = config["passwordStrengthRegularExpression"]; + if (this._PasswordStrengthRegularExpression != null) + { + this._PasswordStrengthRegularExpression = this._PasswordStrengthRegularExpression.Trim(); + if (this._PasswordStrengthRegularExpression.Length != 0) + { + try + { + new Regex(this._PasswordStrengthRegularExpression); + } + catch (ArgumentException ex) + { + throw new ProviderException(ex.Message, ex); + } + } + } + this._PasswordStrengthRegularExpression = string.Empty; + if (this._MinRequiredNonalphanumericCharacters > this._MinRequiredPasswordLength) + { + throw new HttpException("MinRequiredNonalphanumericCharacters can not be more than MinRequiredPasswordLength"); + } + this._AppName = config["applicationName"]; + if (string.IsNullOrEmpty(this._AppName)) + { + this._AppName = "CronosControl"; + } + if (this._AppName.Length > 0x100) + { + throw new ProviderException("Provider application name too long"); + } + + string connectionStringName = config["connectionStringName"]; + if (string.IsNullOrEmpty(connectionStringName)) + { + this._AppName = "CronosControlEntities"; + } + + config.Remove("enablePasswordReset"); + config.Remove("enablePasswordRetrieval"); + config.Remove("requiresQuestionAndAnswer"); + config.Remove("applicationName"); + config.Remove("requiresUniqueEmail"); + config.Remove("maxInvalidPasswordAttempts"); + config.Remove("passwordAttemptWindow"); + config.Remove("commandTimeout"); + config.Remove("name"); + config.Remove("minRequiredPasswordLength"); + config.Remove("minRequiredNonalphanumericCharacters"); + config.Remove("passwordStrengthRegularExpression"); + config.Remove("connectionStringName"); + if (config.Count > 0) + { + string key = config.GetKey(0); + if (!string.IsNullOrEmpty(key)) + { + throw new ProviderException(string.Format("Provider unrecognized attribute {0}", key)); + } + } + } + + /// <summary> + /// Resets a user's password to a new, automatically generated password. + /// </summary> + /// <param name="username">The user to reset the password for.</param> + /// <param name="answer">The password answer for the specified user.</param> + /// <returns>The new password for the specified user.</returns> + public override string ResetPassword(string username, string answer) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Clears a lock so that the membership user can be validated. + /// </summary> + /// <param name="userName">The membership user whose lock status you want to clear.</param> + /// <returns>true if the membership user was successfully unlocked; otherwise, false.</returns> + public override bool UnlockUser(string userName) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Updates information about a user in the data source. + /// </summary> + /// <param name="user">A MembershipUser object that represents the user to update and the updated information for the user.</param> + public override void UpdateUser(MembershipUser user) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Verifies that the specified user name and password exist in the data source. + /// </summary> + /// <param name="username">The name of the user to validate.</param> + /// <param name="password">The password for the specified user.</param> + /// <returns>true if the specified username and password are valid; otherwise, false.</returns> + public override bool ValidateUser(string username, string password) + { + User user = TrackerManager.GetTrackerByUsername(username); + return TrackerManager.Login(username, password); + } + #endregion + + #region Properties + /// <summary> + /// The name of the application using the custom membership provider. + /// </summary> + public override string ApplicationName + { + get + { + return this._AppName; + } + set + { + this._AppName = value; + } + } + + /// <summary> + /// Indicates whether the membership provider is configured to allow users to reset their passwords. + /// </summary> + public override bool EnablePasswordReset + { + get + { + return this._EnablePasswordReset; + } + } + + /// <summary> + /// Gets the number of invalid password or password-answer attempts allowed before the membership user is locked out. + /// </summary> + public override int MaxInvalidPasswordAttempts + { + get + { + return this._MaxInvalidPasswordAttempts; + } + } + + /// <summary> + /// Gets the minimum number of special characters that must be present in a valid password. + /// </summary> + public override int MinRequiredNonAlphanumericCharacters + { + get + { + return this._MinRequiredNonalphanumericCharacters; + } + } + + /// <summary> + /// Gets the minimum length required for a password. + /// </summary> + public override int MinRequiredPasswordLength + { + get + { + return this._MinRequiredPasswordLength; + } + } + + /// <summary> + /// Gets the number of minutes in which a maximum number of invalid password or password-answer attempts are allowed before the membership user is locked out. + /// </summary> + public override int PasswordAttemptWindow + { + get + { + return this._PasswordAttemptWindow; + } + } + + /// <summary> + /// Gets the regular expression used to evaluate a password. + /// </summary> + public override string PasswordStrengthRegularExpression + { + get + { + return this._PasswordStrengthRegularExpression; + } + } + + /// <summary> + /// Gets a value indicating whether the membership provider is configured to require the user to answer a password question for password reset and retrieval. + /// </summary> + public override bool RequiresQuestionAndAnswer + { + get + { + return this._RequiresQuestionAndAnswer; + } + } + + /// <summary> + /// Gets a value indicating whether the membership provider is configured to require a unique e-mail address for each user name. + /// </summary> + public override bool RequiresUniqueEmail + { + get + { + return this._RequiresUniqueEmail; + } + } + + /// <summary> + /// Indicates whether the membership provider is configured to allow users to retrieve their passwords. + /// </summary> + public override bool EnablePasswordRetrieval + { + get + { + return _EnablePasswordRetrieval; + } + } + + /// <summary> + /// Gets a value indicating the format for storing passwords in the membership data store. + /// </summary> + public override MembershipPasswordFormat PasswordFormat + { + get + { + return MembershipPasswordFormat.Hashed; + } + } + #endregion + } +} Added: source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs 2010-02-06 23:19:47 UTC (rev 18) @@ -0,0 +1,234 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Linq; +using System.Text; +using System.Web.Security; +using System.Collections.Generic; +using System.Security.Cryptography; +using CronosControl.Model; +using CronosControl.BusinessLogic.Configuration.Settings; +using CronosControl.Business; +using CronosControl.Common.Utils; + +namespace CronosControl.BusinessLogic.Tracker +{ + /// <summary> + /// Tracker manager + /// </summary> + public partial class TrackerManager + { + #region Methods + /// <summary> + /// Adds a tracker + /// </summary> + /// <param name="Email">The email</param> + /// <param name="Username">The username</param> + /// <param name="Password">The password</param> + /// <param name="Name">A value indicating whether the name of the tracker</param> + /// <param name="Lastname">A value indicating whether the lastname of the tracker</param> + /// <param name="Enabled">A value indicating whether the tracker is active</param> + /// <param name="status">Status</param> + /// <returns>A tracker</returns> + public static User AddTracker(string email, string username, string password, + string name, string lastname, + bool enabled, out MembershipCreateStatus status) + { + string saltKey = string.Empty; + string passwordHash = string.Empty; + status = MembershipCreateStatus.UserRejected; + + // duplicated UserName ? + //status = MembershipCreateStatus.DuplicateUserName; + + // invalid UserName ? + //status = MembershipCreateStatus.InvalidUserName; + + // duplicated email ? + //status = MembershipCreateStatus.DuplicateEmail; + + // invalid email ? + if (!CommonHelper.IsValidEmail(email)) + status = MembershipCreateStatus.InvalidEmail; + + + int idCompany = Convert.ToInt32(SettingManager.Current["base", "idCompany"]); + passwordHash = CreatePasswordMd5Hash(password); + + User userEntity = new User(); + userEntity.Name = name; + userEntity.Lastname = lastname; + userEntity.Username = username; + userEntity.Password = passwordHash; + userEntity.Email = email; + userEntity.IdCompany = idCompany; + userEntity.CreatedAt = DateTimeHelper.ConvertToUtcTime(DateTime.Now); + userEntity.Enabled = enabled; + + try + { + Users users = new Users(); + users.Save(userEntity); + } + catch + { + status = MembershipCreateStatus.ProviderError; + } + + status = MembershipCreateStatus.Success; + return userEntity; + } + + /// <summary> + /// Creates a salt + /// </summary> + /// <param name="size">A salt size</param> + /// <returns>A salt</returns> + private static string CreateSalt(int size) + { + RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider(); + byte[] data = new byte[size]; + provider.GetBytes(data); + return Convert.ToBase64String(data); + } + + /// <summary> + /// Creates a password hash + /// </summary> + /// <param name="Password">Password</param> + /// <param name="Salt">Salt</param> + /// <returns>Password hash</returns> + private static string CreatePasswordHash(string Password, string Salt) + { + //MD5, SHA1 + string passwordFormat = SettingManager.Current["Security", "PasswordFormat"]; + if (String.IsNullOrEmpty(passwordFormat)) + passwordFormat = "SHA1"; + + return FormsAuthentication.HashPasswordForStoringInConfigFile(Password + Salt, passwordFormat); + } + + /// <summary> + /// Creates a password Md5 hash + /// </summary> + /// <param name="Password">Password</param> + /// <returns>Password hash</returns> + private static string CreatePasswordMd5Hash(string password) + { + if (string.IsNullOrEmpty(password)) + return string.Empty; + + // Create a new instance of the MD5CryptoServiceProvider object. + MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); + + // Convert the input string to a byte array and compute the hash. + byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(password)); + + // Create a new Stringbuilder to collect the bytes + // and create a string. + StringBuilder sBuilder = new StringBuilder(); + + // Loop through each byte of the hashed data + // and format each one as a hexadecimal string. + for (int i = 0; i < data.Length; i++) + { + sBuilder.Append(data[i].ToString("x2")); + } + + // Return the hexadecimal string. + return sBuilder.ToString(); + } + + /// <summary> + /// Gets a tracket by email + /// </summary> + /// <param name="Username">Tracker email</param> + /// <returns>A tracker</returns> + public static User GetTrackerByEmail(string email) + { + if (string.IsNullOrEmpty(email)) + return null; + if (!CommonHelper.IsValidEmail(email)) + return null; + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + User user = (from u in cronosControlEntities.User + where u.Email.Equals(email) + select u).First<User>(); + + return user; + } + + /// <summary> + /// Gets a tracket + /// </summary> + /// <param name="Username">Tracker identifier</param> + /// <returns>A tracker</returns> + public static User GetTrackerByID(int trackerID) + { + if (trackerID == 0) + return null; + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + User user = (from u in cronosControlEntities.User + where u.IdUser.Equals(trackerID) + select u).First<User>(); + + return user; + } + + /// <summary> + /// Gets a tracket by username + /// </summary> + /// <param name="Username">Tracker username</param> + /// <returns>A tracker</returns> + public static User GetTrackerByUsername(string username) + { + if (string.IsNullOrEmpty(username)) + return null; + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + User user = (from u in cronosControlEntities.User + where u.Username.Equals(username) + select u).First<User>(); + + return user; + } + + /// <summary> + /// Login a tracker + /// </summary> + /// <param name="Email">A tracker username</param> + /// <param name="Password">Password</param> + /// <returns>Result</returns> + public static bool Login(string username, string password) + { + User user = GetTrackerByUsername(username); + + if (user == null) + return false; + if (!user.Enabled) + return false; + + string passwordHash = CreatePasswordMd5Hash(password); + bool result = user.Password.Equals(passwordHash); + + // any session stuff here ... + + return result; + } + #endregion + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-02-06 23:05:22
|
Revision: 14 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=14&view=rev Author: marioarce Date: 2010-02-06 23:05:15 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Ticket #5 BusinessLogic library: added base files and structure This Library is created to implement business logic, units and modules to solve system requirements Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj source/trunk/CronosControl/Libraries/BusinessLogic/Properties/ source/trunk/CronosControl/Libraries/BusinessLogic/Properties/AssemblyInfo.cs source/trunk/CronosControl/Libraries/BusinessLogic/bin/ source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/ source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.xml source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.xml source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.ObjectBuilder2.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.Unity.dll source/trunk/CronosControl/Libraries/BusinessLogic/obj/ source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/ source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/BusinessLogic.csproj.FileListAbsolute.txt source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.dll source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.pdb source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/TempPE/ Added: source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj 2010-02-06 23:05:15 UTC (rev 14) @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{2981718C-6614-46DF-96A5-77C016AE23A7}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>CronosControl.BusinessLogic</RootNamespace> + <AssemblyName>CronosControl.BusinessLogic</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.configuration" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.Entity"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Web" /> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Configuration\Settings\SettingManager.cs" /> + <Compile Include="Profile\CronosControlMembershipProvider.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Tracker\TrackerManager.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\CronosControlBusinessClassLibrary\CronosControlBusinessClassLibrary.csproj"> + <Project>{2D8FF602-961B-470C-AECF-817AFF0C4E9C}</Project> + <Name>CronosControlBusinessClassLibrary</Name> + </ProjectReference> + <ProjectReference Include="..\..\CronosControlClassLibrary\CronosControlDataAccessClassLibrary.csproj"> + <Project>{7191E8B4-4497-40E8-BD9A-04CD4EF802FC}</Project> + <Name>CronosControlDataAccessClassLibrary</Name> + </ProjectReference> + <ProjectReference Include="..\Common\Common.csproj"> + <Project>{D3EBAC29-E2B4-4E13-97B2-B09FD3F04254}</Project> + <Name>Common</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: source/trunk/CronosControl/Libraries/BusinessLogic/Properties/AssemblyInfo.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Properties/AssemblyInfo.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Properties/AssemblyInfo.cs 2010-02-06 23:05:15 UTC (rev 14) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CronosControl.BusinessLogic")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CronosControl.BusinessLogic")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d83cab61-73e5-46df-ae70-5cb8a3b98704")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.dll =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.pdb =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.dll =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.pdb =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.dll =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.pdb =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.dll =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.pdb =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll =================================================================== (Binary files differ) Property changes on: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.xml =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.xml (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/Microsoft.Practices.EnterpriseLibrary.Common.xml 2010-02-06 23:05:15 UTC (rev 14) @@ -0,0 +1,7434 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>Microsoft.Practices.EnterpriseLibrary.Common</name> + </assembly> + <members> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter"> + <summary> + Provides the friendly name of the app domain as the prefix in formatting a + particular instance of a performance counter. + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.IPerformanceCounterNameFormatter"> + <summary> + Provides a pluggable way to format the name given to a particular instance of a performance counter. + Each instance of a performance counter in Enterprise Library is given a name of the format + "Name prefix - counter name" + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.IPerformanceCounterNameFormatter.CreateName(System.String)"> + <summary> + Creates the formatted instance name for a performance counter, providing the prefix for the + instance. + </summary> + <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param> + <returns>Formatted instance name in form of "prefix - nameSuffix"</returns> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter.#ctor"> + <summary> + Creates an instance of the <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter"/> + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter.#ctor(System.String)"> + <summary> + Creates an instance of the <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter"/> with an Application Instance Name + </summary> + <param name="applicationInstanceName"></param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.AppDomainNameFormatter.CreateName(System.String)"> + <summary> + Creates the formatted instance name for a performance counter, providing the Application + Domain friendly name for the prefix for the instance. + </summary> + <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param> + <returns>Formatted instance name in form of "appDomainFriendlyName - nameSuffix"</returns> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter"> + <summary> + Provides a virtual PerformanceCounter interface that allows an application to maintain both individually + named counter instances and a single counter total instance. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.#ctor(System.String,System.String)"> + <summary> + Initializes a single performance counter instance named "Total" + </summary> + <param name="counterCategoryName">Performance counter category name, as defined during installation</param> + <param name="counterName">Performance counter name, as defined during installation</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.#ctor(System.String,System.String,System.String[])"> + <summary> + Initializes multiple instances of performance counters to be managed by this object. + </summary> + <param name="counterCategoryName">Performance counter category name, as defined during installation</param> + <param name="counterName">Performance counter name, as defined during installation</param> + <param name="instanceNames">Param array of instance names to be managed</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.#ctor(System.Diagnostics.PerformanceCounter[])"> + <summary> + Initializes this object with performance counters created externally. It is the responsibility of the external + counter factory to create an instance for the "Total" counter. + </summary> + <param name="counters">Param array of already initialized <see cref="T:System.Diagnostics.PerformanceCounter"></see>s to be managed + by this instance.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.Clear"> + <summary> + Clears the raw count associated with all managed performance counters + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.Increment"> + <summary> + Increments each performance counter managed by this instance. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.IncrementBy(System.Int64)"> + <summary> + Increments by the given <paramref name="value"></paramref> each performance counter managed by this instance. + </summary> + <param name="value">Amount by which to increment each counter</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.GetValueFor(System.String)"> + <summary> + Gets the current value of the given performance counter instance. + </summary> + <param name="instanceName">Instance name of counter for which to get value.</param> + <returns>Value of the given performance counter.</returns> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.SetValueFor(System.String,System.Int64)"> + <summary> + Sets the value of the given performance counter instance. + </summary> + <param name="instanceName">Instance name of counter for which to set the value.</param> + <param name="value">Value to which the given instance should be set.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.InstantiateCounter(System.String)"> + <summary> + Instantiates a performance counter, giving it the specified <paramref name="instanceName"></paramref>. + </summary> + <param name="instanceName">Instance name to be given to the instantiated <see cref="T:System.Diagnostics.PerformanceCounter"></see></param>. + <returns>Initialized <see cref="T:System.Diagnostics.PerformanceCounter"></see></returns>. + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.Counters"> + <summary> + Gets the list of performance counter instances managed by this object. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EnterpriseLibraryPerformanceCounter.Value"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EventBinder"> + <summary> + Binds an event source to an event handler. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EventBinder.#ctor(System.Object,System.Object)"> + <summary> + Initializes this object with the source and listener objects to be bound together. + </summary> + <param name="source">Object owning the event that will be bound to</param> + <param name="listener">Object owning the method that will be added as a handler for specified event.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.EventBinder.Bind(System.Reflection.EventInfo,System.Reflection.MethodInfo)"> + <summary> + Adds specified <paramref name="listenerMethod"></paramref> as an event handler for + the <paramref name="sourceEvent"></paramref>. + </summary> + <param name="sourceEvent">Event on source object to which <paramref name="listenerMethod"></paramref> will be added.</param> + <param name="listenerMethod">Method to be added as event handler for <paramref name="listenerMethod"></paramref>.</param> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationBaseAttribute"> + <summary> + Base class for attributes used to identify instrumentation producers or consumers. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationBaseAttribute.#ctor(System.String)"> + <summary> + Initializes this instance with the instrumentation subject name. + </summary> + <param name="subjectName">Subject name being produced or consumed</param> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationBaseAttribute.SubjectName"> + <summary> + Gets the subject name + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationConsumerAttribute"> + <summary> + Defines methods that are consuming instrumentation events. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationConsumerAttribute.#ctor(System.String)"> + <summary> + Initializes this instance with the instrumentation subject name being consumed. + </summary> + <param name="subjectName">Subject name of the event being consumed.</param> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationListenerAttribute"> + <summary> + Defines a class that will listen for instrumentation events broadcast by other classes + and report them to system services. This attribute is placed on the class that is to be + listened to to define the class that will listen to it. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationListenerAttribute.#ctor(System.Type)"> + <overloads> + Initializes attribute with given <paramref name="listenerType"></paramref>. + </overloads> + <summary> + Initializes attribute with given <paramref name="listenerType"></paramref>. + </summary> + <param name="listenerType">Instrumentation listener type to instantiate.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationListenerAttribute.#ctor(System.Type,System.Type)"> + <summary> + Initializes attribute with given <paramref name="listenerType"></paramref>. Use when + you need to specify an explicit binder class. + </summary> + <param name="listenerType">Instrumentation listener type to instantiate.</param> + <param name="listenerBinderType">Instrumentation binder listener type to instantiate.</param> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationListenerAttribute.ListenerType"> + <summary> + Gets type of class to instantiate to listen for events. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationListenerAttribute.ListenerBinderType"> + <summary> + Gets type of class to use to bind an instance of the attributed class to + an instance of the listener class + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationProviderAttribute"> + <summary> + Defines events that are producing instrumentation events. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationProviderAttribute.#ctor(System.String)"> + <summary> + Initializes this object with the instrumentation subject name being produced. + </summary> + <param name="subjectName">Subect name of event being produced.</param> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.HasInstallableResourcesAttribute"> + <summary> + Defines those classes and structs that have some sort of resources that need to be installed. + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute"> + <summary> + Defines a <see cref="T:System.Diagnostics.PerformanceCounter"></see>. Used by the reflection-based installers to + prepare a performance counter for installation. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.#ctor(System.String,System.String,System.Diagnostics.PerformanceCounterType)"> + <summary> + Initializes this object with all data needed to install a <see cref="T:System.Diagnostics.PerformanceCounter"></see>. + </summary> + <param name="counterName">Performance counter name.</param> + <param name="counterHelp">Name of Help resource string. This is not the help text itself, + but is the resource name used to look up the internationalized help text at install-time.</param> + <param name="counterType">Performance Counter type.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.HasBaseCounter"> + <summary> + Used to determine if the counter being installed has a base counter associated with it. + </summary> + <returns>True if counter being installed has a base counter associated with it.</returns> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.CounterType"> + <summary> + Gets the <see cref="T:System.Diagnostics.PerformanceCounter"></see> type. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.CounterHelp"> + <summary> + Get the name of Help resource string. This is not the help text itself, + but is the resource name used to look up the internationalized help text at install-time. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.CounterName"> + <summary> + Gets the <see cref="T:System.Diagnostics.PerformanceCounter"></see> name. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.BaseCounterType"> + <summary> + Gets and sets the base <see cref="T:System.Diagnostics.PerformanceCounter"></see> type. This is an optional + property used when the counter being defined requires a base counter to operate, such as for + averages, etc. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.BaseCounterHelp"> + <summary> + Gets and sets the base <see cref="T:System.Diagnostics.PerformanceCounter"></see> help resource name. + This is not the help text itself, + but is the resource name used to look up the internationalized help text at install-time. + This is an optional + property used when the counter being defined requires a base counter to operate, such as for + averages, etc. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.PerformanceCounterAttribute.BaseCounterName"> + <summary> + Gets and sets the base <see cref="T:System.Diagnostics.PerformanceCounter"></see> name. This is an optional + property used when the counter being defined requires a base counter to operate, such as for + averages, etc. + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.ReflectionInstrumentationBinder"> + <summary> + Binds together source events and listener handler methods through reflection. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.ReflectionInstrumentationBinder.Bind(System.Object,System.Object)"> + <summary> + Binds together source events and listener handler methods through reflection. + </summary> + <param name="eventSource">Object containing events attributed with <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationProviderAttribute"></see>.</param> + <param name="eventListener">Object containing handler methods attribute with <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.InstrumentationConsumerAttribute"></see>.</param> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.NoPrefixNameFormatter"> + <summary> + Provides a pluggable way to format the name given to a particular instance of a performance counter. + This class does no formatting, returning the provided name suffix as the counter name. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.NoPrefixNameFormatter.CreateName(System.String)"> + <summary> + Returns the given <paramref name="nameSuffix"></paramref> as the created name. + </summary> + <param name="nameSuffix">Performance counter name, as defined during installation of the counter</param> + <returns>Formatted instance name in form of "nameSuffix"</returns> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources"> + <summary> + A strongly-typed resource class, for looking up localized strings, etc. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ResourceManager"> + <summary> + Returns the cached ResourceManager instance used by this class. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.Culture"> + <summary> + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.EventLogEntryExceptionTemplate"> + <summary> + Looks up a localized string similar to The exception that occured was: {0}. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.EventLogEntryHeaderTemplate"> + <summary> + Looks up a localized string similar to An error occurred in application {0} in the {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionArgumentShouldDeriveFromIDictionary"> + <summary> + Looks up a localized string similar to The type '{0}' does not derive from IDictionary.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionArgumentShouldDeriveFromIList"> + <summary> + Looks up a localized string similar to The type '{0}' does not derive from IList.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionAssemblerAttributeNotSet"> + <summary> + Looks up a localized string similar to The [Assembler] attribute is not set in the configuration object type {0}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionAssemblerTypeNotCompatible"> + <summary> + Looks up a localized string similar to The assembler configured for type {0} has type {2} which is not compatible with type {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionBaseConfigurationSourceElementIsInvalid"> + <summary> + Looks up a localized string similar to The base ConfigurationSourceElement configuration type can not be used as a concrete configuration element.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionCannotAddParametersAfterDispose"> + <summary> + Looks up a localized string similar to Cannot add new paramters after Finish() or Dispose().. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionCanNotConvertType"> + <summary> + Looks up a localized string similar to The AssemblyQualifiedTypeNameConverter can only convert values of type '{0}'.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionCannotFinish"> + <summary> + Looks up a localized string similar to Builder has already added policies.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionConfigurationFileNotFound"> + <summary> + Looks up a localized string similar to The section {0} could not be saved because the file does not exist.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionConfigurationLoadFileNotFound"> + <summary> + Looks up a localized string similar to The configuration file {0} could not be found.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionConfigurationObjectIsNotCustomProviderData"> + <summary> + Looks up a localized string similar to The configuration object for type '{0}' with name '{1}' has type '{2}' which is does not implement ICustomProviderData.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionConfigurationObjectWithTypeDoesNotHaveTypeSet"> + <summary> + Looks up a localized string similar to The concrete type for polymorphic object named '{1}' in hierarchy {2} is not defined in configuration object {0}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionConfigurationSourceSectionNotFound"> + <summary> + Looks up a localized string similar to The configuration source section is not found in the application configuration file.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionContainerPolicyCreatorAttributeNotPresent"> + <summary> + Looks up a localized string similar to The required "ContainerPolicyCreatorAttribute" is not present in the supplied type "{0}".. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionCustomFactoryAttributeNotFound"> + <summary> + Looks up a localized string similar to The [CustomFactory] attribute was not found on type {0} while processing request for id '{1}'.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionCustomProviderTypeDoesNotHaveTheRequiredConstructor"> + <summary> + Looks up a localized string similar to Type '{0}' specified as a custom provider does not have the required public constructor with a single NameValueCollection parameter.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionEventRaisingFailed"> + <summary> + Looks up a localized string similar to There was an error raising an event in . + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionFactoryMethodHasInvalidReturnType"> + <summary> + Looks up a localized string similar to The method with signature {0} is not a valid factory method to build type {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionInvalidType"> + <summary> + Looks up a localized string similar to The type '{0}' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionMustBeNameTypeConfigurationElement"> + <summary> + Looks up a localized string similar to The supplied configuration object has type '{0}', which is not a descendant of 'NameTypeConfigurationElement' as required.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionMustHaveNoArgsConstructor"> + <summary> + Looks up a localized string similar to The required zero argument constructor is not available for the supplied type "{0}".. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionMustImplementIContainerPolicyCreator"> + <summary> + Looks up a localized string similar to The required interface "IContainerPolicyCreator" is not implemented by the supplied type "{0}".. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNamedConfigurationNotFound"> + <summary> + Looks up a localized string similar to The configuration could not be found for name '{0}' in factory {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoConfigurationElementAttribute"> + <summary> + Looks up a localized string similar to The type {0} does not contain the ConfigurationElementTypeAttribute.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoConfigurationObjectPolicySet"> + <summary> + Looks up a localized string similar to No policy specifying the configuration source for the container has been set. The EnterpriseLibraryCoreExtension is probably missing.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoMatchingConstructorFound"> + <summary> + Looks up a localized string similar to No public constructor with {1} arguments was found for type "{0}".. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoMethodAnnotatedForInjectionFound"> + <summary> + Looks up a localized string similar to The type {0} does not have a public method annotated as an injection target as required by the use of injection.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoSuitableFactoryMethodFound"> + <summary> + Looks up a localized string similar to The type {0} does not have a static method with a TargetConstructorAttribuite suitable to create an object of type {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionNoTypeAttribute"> + <summary> + Looks up a localized string similar to The type attribute does not exist on the element {0}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionParameterNotAnnotatedForInjection"> + <summary> + Looks up a localized string similar to The parameter '{0}' for injection target '{1}' in type '{2}' is missing the injection interpretation attribute.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionPerformanceCounterRedefined"> + <summary> + Looks up a localized string similar to The performance counter '{0}' in category '{1}' is redefined in type {2} with a different configuration.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionPolicyBuilderFinished"> + <summary> + Looks up a localized string similar to Attempt to continue working with a PolicyBuilder after the policies have been added to a policy list for type '{1}' with key '{0}'.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionPolicyBuilderStillWaitingForPropertyPolicy"> + <summary> + Looks up a localized string similar to The specified policies cannot be added: a property policy mapping is still taking place.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionPropertyAccessExpressionNotPropertyAccess"> + <summary> + Looks up a localized string similar to The supplied expression is not a valid property access expression: '{0}'.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionPropertyNotFound"> + <summary> + Looks up a localized string similar to e {2}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionRetrievalAttributeNotFound"> + <summary> + Looks up a localized string similar to The type {0} does not contain the ConfigurationDataRetrievalAttribute required to resolve named references.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionSourcePropertyDoesNotExist"> + <summary> + Looks up a localized string similar to Could not retrieve parameter value. The property {0} does not exist for type {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionStringNullOrEmpty"> + <summary> + Looks up a localized string similar to The value can not be null or string or empty.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionSuppliedCreationExpressionIsNotNewExpression"> + <summary> + Looks up a localized string similar to A creation expression must be a constructor call, but the supplied expression was '{0}'.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionSystemSourceNotDefined"> + <summary> + Looks up a localized string similar to The system configuration source is not defined in the configuration file.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionTheSpecifiedDefaultProviderDoesNotExistInConfiguration"> + <summary> + Looks up a localized string similar to The configuration object for default provider named '{0}' for type '{1}' was not found in the supplied list.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionTypeCouldNotBeCreated"> + <summary> + Looks up a localized string similar to The type {0} from configuration could not be created.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionTypeNotCustomFactory"> + <summary> + Looks up a localized string similar to Type {0} is not an implementation of ICustomFactory for CustomFactoryAttribute.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionTypeNotNameMapper"> + <summary> + Looks up a localized string similar to Type {0} is not an implementation of IConfigurationNameMapper for ConfigurationNameMapperAttribute.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionTypeNotRetriever"> + <summary> + Looks up a localized string similar to Type {0} is not an implementation of IConfigurationDataRetriever for ConfigurationDataRetrievalAttribute.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionUnableToMatchConstructorToConfigurationObject"> + <summary> + Looks up a localized string similar to Default policy creation failed: The properties in the supplied configuration object of type {0} cannot be matched to any constructor on type {1}.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionUnexpectedType"> + <summary> + Looks up a localized string similar to The expected type '{0}' was not provided.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.ExceptionUnknownResolveMethod"> + <summary> + Looks up a localized string similar to An call to an unknown method named '{0}' in the Resolve class was found in the supplied argument expression: '{1}'. Cannot create policies for this expression.. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.FileConfigurationSourceName"> + <summary> + Looks up a localized string similar to File Configuration Source. + </summary> + </member> + <member name="P:Microsoft.Practices.EnterpriseLibrary.Common.Properties.Resources.SystemConfigurationSourceName"> + <summary> + Looks up a localized string similar to System Configuration Source. + </summary> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter"> + <summary> + Represents a configuration converter that converts a string to <see cref="T:System.Type"/> based on a fully qualified name. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)"> + <summary> + Returns the assembly qualified name for the passed in Type. + </summary> + <param name="context">The container representing this System.ComponentModel.TypeDescriptor.</param> + <param name="culture">Culture info for assembly</param> + <param name="value">Value to convert.</param> + <param name="destinationType">Type to convert to.</param> + <returns>Assembly Qualified Name as a string</returns> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object)"> + <summary> + Returns a type based on the assembly qualified name passed in as data. + </summary> + <param name="context">The container representing this System.ComponentModel.TypeDescriptor.</param> + <param name="culture">Culture info for assembly.</param> + <param name="value">Data to convert.</param> + <returns>Type of the data</returns> + </member> + <member name="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation"> + <summary> + This type supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + Represents the implementation details for file-based configuration sources. + </summary> + <remarks> + This implementation deals with setting up the watcher over the configuration files to detect changes and update + the configuration representation. It also manages the change notification features provided by the file based + configuration sources. + </remarks> + </member> + <member name="F:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.NullConfigSource"> + <summary> + This field supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + ConfigSource value for sections that existed in configuration but were later removed. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.#ctor(System.String,System.Boolean)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + Initializes a new instance of the <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSourceImplementation"/> class. + </summary> + <param name="configurationFilepath">The path for the main configuration file.</param> + <param name="refresh"><b>true</b>if runtime changes should be refreshed, <b>false</b> otherwise.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.#ctor(System.String)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + Initializes a new instance of the <see cref="T:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSourceImplementation"/> class. + </summary> + <param name="configurationFilepath">The path for the main configuration file.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.AddSectionChangeHandler(System.String,Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationChangedEventHandler)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + Adds a handler to be called when changes to section <code>sectionName</code> are detected. + </summary> + <param name="sectionName">The name of the section to watch for.</param> + <param name="handler">The handler.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.ConfigSourceChanged(System.String)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + </summary> + <param name="configSource">The name of the updated configuration source.</param> + <devdoc> + Only needs to deal with concurrency to get the current sections and to update the watchers. + + Rationale: + - Sections' are only added or updated. + - For this notification, all sections in the config file must be updated, and sections in external + files must be refreshed only if the config source changed. + - why not check after the original set of sections is retrieved? + -- Sections might have been added to the listener set after the original set is retrieved, but... + -- If they were added after the original set was retrieved, then they are up to date. + --- For this to happen, they couldn't have been read before the o.s., otherwise they would be a listener for them. + --- So, the retrieved information must be fresh (checked this with a test). + -- What about other changes? + --- Erased sections: only tested in the config file watching thread, because the meta configuration + is kept in the configuration file. + ---- Even if the external file an external is deleted because of the deletion, and this change is processed + before the config file change, the refresh for the external section will refresh all the sections for the file and + notify a change, without need for checking the change. The change would later be picked up by the config file watcher + which will notify again. This shouldn't be a problem. + --- External sections with changed sources. If they existed before, they must have been in the config file and there + was an entry in the bookeeping data structures. + - Concurrent updates for sections values should be handled by the system.config fx + </devdoc> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.Dispose"> + <summary> + Releases the resources used by the change watchers. + </summary> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.ExternalConfigSourceChanged(System.String)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + </summary> + <param name="configSource">The name of the updated configuration source.</param> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.GetSection(System.String)"> + <summary> + This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. + Retrieves the specified <see cref="T:System.Configuration.ConfigurationSection"/> from the configuration file, and starts watching for + its changes if not watching already. + </summary> + <param name="sectionName">The section name.</param> + <returns>The section, or <see langword="null"/> if it doesn't exist.</returns> + </member> + <member name="M:Microsoft.Practices.EnterpriseLibrary.Common.Configuration.BaseFileConfigurationSourceImplementation.RefreshAndValidateSections(System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.ICollection{System.String}@,System.Collections.Generic.IDictionary{System.String,System.String}@)"> + <summary> + ... [truncated message content] |
From: <mar...@us...> - 2010-02-13 20:41:29
|
Revision: 22 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=22&view=rev Author: marioarce Date: 2010-02-13 20:41:22 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Ticket #6 Custom Role Provider for CronosControl * Implements the methods of RoleProvider to provide the ASP.NET role services for CronosControl TrackerManager.cs * Added the methods AddUsersToRoles(), GetRolesForUser(), IsUserInRole() that supports the Custom Role Provider for CronosControl * Modified the method AddTracker() in order to use the CronosControlContext instead of SettingManager Modified Paths: -------------- source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs Added: source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs 2010-02-13 20:41:22 UTC (rev 22) @@ -0,0 +1,220 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Linq; +using System.Text; +using System.Web.Security; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration.Provider; +using CronosControl.Model; +using CronosControl.BusinessLogic.Tracker; + +namespace CronosControl.BusinessLogic.Profile +{ + /// <summary> + /// Manages storage of role membership information for Cronos Control in a data source. + /// </summary> + public class CronosControlRoleProvider : RoleProvider + { + #region Fields + private string _AppName; + #endregion + + #region Methods + /// <summary> + /// Adds the specified user names to the specified roles for the configured applicationName + /// </summary> + /// <param name="usernames">A string array of user names to be added to the specified roles.</param> + /// <param name="roleNames">A string array of the role names to add the specified user names to.</param> + public override void AddUsersToRoles(string[] usernames, string[] roleNames) + { + try + { + TrackerManager.AddUsersToRoles(usernames, roleNames); + } + catch (Exception ex) + { + throw new ProviderException(ex.Message, ex); + } + } + + /// <summary> + /// Adds a new role to the data source for the configured applicationName. + /// </summary> + /// <param name="roleName">The name of the role to create.</param> + public override void CreateRole(string roleName) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Removes a role from the data source for the configured applicationName. + /// </summary> + /// <param name="roleName">The name of the role to delete.</param> + /// <param name="throwOnPopulatedRole">If true, throw an exception if roleName has one or more members and do not delete roleName.</param> + /// <returns>true if the role was successfully deleted; otherwise, false.</returns> + public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets an array of user names in a role where the user name contains the specified user name to match. + /// </summary> + /// <param name="roleName">The role to search in.</param> + /// <param name="usernameToMatch">The user name to search for.</param> + /// <returns>A string array containing the names of all the users where the user name matches usernameToMatch and the user is a member of the specified role.</returns> + public override string[] FindUsersInRole(string roleName, string usernameToMatch) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a list of all the roles for the configured applicationName. + /// </summary> + /// <returns>A string array containing the names of all the roles stored in the data source for the configured applicationName.</returns> + public override string[] GetAllRoles() + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a list of the roles that a specified user is in for the configured applicationName. + /// </summary> + /// <param name="username">The user to return a list of roles for.</param> + /// <returns>A string array containing the names of all the roles that the specified user is in for the configured applicationName.</returns> + public override string[] GetRolesForUser(string username) + { + User user = TrackerManager.GetTrackerByUsername(username); + if (user == null) + return new string[] { }; + + return TrackerManager.GetRolesForUser(username); + } + + /// <summary> + /// Gets a list of users in the specified role for the configured applicationName. + /// </summary> + /// <param name="roleName">The name of the role to get the list of users for.</param> + /// <returns>A string array containing the names of all the users who are members of the specified role for the configured applicationName.</returns> + public override string[] GetUsersInRole(string roleName) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Initializes the provider. + /// </summary> + /// <param name="name">The friendly name of the provider.</param> + /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param> + public override void Initialize(string name, NameValueCollection config) + { + if (config == null) + { + throw new ArgumentNullException("config"); + } + if (string.IsNullOrEmpty(name)) + { + name = "StoreRoleProvider"; + } + if (string.IsNullOrEmpty(config["description"])) + { + config.Remove("description"); + config.Add("description", "Roles Provider"); + } + base.Initialize(name, config); + this._AppName = config["applicationName"]; + if (string.IsNullOrEmpty(this._AppName)) + { + this._AppName = "CronosControl"; + } + if (this._AppName.Length > 0x100) + { + throw new ProviderException("Provider application name too long"); + } + config.Remove("applicationName"); + + string connectionStringName = config["connectionStringName"]; + if (string.IsNullOrEmpty(connectionStringName)) + { + this._AppName = "CronosControlEntities"; + } + config.Remove("connectionStringName"); + + if (config.Count > 0) + { + string text2 = config.GetKey(0); + if (!string.IsNullOrEmpty(text2)) + { + throw new ProviderException(string.Format("Provider unrecognized attribute {0}", text2)); + } + } + } + + /// <summary> + /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName. + /// </summary> + /// <param name="username">The user name to search for.</param> + /// <param name="roleName">The role to search in.</param> + /// <returns>true if the specified user is in the specified role for the configured applicationName; otherwise, false.</returns> + public override bool IsUserInRole(string username, string roleName) + { + User user = TrackerManager.GetTrackerByUsername(username); + if (user == null) + return false; + + return TrackerManager.IsUserInRole(username, roleName); + } + + /// <summary> + /// Removes the specified user names from the specified roles for the configured applicationName. + /// </summary> + /// <param name="usernames">A string array of user names to be removed from the specified roles.</param> + /// <param name="roleNames">A string array of role names to remove the specified user names from.</param> + public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) + { + throw new NotImplementedException(); + } + + /// <summary> + /// Gets a value indicating whether the specified role name already exists in the role data source for the configured applicationName. + /// </summary> + /// <param name="roleName">The name of the role to search for in the data source.</param> + /// <returns>true if the role name already exists in the data source for the configured applicationName; otherwise, false.</returns> + public override bool RoleExists(string roleName) + { + throw new NotImplementedException(); + } + #endregion + + #region Properties + /// <summary> + /// Gets or sets the name of the application to store and retrieve role information for. + /// </summary> + public override string ApplicationName + { + get + { + return this._AppName; + } + set + { + this._AppName = value; + } + } + #endregion + } +} Modified: source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs 2010-02-10 04:00:26 UTC (rev 21) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerManager.cs 2010-02-13 20:41:22 UTC (rev 22) @@ -17,11 +17,12 @@ using System.Text; using System.Web.Security; using System.Collections.Generic; +using System.Configuration.Provider; using System.Security.Cryptography; using CronosControl.Model; -using CronosControl.BusinessLogic.Configuration.Settings; using CronosControl.Business; using CronosControl.Common.Utils; +using CronosControl.BusinessLogic.Configuration.Settings; namespace CronosControl.BusinessLogic.Tracker { @@ -64,7 +65,7 @@ status = MembershipCreateStatus.InvalidEmail; - int idCompany = Convert.ToInt32(SettingManager.Current["base", "idCompany"]); + int idCompany = CronosControlContext.Current.CurrentCompany.IdCompany; passwordHash = CreatePasswordMd5Hash(password); User userEntity = new User(); @@ -92,6 +93,45 @@ } /// <summary> + /// Adds the specified user names to the specified roles for the configured applicationName + /// </summary> + /// <param name="usernames">A string array of user names to be added to the specified roles.</param> + /// <param name="roleNames">A string array of the role names to add the specified user names to.</param> + public static void AddUsersToRoles(string[] usernames, string[] roleNames) + { + foreach (string username in usernames) + { + // get User + User user = GetTrackerByUsername(username); + if (user == null) + { + // user not found!, continue... + continue; + } + + foreach (var roleName in roleNames) + { + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + // get Role + Role role = (from r in cronosControlEntities.Role + where r.Name.Equals(roleName) + select r).First<Role>(); + + Project project = CronosControlContext.Current.CurrentProject; + + // assign role to the user + UserProjectRole userProjectRole = new UserProjectRole(); + userProjectRole.Role = role; + userProjectRole.Project = project; + userProjectRole.IdUser = user.IdUser; + + cronosControlEntities.AddToUserProjectRole(userProjectRole); + cronosControlEntities.SaveChanges(); + } + } + } + + /// <summary> /// Creates a salt /// </summary> /// <param name="size">A salt size</param> @@ -152,6 +192,40 @@ } /// <summary> + /// Gets a list of the roles that a specified user is in for the configured applicationName. + /// </summary> + /// <param name="username">The user to return a list of roles for.</param> + /// <returns>A string array containing the names of all the roles that the specified user is in for the configured applicationName.</returns> + public static string[] GetRolesForUser(string username) + { + // get User + User user = GetTrackerByUsername(username); + if (user == null) + { + // user not found! + return new string[] { }; + } + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + + Project project = CronosControlContext.Current.CurrentProject; + + // get UserProjectRole + List<string> userProjectRoles = (from upr in cronosControlEntities.UserProjectRole + join ro in cronosControlEntities.Role + on new { upr.Role.IdRole } equals new { ro.IdRole } + where (upr.IdUser == user.IdUser && upr.Project.IdProject == project.IdProject) + select ro.Name).ToList<string>(); + + string[] result = new string[userProjectRoles.Count]; + for (int i = 0; i < userProjectRoles.Count; i++) + { + result[i] = userProjectRoles[i]; + } + return result; + } + + /// <summary> /// Gets a tracket by email /// </summary> /// <param name="Username">Tracker email</param> @@ -199,15 +273,46 @@ if (string.IsNullOrEmpty(username)) return null; + User user; CronosControlEntities cronosControlEntities = new CronosControlEntities(); - User user = (from u in cronosControlEntities.User - where u.Username.Equals(username) - select u).First<User>(); + try + { + user = (from u in cronosControlEntities.User + where u.Username.Equals(username) + select u).First<User>(); + } + catch + { + return null; + } return user; } /// <summary> + /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName. + /// </summary> + /// <param name="username">The user name to search for.</param> + /// <param name="roleName">The role to search in.</param> + /// <returns>true if the specified user is in the specified role for the configured applicationName; otherwise, false.</returns> + public static bool IsUserInRole(string username, string roleName) + { + if (string.IsNullOrEmpty(username)) + return false; + if (string.IsNullOrEmpty(roleName)) + return false; + + User user = GetTrackerByUsername(username); + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + int result = (from upr in cronosControlEntities.UserProjectRole + where (upr.IdUser == 1 && upr.Role.Name.Equals(roleName)) + select upr).Count<UserProjectRole>(); + + return (result == 1); + } + + /// <summary> /// Login a tracker /// </summary> /// <param name="Email">A tracker username</param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-02-13 20:47:47
|
Revision: 23 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=23&view=rev Author: marioarce Date: 2010-02-13 20:47:40 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Ticket #7 Implementing user authentication and session Classes /CronosControlContext.cs * represents a CronosControl Context , added some base methods to manage current session, current context objects, values and properties, and to manage cookies and culture Classes /Tracker/TrackerSession.cs * represents a tracker session object Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/BaseEntity.cs source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerSession.cs Added: source/trunk/CronosControl/Libraries/BusinessLogic/BaseEntity.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/BaseEntity.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/BaseEntity.cs 2010-02-13 20:47:40 UTC (rev 23) @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CronosControl.BusinessLogic +{ + /// <summary> + /// Provides a base class for entities + /// </summary> + public abstract partial class BaseEntity + { + } +} Added: source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs 2010-02-13 20:47:40 UTC (rev 23) @@ -0,0 +1,266 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Globalization; +using System.Threading; +using System.Web; +using CronosControl.Model; +using CronosControl.BusinessLogic.Tracker; +using CronosControl.BusinessLogic.Configuration.Settings; + +namespace CronosControl.BusinessLogic +{ + /// <summary> + /// Represents a CronosControlContext + /// </summary> + public partial class CronosControlContext + { + #region Constants + private const string CONST_TRACKERSESSION = "CronosControl.TrackerSession"; + private const string CONST_TRACKERSESSIONCOOKIE = "CronosControl.TrackerSessionGUIDCookie"; + #endregion + + #region Fields + private User currentTracker; + private bool isAdmin; + private HttpContext context = HttpContext.Current; + private Project currentProject; + private Company currentCompany; + #endregion + + #region Constructor + /// <summary> + /// Creates a new instance of the CronosControlContext class + /// </summary> + private CronosControlContext() + { + + } + #endregion + + #region Methods + /// <summary> + /// Save tracker session to data source + /// </summary> + /// <returns>Saved tracker session</returns> + private TrackerSession SaveSessionToDatabase() + { + return null; + } + + /// <summary> + /// Gets tracker session + /// </summary> + /// <param name="createInDatabase">Create session in database if no one exists</param> + /// <returns>Tracker session</returns> + public TrackerSession GetSession(bool createInDatabase) + { + return this.GetSession(createInDatabase, null); + } + + /// <summary> + /// Gets tracker session + /// </summary> + /// <param name="createInDatabase">Create session in database if no one exists</param> + /// <param name="sessionId">Session identifier</param> + /// <returns>Tracker session</returns> + public TrackerSession GetSession(bool createInDatabase, Guid? sessionId) + { + return null; + } + + /// <summary> + /// Saves current session to client + /// </summary> + public void SessionSaveToClient() + { + if (HttpContext.Current != null && this.Session != null) + SetCookie(HttpContext.Current.ApplicationInstance, CONST_TRACKERSESSIONCOOKIE, this.Session.TrackerSessionGUID.ToString()); + } + + /// <summary> + /// Reset tracker session + /// </summary> + public void ResetSession() + { + if (HttpContext.Current != null) + SetCookie(HttpContext.Current.ApplicationInstance, CONST_TRACKERSESSIONCOOKIE, string.Empty); + this.Session = null; + this.User = null; + this["CronosControl.SessionReseted"] = true; + } + + /// <summary> + /// Sets cookie + /// </summary> + /// <param name="application">Application</param> + /// <param name="key">Key</param> + /// <param name="val">Value</param> + private static void SetCookie(HttpApplication application, string key, string val) + { + HttpCookie cookie = new HttpCookie(key); + cookie.Value = val; + if (string.IsNullOrEmpty(val)) + { + cookie.Expires = DateTime.Now.AddMonths(-1); + } + else + { + cookie.Expires = DateTime.Now.AddHours(Convert.ToDouble(SettingManager.Current["base", "cookieExpires"])); + } + application.Response.Cookies.Remove(key); + application.Response.Cookies.Add(cookie); + } + #endregion + + #region Properties + /// <summary> + /// Gets an instance of the CronosControlContext, which can be used to retrieve information about current context. + /// </summary> + public static CronosControlContext Current + { + get + { + if (HttpContext.Current == null) + return null; + + if (HttpContext.Current.Items["CronosControlContext"] == null) + { + CronosControlContext context2 = new CronosControlContext(); + HttpContext.Current.Items.Add("CronosControlContext", context2); + return context2; + } + return (CronosControlContext)HttpContext.Current.Items["CronosControlContext"]; + } + } + + /// <summary> + /// Gets or sets a value indicating whether the context is running in admin-mode + /// </summary> + public bool IsAdmin + { + get + { + return isAdmin; + } + set + { + isAdmin = value; + } + } + + /// <summary> + /// Gets or sets an object item in the context by the specified key. + /// </summary> + /// <param name="key">The key of the value to get.</param> + /// <returns>The value associated with the specified key.</returns> + public object this[string key] + { + get + { + if (this.context == null) + { + return null; + } + + if (this.context.Items[key] != null) + { + return this.context.Items[key]; + } + return null; + } + set + { + if (this.context != null) + { + this.context.Items.Remove(key); + this.context.Items.Add(key, value); + + } + } + } + + /// <summary> + /// Gets or sets the current session + /// </summary> + public TrackerSession Session + { + get + { + return this.GetSession(false); + } + set + { + Current[CONST_TRACKERSESSION] = value; + } + } + + /// <summary> + /// Gets or sets the current user + /// </summary> + public User User + { + get + { + return this.currentTracker; + } + set + { + this.currentTracker = value; + } + } + + /// <summary> + /// Gets or sets the current project + /// </summary> + public Project CurrentProject + { + get + { + return this.currentProject; + } + set + { + this.currentProject = value; + } + } + + /// <summary> + /// Gets or sets the current company + /// </summary> + public Company CurrentCompany + { + get + { + return this.currentCompany; + } + set + { + this.currentCompany = value; + } + } + + /// <summary> + /// Sets the CultureInfo + /// </summary> + /// <param name="culture">Culture</param> + public void SetCulture(CultureInfo culture) + { + Thread.CurrentThread.CurrentCulture = culture; + Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; + } + #endregion + } +} Added: source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerSession.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerSession.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Tracker/TrackerSession.cs 2010-02-13 20:47:40 UTC (rev 23) @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using System.Web; +using System.Xml; +using CronosControl.Model; + +namespace CronosControl.BusinessLogic.Tracker +{ + /// <summary> + /// Represents a tracker session + /// </summary> + public partial class TrackerSession : BaseEntity + { + #region Constructor + /// <summary> + /// Creates a new instance of the TrackerSession class + /// </summary> + public TrackerSession() + { + } + #endregion + + #region Properties + /// <summary> + /// Gets or sets the tracker session identifier + /// </summary> + public Guid TrackerSessionGUID { get; set; } + + /// <summary> + /// Gets or sets the tracker identifier + /// </summary> + public int TrackerID { get; set; } + + /// <summary> + /// Gets or sets the last accessed date and time + /// </summary> + public DateTime LastAccessed { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether the tracker session is expired + /// </summary> + public bool IsExpired { get; set; } + #endregion + + #region Custom Properties + /// <summary> + /// Gets or sets the tracker + /// </summary> + public User User + { + get + { + return TrackerManager.GetTrackerByID(TrackerID); + } + } + #endregion + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-02-13 21:22:07
|
Revision: 29 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=29&view=rev Author: marioarce Date: 2010-02-13 21:22:01 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Ticket #5 renamed concept from 'Tracker' to 'Project User'. Project User includes a 'project manager', a 'project team members', and any other project stakeholder The following are examples of project stakeholders: * Project manager * Project team members * Upper management * Project customer * Resource Managers * Product user group * Project testers * Sponsor Modified Paths: -------------- source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.pdb source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.dll source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.pdb source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.dll source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.pdb Modified: source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj 2010-02-13 21:18:21 UTC (rev 28) +++ source/trunk/CronosControl/Libraries/BusinessLogic/BusinessLogic.csproj 2010-02-13 21:22:01 UTC (rev 29) @@ -62,9 +62,9 @@ <Compile Include="CronosControlContext.cs" /> <Compile Include="Profile\CronosControlMembershipProvider.cs" /> <Compile Include="Profile\CronosControlRoleProvider.cs" /> + <Compile Include="ProjectUser\ProjectUserManager.cs" /> + <Compile Include="ProjectUser\ProjectUserSession.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Tracker\TrackerManager.cs" /> - <Compile Include="Tracker\TrackerSession.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\CronosControlBusinessClassLibrary\CronosControlBusinessClassLibrary.csproj"> Modified: source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs 2010-02-13 21:18:21 UTC (rev 28) +++ source/trunk/CronosControl/Libraries/BusinessLogic/CronosControlContext.cs 2010-02-13 21:22:01 UTC (rev 29) @@ -17,7 +17,7 @@ using System.Threading; using System.Web; using CronosControl.Model; -using CronosControl.BusinessLogic.Tracker; +using CronosControl.BusinessLogic.ProjectUser; using CronosControl.BusinessLogic.Configuration.Settings; namespace CronosControl.BusinessLogic @@ -28,12 +28,12 @@ public partial class CronosControlContext { #region Constants - private const string CONST_TRACKERSESSION = "CronosControl.TrackerSession"; - private const string CONST_TRACKERSESSIONCOOKIE = "CronosControl.TrackerSessionGUIDCookie"; + private const string CONST_PROJECTUSERSESSION = "CronosControl.ProjectUserSession"; + private const string CONST_PROJECTUSERSESSIONCOOKIE = "CronosControl.ProjectUserSessionGUIDCookie"; #endregion #region Fields - private User currentTracker; + private User currentProjectUser; private bool isAdmin; private HttpContext context = HttpContext.Current; private Project currentProject; @@ -52,31 +52,31 @@ #region Methods /// <summary> - /// Save tracker session to data source + /// Save project user session to data source /// </summary> - /// <returns>Saved tracker session</returns> - private TrackerSession SaveSessionToDatabase() + /// <returns>Saved project user session</returns> + private ProjectUserSession SaveSessionToDatabase() { return null; } /// <summary> - /// Gets tracker session + /// Gets project user session /// </summary> /// <param name="createInDatabase">Create session in database if no one exists</param> - /// <returns>Tracker session</returns> - public TrackerSession GetSession(bool createInDatabase) + /// <returns>Project User session</returns> + public ProjectUserSession GetSession(bool createInDatabase) { return this.GetSession(createInDatabase, null); } /// <summary> - /// Gets tracker session + /// Gets project user session /// </summary> /// <param name="createInDatabase">Create session in database if no one exists</param> /// <param name="sessionId">Session identifier</param> - /// <returns>Tracker session</returns> - public TrackerSession GetSession(bool createInDatabase, Guid? sessionId) + /// <returns>Project user session</returns> + public ProjectUserSession GetSession(bool createInDatabase, Guid? sessionId) { return null; } @@ -87,16 +87,16 @@ public void SessionSaveToClient() { if (HttpContext.Current != null && this.Session != null) - SetCookie(HttpContext.Current.ApplicationInstance, CONST_TRACKERSESSIONCOOKIE, this.Session.TrackerSessionGUID.ToString()); + SetCookie(HttpContext.Current.ApplicationInstance, CONST_PROJECTUSERSESSIONCOOKIE, this.Session.ProjectUserSessionGUID.ToString()); } /// <summary> - /// Reset tracker session + /// Reset project user session /// </summary> public void ResetSession() { if (HttpContext.Current != null) - SetCookie(HttpContext.Current.ApplicationInstance, CONST_TRACKERSESSIONCOOKIE, string.Empty); + SetCookie(HttpContext.Current.ApplicationInstance, CONST_PROJECTUSERSESSIONCOOKIE, string.Empty); this.Session = null; this.User = null; this["CronosControl.SessionReseted"] = true; @@ -195,7 +195,7 @@ /// <summary> /// Gets or sets the current session /// </summary> - public TrackerSession Session + public ProjectUserSession Session { get { @@ -203,7 +203,7 @@ } set { - Current[CONST_TRACKERSESSION] = value; + Current[CONST_PROJECTUSERSESSION] = value; } } @@ -214,11 +214,11 @@ { get { - return this.currentTracker; + return this.currentProjectUser; } set { - this.currentTracker = value; + this.currentProjectUser = value; } } Modified: source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs 2010-02-13 21:18:21 UTC (rev 28) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlMembershipProvider.cs 2010-02-13 21:22:01 UTC (rev 29) @@ -20,7 +20,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using CronosControl.Common.Utils; -using CronosControl.BusinessLogic.Tracker; +using CronosControl.BusinessLogic.ProjectUser; using CronosControl.Model; namespace CronosControl.BusinessLogic.Profile @@ -85,8 +85,8 @@ { MembershipUser user = null; - // add tracker - TrackerManager.AddTracker(email, username, password, username, "-", isApproved, out status); + // add project user + ProjectUserManager.AddProjectUser(email, username, password, username, "-", isApproved, out status); // user key string userKey = string.Empty; @@ -185,7 +185,7 @@ /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns> public override MembershipUser GetUser(string username, bool userIsOnline) { - User user = TrackerManager.GetTrackerByUsername(username); + User user = ProjectUserManager.GetProjectUserByUsername(username); if (user == null) return null; @@ -212,7 +212,7 @@ /// <returns>The user name associated with the specified e-mail address. If no match is found, return null.</returns> public override string GetUserNameByEmail(string email) { - User user = TrackerManager.GetTrackerByEmail(email); + User user = ProjectUserManager.GetProjectUserByEmail(email); if (user == null) return null; return user.Username; @@ -345,8 +345,8 @@ /// <returns>true if the specified username and password are valid; otherwise, false.</returns> public override bool ValidateUser(string username, string password) { - User user = TrackerManager.GetTrackerByUsername(username); - return TrackerManager.Login(username, password); + User user = ProjectUserManager.GetProjectUserByUsername(username); + return ProjectUserManager.Login(username, password); } #endregion Modified: source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs 2010-02-13 21:18:21 UTC (rev 28) +++ source/trunk/CronosControl/Libraries/BusinessLogic/Profile/CronosControlRoleProvider.cs 2010-02-13 21:22:01 UTC (rev 29) @@ -20,7 +20,7 @@ using System.Collections.Specialized; using System.Configuration.Provider; using CronosControl.Model; -using CronosControl.BusinessLogic.Tracker; +using CronosControl.BusinessLogic.ProjectUser; namespace CronosControl.BusinessLogic.Profile { @@ -43,7 +43,7 @@ { try { - TrackerManager.AddUsersToRoles(usernames, roleNames); + ProjectUserManager.AddUsersToRoles(usernames, roleNames); } catch (Exception ex) { @@ -98,11 +98,11 @@ /// <returns>A string array containing the names of all the roles that the specified user is in for the configured applicationName.</returns> public override string[] GetRolesForUser(string username) { - User user = TrackerManager.GetTrackerByUsername(username); + User user = ProjectUserManager.GetProjectUserByUsername(username); if (user == null) return new string[] { }; - return TrackerManager.GetRolesForUser(username); + return ProjectUserManager.GetRolesForUser(username); } /// <summary> @@ -172,11 +172,11 @@ /// <returns>true if the specified user is in the specified role for the configured applicationName; otherwise, false.</returns> public override bool IsUserInRole(string username, string roleName) { - User user = TrackerManager.GetTrackerByUsername(username); + User user = ProjectUserManager.GetProjectUserByUsername(username); if (user == null) return false; - return TrackerManager.IsUserInRole(username, roleName); + return ProjectUserManager.IsUserInRole(username, roleName); } /// <summary> Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.dll =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.BusinessLogic.pdb =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.dll =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControl.Common.pdb =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.dll =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlBusinessClassLibrary.pdb =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.dll =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/bin/Debug/CronosControlClassLibrary.pdb =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.dll =================================================================== (Binary files differ) Modified: source/trunk/CronosControl/Libraries/BusinessLogic/obj/Debug/CronosControl.BusinessLogic.pdb =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-02-13 21:24:59
|
Revision: 30 http://cronoscontrol.svn.sourceforge.net/cronoscontrol/?rev=30&view=rev Author: marioarce Date: 2010-02-13 21:24:52 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Ticket #5 renamed concept from 'Tracker' to 'Project User'. Project User includes a 'project manager', a 'project team members', and any other project stakeholder The following are examples of project stakeholders: * Project manager * Project team members * Upper management * Project customer * Resource Managers * Product user group * Project testers * Sponsor Added Paths: ----------- source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserManager.cs source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserSession.cs Added: source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserManager.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserManager.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserManager.cs 2010-02-13 21:24:52 UTC (rev 30) @@ -0,0 +1,339 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Linq; +using System.Text; +using System.Web.Security; +using System.Collections.Generic; +using System.Configuration.Provider; +using System.Security.Cryptography; +using CronosControl.Model; +using CronosControl.Business; +using CronosControl.Common.Utils; +using CronosControl.BusinessLogic.Configuration.Settings; + +namespace CronosControl.BusinessLogic.ProjectUser +{ + /// <summary> + /// Project User manager + /// </summary> + public partial class ProjectUserManager + { + #region Methods + /// <summary> + /// Adds a project user + /// </summary> + /// <param name="Email">The email</param> + /// <param name="Username">The username</param> + /// <param name="Password">The password</param> + /// <param name="Name">A value indicating whether the name of the project user</param> + /// <param name="Lastname">A value indicating whether the lastname of the project user</param> + /// <param name="Enabled">A value indicating whether the project user is active</param> + /// <param name="status">Status</param> + /// <returns>A project user</returns> + public static User AddProjectUser(string email, string username, string password, + string name, string lastname, + bool enabled, out MembershipCreateStatus status) + { + string saltKey = string.Empty; + string passwordHash = string.Empty; + status = MembershipCreateStatus.UserRejected; + + // duplicated UserName ? + //status = MembershipCreateStatus.DuplicateUserName; + + // invalid UserName ? + //status = MembershipCreateStatus.InvalidUserName; + + // duplicated email ? + //status = MembershipCreateStatus.DuplicateEmail; + + // invalid email ? + if (!CommonHelper.IsValidEmail(email)) + status = MembershipCreateStatus.InvalidEmail; + + + int idCompany = CronosControlContext.Current.CurrentCompany.IdCompany; + passwordHash = CreatePasswordMd5Hash(password); + + User userEntity = new User(); + userEntity.Name = name; + userEntity.Lastname = lastname; + userEntity.Username = username; + userEntity.Password = passwordHash; + userEntity.Email = email; + userEntity.IdCompany = idCompany; + userEntity.CreatedAt = DateTimeHelper.ConvertToUtcTime(DateTime.Now); + userEntity.Enabled = enabled; + + try + { + Users users = new Users(); + users.Save(userEntity); + } + catch + { + status = MembershipCreateStatus.ProviderError; + } + + status = MembershipCreateStatus.Success; + return userEntity; + } + + /// <summary> + /// Adds the specified user names to the specified roles for the configured applicationName + /// </summary> + /// <param name="usernames">A string array of user names to be added to the specified roles.</param> + /// <param name="roleNames">A string array of the role names to add the specified user names to.</param> + public static void AddUsersToRoles(string[] usernames, string[] roleNames) + { + foreach (string username in usernames) + { + // get User + User user = GetProjectUserByUsername(username); + if (user == null) + { + // user not found!, continue... + continue; + } + + foreach (var roleName in roleNames) + { + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + // get Role + Role role = (from r in cronosControlEntities.Role + where r.Name.Equals(roleName) + select r).First<Role>(); + + Project project = CronosControlContext.Current.CurrentProject; + + // assign role to the user + UserProjectRole userProjectRole = new UserProjectRole(); + userProjectRole.Role = role; + userProjectRole.Project = project; + userProjectRole.IdUser = user.IdUser; + + cronosControlEntities.AddToUserProjectRole(userProjectRole); + cronosControlEntities.SaveChanges(); + } + } + } + + /// <summary> + /// Creates a salt + /// </summary> + /// <param name="size">A salt size</param> + /// <returns>A salt</returns> + private static string CreateSalt(int size) + { + RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider(); + byte[] data = new byte[size]; + provider.GetBytes(data); + return Convert.ToBase64String(data); + } + + /// <summary> + /// Creates a password hash + /// </summary> + /// <param name="Password">Password</param> + /// <param name="Salt">Salt</param> + /// <returns>Password hash</returns> + private static string CreatePasswordHash(string Password, string Salt) + { + //MD5, SHA1 + string passwordFormat = SettingManager.Current["Security", "PasswordFormat"]; + if (String.IsNullOrEmpty(passwordFormat)) + passwordFormat = "SHA1"; + + return FormsAuthentication.HashPasswordForStoringInConfigFile(Password + Salt, passwordFormat); + } + + /// <summary> + /// Creates a password Md5 hash + /// </summary> + /// <param name="Password">Password</param> + /// <returns>Password hash</returns> + private static string CreatePasswordMd5Hash(string password) + { + if (string.IsNullOrEmpty(password)) + return string.Empty; + + // Create a new instance of the MD5CryptoServiceProvider object. + MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); + + // Convert the input string to a byte array and compute the hash. + byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(password)); + + // Create a new Stringbuilder to collect the bytes + // and create a string. + StringBuilder sBuilder = new StringBuilder(); + + // Loop through each byte of the hashed data + // and format each one as a hexadecimal string. + for (int i = 0; i < data.Length; i++) + { + sBuilder.Append(data[i].ToString("x2")); + } + + // Return the hexadecimal string. + return sBuilder.ToString(); + } + + /// <summary> + /// Gets a list of the roles that a specified user is in for the configured applicationName. + /// </summary> + /// <param name="username">The user to return a list of roles for.</param> + /// <returns>A string array containing the names of all the roles that the specified user is in for the configured applicationName.</returns> + public static string[] GetRolesForUser(string username) + { + // get User + User user = GetProjectUserByUsername(username); + if (user == null) + { + // user not found! + return new string[] { }; + } + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + + Project project = CronosControlContext.Current.CurrentProject; + + // get UserProjectRole + List<string> userProjectRoles = (from upr in cronosControlEntities.UserProjectRole + join ro in cronosControlEntities.Role + on new { upr.Role.IdRole } equals new { ro.IdRole } + where (upr.IdUser == user.IdUser && upr.Project.IdProject == project.IdProject) + select ro.Name).ToList<string>(); + + string[] result = new string[userProjectRoles.Count]; + for (int i = 0; i < userProjectRoles.Count; i++) + { + result[i] = userProjectRoles[i]; + } + return result; + } + + /// <summary> + /// Gets a tracket by email + /// </summary> + /// <param name="Username">Project user email</param> + /// <returns>A project user</returns> + public static User GetProjectUserByEmail(string email) + { + if (string.IsNullOrEmpty(email)) + return null; + if (!CommonHelper.IsValidEmail(email)) + return null; + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + User user = (from u in cronosControlEntities.User + where u.Email.Equals(email) + select u).First<User>(); + + return user; + } + + /// <summary> + /// Gets a tracket + /// </summary> + /// <param name="Username">Project user identifier</param> + /// <returns>A project user</returns> + public static User GetProjectUserByID(int projectUserID) + { + if (projectUserID == 0) + return null; + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + User user = (from u in cronosControlEntities.User + where u.IdUser.Equals(projectUserID) + select u).First<User>(); + + return user; + } + + /// <summary> + /// Gets a tracket by username + /// </summary> + /// <param name="Username">Project user username</param> + /// <returns>A project user</returns> + public static User GetProjectUserByUsername(string username) + { + if (string.IsNullOrEmpty(username)) + return null; + + User user; + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + try + { + user = (from u in cronosControlEntities.User + where u.Username.Equals(username) + select u).First<User>(); + } + catch + { + return null; + } + + return user; + } + + /// <summary> + /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName. + /// </summary> + /// <param name="username">The user name to search for.</param> + /// <param name="roleName">The role to search in.</param> + /// <returns>true if the specified user is in the specified role for the configured applicationName; otherwise, false.</returns> + public static bool IsUserInRole(string username, string roleName) + { + if (string.IsNullOrEmpty(username)) + return false; + if (string.IsNullOrEmpty(roleName)) + return false; + + User user = GetProjectUserByUsername(username); + + CronosControlEntities cronosControlEntities = new CronosControlEntities(); + int result = (from upr in cronosControlEntities.UserProjectRole + where (upr.IdUser == 1 && upr.Role.Name.Equals(roleName)) + select upr).Count<UserProjectRole>(); + + return (result == 1); + } + + /// <summary> + /// Login a project user + /// </summary> + /// <param name="Email">A project user username</param> + /// <param name="Password">Password</param> + /// <returns>Result</returns> + public static bool Login(string username, string password) + { + User user = GetProjectUserByUsername(username); + + if (user == null) + return false; + if (!user.Enabled) + return false; + + string passwordHash = CreatePasswordMd5Hash(password); + bool result = user.Password.Equals(passwordHash); + + // any session stuff here ... + + return result; + } + #endregion + } +} Added: source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserSession.cs =================================================================== --- source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserSession.cs (rev 0) +++ source/trunk/CronosControl/Libraries/BusinessLogic/ProjectUser/ProjectUserSession.cs 2010-02-13 21:24:52 UTC (rev 30) @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------------ +// The contents of this file are subject to the GNU General Public License Version 3.0 ("License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.cronoscontrol.net/license.html. +// +// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is CronosControl. +// The Initial Developer of the Original Code is WebImageConsulting http://www.wicnow.com/. +// All Rights Reserved. +// +// Contributor(s): Mario Alberto Arce, _______. +//------------------------------------------------------------------------------ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using System.Web; +using System.Xml; +using CronosControl.Model; + +namespace CronosControl.BusinessLogic.ProjectUser +{ + /// <summary> + /// Represents a project user session + /// </summary> + public partial class ProjectUserSession : BaseEntity + { + #region Constructor + /// <summary> + /// Creates a new instance of the ProjectUserSession class + /// </summary> + public ProjectUserSession() + { + } + #endregion + + #region Properties + /// <summary> + /// Gets or sets the project user session identifier + /// </summary> + public Guid ProjectUserSessionGUID { get; set; } + + /// <summary> + /// Gets or sets the project user identifier + /// </summary> + public int ProjectUserID { get; set; } + + /// <summary> + /// Gets or sets the last accessed date and time + /// </summary> + public DateTime LastAccessed { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether the project user session is expired + /// </summary> + public bool IsExpired { get; set; } + #endregion + + #region Custom Properties + /// <summary> + /// Gets or sets the project user + /// </summary> + public User User + { + get + { + return ProjectUserManager.GetProjectUserByID(ProjectUserID); + } + } + #endregion + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |