📄 sourcelibrary.cs
字号:
using System;
namespace SourceFtp.SourceLibrary
{
/// <summary>
/// Summary description for SourceLibrary.
/// </summary>
public class SourceLibrary
{
private FileSystem.ILibrary m_Library;
private string m_LocalPath;
private string m_strUserID;
private string m_BackupPath;
private string m_RemoteRoot;
public SourceLibrary(FileSystem.ILibrary p_Library, string p_RemoteRoot, string p_LocalPath, string p_strUserID, string p_BackupPath)
{
m_RemoteRoot = p_RemoteRoot;
m_Library = p_Library;
m_LocalPath = p_LocalPath;
m_strUserID = p_strUserID;
m_BackupPath = p_BackupPath;
}
public string RootPath
{
get{return m_RemoteRoot;}
}
public FileSystem.Directory Root
{
get{return m_Library.GetDirectory(m_RemoteRoot);}
}
public string UserID
{
get{return m_strUserID;}
}
public FileSystem.ILibrary FileSystemLibrary
{
get{return m_Library;}
}
public SourceItemCollection GetSourceItems(FileSystem.Directory p_Directory)
{
return new SourceItemCollection(this,p_Directory);
}
public void AddLocalFileToSourceControl(FileSystem.Directory p_RemoteDirectory, string p_strLocalFile)
{
//set read only attributes
System.IO.FileAttributes l_attributes = System.IO.File.GetAttributes(p_strLocalFile);
System.IO.File.SetAttributes(p_strLocalFile,l_attributes|System.IO.FileAttributes.ReadOnly);
p_RemoteDirectory.Files.Add(p_strLocalFile);
}
private void InternalGetLatestVersion(SourceFileInfo p_SourceFile, string p_DestinationPath, string p_DestinationFileName)
{
string l_LocalFileName = System.IO.Path.Combine(p_DestinationPath,p_DestinationFileName);
if (System.IO.File.Exists(l_LocalFileName))
{
//create backup copy of the current file
int i = 1;
while(System.IO.File.Exists(System.IO.Path.Combine(m_BackupPath, p_DestinationFileName + i.ToString() + ".bck")))
{
i++;
}
System.IO.File.Move(l_LocalFileName,System.IO.Path.Combine(m_BackupPath, p_DestinationFileName + i.ToString() + ".bck"));
}
//get latest version from server
p_SourceFile.File.Download(l_LocalFileName);
//set read only attributes
System.IO.FileAttributes l_attributes = System.IO.File.GetAttributes(l_LocalFileName);
System.IO.File.SetAttributes(l_LocalFileName,l_attributes|System.IO.FileAttributes.ReadOnly);
}
public void GetHistoryFile(SourceFileInfo p_SourceFile, string p_DestinationFullFileName)
{
if (System.IO.File.Exists(p_DestinationFullFileName))
{
string l_Name = System.IO.Path.GetFileName(p_DestinationFullFileName);
//create backup copy of the current file
int i = 1;
while(System.IO.File.Exists(System.IO.Path.Combine(m_BackupPath, l_Name + i.ToString() + ".bck")))
{
i++;
}
System.IO.File.Move(p_DestinationFullFileName,System.IO.Path.Combine(m_BackupPath, l_Name + i.ToString() + ".bck"));
}
//get latest version from server
p_SourceFile.File.Download(p_DestinationFullFileName);
//set read only attributes
System.IO.FileAttributes l_attributes = System.IO.File.GetAttributes(p_DestinationFullFileName);
System.IO.File.SetAttributes(p_DestinationFullFileName,l_attributes|System.IO.FileAttributes.ReadOnly);
}
public void GetLatestVersion(SourceItem p_File, string p_DestinationPath)
{
SourceFileInfo l_Latest = p_File.LatestFile;
if (l_Latest==null)
throw new ApplicationException("Invalid file, latest version not found");
InternalGetLatestVersion(l_Latest,p_DestinationPath,p_File.Name);
}
private const string c_TAG_CHECKOUT = "COUT";
private const string c_TAG_HISTORY = "HIST";
public SourceFileInfo ParseFileName(FileSystem.File p_File)
{
#region Help
// SPIEGAZIONIE DEI CODICI
// pippo.cs //latest version
// pippo.cs.dav.COUT //file in check-out da 'dav'
// pippo.cs.dav.2.HIST //file storico versione 2
// Un file non in check-out
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -