/// <summary>
        ///    sample:<temp name=[模板名称]></>
        /// </summary>
        /// <returns></returns>
        internal static string BuildSql(IContext context, string oldSql, Segment segment)
        {
            var      templateName = segment.Args.ElementAt(1);
            Template template;
            var      index = templateName.LastIndexOf('/');

            if (index < 0)
            {
                template = context.GetHandlerConfig().Templates.FirstOrDefault(t => string.Equals(t.Name, templateName, StringComparison.OrdinalIgnoreCase));
            }
            else
            {
                var           config        = templateName.Substring(0, index);
                HandlerConfig handlerConfig = JsonParser.ReadHandlerConfig <HandlerConfig>(config);
                templateName = templateName.Substring(index + 1);
                template     = handlerConfig.Templates.FirstOrDefault(t => string.Equals(t.Name, templateName, StringComparison.OrdinalIgnoreCase));
            }

            var content = SegmentUtil.GetContent(oldSql, segment);

            content = SegmentUtil.BuildContent(context, oldSql, content, segment);
            var paramStrs        = content.Trim().Split(SqlKeyWorld.Split4);
            var newTemplateValue = SqlParser.GetFormatSql(context, template.Value);

            return(string.Format(newTemplateValue, paramStrs));
        }
Beispiel #2
0
 void Application_Start(object sender, EventArgs e)
 {
     // Código que se ejecuta al iniciar la aplicación
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     HandlerConfig.RegisterHandlers(GlobalConfiguration.Configuration.MessageHandlers);
 }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            HandlerConfig.RegisterHandlers(GlobalConfiguration.Configuration.MessageHandlers);
        }
        private HandlerConfigDTO ToDTO(HandlerConfig handlerConfig)
        {
            var dto = new HandlerConfigDTO()
            {
                AppId       = handlerConfig.AppId,
                ClassName   = handlerConfig.ClassName,
                HandlerName = handlerConfig.HandlerName
            };

            return(dto);
        }
 public override IHandlerRuntime Initialize(string config)
 {
     //deserialize the Config from the Handler declaration
     this.config = DeserializeOrNew <ActiveDirectoryHandlerConfig>(config);
     if (handlerConfig == null)
     {
         this.handlerConfig = HandlerConfig.DeserializeOrNew();
         this.roleManager   = AssemblyLoader.Load <IRoleManager>(handlerConfig.RoleManager.Name, @"Synapse.ActiveDirectory.Core:DefaultRoleManager");
         this.roleManager.Initialize(handlerConfig?.RoleManager?.Config);
     }
     return(this);
 }
Beispiel #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            HandlerConfig.RegisterHandlers(GlobalConfiguration.Configuration.MessageHandlers);
            GlobalConfiguration.Configuration.Filters.Add(new ExceptionHandlingAttribute());
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AutofacConfig.RegisterAutoFac();
        }
Beispiel #7
0
        public WebSocketAwareHttpHandler()
        {
            var path      = HostingEnvironment.ApplicationVirtualPath;
            var webConfig = WebConfigurationManager.OpenWebConfiguration(path);

            // Parse WebConfig to a HandlerConfig object, then read the inner handler type.
            // We'll get a default if no custom handler has been specified.
            var handlerConfig = new HandlerConfig(webConfig);
            var handlerType   = handlerConfig.HandlerType;

            // Create the inner handler. Assume it has a default constructor.
            _handler = (IHttpAsyncHandler)Activator.CreateInstance(handlerType);
        }
Beispiel #8
0
    public override IHandlerRuntime Initialize(string values)
    {
        try
        {
            _config = DeserializeOrNew <HandlerConfig>(values) ?? new HandlerConfig();
        }
        catch (Exception ex)
        {
            OnLogMessage("Initialization", "Encountered exception while deserializing handler config.", LogLevel.Error, ex);
        }

        return(this);
    }
