سؤال

I'm working on a migration from VSS to TFS. The installation that I'm migrating is using multiple VSS databases (a lot of them).

I am looking for an easy way to determine, for each vss database the date and time of the last check-in, so that I can know if I need to refresh code that is already in TFS.

At a high-level, I would want to write a method like this:

DateTime GetLatestCheckIn(string pathToVssDatabase) {}

Is there a way to accomplish this with the VSS COM API?

هل كانت مفيدة؟

المحلول

I think I got it!

Here's an extremely rough cut, just a console app that displays the most recent update and the date of the update. This is not highly efficient -- now that I know what to do, I will eliminate the sort and just do a single pass, comparing for the most recent item, but, here's the gist of it:


    class Program
    {
        static void Main(string[] args)
        {
            //Environment.CurrentDirectory = @"c:\Program Files (x86)\Microsoft Visual SourceSafe Upgrade";
            IVSSDatabase db = new VSSDatabase();

            db.Open(@"ThePath\srcsafe.ini", "Admin", "ThePassword");
            IVSSItem rootFolder = db.get_VSSItem("$/", false);
            var versions = new List();
            foreach (IVSSVersion item in rootFolder.get_Versions((int)Microsoft.VisualStudio.SourceSafe.Interop.VSSFlags.VSSFLAG_RECURSYES))
            {
                versions.Add(new VersionInfo()
                {
                    ItemName = item.VSSItem.Name,
                    ItemFullPath = item.VSSItem.Spec,
                    ItemVersionDate = item.Date,
                    ItemVersionNumber = item.VersionNumber
                });
            }

            // echo all 
            var versionInfo = versions.OrderByDescending(i => i.ItemVersionDate).First();
            Console.WriteLine("{0} {1}", versionInfo.ItemFullPath, versionInfo.ItemVersionDate);
            Console.ReadLine();
        }
    }

    class VersionInfo
    {
        public string ItemName { get; set; }
        public string ItemFullPath { get; set; }
        public DateTime ItemVersionDate { get; set; }
        public int ItemVersionNumber { get; set; }
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top