public Result Ini(ProjModel projModel) { Result res = new Result(); try { _projModel = projModel; _dirSimpleNames = ProjModel.ToDirSimpleNames(projModel.PublishDir); if (_projModel.ProjType == "Library") { lbAppType.Text = "IIS"; _appViews = PublishService.GetAllIISAppNames(); if (_appViews == null || !_appViews.Any()) { throw new Exception("未连接到可用的IIS服务"); } } else { lbAppType.Text = "Exe"; _appViews = PublishService.GetExeAppView(_projModel.LibName); if (_appViews == null || !_appViews.Any()) { throw new Exception("未找到该进程"); } } cbAppName.DataSource = _appViews; cbAppName.DisplayMember = "AppAlias"; cbAppName.ValueMember = "AppPhysicalPath"; cbAppName.SelectedIndex = _appViews.FindIndex(n => n.Id == _projModel.LastChooseInfo.LastChooseAppName); showLbText(lbAppPath, (cbAppName.SelectedItem as AppView)?.AppPhysicalPath ?? string.Empty); cbAppPublishDir.DataSource = _dirSimpleNames; cbAppPublishDir.DisplayMember = "Name"; cbAppPublishDir.ValueMember = "FullName"; string lastChoosePublishDir = _projModel.LastChooseInfo.LastChoosePublishDir ?? _dirSimpleNames[0].FullName; _projModel.LastChooseInfo.LastChoosePublishDir = lastChoosePublishDir; cbAppPublishDir.SelectedIndex = cbAppPublishDir.FindString(_dirSimpleNames.Count > 0 ? new DirectoryInfo(_projModel.LastChooseInfo.LastChoosePublishDir ?? _dirSimpleNames[0].FullName) .Name : string.Empty); lbChoosedFiles.Text = $"(已选择{_projModel?.LastChooseInfo?.LastChoosePublishFiles?.Where(n => !n.EndsWith("pdb"))?.Count() ?? 0}个文件)"; isIni = false; res.IsSucceed = true; } catch (Exception e) { res.Message = e.Message; } return(res); }