예제 #1
0
        public void SaveConfig(CustomerConfig config)
        {
            string content = JsonConvert.SerializeObject(config);

            File.WriteAllText(FrontFilepath, content);
            File.WriteAllText(ManagementFilepath, content);
        }
예제 #2
0
        private void Button_MouseClick(object sender, EventArgs e)
        {
            string frontUrl            = txtFront.Text;
            string managementUrl       = txtManagement.Text;
            string resourceUrl         = txtResource.Text;
            string masterFrontUrl      = txtMasterFront.Text;
            string masterManagementUrl = txtMasterManagement.Text;
            string frontFilepath       = cbFront.SelectedValue + "\\bin\\Handan.Config.dll";
            string managementFilepath  = cbManagement.SelectedValue + "\\bin\\Handan.Config.dll";

            CustomerConfig customerConfig = new CustomerConfig(frontFilepath, managementFilepath);
            var            config         = customerConfig.LoadConfig();

            if (!string.IsNullOrEmpty(frontUrl))
            {
                config.FrontUrl = frontUrl;
            }
            if (!string.IsNullOrEmpty(managementUrl))
            {
                config.AdminUrl = managementUrl;
            }
            if (!string.IsNullOrEmpty(resourceUrl))
            {
                config.ImageUrl = $"http://{resourceUrl}";
            }
            if (!string.IsNullOrEmpty(masterFrontUrl))
            {
                config.MasterFrontUrl = masterFrontUrl;
            }
            if (!string.IsNullOrEmpty(masterManagementUrl))
            {
                config.MasterAdminUrl = masterManagementUrl;
            }
            customerConfig.SaveConfig(config);
            MessageBox.Show("Config文件已替换");

            Dictionary <string, string> dicSiteUrl = new Dictionary <string, string>
            {
                { cbFront.Text, frontUrl },
                { cbManagement.Text, managementUrl },
                { cbResrouce.Text, resourceUrl }
            };

            BindUrl(dicSiteUrl);
            MessageBox.Show("域名已添加");
        }