本文整理汇总了C#中JMMServer.Repositories.VideoLocalRepository.GetByFilePathAndShareID方法的典型用法代码示例。如果您正苦于以下问题:C# VideoLocalRepository.GetByFilePathAndShareID方法的具体用法?C# VideoLocalRepository.GetByFilePathAndShareID怎么用?C# VideoLocalRepository.GetByFilePathAndShareID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.VideoLocalRepository
的用法示例。
在下文中一共展示了VideoLocalRepository.GetByFilePathAndShareID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessFile_LocalInfo
private VideoLocal ProcessFile_LocalInfo()
{
// hash and read media info for file
int nshareID = -1;
string filePath = "";
ImportFolderRepository repNS = new ImportFolderRepository();
List<ImportFolder> shares = repNS.GetAll();
DataAccessHelper.GetShareAndPath(FileName, shares, ref nshareID, ref filePath);
if (!File.Exists(FileName))
{
logger.Error("File does not exist: {0}", FileName);
return null;
}
int numAttempts = 0;
// Wait 3 minutes seconds before giving up on trying to access the file
while ((!CanAccessFile(FileName)) && (numAttempts < 180))
{
numAttempts++;
Thread.Sleep(1000);
Console.WriteLine("Attempt # " + numAttempts.ToString());
}
// if we failed to access the file, get ouuta here
if (numAttempts == 180)
{
logger.Error("Could not access file: " + FileName);
return null;
}
// check if we have already processed this file
VideoLocal vlocal = null;
VideoLocalRepository repVidLocal = new VideoLocalRepository();
FileNameHashRepository repFNHash = new FileNameHashRepository();
List<VideoLocal> vidLocals = repVidLocal.GetByFilePathAndShareID(filePath, nshareID);
FileInfo fi = new FileInfo(FileName);
if (vidLocals.Count > 0)
{
vlocal = vidLocals[0];
logger.Trace("VideoLocal record found in database: {0}", vlocal.VideoLocalID);
if (ForceHash)
{
vlocal.FileSize = fi.Length;
vlocal.DateTimeUpdated = DateTime.Now;
}
}
else
{
logger.Trace("VideoLocal, creating new record");
vlocal = new VideoLocal();
vlocal.DateTimeUpdated = DateTime.Now;
vlocal.DateTimeCreated = vlocal.DateTimeUpdated;
vlocal.FilePath = filePath;
vlocal.FileSize = fi.Length;
vlocal.ImportFolderID = nshareID;
vlocal.Hash = "";
vlocal.CRC32 = "";
vlocal.MD5 = "";
vlocal.SHA1 = "";
vlocal.IsIgnored = 0;
vlocal.IsVariation = 0;
}
// check if we need to get a hash this file
Hashes hashes = null;
if (string.IsNullOrEmpty(vlocal.Hash) || ForceHash)
{
// try getting the hash from the CrossRef
if (!ForceHash)
{
CrossRef_File_EpisodeRepository repCrossRefs = new CrossRef_File_EpisodeRepository();
List<CrossRef_File_Episode> crossRefs = repCrossRefs.GetByFileNameAndSize(Path.GetFileName(vlocal.FilePath), vlocal.FileSize);
if (crossRefs.Count == 1)
{
vlocal.Hash = crossRefs[0].Hash;
vlocal.HashSource = (int)HashSource.DirectHash;
}
}
// try getting the hash from the LOCAL cache
if (!ForceHash && string.IsNullOrEmpty(vlocal.Hash))
{
List<FileNameHash> fnhashes = repFNHash.GetByFileNameAndSize(Path.GetFileName(vlocal.FilePath), vlocal.FileSize);
if (fnhashes != null && fnhashes.Count > 1)
{
// if we have more than one record it probably means there is some sort of corruption
// lets delete the local records
foreach (FileNameHash fnh in fnhashes)
{
repFNHash.Delete(fnh.FileNameHashID);
}
}
if (fnhashes != null && fnhashes.Count == 1)
{
//.........这里部分代码省略.........