本文整理汇总了C#中JMMServer.Repositories.VideoLocalRepository.Save方法的典型用法代码示例。如果您正苦于以下问题:C# VideoLocalRepository.Save方法的具体用法?C# VideoLocalRepository.Save怎么用?C# VideoLocalRepository.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.VideoLocalRepository
的用法示例。
在下文中一共展示了VideoLocalRepository.Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVariationStatusOnFile
public string SetVariationStatusOnFile(int videoLocalID, bool isVariation)
{
try
{
VideoLocalRepository repVids = new VideoLocalRepository();
VideoLocal vid = repVids.GetByID(videoLocalID);
if (vid == null)
return "Could not find video record";
vid.IsVariation = isVariation ? 1 : 0;
repVids.Save(vid);
return "";
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
return ex.Message;
}
}
示例2: RenameFile
public Contract_VideoLocalRenamed RenameFile(int videoLocalID, string renameRules)
{
Contract_VideoLocalRenamed ret = new Contract_VideoLocalRenamed();
ret.VideoLocalID = videoLocalID;
ret.Success = true;
try
{
VideoLocalRepository repVids = new VideoLocalRepository();
VideoLocal vid = repVids.GetByID(videoLocalID);
if (vid == null)
{
ret.VideoLocal = null;
ret.NewFileName = string.Format("ERROR: Could not find file record");
ret.Success = false;
}
else
{
ret.VideoLocal = null;
ret.NewFileName = RenameFileHelper.GetNewFileName(vid, renameRules);
if (!string.IsNullOrEmpty(ret.NewFileName))
{
// check if the file exists
string fullFileName = vid.FullServerPath;
if (!File.Exists(fullFileName))
{
ret.NewFileName = "Error could not find the original file";
ret.Success = false;
return ret;
}
// actually rename the file
string path = Path.GetDirectoryName(fullFileName);
string newFullName = Path.Combine(path, ret.NewFileName);
try
{
logger.Info(string.Format("Renaming file From ({0}) to ({1})....", fullFileName, newFullName));
if (fullFileName.Equals(newFullName, StringComparison.InvariantCultureIgnoreCase))
{
logger.Info(string.Format("Renaming file SKIPPED, no change From ({0}) to ({1})", fullFileName, newFullName));
ret.NewFileName = newFullName;
}
else
{
File.Move(fullFileName, newFullName);
logger.Info(string.Format("Renaming file SUCCESS From ({0}) to ({1})", fullFileName, newFullName));
ret.NewFileName = newFullName;
string newPartialPath = "";
int folderID = vid.ImportFolderID;
ImportFolderRepository repFolders = new ImportFolderRepository();
DataAccessHelper.GetShareAndPath(newFullName, repFolders.GetAll(), ref folderID, ref newPartialPath);
vid.FilePath = newPartialPath;
repVids.Save(vid);
}
}
catch (Exception ex)
{
logger.Info(string.Format("Renaming file FAIL From ({0}) to ({1}) - {2}", fullFileName, newFullName, ex.Message));
logger.ErrorException(ex.ToString(), ex);
ret.Success = false;
ret.NewFileName = ex.Message;
}
}
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
ret.VideoLocal = null;
ret.NewFileName = string.Format("ERROR: {0}", ex.Message);
ret.Success = false;
}
return ret;
}
示例3: ProcessFile_LocalInfo
//.........这里部分代码省略.........
vlocal.HashSource = (int)HashSource.DirectHash;
}
// We should have a hash by now
// before we save it, lets make sure there is not any other record with this hash (possible duplicate file)
VideoLocal vidTemp = repVidLocal.GetByHash(vlocal.Hash);
if (vidTemp != null)
{
// don't delete it, if it is actually the same record
if (vidTemp.VideoLocalID != vlocal.VideoLocalID)
{
// delete the VideoLocal record
logger.Warn("Deleting duplicate video file record");
logger.Warn("---------------------------------------------");
logger.Warn("Keeping record for: {0}", vlocal.FullServerPath);
logger.Warn("Deleting record for: {0}", vidTemp.FullServerPath);
logger.Warn("---------------------------------------------");
// check if we have a record of this in the database, if not create one
DuplicateFileRepository repDups = new DuplicateFileRepository();
List<DuplicateFile> dupFiles = repDups.GetByFilePathsAndImportFolder(vlocal.FilePath, vidTemp.FilePath, vlocal.ImportFolderID, vidTemp.ImportFolderID);
if (dupFiles.Count == 0)
dupFiles = repDups.GetByFilePathsAndImportFolder(vidTemp.FilePath, vlocal.FilePath, vidTemp.ImportFolderID, vlocal.ImportFolderID);
if (dupFiles.Count == 0)
{
DuplicateFile dup = new DuplicateFile();
dup.DateTimeUpdated = DateTime.Now;
dup.FilePathFile1 = vlocal.FilePath;
dup.FilePathFile2 = vidTemp.FilePath;
dup.ImportFolderIDFile1 = vlocal.ImportFolderID;
dup.ImportFolderIDFile2 = vidTemp.ImportFolderID;
dup.Hash = vlocal.Hash;
repDups.Save(dup);
}
repVidLocal.Delete(vidTemp.VideoLocalID);
}
}
repVidLocal.Save(vlocal);
// also save the filename to hash record
// replace the existing records just in case it was corrupt
FileNameHash fnhash = null;
List<FileNameHash> fnhashes2 = repFNHash.GetByFileNameAndSize(Path.GetFileName(vlocal.FilePath), vlocal.FileSize);
if (fnhashes2 != null && fnhashes2.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 fnhashes2)
{
repFNHash.Delete(fnh.FileNameHashID);
}
}
if (fnhashes2 != null && fnhashes2.Count == 1)
fnhash = fnhashes2[0];
else
fnhash = new FileNameHash();
fnhash.FileName = Path.GetFileName(vlocal.FilePath);
fnhash.FileSize = vlocal.FileSize;
fnhash.Hash = vlocal.Hash;
fnhash.DateTimeUpdated = DateTime.Now;
repFNHash.Save(fnhash);
示例4: FixHashes
public static void FixHashes()
{
try
{
VideoLocalRepository repVids = new VideoLocalRepository();
foreach (VideoLocal vid in repVids.GetAll())
{
bool fixedHash = false;
if (vid.CRC32.Equals("00000000"))
{
vid.CRC32 = null;
fixedHash = true;
}
if (vid.MD5.Equals("00000000000000000000000000000000"))
{
vid.MD5 = null;
fixedHash = true;
}
if (vid.SHA1.Equals("0000000000000000000000000000000000000000"))
{
vid.SHA1 = null;
fixedHash = true;
}
if (fixedHash)
{
repVids.Save(vid);
logger.Info("Fixed hashes on file: {0}", vid.FullServerPath);
}
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
}
示例5: MoveFileIfRequired
public void MoveFileIfRequired()
{
// check if this file is in the drop folder
// otherwise we don't need to move it
if (this.ImportFolder.IsDropSource == 0) return;
if (!File.Exists(this.FullServerPath)) return;
// find the default destination
ImportFolder destFolder = null;
ImportFolderRepository repFolders = new ImportFolderRepository();
foreach (ImportFolder fldr in repFolders.GetAll())
{
if (fldr.IsDropDestination == 1)
{
destFolder = fldr;
break;
}
}
if (destFolder == null) return;
if (!Directory.Exists(destFolder.ImportFolderLocation)) return;
// we can only move the file if it has an anime associated with it
List<CrossRef_File_Episode> xrefs = this.EpisodeCrossRefs;
if (xrefs.Count == 0) return;
CrossRef_File_Episode xref = xrefs[0];
// find the series associated with this episode
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries series = repSeries.GetByAnimeID(xref.AnimeID);
if (series == null) return;
// find where the other files are stored for this series
// if there are no other files except for this one, it means we need to create a new location
bool foundLocation = false;
string newFullPath = "";
// sort the episodes by air date, so that we will move the file to the location of the latest episode
List<AnimeEpisode> allEps = series.GetAnimeEpisodes();
List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
sortCriteria.Add(new SortPropOrFieldAndDirection("AniDB_EpisodeID", true, SortType.eInteger));
allEps = Sorting.MultiSort<AnimeEpisode>(allEps, sortCriteria);
foreach (AnimeEpisode ep in allEps)
{
foreach (VideoLocal vid in ep.GetVideoLocals())
{
if (vid.VideoLocalID != this.VideoLocalID)
{
// make sure this folder is not the drop source
if (vid.ImportFolder.IsDropSource == 1) continue;
string thisFileName = vid.FullServerPath;
string folderName = Path.GetDirectoryName(thisFileName);
if (Directory.Exists(folderName))
{
newFullPath = folderName;
foundLocation = true;
break;
}
}
}
if (foundLocation) break;
}
if (!foundLocation)
{
// we need to create a new folder
string newFolderName = Utils.RemoveInvalidFolderNameCharacters(series.GetAnime().MainTitle);
newFullPath = Path.Combine(destFolder.ImportFolderLocation, newFolderName);
if (!Directory.Exists(newFullPath))
Directory.CreateDirectory(newFullPath);
}
int newFolderID = 0;
string newPartialPath = "";
string newFullServerPath = Path.Combine(newFullPath, Path.GetFileName(this.FullServerPath));
DataAccessHelper.GetShareAndPath(newFullServerPath, repFolders.GetAll(), ref newFolderID, ref newPartialPath);
logger.Info("Moving file from {0} to {1}", this.FullServerPath, newFullServerPath);
if (File.Exists(newFullServerPath))
{
// if the file already exists, we can just delete the source file instead
// this is safer than deleting and moving
File.Delete(this.FullServerPath);
this.ImportFolderID = newFolderID;
this.FilePath = newPartialPath;
VideoLocalRepository repVids = new VideoLocalRepository();
repVids.Save(this);
}
else
//.........这里部分代码省略.........
示例6: RenameFile
public void RenameFile(string renameScript)
{
string renamed = RenameFileHelper.GetNewFileName(this, renameScript);
if (string.IsNullOrEmpty(renamed)) return;
ImportFolderRepository repFolders = new ImportFolderRepository();
VideoLocalRepository repVids = new VideoLocalRepository();
// actually rename the file
string fullFileName = this.FullServerPath;
// check if the file exists
if (!File.Exists(fullFileName))
{
logger.Error("Error could not find the original file for renaming: " + fullFileName);
return;
}
// actually rename the file
string path = Path.GetDirectoryName(fullFileName);
string newFullName = Path.Combine(path, renamed);
try
{
logger.Info(string.Format("Renaming file From ({0}) to ({1})....", fullFileName, newFullName));
if (fullFileName.Equals(newFullName, StringComparison.InvariantCultureIgnoreCase))
{
logger.Info(string.Format("Renaming file SKIPPED, no change From ({0}) to ({1})", fullFileName, newFullName));
}
else
{
File.Move(fullFileName, newFullName);
logger.Info(string.Format("Renaming file SUCCESS From ({0}) to ({1})", fullFileName, newFullName));
string newPartialPath = "";
int folderID = this.ImportFolderID;
DataAccessHelper.GetShareAndPath(newFullName, repFolders.GetAll(), ref folderID, ref newPartialPath);
this.FilePath = newPartialPath;
repVids.Save(this);
}
}
catch (Exception ex)
{
logger.Info(string.Format("Renaming file FAIL From ({0}) to ({1}) - {2}", fullFileName, newFullName, ex.Message));
logger.ErrorException(ex.ToString(), ex);
}
}