本文介绍了如何获得从SourceSafe文件编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从SourceSafe数据库文件编程。任何想法怎么办呢?
PS:我会做,通过使用C#
解决方案
<$。 p $ p> 使用系统;
使用System.Collections.Generic;
使用SourceSafeTypeLib;
命名空间YourNamespace
{
公共类SourceSafeDatabase
{
私人只读字符串DBPATH;
私人只读字符串密码;
私人只读字符串rootProject;
私人只读字符串用户名;
私人只读VSSDatabaseClass vssDatabase;
公共SourceSafeDatabase(字符串DBPATH,用户名字符串,字符串密码,串rootProject)
{
this.dbPath = DBPATH;
this.username =用户名;
this.password =密码;
this.rootProject = rootProject;
vssDatabase =新VSSDatabaseClass();
}
公开名单<串GT; GetAllLabels()
{
名单,LT;字符串> allLabels =新的List<串GT;();
VSSItem项目= vssDatabase.get_VSSItem(rootProject,FALSE);
IVSSVersions版本= item.get_Versions(0);
的foreach(IVSSVersion版本的版本)
{
如果(version.Label.Length大于0)
{
allLabels.Add(版本。标签);
}
}
返回allLabels;
}
公共无效GetLabelledVersion(串标,串项目,字符串目录)
{
串OUTDIR =目录;
vssDatabase.get_VSSItem(rootProject,FALSE).get_Version(标签)获得(REF OUTDIR,(INT)VSSFlags.VSSFLAG_RECURSYES +(INT)VSSFlags.VSSFLAG_USERRONO);
}
公共无效的open()
{
vssDatabase.Open(DBPATH,用户名,密码);
}
公共无效关闭()
{
vssDatabase.Close();
}
}
//使用它
SourceSafeDatabase sourceControlDatabase =新sourceControlDatabase(其他一些代码.. );
sourceControlDatabase.Open();
sourceControlDatabase.GetLabelledVersion(标签,rootProject,projectDirectory);
sourceControlDatabase.Close();
I need to get a file from sourcesafe database programmatically. Any idea of how to do it?
ps: I'll do that by using C#.
解决方案
using System;
using System.Collections.Generic;
using SourceSafeTypeLib;
namespace YourNamespace
{
public class SourceSafeDatabase
{
private readonly string dbPath;
private readonly string password;
private readonly string rootProject;
private readonly string username;
private readonly VSSDatabaseClass vssDatabase;
public SourceSafeDatabase(string dbPath, string username, string password, string rootProject)
{
this.dbPath = dbPath;
this.username = username;
this.password = password;
this.rootProject = rootProject;
vssDatabase = new VSSDatabaseClass();
}
public List<string> GetAllLabels()
{
List<string> allLabels = new List<string>();
VSSItem item = vssDatabase.get_VSSItem(rootProject, false);
IVSSVersions versions = item.get_Versions(0);
foreach (IVSSVersion version in versions)
{
if (version.Label.Length > 0)
{
allLabels.Add(version.Label);
}
}
return allLabels;
}
public void GetLabelledVersion(string label, string project, string directory)
{
string outDir = directory;
vssDatabase.get_VSSItem(rootProject, false).get_Version(label).Get(ref outDir, (int)VSSFlags.VSSFLAG_RECURSYES + (int)VSSFlags.VSSFLAG_USERRONO);
}
public void Open()
{
vssDatabase.Open(dbPath, username, password);
}
public void Close()
{
vssDatabase.Close();
}
}
// some other code that uses it
SourceSafeDatabase sourceControlDatabase = new sourceControlDatabase(...);
sourceControlDatabase.Open();
sourceControlDatabase.GetLabelledVersion(label, rootProject, projectDirectory);
sourceControlDatabase.Close();
这篇关于如何获得从SourceSafe文件编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!