Remove() public method

public Remove ( String name ) : void
name String
return void
        public override void Initialize(string name, NameValueCollection config){
            if (String.IsNullOrEmpty(name))
                name = "WindowsTokenProvider";
            if (string.IsNullOrEmpty(config["description"])) {
                config.Remove("description");
                config.Add("description", SR.GetString(SR.RoleWindowsTokenProvider_description));
            }
            base.Initialize(name, config);

            if (config == null)
               throw new ArgumentNullException("config");
            _AppName = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
                _AppName = SecUtility.GetDefaultAppName();

            if( _AppName.Length > 256 )
            {
                throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
            }

            config.Remove("applicationName");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                    throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
            }
        }
Beispiel #2
0
        public Response(string resp)
        {
            _resp = resp;
            _nvc = new NameValueCollection();
            string[] parts = resp.Split( '&' );
            for( int i = 0; i < parts.Length; i++ )
            {
                string[] ps = parts[i].Split( '=' );
                string name = System.Web.HttpContext.Current.Server.UrlDecode( ps[0] );
                string value = System.Web.HttpContext.Current.Server.UrlDecode( ps[1] );
                _nvc[name] = value;
            }

            _errors = new List<Error>();
            int index = 0;
            while(true)
            {
                if( _nvc["L_ERRORCODE" + index] == null )
                    break;

                var e = new Error() { ErrorCode = _nvc["L_ERRORCODE" + index], ShortMessage = _nvc["L_SHORTMESSAGE" + index], LongMessage = _nvc["L_LONGMESSAGE" + index], SeverityCode = _nvc["L_SEVERITYCODE" + index] };
                _errors.Add( e );

                _nvc.Remove( "L_ERRORCODE" + index );
                _nvc.Remove( "L_SHORTMESSAGE" + index );
                _nvc.Remove( "L_LONGMESSAGE" + index );
                _nvc.Remove( "L_SEVERITYCODE" + index );

                index++;
            }
        }
 void FilterInputParameters(NameValueCollection inputParameters)
 {
     inputParameters.Remove("_");
     inputParameters.Remove("_q");
     inputParameters.Remove("_rm");
     inputParameters.Remove("_cmd");
 }
		public override NameValueCollection GetNavigationData(State state, NameValueCollection data)
		{
			data[NavigationSettings.Config.PreviousStateIdKey] = data["previous"];
			data.Remove("previous");
			data.Remove("custom");
			return data;
		}
        /// <summary>
        /// init
        /// </summary>
        /// <param name="name"></param>
        /// <param name="config"></param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "DbBlogProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Generic Database Blog Provider");
            }

            base.Initialize(name, config);

            if (config["storageVariable"] == null)
            {
                // default to BlogEngine
                config["storageVariable"] = "BlogEngine";
            }

            this.connStringName = config["storageVariable"];
            config.Remove("storageVariable");

            if (config["tablePrefix"] == null)
            {
                // default
                config["tablePrefix"] = "be_";
            }

            this.tablePrefix = config["tablePrefix"];
            config.Remove("tablePrefix");

            if (config["parmPrefix"] == null)
            {
                // default
                config["parmPrefix"] = "@";
            }

            this.parmPrefix = config["parmPrefix"];
            config.Remove("parmPrefix");

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                var attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException(string.Format("Unrecognized attribute: {0}", attr));
                }
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            this.mongoCollection = ConnectionHelper.GetDatabase(config).GetCollection(config["collection"] ?? "WebEvents");

            config.Remove("collection");
            config.Remove("connectionString");
            config.Remove("database");

            base.Initialize(name, config);
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            this.mongoCollection = new MongoClient(config["connectionString"] ?? "mongodb://localhost").GetServer().GetDatabase(config["database"] ?? "ASPNETDB").GetCollection(config["collection"] ?? "WebEvents");

            config.Remove("collection");
            config.Remove("connectionString");
            config.Remove("database");

            base.Initialize(name, config);
        }
        public override void Initialize(string name,
            NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "SimpleMySqlPersonalizationProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description",
                    "Simple MySql personalization provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            if (string.IsNullOrEmpty(config["connectionStringName"]))
            {
                throw new ProviderException
                    ("ConnectionStringName property has not been specified");
            }
            else
            {
                m_ConnectionStringName = config["connectionStringName"];
                config.Remove("connectionStringName");
            }

            if (string.IsNullOrEmpty(config["applicationName"]))
            {
                throw new ProviderException
                    ("applicationName property has not been specified");
            }
            else
            {
                m_ApplicationName = config["applicationName"];
                config.Remove("applicationName");
            }

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException
                        ("Unrecognized attribute: " + attr);
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            this.mongoCollection = MongoDatabase.Create(
                ConfigurationManager.ConnectionStrings[config["connectionStringName"] ?? "MongoConnection"].ConnectionString ?? "mongodb://localhost")
                .GetCollection(config["collection"] ?? "WebEvents");

            config.Remove("collection");
            config.Remove("connectionStringName");

            base.Initialize(name, config);
        }
        public override void Initialize(string name, NameValueCollection settings)
        {
            var config = DependencyResolver.Current.GetService<IConfig>();

            this.mongoCollection = ConnectionUtils.GetCollection(settings, config, "WebEvents");

            settings.Remove("collection");
            settings.Remove("connectionString");
            settings.Remove("database");

            base.Initialize(name, settings);
        }
        ////////////////////////////////////////////////////////////
        // Public properties

        public override void Initialize(string name, NameValueCollection config)
        {
            if (name == null || name.Length < 1)
                name = "AccessProfileProvider";

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Nada.DA Profile Provider");
            }
            base.Initialize(name, config);
            if (config == null)
                throw new ArgumentNullException("config");

            _DatabaseFileName = config["connectionStringName"];
            if (_DatabaseFileName == null || _DatabaseFileName.Length < 1)
                throw new ProviderException("Connection name not specified");
            string temp = AccessConnectionHelper.GetFileNameFromConnectionName(_DatabaseFileName, true);
            if (temp == null || temp.Length < 1)
            {
                throw new ProviderException("Connection string not found" + _DatabaseFileName);
            }
            _DatabaseFileName = temp;

            // EDIT GET THE IN MEMORY CONNECTION STRING
            _DatabaseFileName = DatabaseData.Instance.AccessConnectionString;
            //HandlerBase.CheckAndReadRegistryValue(ref _DatabaseFileName, true);
            AccessConnectionHelper.CheckConnectionString(_DatabaseFileName);

            _AppName = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
                _AppName = SecUtility.GetDefaultAppName();

            if (_AppName.Length > 255)
            {
                throw new ProviderException("ApplicationName exceeded max length of " + 255);
            }

            //_Description = config["description"];
            config.Remove("connectionStringName");
            config.Remove("applicationName");
            config.Remove("description");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                    throw new ProviderException("Unrecognized attribute: " + attribUnrecognized);
            }
        }
        private void RemoveIgnoredParameters(NameValueCollection parameters, ICollection<string> ignoreList)
        {
            foreach (string parameterName in ignoreList)
            {
                parameters.Remove(parameterName);
            }

            // This is in a somewhat obscure location (mostly used to remove slider filters).
            // Maybe I should move this somewhere else?
            for (int i = parameters.AllKeys.Length - 1; i >= 0; i--)
            {
                if (parameters[i].Length == 0)
                    parameters.Remove(parameters.AllKeys[i]);
            }
        }
