/// <summary> /// 打开设置页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void linkSetting_Click(object sender, EventArgs e) { var settingBackUp = _settingInfo.DeepCopy(); SettingForm settingForm = new SettingForm(_settingInfo); settingForm.Activate(); var dlgRes = settingForm.ShowDialog(); if (dlgRes != DialogResult.OK) { _settingInfo = settingBackUp; } if (_settingInfo == null) { _settingInfo = new MSettingInfo(); } this.metroStyleManager1.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; if (_settingInfo.MetroColorStyle < 0 || _settingInfo.MetroColorStyle >= 15) { _settingInfo.MetroColorStyle = MetroColorStyle.Blue.GetHashCode(); } this.metroStyleManager1.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.StyleManager = this.metroStyleManager1; this.deployStep.StyleManager = this.metroStyleManager1; this.linkSetting.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.linkSetting.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.buildProgressBar.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.buildProgressBar.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.metroToolTip1.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.metroToolTip1.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.metroCbDeployType.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.metroCbDeployType.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.Refresh(); }
public SelectFilesForm(MProjectSettingInfo projectSetting, string basePath, MSettingInfo settingInfo) { InitializeComponent(); _projectSetting = projectSetting; _basePath = basePath; _settingInfo = settingInfo ?? new MSettingInfo(); }
public static Result UploadZipFile(MSettingInfo setting, ServiceInfo serviceInfo, string projType, string appId, string fullZipPath) { Result res = new Result(); try { NameValueCollection dic = new NameValueCollection(); dic.Add("Type", projType == "Library" ? "iis" : "exe"); dic.Add("AppId", appId); if (serviceInfo == null || serviceInfo.ApiIpAdress.IsNullOrEmpty()) { serviceInfo = setting.GetCurrServiceInfo(); } string url = $"{serviceInfo?.GetApiUrl()}/UploadZip"; string uploadResStr = HttpHelper.HttpPostData(url, 30000, Path.GetFileName(fullZipPath), fullZipPath, dic); var uploadRes = uploadResStr.DeserializeObject <Result>(); return(uploadRes); } catch (Exception e) { res.Message = e.Message; } return(res); }
/// <summary> /// 加载配置文件 /// </summary> /// <returns></returns> public static MSettingInfo LoadSettingInfo() { MSettingInfo res = new MSettingInfo(); var settingFile = Path.Combine(GetPluginConfigPath(), "Setting.json"); if (!File.Exists(settingFile)) { res = new MSettingInfo(); } else { var str = File.ReadAllText(settingFile); res = str.DeserializeObject <MSettingInfo>() ?? new MSettingInfo(); } if (string.IsNullOrWhiteSpace(res.MsBuildExePath)) { res.MsBuildExePath = GetMsBuildPath(); } if (res.SelectedItems == null) { res.SelectedItems = new List <MSelectedItem>(); } if (res.SelectedItems.Count > 20) { res.SelectedItems = res.SelectedItems.OrderByDescending(n => n.CreateTime).Take(20).ToList(); } return(res); }
public SettingForm(MSettingInfo settingInfo) { InitializeComponent(); _settingInfo = settingInfo ?? new MSettingInfo(); this.txtAuthor.Text = _settingInfo.Authour; this.txtMsBuildPath.Text = _settingInfo.MsBuildExePath; }
public ServiceForm(ProjectModel projectModel, MProjectSettingInfo projectSetting, MSettingInfo settingInfo) { InitializeComponent(); _projectModel = projectModel ?? new ProjectModel(); _projectSetting = projectSetting ?? new MProjectSettingInfo(); _settingInfo = settingInfo ?? new MSettingInfo(); _currSelectedServiceInfo = _settingInfo.GetCurrServiceInfo(); }
private void DeployForm_Shown(object sender, EventArgs e) { _settingInfo = SettingHelper.LoadSettingInfo(); if (_settingInfo?.GetCurrServiceInfo() == null) { var settingBackUp = _settingInfo.DeepCopy(); SettingForm settingForm = new SettingForm(_settingInfo); settingForm.Activate(); var dlgRes = settingForm.ShowDialog(); if (dlgRes != DialogResult.OK) { _settingInfo = settingBackUp; } } if (_settingInfo == null) { _settingInfo = new MSettingInfo() { SelectedItems = new List <MSelectedItem>(), ServiceInfos = new List <ServiceInfo>() }; } this.metroStyleManager1.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; if (_settingInfo.MetroColorStyle < 0 || _settingInfo.MetroColorStyle >= 15) { _settingInfo.MetroColorStyle = MetroColorStyle.Blue.GetHashCode(); } this.metroStyleManager1.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.StyleManager = this.metroStyleManager1; this.deployStep.StyleManager = this.metroStyleManager1; this.linkSetting.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.linkSetting.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.buildProgressBar.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.buildProgressBar.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.metroToolTip1.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.metroToolTip1.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.metroCbDeployType.Style = (MetroColorStyle)_settingInfo.MetroColorStyle; this.metroCbDeployType.Theme = _settingInfo.MetroThemeStyle <= 1 ? MetroThemeStyle.Light : MetroThemeStyle.Dark; this.Refresh(); // 尝试连接服务器 var isConnect = ApiHelper.Connect(_settingInfo); if (!isConnect) { MetroMessageBox.Show(this, "默认服务器连接失败,请检查服务器地址或者选择其他服务器进行部署", "无法连接到服务器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SetStepIndex(1); }
public static bool Connect(MSettingInfo setting) { try { var currService = setting.GetCurrServiceInfo(); string url = $"{currService.GetApiUrl()}/CheckConnection?apiKey=" + currService.ApiKey; WebClient client = new WebClient(); var res = client.DownloadString(url) == "OK"; return(res); } catch (Exception) { return(false); } }
/// <summary> /// 保存配置文件 /// </summary> /// <param name="settingInfo"></param> /// <returns></returns> public static bool SaveSettingInfo(MSettingInfo settingInfo) { try { var settingFile = Path.Combine(GetPluginConfigPath(), "Setting.json"); using (StreamWriter writer = File.CreateText(settingFile)) { writer.WriteLine(settingInfo.SerializeObject().FormatJsonString()); writer.Flush(); } return(true); } catch (Exception) { return(false); } }
public AddServiceForm(MSettingInfo settingInfo) { InitializeComponent(); this._settingInfo = settingInfo.DeepCopy(); }
public SelectProjectForm(MSettingInfo settingInfo) { InitializeComponent(); _settingInfo = settingInfo ?? new MSettingInfo(); }