Beispiel #9
0
    public override object GetConfigInstance()
    {
        HandlerConfig config = new HandlerConfig();

        config.ConnectionString  = @"DSN=SOMEDSN";
        config.ConnectionTimeout = 60;
        config.CommandTimeout    = 300;
        config.OutputType        = OutputTypeType.Xml;
        config.OutputFile        = @"C:\Temp\FileNotReallyNeeded.xml";
        config.PrettyPrint       = true;

        return(config);
    }
Beispiel #10
0
        /// <summary>
        /// Init the handler, for loading the config file.
        /// </summary>
        public override void Init(HandlerConfig oConfig)
        {
            lock (_monitor)
            {
                m_sConfigFile = FixConfigPath(oConfig.ConfigFile);

                //if (Path.IsPathRooted(oConfig.ConfigFile))
                //    m_sConfigFile = oConfig.ConfigFile;
                //else
                //    m_sConfigFile = AppDomain.CurrentDomain.BaseDirectory + "config/" + oConfig.ConfigFile;

                m_oConfig = (FileHandlerConfig)LoggerUtils.XMLSerializer.DeserializeObjectFromFile(typeof(FileHandlerConfig), m_sConfigFile);
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            ServerConfig config = new ServerConfig();

            ListenConfig listenConfig = new ListenConfig();

            listenConfig.Addresses    = new ListenAddress[1];
            listenConfig.Addresses[0] = new ListenAddress
            {
                Host = "127.0.0.1",
                Name = "1",
                Port = 8080
            };

            WorkConfig workConfig = new WorkConfig();

            workConfig.ProcessQueueMaxLength = 2000;
            workConfig.WorkThreadNum         = 8;

            HandlerConfig handlerConfig = new HandlerConfig();

            handlerConfig.Handlers    = new HandlerMatching[1];
            handlerConfig.Handlers[0] = new HandlerMatching
            {
                Select = "http://127.0.0.1:8080/*:",
                Type   = "Test,Test.TestHandler"
            };

            StaticContentConfig staticContentConfig = new StaticContentConfig();

            staticContentConfig.MimeMaps    = new MimeMap[1];
            staticContentConfig.MimeMaps[0] = new MimeMap
            {
                FileExtension = ".repx",
                MimeType      = "test"
            };

            config.RootDirectory       = @"d:\test\web";
            config.HandlerConfig       = handlerConfig;
            config.WorkConfig          = workConfig;
            config.ListenConfig        = listenConfig;
            config.StaticContentConfig = staticContentConfig;

            XmlSerializer serializer = new XmlSerializer(typeof(ServerConfig));

            using (FileStream stream = new FileStream("Server.config", FileMode.CreateNew, FileAccess.Write))
            {
                serializer.Serialize(stream, config);
            }
        }
Beispiel #12
0
        public static object Query(string name, object param)
        {
            var type = param.GetType();
            IDictionary <string, object> queryParams = new Dictionary <string, object>();

            foreach (var p in type.GetProperties())
            {
                var val = p.GetValue(param);
                queryParams.Add(p.Name, val);
            }

            HandlerConfig handlerConfig = JsonParser.ReadHandlerConfig <HandlerConfig>(name);

            return(Query(handlerConfig, null, queryParams));
        }
Beispiel #13
0
        protected void Application_Start()
        {
            //AreaRegistration.RegisterAllAreas();
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //RouteConfig.RegisterRoutes(RouteTable.Routes);


            //Http Client Protocol Settings
            System.Net.ServicePointManager.Expect100Continue       = false;
            System.Net.ServicePointManager.MaxServicePointIdleTime = 60 * 60 * 1000;//60 Minutes
            ServicePointManager.DefaultConnectionLimit             = 132;


            FileInfo fi = new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\web.config");

            log4net.Config.XmlConfigurator.ConfigureAndWatch(fi);

            Assembly     assem     = Assembly.GetExecutingAssembly();
            AssemblyName assemName = assem.GetName();

            AggieGlobalLogManager.Info("=================================================================");
            AggieGlobalLogManager.Info("Starting SKYSITE-Web-API-Service v{0}", assemName.Version);
            AggieGlobalLogManager.Info("=================================================================");

            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            FilterConfig.RegisterHttpFilters(GlobalConfiguration.Configuration.Filters);

            RouteConfig.RegisterRoutes(RouteTable.Routes);


            FormatterConfig.RegisterFormatters(GlobalConfiguration.Configuration.Formatters);
            HandlerConfig.RegisterHandlers(GlobalConfiguration.Configuration.MessageHandlers);

            //Instnatiate the one & only instance of GlobalApp - facade design pattern to Provide an unified interface to a set of interfaces to deal with business functions
            if (_theGlobalApp == null)
            {
                string dbConnectionStringName = "AggieGlobalDB";
                GlobalApp.Initialize(dbConnectionStringName);
                _theGlobalApp = GlobalApp.Instance;
            }
        }
Beispiel #14
0
        /// <summary>
        /// Init the handler, loads the config file and creates the log table if needed.
        /// </summary>
        public override void Init(HandlerConfig oConfig)
        {
            lock (_monitor)
            {
                m_sConfigFile = FixConfigPath(oConfig.ConfigFile);

                m_oConfig     = (SQLDBHandlerConfig)LoggerUtils.XMLSerializer.DeserializeObjectFromFile(typeof(SQLDBHandlerConfig), m_sConfigFile);
                m_sConnString = string.Format(m_sConnString, m_oConfig.Server, m_oConfig.Database, m_oConfig.User, m_oConfig.Password);

                if (m_oConfig.DateFormat != "")
                {
                    m_sSql = "SET DateFormat " + m_oConfig.DateFormat + ";" + m_sSql;
                }

                if (m_oConfig.AutoGenerateTable)
                {
                    CreateTable();
                }
            }
        }
Beispiel #15
0
        public static object Query(HandlerConfig handlerConfig, object complexData, IDictionary <string, object> queryParams = null)
        {
            IQueryHandler queryHandler = QueryHandlerFactory.GetQueryHandler(handlerConfig.QueryType);

            if (handlerConfig.Configs == null || handlerConfig.Configs.Any() == false)
            {
                throw new ArgumentNullException("handlerConfig.Configs");
            }

            var context = new Context
            {
                HandlerConfig = handlerConfig,
                Configs       = handlerConfig.Configs,
                Params        = queryParams,
                ComplexData   = complexData,
            };

            ParamConvertUtil.DoConvert(context);
            var returnData = queryHandler.Query(context);

            //执行完查询后回调
            return(handlerConfig.OnQueryEnd(returnData, queryParams));
        }
        public async Task <long> AddNew(string appId, string className, string handleName)
        {
            using (var db = new WeixinDbContext())
            {
                CommonService <HandlerConfig> service = new CommonService <HandlerConfig>(db);
                var handelConfig = new HandlerConfig()
                {
                    AppId       = appId,
                    ClassName   = className,
                    HandlerName = handleName
                };
                var exists = await service.GetAll().AnyAsync(s => s.AppId == appId);

                if (exists)
                {
                    throw new ArgumentException("该公众号appid已经存在");
                }
                db.HandlerConfig.Add(handelConfig);
                await db.SaveChangesAsync();

                return(handelConfig.Id);
            }
        }
Beispiel #17
0
    public override IHandlerRuntime Initialize(string values)
    {
        _config = DeserializeOrNew <HandlerConfig>(values);

        Mapper.Initialize(cfg =>
        {
            cfg.CreateMap <Instance, Ec2Instance>()
            .ForMember(d => d.Architecture, o => o.MapFrom(s => s.Architecture))
            .ForMember(d => d.AvailabilityZone, o => o.MapFrom(s => s.Placement.AvailabilityZone))
            .ForMember(d => d.CloudEnvironment, o => o.MapFrom(s => GetTagValue("cloud-environment", s.Tags)))
            .ForMember(d => d.CloudEnvironmentFriendlyName, o => o.MapFrom(s => GetTagValue("cloud-environment-friendly-name", s.Tags)))
            .ForMember(d => d.CostCentre, o => o.MapFrom(s => GetTagValue("cost-centre", s.Tags)))
            .ForMember(d => d.InstanceId, o => o.MapFrom(s => s.InstanceId))
            .ForMember(d => d.InstanceState, o => o.MapFrom(s => s.State.Name))
            .ForMember(d => d.InstanceType, o => o.MapFrom(s => s.InstanceType))
            .ForMember(d => d.Name, o => o.MapFrom(s => GetTagValue("Name", s.Tags)))
            .ForMember(d => d.LaunchTime, o => o.MapFrom(s => s.LaunchTime))
            .ForMember(d => d.PrivateDnsName, o => o.MapFrom(s => s.PrivateDnsName))
            .ForMember(d => d.PrivateIpAddress, o => o.MapFrom(s => s.PrivateIpAddress))
            .ForMember(d => d.PublicDnsName, o => o.MapFrom(s => s.PublicDnsName))
            .ForMember(d => d.PublicIpAddress, o => o.MapFrom(s => s.PublicIpAddress));
        });
        return(this);
    }
 protected PostServiceHandlerBase(HandlerConfig tConfig)
 {
     HTimerConfig = tConfig;
 }
Beispiel #19
0
 public override void Init(HandlerConfig oConfig)
 {
 }
Beispiel #20
0
 public override IHandlerRuntime Initialize(string configStr)
 {
     config = this.DeserializeOrDefault <SqlServerHandlerConfig>(configStr);
     return(base.Initialize(configStr));
 }
Beispiel #21
0
 public override void Init(HandlerConfig oConfig)
 {
 }
Beispiel #22
0
 public override IHandlerRuntime Initialize(string config)
 {
     this.config = DeserializeOrNew <HandlerConfig>(config);
     return(this);
 }
Beispiel #23
0
    public async Task <SsmCommandResponse> RunSsmCommand(UserRequest request, HandlerConfig config)
    {
        if (request == null || config == null)
        {
            return(null);
        }
        string             errorMessage = string.Empty;
        SsmCommandResponse output       = new SsmCommandResponse()
        {
            Status = "Failed" // If no processing is done.
        };

        AmazonSimpleSystemsManagementConfig clientConfig = new AmazonSimpleSystemsManagementConfig()
        {
            MaxErrorRetry    = config.ClientMaxErrorRetry,
            Timeout          = TimeSpan.FromSeconds(config.ClientTimeoutSeconds),
            ReadWriteTimeout = TimeSpan.FromSeconds(config.ClientReadWriteTimeoutSeconds),
            RegionEndpoint   = RegionEndpoint.GetBySystemName(request.AwsRegion) // Or RegionEndpoint.EUWest1
        };

        try
        {
            // https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html
            // Accessing Credentials and Profiles in an Application
            CredentialProfileStoreChain chain = new CredentialProfileStoreChain(config.AwsProfilesLocation);

            AWSCredentials awsCredentials;
            if (chain.TryGetAWSCredentials(request.AwsRole, out awsCredentials))
            {
                // Use awsCredentials
                AmazonSimpleSystemsManagementClient ssmClient =
                    new AmazonSimpleSystemsManagementClient(awsCredentials, clientConfig);
                if (request.CommandType == "send-command")
                {
                    List <string> instanceIds = new List <string> {
                        request.InstanceId
                    };
                    SendCommandRequest commandRequest = new SendCommandRequest(request.CommandDocument, instanceIds);
                    commandRequest.MaxConcurrency = config.CommandMaxConcurrency; // 50%
                    commandRequest.MaxErrors      = config.CommandMaxErrors;
                    commandRequest.TimeoutSeconds = config.CommandTimeoutSeconds;
                    commandRequest.Comment        = request.CommandComment;
                    commandRequest.Parameters     = request.CommandParameters;
                    SendCommandResponse sendCommandResponse = await ssmClient.SendCommandAsync(commandRequest);

                    output.Status         = "Complete";
                    output.CommandId      = sendCommandResponse.Command.CommandId;
                    output.CommandStatus  = sendCommandResponse.Command.StatusDetails;
                    output.ErrorMessage   = errorMessage;
                    output.CommandComment = sendCommandResponse.Command.Comment;
                }
                else if (request.CommandType == "get-command-invocation")
                {
                    //GetCommandInvocationRequest commandRequest = new GetCommandInvocationRequest()
                    //{
                    //    CommandId = request.CommandId,
                    //    InstanceId = request.InstanceId,
                    //    PluginName = request.CommandPluginName // If there are more than one plugins, this cannot be null.
                    //};
                    //GetCommandInvocationResponse getCommandResponse =
                    //    await ssmClient.GetCommandInvocationAsync(commandRequest);

                    ListCommandInvocationsRequest commandRequest = new ListCommandInvocationsRequest()
                    {
                        CommandId = request.CommandId,
                        Details   = true
                    };
                    ListCommandInvocationsResponse commandResponse = await ssmClient.ListCommandInvocationsAsync(commandRequest);

                    if (commandResponse.CommandInvocations.Count > 0)
                    {
                        output.Status         = "Complete";
                        output.CommandId      = commandResponse.CommandInvocations[0].CommandId;
                        output.CommandStatus  = commandResponse.CommandInvocations[0].StatusDetails;
                        output.CommandComment = commandResponse.CommandInvocations[0].Comment;
                        if (commandResponse.CommandInvocations[0].StatusDetails == "Success" &&
                            commandResponse.CommandInvocations[0].CommandPlugins.Count > 0)
                        {
                            output.StandardOutput = commandResponse.CommandInvocations[0].CommandPlugins[0].Output;
                        }
                        else if (commandResponse.CommandInvocations[0].StatusDetails == "Failed" &&
                                 commandResponse.CommandInvocations[0].CommandPlugins.Count > 0)
                        {
                            GetCommandInvocationRequest invocationRequest = new GetCommandInvocationRequest()
                            {
                                CommandId  = request.CommandId,
                                InstanceId = request.InstanceId,
                                PluginName = request.CommandPluginName // If there are more than one plugins, this cannot be null.
                            };
                            GetCommandInvocationResponse getCommandResponse =
                                await ssmClient.GetCommandInvocationAsync(invocationRequest);

                            output.StandardOutput = getCommandResponse.StandardOutputContent;
                            output.StandardError  = getCommandResponse.StandardErrorContent;
                        }
                    }
                    else
                    {
                        errorMessage = "The command id and instance id specified did not match any invocation.";
                    }
                }
            }
            else
            {
                errorMessage = "AWS credentials cannot be found for the execution.";
            }
        }
        catch (AmazonSimpleSystemsManagementException ex)
        {
            switch (ex.ErrorCode)
            {
            // https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_SendCommand.html
            // Error codes for "SendCommandRequest"
            case "DuplicateInstanceId":
                errorMessage = "You cannot specify an instance ID in more than one association.";
                break;

            case "InternalServerError":
                errorMessage = "Internal server error.";
                break;

            case "InvalidDocument":
                errorMessage = "The specified document does not exist.";
                break;

            case "InvalidDocumentVersion":
                errorMessage = "The document version is not valid or does not exist.";
                break;

            case "ExpiredTokenException":
                errorMessage = "The security token included in the request is expired.";
                break;

            case "InvalidInstanceId":
                errorMessage = "Possible causes are the 1) server instance may not be running 2) Server instance may not exist. 3) SSM agent may not be running. 4) Account used does not have permssion to access the instance.";
                break;

            case "InvalidNotificationConfig":
                errorMessage = "One or more configuration items is not valid.";
                break;

            case "InvalidOutputFolder":
                errorMessage = "The S3 bucket does not exist.";
                break;

            case "InvalidParameters":
                errorMessage =
                    "You must specify values for all required parameters in the Systems Manager document.";
                break;

            case "InvalidRole":
                errorMessage = "The role name can't contain invalid characters.";
                break;

            case "MaxDocumentSizeExceeded":
                errorMessage = "The size limit of a document is 64 KB.";
                break;

            case "UnsupportedPlatformType":
                errorMessage = "The document does not support the platform type of the given instance ID(s).";
                break;

            // Error codes for "GetcommandInvocation"
            case "InvalidCommandId":
                errorMessage = "The command ID is invalid.";
                break;

            case "InvocationDoesNotExist":
                errorMessage =
                    "The command id and instance id specified did not match any invocation.";
                break;

            case "ValidationException":
                errorMessage = ex.Message;
                break;

            default:
                errorMessage = ex.Message;
                break;
            }
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }

        if (!string.IsNullOrWhiteSpace(errorMessage))
        {
            throw new Exception(errorMessage);
        }
        return(output);
    }
 public AsynPostHandlerImpl(HandlerConfig config)
     : base(config)
 {
 }
Beispiel #25
0
        /// <summary>
        /// Init the handler, loads the config file and creates the log table if needed.
        /// </summary>
        public override void Init(HandlerConfig oConfig)
        {
            lock (_monitor)
            {
                m_sConfigFile = FixConfigPath(oConfig.ConfigFile);

                m_oConfig = (SQLDBHandlerConfig)LoggerUtils.XMLSerializer.DeserializeObjectFromFile(typeof(SQLDBHandlerConfig), m_sConfigFile);
                m_sConnString = string.Format(m_sConnString, m_oConfig.Server, m_oConfig.Database, m_oConfig.User, m_oConfig.Password);

                if (m_oConfig.DateFormat != "")
                    m_sSql = "SET DateFormat " + m_oConfig.DateFormat + ";" + m_sSql;

                if (m_oConfig.AutoGenerateTable)
                    CreateTable();
            }
        }
Beispiel #26
0
        /// <summary>
        /// Init the handler, for loading the config file.
        /// </summary>
        public override void Init(HandlerConfig oConfig)
        {
            lock (_monitor)
            {
                m_sConfigFile = FixConfigPath(oConfig.ConfigFile);

                //if (Path.IsPathRooted(oConfig.ConfigFile))
                //    m_sConfigFile = oConfig.ConfigFile;
                //else
                //    m_sConfigFile = AppDomain.CurrentDomain.BaseDirectory + "config/" + oConfig.ConfigFile;

                m_oConfig = (FileHandlerConfig)LoggerUtils.XMLSerializer.DeserializeObjectFromFile(typeof(FileHandlerConfig), m_sConfigFile);
            }
        }
Beispiel #27
0
 public static object Query(HandlerConfig handlerConfig, IDictionary <string, object> queryParams = null)
 {
     return(Query(handlerConfig, null, queryParams));
 }
Beispiel #28
0
        public static object Query(string name, object complexData, IDictionary <string, object> queryParams = null)
        {
            HandlerConfig handlerConfig = JsonParser.ReadHandlerConfig <HandlerConfig>(name);

            return(Query(handlerConfig, complexData, queryParams));
        }
Beispiel #29
0
        /// <summary>
        /// Creates a handler object and adds it to the internal list.
        /// </summary>
        /// <param name="sHandlerName">The name of the handler to load.</param>
        private static void LoadHandler(string sHandlerName)
        {
            Debug.WriteLine("Loading handler: " + sHandlerName, "HandlerFactory.LoadHandler");

            try
            {
                HandlerConfig oHandlerConfig = m_oLoggerConfig.Handlers.Find(delegate(HandlerConfig obj) { return(obj.Name.Equals(sHandlerName, StringComparison.OrdinalIgnoreCase)); });

                if (oHandlerConfig == null)
                {
                    Debug.WriteLine("A handler with the name '" + sHandlerName + "' could not be found. Loading default handler for this handler name.");
                    m_colHanderList.Add(sHandlerName, new WindowsEventHandler());
                    //throw new Exception("The configuration for the handler '" + sHandlerName + "' was not found. Check the 'Handlers' section of loggerconfig.xml and make sure the log handler is registered there.");
                }
                else
                {
                    System.Reflection.Assembly assembly = Assembly.LoadFrom(m_sRootFolder + oHandlerConfig.Assembly);
                    Type t = assembly.GetType(oHandlerConfig.Type);

                    if (t == null)
                    {
                        throw new Exception("Unable to load the type '" + oHandlerConfig.Type + "' for the handler '" + sHandlerName + "'. Check the 'Handlers' section of loggerconfig.xml and make sure the correct type is specified in the Type tag.");
                    }

                    AHandler oPlugin = (AHandler)Activator.CreateInstance(t);
                    oPlugin.Init(oHandlerConfig);

                    m_colHanderList.Add(sHandlerName, oPlugin);
                }

                //switch (sHandlerName)
                //{
                //    case "FileHandler":
                //    {
                //        //m_colHanderList.Add(sHandlerName, new FileHandler());

                //        System.Reflection.Assembly assembly = Assembly.LoadFrom("Logger.dll");
                //        Type t = assembly.GetType("Utils.Log.Handlers.FileHandler");
                //        AHandler oPlugin = (AHandler)Activator.CreateInstance(t);

                //        HandlerConfig oHandlerConfig = m_oLoggerConfig.Handlers.Find(delegate(HandlerConfig obj) { return obj.Name.Equals(sHandlerName, StringComparison.OrdinalIgnoreCase); });

                //        if (oHandlerConfig != null)
                //            oPlugin.Init(oHandlerConfig);
                //        else
                //            throw new Exception("The configuration for the handler '" + sHandlerName + "' was not found. Check the 'Handlers' section of loggerconfig.xml and make sure the log handler is registered there");

                //        m_colHanderList.Add(sHandlerName, oPlugin);

                //        break;
                //    }

                //    case "WindowsEventHandler":
                //        m_colHanderList.Add(sHandlerName, new WindowsEventHandler());
                //        break;

                //    case "SQLDBHandler":
                //        m_colHanderList.Add(sHandlerName, new SQLDBHandler());
                //        break;

                //    default: //WindowsEventHandler
                //        Debug.WriteLine("A handler with the name '" + sHandlerName + "' could not be found. Loading default handler for this handler name.");
                //        m_colHanderList.Add(sHandlerName, new WindowsEventHandler());
                //        break;
                //}
            }
            catch (Exception exp)
            {
                if (!EventLog.SourceExists(m_sAppName))
                {
                    EventLog.CreateEventSource(m_sAppName, "Application");
                }

                EventLog oEventLog = new EventLog();
                oEventLog.Source = m_sAppName;

                oEventLog.WriteEntry("Error loading handler: " + exp.Message, EventLogEntryType.Error, 0);

                if (exp.InnerException != null)
                {
                    oEventLog.WriteEntry("Error loading handler (inner exception):" + exp.InnerException.Message, EventLogEntryType.Error, 0);
                }

                //while (exp.InnerException != null)
                //{
                //    exp = exp.InnerException;
                //    oEventLog.WriteEntry("Error loading handler (inner exception):" + exp.Message, EventLogEntryType.Error, 0);
                //}

                oEventLog.Close();
            }
        }