Beispiel #13
0
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "ProductProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SQL Account provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            // Initialize _connectionString
            string connect = config["connectionStringName"];

            if (String.IsNullOrEmpty(connect))
                throw new ProviderException
                    ("Empty or missing connectionStringName");

            config.Remove("connectionStringName");

            if (WebConfigurationManager.ConnectionStrings[connect] == null)
                throw new ProviderException("Missing connection string");

            _connectionString = WebConfigurationManager.ConnectionStrings
                [connect].ConnectionString;

            if (String.IsNullOrEmpty(_connectionString))
                throw new ProviderException("Empty connection string");

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException
                        ("Unrecognized attribute: " + attr);
            }
        }
        public override void Initialize(string name, NameValueCollection configSettings)
        {
            if (configSettings == null)
                throw new ArgumentNullException("configSettings");

            if (string.IsNullOrEmpty(name))
                name = "PersonalizationProvider";

            if (string.IsNullOrEmpty(configSettings["description"]))
            {
                configSettings.Remove("description");
                configSettings.Add("description", ResourceStringLoader.GetResourceString(
                    "PersonalizationProvider_Description"));
            }

            base.Initialize(name, configSettings);

            this._applicationName = configSettings["applicationName"];

            if (this._applicationName != null)
            {
                configSettings.Remove("applicationName");
                if (this._applicationName.Length > 0x100)
                {
                    object[] args = new object[] { 0x100.ToString(CultureInfo.CurrentCulture) };
                    throw new ProviderException(ResourceStringLoader.GetResourceString(
                        "PersonalizationProvider_ApplicationNameExceedMaxLength", args));
                }
            }

            if (!string.IsNullOrEmpty(configSettings["directoryName"]))
                this._directoryName = configSettings["directoryName"];

            configSettings.Remove("directoryName");

            if (!VirtualPathUtility.IsAppRelative(this._directoryName))
                throw new ProviderException(ResourceStringLoader.GetResourceString(
                    "PersonalizationProvider_DirectoryNameNotRelative"));

            this._directoryName = VirtualPathUtility.AppendTrailingSlash(this._directoryName);

            if (configSettings.Count > 0)
            {
                string key = configSettings.GetKey(0);
                throw new ProviderException(ResourceStringLoader.GetResourceString(
                    "PersonalizationProvider_UnknownProp", new object[] { key, name }));
            }
        }
        public override void Initialize(string name, NameValueCollection attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "MvcSitemapProvider";
            }

            if (string.IsNullOrEmpty(attributes["description"]))
            {
                attributes.Remove("description");
                attributes.Add("description", "MVC site map provider");
            }
            base.Initialize(name,attributes);

           
            if (attributes.Count > 0)
            {
                string attr = attributes.GetKey(0);
                if (!string.IsNullOrEmpty(attr))
                    throw new ProviderException(string.Format(
                      "Unrecognized attribute: {0}", attr));
            }
        }
    public override void Initialize(string name, NameValueCollection config)
    {
      // Initialize values from web.config.
      if (config == null) throw new ArgumentNullException("config");
      if (name == null || name.Length == 0) name = "VauctionSessionStateStore";
      if (String.IsNullOrEmpty(config["description"]))
      {
        config.Remove("description");
        config.Add("description", "Vauction Session State Store provider");
      }
      // Initialize the abstract base class.
      base.Initialize(name, config);
      // Initialize the ApplicationName property.

      // Get <sessionState> configuration element.
      System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration(ApplicationName);
      pConfig = (SessionStateSection)cfg.GetSection("system.web/sessionState");

      // Initialize connection string.
      pConnectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];

      if (pConnectionStringSettings == null || pConnectionStringSettings.ConnectionString.Trim() == "")
        throw new ProviderException("Connection string cannot be blank.");
      connectionString = pConnectionStringSettings.ConnectionString;

      // Initialize WriteExceptionsToEventLog
      pWriteExceptionsToEventLog = false;
      if (config["writeExceptionsToEventLog"] != null)
      {
        if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE")
          pWriteExceptionsToEventLog = true;
      }
      pApplicationName = (config["application"] != null) ? config["application"] : System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
      eventSource = (!String.IsNullOrEmpty(config["eventLogSource"])) ? config["eventLogSource"] : "VauctionSessionStateStore";
    }
        /// <summary>
        /// Initialize role provider.
        /// </summary>
        /// <param name="name">
        /// The provider name.
        /// </param>
        /// <param name="config">
        /// The config.
        /// </param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "ShopAnyWareRoleProvider";
            }

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Shop Any Ware Role Provider");
            }

            base.Initialize(name, config);

            foreach (string key in config.Keys)
            {
                if (string.Compare(key, "applicationname", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    this.ApplicationName = config[key];
                }
            }
        }
        /// <summary>
        /// Initialise membership properties from config file
        /// </summary>
        /// <param name="name"></param>
        /// <param name="config"></param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(name))
            {
                name = "n3oSqlMembershipProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "MVCForum Standard Membership Provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            _applicationName = GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            _maxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            _passwordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));
            _minRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
            _minRequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"));
            _requiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            _requiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));
            _enablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
        }
