private LocalItemStatus ToStatus(SvnStatus svn) { LocalItemStatus status; if (!Enum.TryParse(svn.ToString(), true, out status)) { status = LocalItemStatus.Unknown; } return(status); }
static string CombineChange(SvnStatus svnStatus, SvnStatus svnStatus_2) { return(svnStatus.ToString() + " " + svnStatus_2.ToString()); }
// 点击“获取本地表状态”按钮 private void btnGetLocalExcelFileState_Click(object sender, EventArgs e) { FileState fileState = Utils.GetFileState(AppValues.LocalExcelFilePath); if (fileState == FileState.Inexist) { MessageBox.Show("本地表已不存在,请勿在使用本工具时对母表进行操作", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SvnException svnException = null; SvnStatusEventArgs localFileState = OperateSvnHelper.GetLocalFileState(AppValues.LocalExcelFilePath, out svnException); if (svnException == null) { SvnInfoEventArgs svnFileInfo = OperateSvnHelper.GetSvnFileInfo(AppValues.SvnExcelFilePath, out svnException); if (svnException == null) { // 本地表的版本号 long localFileRevision = localFileState.LastChangeRevision; // 本地表文件相较SVN中的状态 SvnStatus svnStatus = localFileState.LocalContentStatus; // SVN中的母表的版本号 long svnFileRevision = svnFileInfo.LastChangeRevision; // 最后修改时间 DateTime svnFileChangeTime = svnFileInfo.LastChangeTime; // 最后修改者 string svnFileChangeAuthor = svnFileInfo.LastChangeAuthor; StringBuilder infoStringBuilder = new StringBuilder(); infoStringBuilder.Append("本地路径:").AppendLine(AppValues.LocalExcelFilePath); infoStringBuilder.Append("SVN路径:").AppendLine(AppValues.SvnExcelFilePath); infoStringBuilder.Append("本地版本号:").AppendLine(localFileRevision.ToString()); infoStringBuilder.Append("SVN版本号:").AppendLine(svnFileRevision.ToString()); infoStringBuilder.Append("SVN版本最后修改时间:").AppendLine(svnFileChangeTime.ToLocalTime().ToString()); infoStringBuilder.Append("SVN版本最后修改者:").AppendLine(svnFileChangeAuthor); infoStringBuilder.Append("本地文件是否被打开:").AppendLine(fileState == FileState.IsOpen ? "是" : "否"); if (svnFileInfo.Lock != null) { infoStringBuilder.AppendLine("SVN中此文件是否被锁定:是"); infoStringBuilder.Append("锁定者:").AppendLine(svnFileInfo.Lock.Owner); infoStringBuilder.Append("锁定时间:").AppendLine(svnFileInfo.Lock.CreationTime.ToLocalTime().ToString()); infoStringBuilder.Append("锁定原因:").AppendLine(svnFileInfo.Lock.Comment); } infoStringBuilder.Append("本地文件相较SVN中的状态:").Append(svnStatus.ToString()).Append("(").Append(OperateSvnHelper.GetSvnStatusDescription(svnStatus)).AppendLine(")"); infoStringBuilder.Append("本地文件是否是SVN中最新版本且本地内容未作修改:").AppendLine(localFileRevision == svnFileRevision && svnStatus == SvnStatus.Normal ? "是" : "否"); MessageBox.Show(infoStringBuilder.ToString(), "本地表状态信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Concat("无法获取SVN中母表信息,错误原因为:", svnException.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show(string.Concat("无法获取本地表状态,错误原因为:", svnException.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
static string CombineChange(SvnStatus svnStatus, SvnStatus svnStatus_2) { return svnStatus.ToString() + " " + svnStatus_2.ToString(); }