/// <summary> /// Add file 命令的接口核心实现 /// </summary> /// <param name="vssWorkFolder"></param> /// <param name="localFile"></param> /// <param name="comment"></param> public void AddFile(string vssWorkFolder, string localFile, string comment) { //TODO:添加判断文件是否存在 IVSSDatabase vssDatabase = new VSSDatabase(); vssDatabase.Open(this.srcSafeIni, this.username, this.password); VSSItem vssFolder = vssDatabase.get_VSSItem(vssWorkFolder, false); DisplayFolderContent(vssFolder); VSSItem vssTestFile = vssFolder.Add(localFile, comment, 0); DisplayFolderContent(vssFolder); vssTestFile.Destroy(); DisplayFolderContent(vssFolder); }
private void AddToSourcesafe(Database db, string dest) { try { dname.Text = "Check out from Sourcesafe. Objects = " + objectCount.ToString(); oname.Text = ""; string vssPath = m_vssRootPath; VSSItem VssDbItem = GetVssItem(vssPath, VSSItemType.VSSITEM_PROJECT, serverName, db.Name); VssDbItem.LocalSpec = dest; dname.Text = "Checking in to Sourcesafe. Objects = " + objectCount.ToString(); oname.Text = ""; VssDbItem.Checkin("DBScriptManager Automatic Checkin", dest, (int)(VSSFlags.VSSFLAG_DELTAYES | VSSFlags.VSSFLAG_RECURSYES | VSSFlags.VSSFLAG_DELYES)); dname.Text = "Undoing checkouts. Objects = " + objectCount.ToString(); oname.Text = ""; VssDbItem.UndoCheckout(dest, (int)(VSSFlags.VSSFLAG_GETNO | VSSFlags.VSSFLAG_DELYES | VSSFlags.VSSFLAG_RECURSYES)); // Now ensure that all the files that were originally retrieved from Sourcesafe have been removed foreach (string file in preExistingSourcesafeEntries) { File.Delete(file); } dname.Text = "Adding to Sourcesafe. Objects = " + objectCount.ToString(); oname.Text = ""; VssDbItem.Add(dest, "Created by DBScriptManager", (int)(VSSFlags.VSSFLAG_DELYES | VSSFlags.VSSFLAG_RECURSYES)); dname.Text = "Sourcesafe check in complete."; oname.Text = ""; } catch (Exception ex) { dname.Text = "Error in AddToSourcesafe method. [" + ex.Message + "]"; oname.Text = ""; m_vssDatabase.Close(); m_vssDatabase = null; errorsOccurred = true; Logger.Log("AddToSourcesafe Error\r\n" + ex.StackTrace); throw; } }