Beispiel #19
0
		/// <summary>
		/// Responds to a <see cref="System.Web.UI.ScriptManager"/> history navigation handler and restores the
		/// <paramref name="data"/> saved by <see cref="AddHistoryPoint(System.Web.UI.Page, Navigation.NavigationData, string)"/> 
		/// method to the <see cref="Navigation.StateContext"/>
		/// </summary>
		/// <param name="data">Saved <see cref="Navigation.StateContext"/> to restore</param>
		/// <exception cref="System.ArgumentNullException"><paramref name="data"/> is null</exception>
		/// <exception cref="Navigation.UrlException">There is data that cannot be converted from a <see cref="System.String"/>;
		/// or the <see cref="Navigation.NavigationShield"/> detects tampering</exception>
		public static void NavigateHistory(NameValueCollection data)
		{
			if (data == null)
				throw new ArgumentNullException("data");
			if (data.Count == 0)
			{
				NavigationData derivedData = new NavigationData(StateContext.State.Derived);
#if NET40Plus
				SetStateContext(StateContext.State.Id, new HttpContextWrapper(HttpContext.Current));
#else
				SetStateContext(StateContext.State.Id, HttpContext.Current.Request.QueryString);
#endif
				StateContext.Data.Add(derivedData);
			}
			else
			{
				RemoveDefaultsAndDerived(data);
				data = StateContext.ShieldDecode(data, true, StateContext.State);
				data.Remove(NavigationSettings.Config.StateIdKey);
				NavigationData derivedData = new NavigationData(StateContext.State.Derived);
				StateContext.Data.Clear();
				StateContext.Data.Add(derivedData);
				foreach (string key in data)
				{
					StateContext.Data[key] = CrumbTrailManager.ParseURLString(key, data[key], StateContext.State);
				}
			}
		}
Beispiel #20
0
		public void PasswordModelBinderShouldReturnValuesForSpecifiedQueryStrings()
		{
			var viewContext = new ViewContext();
			viewContext.HttpContext = MockHttpContext.FakeHttpContext();
			var appraisalCompanyAdminManagement = Substitute.For<IAppraiserManagement>();
			var appraisalCompanyWizardService = Substitute.For<IAppraisalCompanyService>();
		
			var controller = new AppraisalCompanyFeesController(appraisalCompanyWizardService, appraisalCompanyAdminManagement);
			controller.SetFakeControllerContext(viewContext.HttpContext);
			NameValueCollection queryString = new NameValueCollection();

			controller.HttpContext.Request.QueryString.Returns(queryString); 
			PasswordModelBinder target = new PasswordModelBinder();
			var testCases = new[] {
				new {QueryStringParameterName="UserChangePasswordViewModel.NewPassword",Value="17"},
				new {QueryStringParameterName="CreateUserGeneralInfoViewModel.Password",Value="42"},
				new {QueryStringParameterName="Password",Value="2"},
				new {QueryStringParameterName="NewPassword",Value="33"},
				new {QueryStringParameterName="AppraisalCompanyAdmin.Password",Value="asd"},
				new {QueryStringParameterName="GeneralInfo.Password",Value="sssssssssss"},
			};
				
			//act
			foreach (var testCase in testCases)
			{
				queryString.Add(testCase.QueryStringParameterName, testCase.Value);
				
				string result = (string)target.BindModel(controller.ControllerContext, new ModelBindingContext());
				result.Should().BeEquivalentTo(testCase.Value);

				queryString.Remove(testCase.QueryStringParameterName);
			}
		}
        /// <summary>
        /// Return an LtiRequestViewModel suitable for creating an MVC view or AspNet page
        /// that auto-submits an LTI request.
        /// </summary>
        /// <param name="ltiRequest">The LtiRequest to submit.</param>
        /// <param name="consumerSecret">The OAuth consumer secret to sign the request.</param>
        /// <returns></returns>
        public static LtiRequestViewModel GetViewModel(this LtiRequest ltiRequest, string consumerSecret)
        {
            // Create a copy of the parameters (getters should not change the object and this
            // getter changes the parameters to eliminate empty/null values and make custom
            // parameter substitutions)
            var parameters = new NameValueCollection(ltiRequest.Parameters);

            // Remove empty/null parameters
            foreach (var key in parameters.AllKeys.Where(key => string.IsNullOrWhiteSpace(parameters[key])))
            {
                parameters.Remove(key);
            }

            // Perform the custom variable substitutions
            ltiRequest.SubstituteCustomVariables(parameters);

            // Calculate the signature based on the substituted values
            var signature = ltiRequest.GenerateSignature(parameters, consumerSecret);

            return new LtiRequestViewModel
            {
                Action = ltiRequest.Url.ToString(),
                Fields = parameters,
                Signature = signature
            };
        }
Beispiel #22
0
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
    {
        // check to ensure config is not null
        if (config == null)
        {
            throw new ArgumentNullException("config");
        }

        if (string.IsNullOrEmpty(name))
        {
            name = "SqlChatProvider";
        }

        // Check for the connection string
        if (config["connectionStringName"] != null && !string.IsNullOrEmpty(config["connectionStringName"].ToString()) && !string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[config["connectionStringName"].ToString()].ToString()))
        {
            connectionString = ConfigurationManager.ConnectionStrings[config["connectionStringName"].ToString()].ToString();
            config.Remove("connectionStringName");
        }
        else
        {
            throw new ArgumentNullException("The ConnectionStringName is not defined");
        }

        base.Initialize(name, config);
    }
