当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《如何以编程方式从sourcesafe获取文件?》经验,为你挑选了1个好方法。

我需要以编程方式从sourcesafe数据库中获取文件.知道怎么做吗?

ps:我会通过使用C#来做到这一点.



1> solrevdev..:
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 GetAllLabels()
    {
        List allLabels = new List();

        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();

推荐阅读
李桂平2402851397
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有