zoukankan      html  css  js  c++  java
  • 从配置文件获取信息

    基础方法:

            /// <summary>
            /// 通过Singleton模式返回当前实例
            /// </summary>
            public static T Instance(string className)
            {
    
                if (m_instance == null)
                {
                    lock (m_lock)
                    {
                        if (m_instance == null)
                        {
                             
    
                            NameValueCollection nc = (NameValueCollection)ConfigurationManager.GetSection("CLOUDS/BussValue");
                            string bussness = nc[className].ToString();
                            m_instance = (T)Type.GetType(bussness).GetConstructor(System.Type.EmptyTypes).Invoke(null);
                        }
                    }
                }
                
                return m_instance;
            }

    调用方法:

            /// <summary>
            /// 查询出省份与快递公司关联数据
            /// </summary>
            /// <param name="logisticsDispatchingRangeModel">省份与快递公司关联Model</param>
            /// <returns></returns>
            [WebMethod(Description = "查询出省份与快递公司关联数据")]
            public string GetProvinceWithLogisticsDS(string strLogisticsDispatchingRangeModel)
            {
                LogisticsDispatchingRangeModel logisticsDispatchingRangeModel = Newtonsoft.Json.JsonConvert.DeserializeObject<LogisticsDispatchingRangeModel>(strLogisticsDispatchingRangeModel);
                DataSet ds = IBussFactory<BussLogisticsDispatchingRange>.Instance("LogisticsDispatchingRange").GetProvinceWithLogisticsDS(logisticsDispatchingRangeModel);
                string str = Newtonsoft.Json.JsonConvert.SerializeObject(ds);
                return str;
            }

    配置文件:

    View Code
      1 <?xml version="1.0"?>
      2 <configuration>
      3   <configSections>
      4     <sectionGroup name="Mis">
      5       <section name="dataProvider" requirePermission="false" type="Mis.IData.DataProviderSection, Mis.IData" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
      6     </sectionGroup>
      7     <sectionGroup name="CLOUDS">
      8       <!--<section name="dataProvider" requirePermission="false" allowDefinition="MachineToApplication" 
      9                  restartOnExternalChanges="true" type=""/>-->
     10       <section name="BussValue" requirePermission="false" allowDefinition="MachineToApplication" restartOnExternalChanges="true" type="System.Configuration.NameValueSectionHandler"/>
     11     </sectionGroup>
     12 
     13   </configSections>
     14   <appSettings/>
     15   <connectionStrings>
     16 
     17     <!--<add name="OracleConnString"  connectionString="Data Source=mis;User ID=erp;Password=erp;Pooling=true;"/>-->
     18 
     19     <!--<add name="XmlPath" connectionString="Xml文件存放的路径Data Source=BOOKDB;User ID=tsyw;Password=tsyw;Pooling=true"/>-->
     20     <add name="OracleConnString"  connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.253)(PORT=1521)))  
     21       (CONNECT_DATA=(SERVICE_NAME=erp))); User Id=erp;Password=erp;"/>
     22               
     23   </connectionStrings>
     24   <system.web>
     25     <compilation debug="true" targetFramework="4.0"/>
     26     <!--
     27       通过 <authentication> 节可以配置
     28       安全身份验证模式,ASP.NET 
     29       使用该模式来识别来访用户身份。 
     30     -->
     31     <authentication mode="Windows"/>
     32     <!--
     33        如果在执行请求的过程中出现未处理的错误
     34        则通过 <customErrors> 35        可以配置相应的处理步骤。具体而言,
     36        开发人员通过该节可配置要显示的 html 错误页,
     37        以代替错误堆栈跟踪。
     38 
     39        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
     40          <error statusCode="403" redirect="NoAccess.htm" />
     41          <error statusCode="404" redirect="FileNotFound.htm" />
     42        </customErrors>
     43     -->
     44     <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
     45   </system.web>
     46   <Mis> 
     47     <dataProvider   defaultProvider="OracleProvider">
     48       <providers>
     49         <!--<add name="XmlProvider" type="PGERP.Data.SqlServer.XmlProvider, PGERP.Data.SqlServer" connectionStringName="XmlPath"/>-->
     50         <add name="OracleProvider" type="Mis.OracleData.OracleProvider, Mis.OracleData" connectionStringName="OracleConnString"/>
     51       </providers>
     52     </dataProvider>  
     53   </Mis>
     54   <CLOUDS>
     55     <BussValue>
     56       <!--系统管理 公司信息-->
     57       <add key="Company" value="Mis.Business.SystemManage.BussCompany"/>
     58       <!--系统管理 部门信息-->
     59       <add key="Department" value="Mis.Business.SystemManage.BussDepartment"/>
     60       <!--系统管理 用户信息-->
     61       <add key="User" value="Mis.Business.SystemManage.BussUser"/>
     62       
     63       <!--供应商管理 供应商类型信息-->
     64       <add key="ProviderType" value="Mis.Business.SystemManage.BussProviderType"/>
     65       <!--供应商管理 供应商信息-->
     66       <add key="Provider" value="Mis.Business.SystemManage.BussProvider"/>
     67       <!--供应商管理 供应商装箱率信息-->
     68       <add key="ProviderPackRate" value="Mis.Business.SystemManage.BussProviderPackRate"/>
     69       
     70       <!--用户字典档案 -->
     71       <add key="GetDictinary" value="Mis.Business.Dictonary.BussGetDictionary" />
     72       <!--地区信息 -->
     73       <add key="DistrictInfo" value="Mis.Business.Dictonary.BussDistrictInfo" />
     74       <!--省份信息 -->
     75       <add key="Province" value="Mis.Business.Dictonary.BussProvince" />
     76       <!--城市信息 -->
     77       <add key="City" value="Mis.Business.Dictonary.BussCity" />
     78       <!--区县信息 -->
     79       <add key="Town" value="Mis.Business.Dictonary.BussTown" />
     80       <!--仓库类型信息 -->
     81       <add key="StorageType" value="Mis.Business.Dictonary.BussStorageType" />
     82       <!--仓库信息 -->
     83       <add key="StorageInfo" value="Mis.Business.Dictonary.BussStorageInfo" />
     84       <!--库区信息 -->
     85       <add key="AreaInfo" value="Mis.Business.Dictonary.BussAreaInfo" />
     86       <!--库位信息 -->
     87       <add key="LocationInfo" value="Mis.Business.Dictonary.BussLocationinfo" />
     88       <!--物流公司信息 -->
     89       <add key="Logisticscominfo" value="Mis.Business.Dictonary.BussLogisticscominfo" />
     90       <!--付款方式信息 -->
     91       <add key="PayType" value="Mis.Business.Dictonary.BussPayType" />
     92       <!--字典类型对应表信息 -->
     93       <add key="DicTypeHomologous" value="Mis.Business.Dictonary.BussDicTypeHomologous" />
     94       <!--类型字典信息 -->
     95       <add key="Typeinfo" value="Mis.Business.Dictonary.BussTypeinfo" />
     96       <!--店铺信息 -->
     97       <add key="Shoppublic" value="Mis.Business.Dictonary.BussShoppublic" />
     98       <!--物流公司配送范围 -->
     99       <add key="LogisticsDispatchingRange" value="Mis.Business.Dictonary.LogisticsDispatchingRange" />
    100       
    101       
    102       <!--获取用户信息 -->
    103       <add key="GetUser" value="Mis.Business.SystemUserConfig.BussUserWebConfig"/>
    104       <!--到货单-->
    105       <add key="ArrivalOfGoods" value="Mis.Business.PutInStorage.BussArrivalOfGoods"/>
    106       <!--入库单-->
    107       <add key="InNote" value="Mis.Business.PutInStorage.BussInNote"/>
    108       <!--质检单-->
    109       <add key="InQcNote" value="Mis.Business.PutInStorage.BussInQcNote"/>
    110       <!--上架单-->
    111       <add key="StorageShelves" value="Mis.Business.PutInStorage.BussStorageShelves"/>
    112       <!--营销活动-->
    113       <add key="GiveActivity" value="Mis.Business.Activity.BussGiveActivity"/>
    114       <!--出库单-->
    115       <add key="Out" value="Mis.Business.OutStorage.BussOut"/>
    116       <!--下架单-->
    117       <add key="OutDown" value="Mis.Business.OutStorage.BussOutDown"/>
    118       <!--发货单-->
    119       <add key="OutSeedGoods" value="Mis.Business.OutStorage.BussOutSeedGoods"/>
    120       <!--二次分拣-->
    121       <add key="OutSort" value="Mis.Business.OutStorage.BussOutSort"/>
    122 
    123       <!--盘点任务-->
    124       <add key="CheckTask" value="Mis.Business.Inventory.BussCheckTask"/>
    125       <!--库存调整-->
    126       <add key="ChangeStock" value="Mis.Business.Inventory.BussChangeStock"/>
    127       <!--库存管理-->
    128       <add key="StockWork" value="Mis.Business.Inventory.BussStockWork"/>
    129       
    130       <!--联系人管理-->
    131       <add key="LinkMan" value="Mis.Business.Customer.BussLinkMan"/>
    132       <!--客户信息表管理-->
    133       <add key="Customer" value="Mis.Business.Customer.BussCustomer"/>
    134       <!--合同信息表管理-->
    135       <add key="Contract" value="Mis.Business.Customer.BussContract"/>
    136       <!--联系记录表管理-->
    137       <add key="CusRecord" value="Mis.Business.Customer.BussCusRecord"/>
    138       <!--客户评价表管理-->
    139       <add key="Valuation" value="Mis.Business.Customer.BussValuation"/>
    140       <!--客户分组管理-->
    141       <add key="CustomerTeam" value="Mis.Business.Customer.BussCustomerTeam"/>
    142       
    143       <!--采购建议单-->
    144       <add key="Suggest" value="Mis.Business.Purchase.BussSuggest"></add>
    145       <!--采购单-->
    146       <add key="Purchase" value="Mis.Business.Purchase.BussPurchase"></add>
    147       <!--采购付款-->
    148       <add key="Finance" value="Mis.Business.Purchase.BussFinance"></add>
    149       <!--公共窗体-->
    150       <add key="FrmCommon" value="Mis.Business.Common.BussCommon"></add>
    151 
    152       <!--权限-->
    153       <add key="Role" value="Mis.Business.Role.BussRole"></add>
    154 
    155       <!--商品分类-->
    156       <add key="GoodsCategory" value="Mis.Business.Goods.BussGoodsCategory"></add>
    157 
    158       <!--订单-->
    159       <add key="Order" value="Mis.Business.Order.BussOrder"></add>
    160     </BussValue>
    161   </CLOUDS> 
    162 </configuration>
  • 相关阅读:
    组合数学
    gcd和lcm
    快速幂
    线性求逆元
    5月月赛(* ̄︿ ̄)
    通往奥格瑞玛的道路
    Dijkstra学习笔记
    动态规划笔记(2)
    美军战略指导:《维持美国的世界领导力:21世纪国防的优先事项》
    ACM/ICPC2016沈阳网络赛(不完全)解题报告
  • 原文地址:https://www.cnblogs.com/YangBinChina/p/2934863.html
Copyright © 2011-2022 走看看