Beispiel #23
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("Config is null");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "UmbracoSiteMapProvider";
            }

            if (!String.IsNullOrEmpty(config["defaultDescriptionAlias"]))
            {
                m_defaultDescriptionAlias = config["defaultDescriptionAlias"].ToString();
                config.Remove("defaultDescriptionAlias");
            }
            if (config["securityTrimmingEnabled"] != null)
            {
                m_enableSecurityTrimming = bool.Parse(config["securityTrimmingEnabled"]);
            }

            base.Initialize(name, config);

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException
                              (String.Format("Unrecognized attribute: {0}", attr));
                }
            }
        }
Beispiel #24
0
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
    {
        Console.WriteLine("Hola: Iniciado");
        if (config == null)
        {
            throw new ArgumentNullException("config");
        }

        if (name == null || name.Length == 0)
        {
            name = "EpymeRoleProvider";
        }

        if (String.IsNullOrEmpty(config["description"]))
        {
            config.Remove("description");
            config.Add("description", "Epyme Role Provider");
        }

        // Initialize the abstract base class.
        base.Initialize(name, config);


        if (config["applicationName"] == null || config["applicationName"].Trim() == "")
        {
            pApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
        }
        else
        {
            pApplicationName = config["applicationName"];
        }
    }
Beispiel #25
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "SenseNetPersonalizationProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SenseNet Personalization Provider");
            }

            base.Initialize(name, config);

            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException("Unrecognized attribute: " + attr);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Literal LinkText = new Literal();
            LinkText.Text = ElementLabelLiteral;
            Ux_forgot_pwd_link.Controls.Add(LinkText);
            string[] pathparts = Request.Url.Segments;
            StringBuilder sb = new StringBuilder();

            String URI = Request.Url.ToString();
             for (int i = 0; i < pathparts.Length - 1; i++)
            {
                sb.Append(pathparts[i]);
            }
           // if (pathparts[3] == "login_e.aspx") // rfg 2.20
            if(URI.Contains("login_e.aspx"))
            {
                sb.Append("login_forgotpwd_e.aspx?");
            }
            else
            {
                sb.Append("login_forgotpwd.aspx?");
            }
            NameValueCollection oldquery = new NameValueCollection(Request.QueryString.Count, Request.QueryString);
            oldquery.Remove("sent");
            utility.append_querystring(sb, oldquery, sb.Length);
            Ux_forgot_pwd_link.NavigateUrl = sb.ToString();
        }
 public virtual void Initialize(string name, NameValueCollection configuration)
 {
     lock (this)
     {
         if (this.initialized)
         {
             throw new InvalidOperationException("Provider already initialized");
         }
         this.initialized = true;
     }
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw new ArgumentException("configuration provider name null or empty.", "name");
     }
     this.name = name;
     if (configuration != null)
     {
         this.description = configuration["description"];
         configuration.Remove("description");
     }
 }
