public static ErrorType GetErrorType(string exceptionType, string opCoCode, string policyName)
        {
            ErrorType errorType = null;

            //read the config details from file or other source (db) to find the error handling section

            //find all the exception policies
            NamedElementCollection <ExceptionPolicyData> policies =
                ((ExceptionHandlingSettings)ConfigurationSourceFactory.Create().GetSection("exceptionHandling")).ExceptionPolicies;

            //find just the one specified
            if (policies != null)
            {
                ExceptionPolicyData specifiedPolicy = policies.Get(policyName);

                if (specifiedPolicy != null)
                {
                    specifiedPolicy.ExceptionTypes.ForEach(delegate(ExceptionTypeData currentExceptionType)
                    {
                        if (currentExceptionType.Type.ToString() == exceptionType)
                        {
                            errorType = PopulateErrorType(specifiedPolicy.Name, opCoCode, currentExceptionType);
                        }
                    }

                                                           );
                }
            }

            return(errorType);
        }
        LoginResult IFormLoginProvider.Validate(string username, string password)
        {
            if (_validLogins.Contains(username))
            {
                ValidLoginConfigurationElement usernameMatch = _validLogins.Get(username);

                return(usernameMatch.Password == password ? LoginResult.Success : LoginResult.IncorrectPassword);
            }

            return(LoginResult.UserDoesNotExist);
        }
Ejemplo n.º 3
0
        public static ErrorType GetErrorType(string exceptionType, string opCoCode, string policyName)
        {
            ErrorType errorType = null;

            //read the config details from file or other source (db) to find the error handling section

            //find the configuration source section
            ConfigurationSourceSection section = ConfigurationSourceSection.GetConfigurationSourceSection();

            //find the selected source where our config sections are stored
            string selectedSource = section.SelectedSource;
            NameTypeConfigurationElementCollection <ConfigurationSourceElement> sources = section.Sources;

            ConfigurationSourceElement element = sources.Get(selectedSource);

            if (element is SqlConfigurationSourceElement)
            {
                SqlConfigurationSourceElement sqlElement = element as SqlConfigurationSourceElement;

                SqlConfigurationSource configurationSource =
                    new SqlConfigurationSource(sqlElement.ConnectionString, sqlElement.GetStoredProcedure, sqlElement.SetStoredProcedure,
                                               sqlElement.RefreshStoredProcedure, sqlElement.RemoveStoredProcedure);

                //find all the exception policies
                NamedElementCollection <ExceptionPolicyData> policies =
                    ExceptionHandlingSettings.GetExceptionHandlingSettings(configurationSource).ExceptionPolicies;

                //find just the one specified
                if (policies != null)
                {
                    ExceptionPolicyData specifiedPolicy = policies.Get(policyName);

                    if (specifiedPolicy != null)
                    {
                        specifiedPolicy.ExceptionTypes.ForEach(delegate(ExceptionTypeData currentExceptionType)
                        {
                            if (currentExceptionType.Type.ToString() == exceptionType)
                            {
                                errorType = PopulateErrorType(policyName, opCoCode, currentExceptionType);
                            }
                        }

                                                               );
                    }
                }
            }
            return(errorType);
        }
        public static List <ErrorType> GetErrorTypes(string opCoCode, string policyName, string sortExpression)
        {
            List <ErrorType> errorTypes = new List <ErrorType>();

            //find all the exception policies
            NamedElementCollection <ExceptionPolicyData> allPolicies = null;

            allPolicies = ((ExceptionHandlingSettings)ConfigurationSourceFactory.Create().GetSection("exceptionHandling")).ExceptionPolicies;


            if (allPolicies != null)
            {
                NamedElementCollection <ExceptionPolicyData> policies = new NamedElementCollection <ExceptionPolicyData>();

                if (!string.IsNullOrEmpty(policyName))
                {
                    //find just the one specified
                    ExceptionPolicyData specifiedPolicy = allPolicies.Get(policyName);

                    policies.Add(specifiedPolicy);
                }
                else
                {
                    policies = allPolicies;
                }

                foreach (ExceptionPolicyData policy in policies)
                {
                    policy.ExceptionTypes.ForEach(delegate(ExceptionTypeData currentExceptionType)
                    {
                        //go to db for some details
                        ErrorType errorType;
                        errorType =
                            PopulateErrorType(policy.Name, opCoCode,
                                              currentExceptionType);

                        errorTypes.Add(errorType);
                    }
                                                  );
                }
            }


            #region Useful Code
            //policies.ForEach(delegate(ExceptionPolicyData currentPolicy)
            //                     {
            //                         Response.Write("CategoryName: " + currentPolicy.Name + "<br>");

            //                         currentPolicy.ExceptionTypes.ForEach(delegate(ExceptionTypeData currentExceptionType)
            //                                                                  {
            //                                                                      Response.Write("Exception Type: " +
            //                                                                                     currentExceptionType.Name +
            //                                                                                     "<br>");

            //                                                                      currentExceptionType.ExceptionHandlers.
            //                                                                          ForEach(
            //                                                                          delegate(
            //                                                                              ExceptionHandlerData
            //                                                                              currentHandlerData)
            //                                                                              {
            //                                                                                  Response.Write(
            //                                                                                      "Exception Handler: " +
            //                                                                                      currentHandlerData.Name +
            //                                                                                      "<br>");
            //                                                                                  if (currentHandlerData is LoggingExceptionHandlerData)
            //                                                                                  {
            //                                                                                      Response.Write(
            //                                                                                          "CategoryName: " + (currentHandlerData as LoggingExceptionHandlerData).CategoryName.ToString() + "<br>");
            //                                                                                      Response.Write(
            //                                                                                          "Event Id: " + (currentHandlerData as LoggingExceptionHandlerData).EventId.ToString() + "<br>");
            //                                                                                  }

            //                                                                              });
            //                                                                  }
            //                             );
            //                     }
            //    );
            #endregion


            //sort the results
            if (string.IsNullOrEmpty(sortExpression))
            {
                sortExpression = "ExceptionDescription";
            }
            errorTypes.Sort(new UniversalComparer <ErrorType>(sortExpression));


            return(errorTypes);
        }