如何以编程方式从sourcesafe获取文件?

发布于 2024-07-08 15:45:00 字数 66 浏览 9 评论 0原文

我需要以编程方式从源安全数据库获取文件。 知道如何做吗?

ps:我将使用 C# 来做到这一点。

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#.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心的位置 2024-07-15 15:45:00
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();
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();
棒棒糖 2024-07-15 15:45:00

您可以调用一个命令行 SS.EXE 程序来执行源代码管理操作。 但是,它依赖于全局 SourceSafe 配置,因此有时很难让它执行您想要的操作。

There is a command-line SS.EXE program that you can call to do source control operations. However, it relies on global SourceSafe configuration and so it sometimes is hard to make it do what you want.

撩发小公举 2024-07-15 15:45:00

有一个 VSS 的 OLE 库

您可能需要查看 < a href="http://bytes.com/forum/thread229399.html" rel="nofollow noreferrer">此讨论。

There is an OLE library for VSS

You might want to look at this discussion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文