Beispiel #28
0
 static void Main(string[] args)
 {
     // Create an empty NameValueCollection and add multiple values for each key.
     NameValueCollection nvCol = new NameValueCollection();
     nvCol.Add("Minnesota", "St. Paul");
     nvCol.Add("Minnesota", "Minneapolis");
     nvCol.Add("Minnesota", "Rochester");
     nvCol.Add("Florida", "Miami");
     nvCol.Add("Florida", "Orlando");
     nvCol.Add("Arizona", "Pheonix");
     nvCol.Add("Arizona", "Tucson");
     // Get the key at index position 0 (Minnesota).
     string key = nvCol.GetKey(0);
     Console.WriteLine("Key 0: {0}", key);
     // Remove the entry for Minnesota by its key.
     nvCol.Remove(key);
     // Get the values for Florida as a string array.
     foreach (string val in nvCol.GetValues("Florida"))
     {
         Console.WriteLine("A value for 'Florida': {0}", val);
     }
     // Iterate through the entries (Florida and Arizona) in the NameValueCollection.
     foreach (string k in nvCol)
     {
         // Get the values for an entry as a comma-separated list.
         Console.WriteLine("Key: {0} Values: {1}", k, nvCol.Get(k));
     }
 }
 public virtual void Initialize(string name, NameValueCollection config)
 {
     lock (this)
     {
         if (this._Initialized)
         {
             throw new InvalidOperationException(System.Configuration.SR.GetString("Provider_Already_Initialized"));
         }
         this._Initialized = true;
     }
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw new ArgumentException(System.Configuration.SR.GetString("Config_provider_name_null_or_empty"), "name");
     }
     this._name = name;
     if (config != null)
     {
         this._Description = config["description"];
         config.Remove("description");
     }
 }
		public override void Initialize(string name, NameValueCollection config)
		{
			if (config == null)
			{
				throw new ArgumentNullException("config");
			}
			if (string.IsNullOrEmpty(name))
			{
				name = "MemcachedProviders.CacheProvider";
			}
			if (string.IsNullOrEmpty(config["description"]))
			{
				config.Remove("description");
				config.Add("description", "Memcached Cache Provider");
			}

			base.Initialize(name, config);

			if (String.IsNullOrEmpty(config["section"]))
			{
				throw new ArgumentException("未配置 section 属性。");
			}

			IMemcachedClientConfiguration section = (IMemcachedClientConfiguration)this.Configuration.GetSection(config["section"]);
			if (section == null)
			{
				throw new ConfigurationErrorsException(String.Format("未找到适用于 MemcachedDistributeCacheProvider 的配置节 {0}", config["section"]));
			}

			this.client = new CustomMemcachedClient(section);
		}
        // MembershipProvider Methods
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "AtlassianMembershipProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Atlassian web service membership provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            using (IUnityContainer container = new UnityContainer()
                .LoadConfiguration())
            {
                service = container.Resolve<IProjectsService>();
            }

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
        /// <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)
        {
            // Initialize values from web.config
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                name = "DacheSessionStateProvider";
            }

            if (string.IsNullOrWhiteSpace(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Dache Session State Store Provider");
            }

            // Initialize the abstract base class
            base.Initialize(name, config);

            // Initialize the application name
            _applicationName = HostingEnvironment.ApplicationVirtualPath;

            // Get <sessionState> configuration element
            var webConfig = WebConfigurationManager.OpenWebConfiguration(_applicationName);
            _sessionStateSection = (SessionStateSection)webConfig.GetSection("system.web/sessionState");

            // Initialize WriteExceptionsToEventLog
            if (string.Equals(config["writeExceptionsToEventLog"], bool.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                // TODO: Inject custom logging to the cache client?
            }
        }
        /// <summary>
        /// Initializes the provider with the property values specified in the application's configuration file. This method is not intended to be used directly from your code
        /// </summary>
        /// <param name="name">The name of the provider instance to initialize</param>
        /// <param name="config">A NameValueCollection that contains the names and values of configuration options for the provider.</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            base.Initialize(name, config);

            string connectionStringName = config["connectionStringName"];
            if (String.IsNullOrEmpty(connectionStringName))
                throw new ProviderException("Connection name not specified");
            this._sqlConnectionString = NopSqlDataHelper.GetConnectionString(connectionStringName);
            if ((this._sqlConnectionString == null) || (this._sqlConnectionString.Length < 1))
            {
                throw new ProviderException(string.Format("Connection string not found. {0}", connectionStringName));
            }
            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}", new object[] { key }));
                }
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            HttpServerUtility serverUtil = HttpContext.Current.Server;

            const string cacheFolderKey = "cacheFolder";
            string cacheFolderValue = config[cacheFolderKey];
            string folder;

            if (!String.IsNullOrEmpty(cacheFolderValue))
            {
                folder = serverUtil.MapPath(cacheFolderValue);

                config.Remove(cacheFolderKey);
            }
            else
            {
                throw new ArgumentException(String.Format("The attribute '{0}' is missing in the configuration of the '{1}' provider.", cacheFolderKey, name));
            }

            if (folder[folder.Length - 1] != Path.DirectorySeparatorChar)
            {
                folder += Path.DirectorySeparatorChar;
            }

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            this.cacheFolder = folder;

            base.Initialize(name, config);
        }
    /// <summary>
    /// Parameters to add to edit link to preserve context on return.
    /// </summary>
    protected string EditContextParams(int PageIndex)
    {
        System.Collections.Specialized.NameValueCollection dictParams = new System.Collections.Specialized.NameValueCollection();
        // Add the existing keys first - since we may overwrite them below!
        foreach (string szKey in Request.QueryString.Keys)
        {
            dictParams[szKey] = Request.QueryString[szKey];
        }

        // Issue #458: clone and reverse are getting duplicated and the & is getting url encoded, so even edits look like clones
        dictParams.Remove("Clone");
        dictParams.Remove("Reverse");

        if (!Restriction.IsDefault)
        {
            dictParams["fq"] = Restriction.ToBase64CompressedJSONString();
        }
        if (HasPrevSort)
        {
            if (!String.IsNullOrEmpty(LastSortExpr))
            {
                dictParams["se"] = LastSortExpr;
            }
            if (LastSortDir != SortDirection.Descending || !String.IsNullOrEmpty(LastSortExpr))
            {
                dictParams["so"] = LastSortDir.ToString();
            }
        }
        if (PageIndex != 0)
        {
            dictParams["pg"] = PageIndex.ToString(CultureInfo.InvariantCulture);
        }

        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        foreach (string szkey in dictParams)
        {
            sb.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}={2}", sb.Length == 0 ? string.Empty : "&", szkey, HttpUtility.UrlEncode(dictParams[szkey]));
        }

        return(sb.ToString());
    }
Beispiel #36
0
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection attributes)
    {
        if (string.IsNullOrEmpty(attributes["connectionStringName"]))
        {
            throw new ProviderException("Missing provider attribute connectionStringName");
        }

        connectionStringName = attributes["connectionStringName"];

        attributes.Remove("connectionStringName");

        base.Initialize(name, attributes);
    }
Beispiel #37
0
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
    {
        // check to ensure config is not null
        if (config == null)
        {
            throw new ArgumentNullException("config");
        }

        if (string.IsNullOrEmpty(name))
        {
            name = "MemoryOperatorProvider";
        }

        // Get the operator name
        if (!string.IsNullOrEmpty(config["opName"]))
        {
            opName = config["opName"].ToString();
        }

        config.Remove("opName");

        // Get the operator password
        if (!string.IsNullOrEmpty(config["opPassword"]))
        {
            opPassword = config["opPassword"].ToString();
        }

        config.Remove("opPassword");

        // Get the operator email
        if (!string.IsNullOrEmpty(config["opEmail"]))
        {
            opEmail = config["opEmail"].ToString();
        }

        config.Remove("opEmail");

        base.Initialize(name, config);
    }
Beispiel #38
0
 public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
 {
     if (config["providerList"] != null)
     {
         char[]   cSplitchars = { ',' };
         string[] providers   = config["providerList"].ToString().Split(cSplitchars);
         foreach (string providerName in providers)
         {
             m_ProviderList.Add(providerName);
         }
         config.Remove("providerList");
     }
     base.Initialize(name, config);
 }
