DeploySetting GetSettings() { JSONTool jt = new JSONTool(); try { DeploySetting target = jt.Deserialize <DeploySetting>(File.ReadAllText(jt.configPath)); return(target ?? null); } catch (Exception ex) { Console.WriteLine("获取配置失败\n{0}", ex.Message); jt = null; } return(null); }
/// <summary> /// 生成配置 /// </summary> public void GenerateSettings() { DeploySetting deploy = new DeploySetting() { DeployMode = DeployMode.Test, //IsChangeWorkFlowName = true, IsExportSolutions = true, IsImportSolutions = false, PublishAllCustomizationAfterImported = true, PublishAllCustomizationBeforeExported = true, ExportPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), ImportSourcePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) }; deploy.SolutionsToBeExport = new List <string>(); deploy.SolutionsToBeExport.AddRange(new string[] { "WebResources", "PureProcesses", "Reports", "SecurityRoles", }); deploy.SolutionsToBeImport = new List <string>(); deploy.SolutionsToBeImport.AddRange(new string[] { "WebResources_8_2_4_0512", "PureProcesses_8_2_4_0512", "Reports_8_2_4_0512", "SecurityRoles_8_2_4_0512", }); Deployment sourceDeployment = new Deployment() { UserName = "******", Password = "", IsEnable = true, DiscoveryServiceAddress = "https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc", OrganizationServiceAddress = "https://.api.crm5.dynamics.com/XRMServices/2011/Organization.svc", OrganizationUniqueName = "", Domain = ".com", Name = "Online_Dev1" }; deploy.SourceDeployment = sourceDeployment; deploy.DestinationDeployments = new List <Deployment>(); Deployment productionDeployment = new Deployment() { UserName = "******", Password = "", IsEnable = true, DiscoveryServiceAddress = "https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc", OrganizationServiceAddress = "https://.api.crm.dynamics.com/XRMServices/2011/Organization.svc", OrganizationUniqueName = "", Domain = ".com", Name = "Production", }; deploy.DestinationDeployments.Add(productionDeployment); Deployment sitDeployment = new Deployment() { UserName = "******", Password = "", IsEnable = true, DiscoveryServiceAddress = "https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc", OrganizationServiceAddress = "https://.api.crm5.dynamics.com/XRMServices/2011/Organization.svc", OrganizationUniqueName = "", Domain = ".com", Name = "Online_SIT" }; deploy.DestinationDeployments.Add(sitDeployment); Deployment uatDeployment = new Deployment() { UserName = "******", Password = "", IsEnable = true, DiscoveryServiceAddress = "https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc", OrganizationServiceAddress = "https://.api.crm5.dynamics.com/XRMServices/2011/Organization.svc", OrganizationUniqueName = "", Domain = ".com", Name = "Online_UAT" }; deploy.DestinationDeployments.Add(uatDeployment); //某些解决方案也需要导入到开发环境 deploy.DestinationDeployments.Add(sourceDeployment); JSONTool jt = new JSONTool(); jt.Serialize <DeploySetting>(deploy); }