///<summary> /// check that an up-to-date content exists in the cache folder for 'url'. ///</summary> /// <param name="url">URL to a cached file, excluding the server-side time stamp, e.g. /MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml.</param> /// <param name="remoteTime">modification time of the file on the server side.</param> ///<returns>true if content exists for 'url' and matches 'remoteTime'.</returns> public bool CheckFile(string url, string remoteTime) { bool upToDateContentFound = false; lock (this) { String localFilename = URLToLocalFileName(url); String localTime = HandleFiles.getFileTime(localFilename); upToDateContentFound = (HandleFiles.equals(localTime, remoteTime)); } return(upToDateContentFound); }
/// <summary> /// get content from the cache; if the cached content's loading time differs from 'remoteTime', return null. /// </summary> /// <param name="url">URL to a cached file, excluding the server-side time stamp, e.g. /MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml.</param> /// <param name="remoteTime"></param> public byte[] GetFile(String url, String remoteTime) { lock (this) { byte[] content = null; String localFilename = URLToLocalFileName(url); String localTime = HandleFiles.getFileTime(localFilename); if (HandleFiles.equals(localTime, remoteTime)) { content = HandleFiles.readToByteArray(localFilename, ""); } return(content); } }
/// <summary> /// checks file exist with specified remote time. /// when remote time is null, then check only file is exist or not /// otherwise check if source with remotetime exist /// </summary> /// <param name="fileFullName">Full name of the file</param> /// <param name="remoteTime">last modification time of the file (for story#138618: remote time will be null)</param> /// <returns></returns> private bool IsFileExistWithRequestedTime(String fileFullName, String remoteTime) { bool isFileExist = HandleFiles.isExists(fileFullName); try { if (isFileExist && remoteTime != null) { String localTime = HandleFiles.getFileTime(fileFullName); if (!HandleFiles.equals(localTime, remoteTime)) { isFileExist = false; } } } catch (Exception exception) { Logger.Instance.WriteExceptionToLog(exception.Message); throw; } return(isFileExist); }