Beispiel #39
0
        protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
        {
            // Remove the "Server" HTTP Header from response
            HttpApplication app = sender as HttpApplication;

            if (null != app && null != app.Request && !app.Request.IsLocal &&
                null != app.Context && null != app.Context.Response)
            {
                System.Collections.Specialized.NameValueCollection headers = app.Context.Response.Headers;
                if (null != headers)
                {
                    headers.Remove("Server");
                }
            }
        }
    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
    {
        if (!string.IsNullOrEmpty(config["cacheFolder"]))
        {
            _cacheFolder = config["cacheFolder"];
            if (!_cacheFolder.EndsWith(@"\"))
            {
                _cacheFolder += @"\";
            }

            config.Remove("cacheFolder");
        }

        base.Initialize(name, config);
    }
    private void RedirectForComponents()
    {
        UriBuilder uriBuilder = new UriBuilder(String.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, Request.Url.AbsolutePath));

        System.Collections.Specialized.NameValueCollection nvc = HttpUtility.ParseQueryString(Request.Url.Query);
        nvc.Remove(szParamComponents);

        List <string> lstParts = new List <string>();

        if (ckShowMaps.Checked)
        {
            lstParts.Add(szMap);
        }
        if (ckShowAirports.Checked)
        {
            lstParts.Add(szAirports);
        }
        if (ckShowDetails.Checked)
        {
            lstParts.Add(szDetails);
        }
        if (ckShowPictures.Checked)
        {
            lstParts.Add(szPix);
        }
        if (ckShowVids.Checked)
        {
            lstParts.Add(szVids);
        }

        // Add the parameters for what to show
        // But if *ALL* of the pieces are shown, just remove the query parameters and show everything.
        if (lstParts.Any() && lstParts.Count != 5)
        {
            nvc.Add(szParamComponents, String.Join(",", lstParts));
        }

        foreach (string key in nvc.Keys)
        {
            uriBuilder.AppendQueryArgument(key, nvc[key]);
        }

        Response.Redirect(uriBuilder.Uri.ToString());
    }
    public override void Initialize(String name, System.Collections.Specialized.NameValueCollection config)
    {
        //
        // Initialize values from web.config.
        //

        if (config == null)
        {
            throw new ArgumentNullException("config");
        }

        if (name == null || name.Length == 0)
        {
            name = "XpoRoleProvider";
        }

        if (String.IsNullOrEmpty(config["description"]))
        {
            config.Remove("description");
            config.Add("description", "XPO Role provider");
        }

        base.Initialize(name, config);

        pApplicationName = GetConfigValue(config["applicationName"],
                                          System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

        //
        // Initialize XPO Connection string.
        //

        ConnectionStringSettings ConnectionStringSettings =
            ConfigurationManager.ConnectionStrings[config["connectionStringName"]];

        if (ConnectionStringSettings == null || ConnectionStringSettings.ConnectionString.Trim() == "")
        {
            throw new ProviderException("Connection String cannot be blank.");
        }

        connectionString = ConnectionStringSettings.ConnectionString;
    }
Beispiel #43
0
        /// <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>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            SecurityUtil.EnsureDataFoler();
            /// prerequisite
            if (string.IsNullOrEmpty(name))
            {
                name = DefaultProviderName;
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", DefaultProviderDescription);
            }
            base.Initialize(name, config);
            _applicationName = SecurityUtil.GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            string fileName = SecurityUtil.GetConfigValue(config["fileName"], DefaultFileName);

            _fileName = SecurityUtil.MapPath(string.Format("~/App_Data/{0}", fileName));
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "HHMembershipProvider";
            }

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "HHOnline Membership Provider");
            }

            // Initialize base class
            base.Initialize(name, config);

            // Get values from config
            enablePasswordRetrieval    = GetBooleanValue(config, "enablePasswordRetrieval", false);
            enablePasswordReset        = GetBooleanValue(config, "enablePasswordReset", true);
            requiresQuestionAndAnswer  = GetBooleanValue(config, "requiresQuestionAndAnswer", true);
            requiresUniqueEmail        = GetBooleanValue(config, "requiresUniqueEmail", true);
            maxInvalidPasswordAttempts = GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
            passwordAttemptWindow      = GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
            minRequiredPasswordLength  = GetIntValue(config, "minRequiredPasswordLength", 7, false, 128);

            // Get hash algorhithm
            hashAlgorithmType = config["hashAlgorithmType"];
            if (String.IsNullOrEmpty(hashAlgorithmType))
            {
                hashAlgorithmType = "SHA1";
            }

            // Get password validation Regular Expression
            passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"];
            if (passwordStrengthRegularExpression != null)
            {
                passwordStrengthRegularExpression = passwordStrengthRegularExpression.Trim();
                if (passwordStrengthRegularExpression.Length != 0)
                {
                    try
                    {
                        Regex regex = new Regex(passwordStrengthRegularExpression);
                    }
                    catch (ArgumentException e)
                    {
                        throw new ProviderException(e.Message, e);
                    }
                }
            }
            else
            {
                passwordStrengthRegularExpression = string.Empty;
            }


            if (applicationName.Length > 255)
            {
                throw new ProviderException("Provider application name is too long, max length is 255.");
            }


            // Get password format
            string strTemp = config["passwordFormat"];

            if (strTemp == null)
            {
                strTemp = "Hashed";
            }
            switch (strTemp)
            {
            case "Clear":
                passwordFormat = MembershipPasswordFormat.Clear;
                break;

            case "Encrypted":
                passwordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Hashed":
                passwordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                throw new ProviderException("Bad password format");
            }

            if (passwordFormat == MembershipPasswordFormat.Hashed && enablePasswordRetrieval)
            {
                throw new ProviderException("Provider cannot retrieve hashed password");
            }

            // Clean up config
            config.Remove("enablePasswordRetrieval");
            config.Remove("enablePasswordReset");
            config.Remove("requiresQuestionAndAnswer");
            config.Remove("applicationName");
            config.Remove("requiresUniqueEmail");
            config.Remove("maxInvalidPasswordAttempts");
            config.Remove("passwordAttemptWindow");
            config.Remove("passwordFormat");
            config.Remove("name");
            config.Remove("description");
            config.Remove("minRequiredPasswordLength");
            config.Remove("passwordStrengthRegularExpression");
            config.Remove("hashAlgorithmType");

            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException("Provider unrecognized attribute: " + attribUnrecognized);
                }
            }
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "FRACMembershipProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "FRAC Membership Provider");
            }

            //Initialize the base class
            base.Initialize(name, config);

            // Initialize default values
            _ApplicationName                      = "DefaultApp";
            _ConnectionString                     = @"Data Source=ROBERTO;Initial Catalog=Kong;Integrated Security=True";
            _Description                          = "DefaultApp";
            _MinRequiredPasswordLength            = SecUtility.GetIntValue(config, "minRequiredPasswordLength", 7, false, 128);
            _MinRequiredNonalphanumericCharacters = SecUtility.GetIntValue(config, "minRequiredNonalphanumericCharacters", 1, true, 128);
            _EnablePasswordRetrieval              = SecUtility.GetBooleanValue(config, "enablePasswordRetrieval", false);
            _EnablePasswordReset                  = SecUtility.GetBooleanValue(config, "enablePasswordReset", true);

            _Name = name;

            // Now go through the properties and initialize custom values
            foreach (string key in config.Keys)
            {
                switch (key.ToLower())
                {
                case "applicationname":
                    _ApplicationName = config[key];
                    break;

                case "connectionstring":
                    _ConnectionString = config[key];
                    break;

                case "description":
                    _Description = config[key];
                    break;

                case "requiresquestionandanswer":
                    _RequiresQuestionAndAnswer = SecUtility.GetBooleanValue(config, key, true);
                    break;

                case "requiresuniqueemail":
                    _RequiresUniqueEmail = SecUtility.GetBooleanValue(config, key, true);
                    break;
                }
            }

            string strTemp = string.IsNullOrEmpty(config["passwordFormat"]) ? "Hashed" : config["passwordFormat"];

            switch (strTemp)
            {
            case "Clear":
                _PasswordFormat = MembershipPasswordFormat.Clear;
                break;

            case "Encrypted":
                _PasswordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Hashed":
                _PasswordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                throw new ProviderException("Bad password format");
            }

            _HashAlgorithmType = config["hashAlgorithmType"];
            if (String.IsNullOrEmpty(_HashAlgorithmType))
            {
                _HashAlgorithmType = "SHA1";
            }

            if (_PasswordStrengthRegularExpression != null)
            {
                _PasswordStrengthRegularExpression = _PasswordStrengthRegularExpression.Trim();
                if (_PasswordStrengthRegularExpression.Length != 0)
                {
                    try
                    {
                        Regex regex = new Regex(_PasswordStrengthRegularExpression);
                    }
                    catch (ArgumentException e)
                    {
                        throw new ProviderException(e.Message, e);
                    }
                }
            }
            else
            {
                _PasswordStrengthRegularExpression = string.Empty;
            }

            if (_PasswordFormat == MembershipPasswordFormat.Hashed && _EnablePasswordRetrieval)
            {
                throw new ProviderException("Provider cannot retrieve hashed password");
            }

            //Setup the dataops -- We probably want to change the 'connection string' to a connection string key
            //pointing to a web.config connection strings section
            _dops = new DataOps();
            _dops.ConnectionString = _ConnectionString;
        }
    //
    // If false, exceptions are thrown to the caller. If true,
    // exceptions are written to the event log.
    //

    public override void Initialize(String name, System.Collections.Specialized.NameValueCollection config)
    {
        //
        // Initialize values from web.config.
        //

        if (config == null)
        {
            throw new ArgumentNullException("config");
        }

        if (name == null || name.Length == 0)
        {
            name = "XpoMembershipProvider";
        }

        if (String.IsNullOrEmpty(config["description"]))
        {
            config.Remove("description");
            config.Add("description", "XPO Membership provider");
        }

        // Initialize the abstract base class.
        base.Initialize(name, config);

        pApplicationName = GetConfigValue(config["applicationName"],
                                          System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
        pMaxInvalidPasswordAttempts           = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
        pPasswordAttemptWindow                = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));
        pMinRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
        pMinRequiredPasswordLength            = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"));
        pPasswordStrengthRegularExpression    = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], ""));
        pEnablePasswordReset       = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
        pEnablePasswordRetrieval   = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
        pRequiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
        pRequiresUniqueEmail       = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));

        String temp_format = config["passwordFormat"];

        if (temp_format == null)
        {
            temp_format = "Hashed";
        }

        switch (temp_format)
        {
        case "Hashed":
            pPasswordFormat = MembershipPasswordFormat.Hashed;
            break;

        case "Encrypted":
            pPasswordFormat = MembershipPasswordFormat.Encrypted;
            break;

        case "Clear":
            pPasswordFormat = MembershipPasswordFormat.Clear;
            break;

        default:
            throw new ProviderException("Password format not supported.");
        }

        //
        // Initialize XPO Connection string.
        //

        ConnectionStringSettings ConnectionStringSettings =
            ConfigurationManager.ConnectionStrings[config["connectionStringName"]];

        if (ConnectionStringSettings == null || ConnectionStringSettings.ConnectionString.Trim() == "")
        {
            throw new ProviderException("Connection String cannot be blank.");
        }

        connectionString = ConnectionStringSettings.ConnectionString;


        // Get encryption and decryption key information from the configuration.
        Configuration cfg =
            WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);

        machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

        if (machineKey.ValidationKey.Contains("AutoGenerate"))
        {
            if (PasswordFormat != MembershipPasswordFormat.Clear)
            {
                throw new ProviderException("Hashed or Encrypted passwords are not supported with auto-generated keys.");
            }
        }
    }
