Пример #1
0
        public void CreateWebConfig()
        {
            var serviceinfors = this.GetServiceInformations();

            System.Configuration.Configuration cfg = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/", this.MyAppsetting.SiteName);
            //设置appsetting
            AppSettingsSection appSetting = cfg.AppSettings;

            appSettingHandle(appSetting, "DatabaseType", this.MyAppsetting.DatabaseType);
            appSettingHandle(appSetting, "DataSource", this.MyAppsetting.DBServer);
            appSettingHandle(appSetting, "InitialCatalog", this.MyAppsetting.DBName);
            appSettingHandle(appSetting, "UserID", this.MyAppsetting.DBUser);
            appSettingHandle(appSetting, "Password", this.MyAppsetting.DBPassword);
            appSettingHandle(appSetting, "B1Type", this.MyAppsetting.B1Type);
            appSettingHandle(appSetting, "B1Server", this.MyAppsetting.B1Server);
            appSettingHandle(appSetting, "IISAddress", this.MyAppsetting.IISAddress);
            var group           = cfg.GetSectionGroup("system.serviceModel");
            var ServicesSection = group.Sections["services"] as System.ServiceModel.Configuration.ServicesSection;

            foreach (var item in serviceinfors)
            {
                System.ServiceModel.Configuration.ServiceElement targetser = null;
                foreach (System.ServiceModel.Configuration.ServiceElement Service in ServicesSection.Services)
                {
                    if (Service.Name.Contains(item.ServiceName))
                    {
                        targetser = Service;
                    }
                }
                if (targetser == null)
                {
                    targetser      = new System.ServiceModel.Configuration.ServiceElement();
                    targetser.Name = string.Format("BizSys.{0}.Service.DataService.{1}JSON", item.ServicePath, item.ServiceName);
                    var sep = new System.ServiceModel.Configuration.ServiceEndpointElement();
                    sep.BehaviorConfiguration = "AjaxJSON";
                    sep.Binding  = "webHttpBinding";
                    sep.Contract = string.Format("BORep.{0}.BORepository.IBORep{0}JSON", item.ServiceName);
                    targetser.Endpoints.Add(sep);
                    ServicesSection.Services.Add(targetser);
                }
                else
                {
                    targetser.Endpoints.Clear();
                    targetser.Name = string.Format("BizSys.{0}.Service.DataService.{1}JSON", item.ServicePath, item.ServiceName);
                    var sep1 = new System.ServiceModel.Configuration.ServiceEndpointElement();
                    sep1.BehaviorConfiguration = "AjaxJSON";
                    sep1.Binding  = "webHttpBinding";
                    sep1.Contract = string.Format("BORep.{0}.BORepository.IBORep{0}JSON", item.ServiceName);
                    targetser.Endpoints.Add(sep1);
                }
            }
            cfg.Save();
        }
Пример #2
0
 protected void LoadConfigurationSection(System.ServiceModel.Configuration.ServiceElement serviceSection)
 {
 }