/// <summary> /// 执行保存已修改数据的方法 /// </summary> private void InitUserConfig() { string dataPath = "config/preferences"; ConfigController configController = new ConfigController(); ConfigInfo configInfo = configController.ConfigQuery(dataPath, "../../../common/res/CIConfig.xml"); Svnpath.Text = configInfo.Svnpath; Updateinterval.Text = configInfo.Updateinterval; switch (configInfo.StandarOutput) { case "true": standaroutput.IsChecked = true; break; case "false": standaroutput.IsChecked = false; break; default: standaroutput.IsChecked = false; break; } switch (configInfo.ServiceSwitch) { case "window": windowprocess.IsChecked = true; break; case "service": serviceprocess.IsChecked = true; break; default: windowprocess.IsChecked = false; serviceprocess.IsChecked = false; break; } }
/// <summary> /// 执行恢复默认数据的方法 /// </summary> private void btnDefault_Click(object sender, RoutedEventArgs e) { ConfigController configController = new ConfigController(); ConfigInfo configInfo = configController.RestoreDefault(); Svnpath.Text = configInfo.Svnpath; Updateinterval.Text = configInfo.Updateinterval; standaroutput.IsChecked = true; windowprocess.IsChecked = true; serviceprocess.IsChecked = false; }
/// <summary> /// 执行保存已修改数据的方法 /// </summary> private void btnApply_Click(object sender, RoutedEventArgs e) { ConfigController configController = new ConfigController(); ConfigInfo configInfo = new ConfigInfo(); configInfo.StandarOutput = standaroutput.IsChecked == true ? "true" : "false"; configInfo.Svnpath = Svnpath.Text; configInfo.Updateinterval = Updateinterval.Text; configInfo.ServiceSwitch = (windowprocess.IsChecked == true) ? "window" : "service"; var result = configController.SaveConfig(configInfo, "../../../common/res/CIConfig.xml"); MessageBox.Show(result); }
/// <summary> /// 初始化项目状态显示 /// </summary> public void InitServiceStatus() { var statusImg = ""; var dataPath = "config/preferences"; ConfigController configController = new ConfigController(); ConfigInfo configInfo = configController.ConfigQuery(dataPath, "../../../common/res/CIConfig.xml"); ServiceController[] service = ServiceController.GetServices(); for (int i = 0; i < service.Length; i++) { if (service[i].DisplayName.Equals("LuckyCIService")) { switch (service[i].Status) { case ServiceControllerStatus.Running: statusImg = "../images/dot_yellow.png"; ServiceStatus.Content = "Running"; break; case ServiceControllerStatus.Stopped: statusImg = "../images/dot_black.png"; ServiceStatus.Content = "Stopped"; break; } StatusFlag.Source = new BitmapImage(new Uri(statusImg, UriKind.Relative)); break; } else { statusImg = "../images/dot_black.png"; ServiceStatus.Content = "Not Install"; StatusFlag.Source = new BitmapImage(new Uri(statusImg, UriKind.Relative)); } } //serviceswitch为service,service按钮可用,否则不可用 if (configInfo.ServiceSwitch == "service") { butOn.IsEnabled = true; butOff.IsEnabled = true; butReset.IsEnabled = true; } else { butOn.IsEnabled = false; butOff.IsEnabled = false; butReset.IsEnabled = false; } }