Beispiel #47
0
        public void WriteData()
        {
            int rNum = 0, cNum = 0;

            try
            {
                ISheet sheet1 = hssfworkbook.CreateSheet("ARTeamReport");
                IRow   row    = sheet1.CreateRow(rNum);
                ICell  cell;
                NameValueCollection headerNames = new System.Collections.Specialized.NameValueCollection()
                {
                    { "WorkItemId", "Work Item Id" }, { "UserName", "Created By" }, { "ActivityName", "Activity Name" }, { "InvoiceNumber", "Invoice #" }, { "RequestNumber", "Request #" },
                    { "ReviewedBy", "Reviewed By" }, { "ReviewerComments", "Reviewer Comments" }, { "ErrFound", "Error Found" }, { "Created", "Created" }, { "Submitted", "Submitted" },
                    { "ReworkingAgin", "Reworking Again" }, { "ReSubmitted", "Re Sumbitted" }, { "InReview", "In Review" }, { "CorrectedErrors", "Corrected Errors" },
                    { "Rework", "Rework" }, { "Approved", "Approved" }
                };

                NameValueCollection headerNamesExpTeam = new NameValueCollection()
                {
                    { "WorkItemId", "Work Item Id" }, { "UserName", "Created By" }, { "ActivityName", "Activity Name" }, { "RequestNumber", "Completion Status" }, { "InvoiceNumber", "Id" },
                    { "Created", "Created" }, { "Submitted", "Submitted" }
                };
                NameValueCollection headerNamesTRTeam = new NameValueCollection()
                {
                    { "WorkItemId", "Work Item Id" }, { "UserName", "Created By" }, { "ActivityName", "Activity Name" }, { "InvoiceNumber", "Id" },
                    { "Comments", "Comments" }, { "Created", "Created" }, { "Submitted", "Submitted" }
                };

                NameValueCollection tmpHederNames = new NameValueCollection();

                ICellStyle headerStyle = hssfworkbook.CreateCellStyle();
                IFont      headerFont  = hssfworkbook.CreateFont();
                ICellStyle detailStyle = hssfworkbook.CreateCellStyle();
                headerFont.Boldweight = Convert.ToInt16(NPOI.SS.UserModel.FontBoldWeight.Bold);
                headerStyle.SetFont(headerFont);

                headerStyle.BorderBottom = BorderStyle.Thin;
                headerStyle.BorderLeft   = BorderStyle.Thin;
                headerStyle.BorderRight  = BorderStyle.Thin;
                headerStyle.BorderTop    = BorderStyle.Thin;

                detailStyle.BorderBottom = BorderStyle.Thin;
                detailStyle.BorderLeft   = BorderStyle.Thin;
                detailStyle.BorderRight  = BorderStyle.Thin;
                detailStyle.BorderTop    = BorderStyle.Thin;


                #region AR Team Sheet
                //Fill the header information.
                foreach (String hdr in headerNames)
                {
                    cell = row.CreateCell(cNum);
                    cell.SetCellValue(headerNames[hdr]);
                    cell.CellStyle = headerStyle;
                    cNum++;
                }
                //Fill the data. after resetting the column count
                rNum++;
                cNum = 0;
                List <PropertyInfo> prop = typeof(WMReportData_AR).GetProperties().ToList <PropertyInfo>();
                foreach (WMReportData_AR data in _dailyData.lst_ar)
                {
                    row = sheet1.CreateRow(rNum);

                    foreach (String hdr in headerNames)
                    {
                        cell = row.CreateCell(cNum);
                        var str = (from p in prop where p.Name == hdr select new { value = (p.GetValue(data, null) == null)?"":p.GetValue(data, null).ToString(),
                                                                                   datatype = p.PropertyType.Name }).Single(); //Get the property value for that perticular thing
                        if (str.datatype == "Int32")
                        {
                            cell.SetCellType(CellType.Numeric);
                        }
                        cell.SetCellValue(str.value);
                        cell.CellStyle = detailStyle;
                        cNum++;
                    }
                    rNum++;
                    cNum = 0;
                }

                //Auto size the columns to fit its contents
                for (cNum = 0; cNum < headerNames.Count; cNum++)
                {
                    sheet1.AutoSizeColumn(cNum);
                }
                #endregion

                #region AP Team Report
                headerNames.Remove("ReviewedBy");
                headerNames.Remove("ReviewerComments");
                headerNames.Remove("InvoiceNumber");
                headerNames.Remove("RequestNumber");
                headerNames.Remove("ErrFound");
                string[] teams = new string[] { "APTeamReport", "ExpenseTeamReport", "FPNATeamReport" }; //These are the teams now generating the report. Same data structure will be used.
                for (int t = 0; t < teams.Length; t++)
                {
                    rNum = cNum = 0;
                    List <WMReportData> objRepdata;
                    switch (t)
                    {
                    case 0: objRepdata = _dailyData.list_ap;
                        tmpHederNames  = headerNames;
                        break;

                    case 1: objRepdata = _dailyData.list_ex;
                        tmpHederNames  = headerNamesExpTeam;
                        break;

                    case 2: objRepdata = _dailyData.list_fpna;
                        tmpHederNames  = headerNamesTRTeam;
                        break;

                    default:
                        objRepdata    = _dailyData.list_ap;
                        tmpHederNames = headerNames;
                        break;
                    }


                    sheet1 = hssfworkbook.CreateSheet(teams[t]);
                    //Fill the header information.
                    row = sheet1.CreateRow(rNum);
                    foreach (String hdr in tmpHederNames)
                    {
                        cell = row.CreateCell(cNum);
                        cell.SetCellValue(tmpHederNames[hdr]);
                        cell.CellStyle = headerStyle;
                        cNum++;
                    }
                    //Fill the data. after resetting the column count
                    rNum++;
                    cNum = 0;
                    prop = typeof(WMReportData).GetProperties().ToList <PropertyInfo>();
                    foreach (WMReportData data in objRepdata)
                    {
                        row = sheet1.CreateRow(rNum);

                        foreach (String hdr in tmpHederNames)
                        {
                            cell = row.CreateCell(cNum);
                            var str = (from p in prop
                                       where p.Name == hdr
                                       select new
                            {
                                value = (p.GetValue(data, null) == null) ? "" : p.GetValue(data, null).ToString(),
                                datatype = p.PropertyType.Name
                            }).Single();            //Get the property value for that perticular thing
                            if (str.datatype == "Int32")
                            {
                                cell.SetCellType(CellType.Numeric);
                            }
                            cell.SetCellValue(str.value);
                            cell.CellStyle = detailStyle;
                            cNum++;
                        }
                        rNum++;
                        cNum = 0;
                    }

                    //Auto size the columns to fit its contents
                    for (cNum = 0; cNum < headerNames.Count; cNum++)
                    {
                        sheet1.AutoSizeColumn(cNum);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Logger.Log(Logger.LogType.Error, ex.ToString());
            }
        }