예제 #1
0
        private void AddTypes()
        {
            XmlNodeList nodeList = DxCfgConfiguratonHelper.GetConnectionNodeList();

            if (nodeList == null)
            {
                return;
            }

            if (nodeList.Count < 1)
            {
                return;
            }

            string   name;
            Assembly asm;
            Type     typ;

            foreach (XmlNode nod in nodeList)
            {
                try
                {
                    name = nod.Attributes[AppCfgValues.ConnectionNodeName].Value;
                    asm  = Assembly.Load(nod.Attributes[AppCfgValues.AssemblyNodeName].Value);
                    typ  = asm.GetType(nod.Attributes[AppCfgValues.TypeNodeName].Value);
                    if (typ.IsClass && typ.GetInterfaces().Contains(typeof(IDbConnection)) &&
                        typ.IsAbstract == false &&
                        typeof(IDbConnection).IsAssignableFrom(typ))
                    {
                        connObjs[name] = typ;

                        if (DxCfgConfiguratonHelper.IsWriteEventLog)
                        {
                            LogEvent($"Connection Name : {name}", $"Assembly : {asm.FullName}", $"Type Name : {typ.FullName}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    //Exception handling
                    if (DxCfgConfiguratonHelper.IsWriteErrorLog)
                    {
                        LogError(ex);
                    }
                    //throw;
                }
            }
        }
예제 #2
0
        private void AddSettings()
        {
            try
            {
                var settingNodes = DxCfgConfiguratonHelper.GetSettingNode().SelectNodes(AppCfgValues.ConfigSettingSectionName);
                foreach (XmlNode item in settingNodes)
                {
                    var key = item.Attributes[AppCfgValues.Key]?.Value ?? string.Empty;
                    if (string.IsNullOrWhiteSpace(key))
                    {
                        continue;
                    }

                    settings[key] = item.InnerText;
                }
            }
            catch (Exception ex)
            {
                if (DxCfgConfiguratonHelper.IsWriteErrorLog)
                {
                    LogError(ex);
                }
            }
        }