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); }
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); } }