refactor: 移除不再使用的配置文件与代码,优化用户界面
- 删除 config.json 和 requirements.txt 文件,移除 Python 版相关代码,简化项目结构。 - 更新 README.md,调整工具说明,强调仅保留 C# WinForms 版本。 - 在 MainForm.cs 中添加输入框的占位提示,提升用户体验。 - 更新 .gitignore,添加 debug.log 文件以记录运行时日志。 - 移除与 Python 版相关的示例 CSV 文件,确保数据源一致性。
This commit is contained in:
@@ -35,7 +35,6 @@ namespace TfsExcelImporter
|
||||
|
||||
private void WireEvents()
|
||||
{
|
||||
_cmbAuth.SelectedIndexChanged += (s, e) => { UpdateAuthUi(); OnFieldChanged(); };
|
||||
_btnTest.Click += async (s, e) => await TestConnectionAsync();
|
||||
_btnLoadIterations.Click += async (s, e) => await LoadIterationsAsync();
|
||||
_btnBrowse.Click += (s, e) => BrowseExcel();
|
||||
@@ -45,13 +44,11 @@ namespace TfsExcelImporter
|
||||
_btnFixArea.Click += async (s, e) => await FixAreaAsync();
|
||||
_btnLinkParent.Click += async (s, e) => await LinkParentAsync();
|
||||
|
||||
foreach (var tb in new[] { _txtUrl, _txtProject, _txtType, _txtUser, _txtPwd, _txtDomain,
|
||||
foreach (var tb in new[] { _txtUrl, _txtProject, _txtType, _txtUser, _txtPwd,
|
||||
_txtExcel, _txtParentPbi, _txtAreaPath })
|
||||
tb.TextChanged += (s, e) => OnFieldChanged();
|
||||
_cmbIteration.TextChanged += (s, e) => OnFieldChanged();
|
||||
_chkSkip.CheckedChanged += (s, e) => OnFieldChanged();
|
||||
_chkBypass.CheckedChanged += (s, e) => OnFieldChanged();
|
||||
_chkProxy.CheckedChanged += (s, e) => OnFieldChanged();
|
||||
|
||||
FormClosing += (s, e) => { try { SaveUiToConfig(); } catch { } };
|
||||
}
|
||||
@@ -62,37 +59,19 @@ namespace TfsExcelImporter
|
||||
RefreshSummaries();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- 认证区联动
|
||||
private void UpdateAuthUi()
|
||||
{
|
||||
bool needCreds = _cmbAuth.SelectedItem != null && _cmbAuth.SelectedItem.ToString() != "default";
|
||||
_txtUser.Enabled = needCreds;
|
||||
_txtPwd.Enabled = needCreds;
|
||||
_txtDomain.Enabled = needCreds;
|
||||
_fUser.Invalid = false;
|
||||
_fPwd.Invalid = false;
|
||||
_fDomain.Invalid = false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- 配置互转
|
||||
private void LoadConfigToUi()
|
||||
{
|
||||
_txtUrl.Text = _cfg.TfsUrl;
|
||||
_txtProject.Text = _cfg.Project;
|
||||
_txtType.Text = _cfg.WorkItemType;
|
||||
_cmbAuth.SelectedItem = _cfg.AuthMode;
|
||||
if (_cmbAuth.SelectedItem == null) _cmbAuth.SelectedItem = "ntlm";
|
||||
_txtUser.Text = _cfg.Username;
|
||||
_txtPwd.Text = _cfg.Password;
|
||||
_txtDomain.Text = _cfg.Domain;
|
||||
_chkProxy.Checked = _cfg.UseSystemProxy;
|
||||
_cmbIteration.Text = _cfg.IterationPath;
|
||||
_txtExcel.Text = _cfg.LastExcelPath;
|
||||
_txtAreaPath.Text = _cfg.AreaPath;
|
||||
_chkSkip.Checked = _cfg.SkipExistingTitles;
|
||||
_chkBypass.Checked = _cfg.BypassRules;
|
||||
_txtParentPbi.Text = _cfg.ParentPbiId;
|
||||
UpdateAuthUi();
|
||||
}
|
||||
|
||||
private void SaveUiToConfig()
|
||||
@@ -100,16 +79,12 @@ namespace TfsExcelImporter
|
||||
_cfg.TfsUrl = _txtUrl.Text.Trim();
|
||||
_cfg.Project = _txtProject.Text.Trim();
|
||||
_cfg.WorkItemType = _txtType.Text.Trim();
|
||||
_cfg.AuthMode = _cmbAuth.SelectedItem != null ? _cmbAuth.SelectedItem.ToString() : "ntlm";
|
||||
_cfg.Username = _txtUser.Text.Trim();
|
||||
_cfg.Password = _txtPwd.Text;
|
||||
_cfg.Domain = _txtDomain.Text.Trim();
|
||||
_cfg.UseSystemProxy = _chkProxy.Checked;
|
||||
_cfg.IterationPath = _cmbIteration.Text.Trim();
|
||||
_cfg.LastExcelPath = _txtExcel.Text.Trim();
|
||||
_cfg.AreaPath = _txtAreaPath.Text.Trim();
|
||||
_cfg.SkipExistingTitles = _chkSkip.Checked;
|
||||
_cfg.BypassRules = _chkBypass.Checked;
|
||||
_cfg.ParentPbiId = _txtParentPbi.Text.Trim();
|
||||
_cfg.Save();
|
||||
}
|
||||
@@ -168,7 +143,7 @@ namespace TfsExcelImporter
|
||||
SetConnection("连接失败", ChipKind.Danger);
|
||||
SetBadgeOf(_cardConn, BadgeKind.Warn);
|
||||
Log("连接失败: " + FirstLine(ex.Message));
|
||||
Log("排查: 内网请确认「使用系统代理」保持关闭;DNS 失败多为 VPN 或未连内网。");
|
||||
Log("排查: 程序固定直连(不走本机系统代理);DNS 失败多为 VPN 或未连内网。");
|
||||
_cardConn.Expanded = true;
|
||||
_cardConn.ApplyHeight();
|
||||
Relayout();
|
||||
@@ -237,7 +212,7 @@ namespace TfsExcelImporter
|
||||
SetBadgeOf(_cardConn, BadgeKind.Warn);
|
||||
ShowError(_errIteration, _fIteration, _cardData, "迭代列表加载失败,可手填完整路径");
|
||||
Log("加载迭代失败: " + FirstLine(ex.Message));
|
||||
Log("排查: 内网请确认「使用系统代理」保持关闭;DNS 失败多为 VPN 或未连内网。");
|
||||
Log("排查: 程序固定直连(不走本机系统代理);DNS 失败多为 VPN 或未连内网。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -551,7 +526,7 @@ namespace TfsExcelImporter
|
||||
var pbiText = !string.IsNullOrWhiteSpace(row.PbiId) ? row.PbiId.Trim() : _cfg.ParentPbiId;
|
||||
int? parentPbi = int.TryParse(pbiText, out var pbiNum) ? pbiNum : (int?)null;
|
||||
|
||||
var id = await client.CreateWorkItemAsync(_cfg.Project, _cfg.WorkItemType, fields, _chkBypass.Checked, parentPbi);
|
||||
var id = await client.CreateWorkItemAsync(_cfg.Project, _cfg.WorkItemType, fields, parentPbi);
|
||||
ok++;
|
||||
report.AppendLine($"{line},\"{row.Title}\",OK,{id},");
|
||||
Log($"[{i + 1}/{_rows.Count}] OK #{id} {row.Title}");
|
||||
@@ -574,7 +549,7 @@ namespace TfsExcelImporter
|
||||
SetConnection("连接失败", ChipKind.Danger);
|
||||
SetRunBadge(BadgeKind.Warn);
|
||||
Log("导入中断: " + FirstLine(ex.Message));
|
||||
Log("排查: 内网请确认「使用系统代理」保持关闭;DNS 失败多为 VPN 或未连内网。");
|
||||
Log("排查: 程序固定直连(不走本机系统代理);DNS 失败多为 VPN 或未连内网。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user