コード例 #1
0
        /// <summary> Saves the initial response in the LastOffline file. </summary>
        /// <param name="initialResponse"></param>
        internal void SaveInitialResponseInLastOfflineFile(String initialResponse)
        {
            String fileName = GetLastOfflineExecutionPropertiesFileName();
            String fileTime = HandleFiles.getFileTime(fileName);

            LastOfflineExecutionProperties[ConstInterface.INITIAL_RESPONSE] = initialResponse;

            LastOfflineExecutionProperties.WriteToXMLFile(fileName);
            HandleFiles.setFileTime(fileName, fileTime);
        }
コード例 #2
0
 /// <summary>
 /// record an offline-required metadata + its local time
 /// </summary>
 /// <param name="requestedURL">complete cache file retrieval request to an offline-required metadata,
 /// e.g. http://[server]/[requester]?CTX=&CACHE=MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml|31/07/2013%2020:15:15</param>
 internal void Collect(string requestedURL)
 {
     if (Enabled)
     {
         string cachedFileServerFileName;
         string cachedFileLocalFileName;
         PersistentOnlyCacheManager.GetInstance().CompleteCacheRequestURLToFileNames(requestedURL, out cachedFileServerFileName, out cachedFileLocalFileName);
         Debug.Assert(HandleFiles.isExists(cachedFileLocalFileName));
         CollectedMetadata[cachedFileServerFileName] = HandleFiles.getFileTime(cachedFileLocalFileName);
     }
 }
コード例 #3
0
        ///<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);
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
ファイル: CommandsProcessorBase.cs プロジェクト: rinavin/RCJS
        /// <summary>
        /// Retrieve a file from the server to the client's default folder.
        /// In case the file wasn't modified since last retrieved, it will not be downloaded from the server
        ///   and will not be copied to the client's default folder.
        /// </summary>
        /// <param name="serverFileName">file name, as known in the server's file system.</param>
        /// <param name="currTask">the current executing task.</param>
        /// <returns>true if the file was found on the client's default folder.</returns>
        internal bool CopyToDefaultFolder(string serverFileName, Task currTask)
        {
            Debug.Assert(currTask != null);

            string clientFileName = (serverFileName.Substring(serverFileName.LastIndexOf('\\') + 1));
            string cachedFileName = GetLocalFileName(serverFileName, currTask, false);

            if (!String.IsNullOrEmpty(cachedFileName))
            {
                // if the file was modified since last retrieved, copy it from the client's cache to the client's default folder
                if (HandleFiles.getFileTime(cachedFileName) != HandleFiles.getFileTime(clientFileName))
                {
                    HandleFiles.copy(cachedFileName, clientFileName, true, false);
                }
            }

            return(HandleFiles.isExists(clientFileName));
        }
コード例 #6
0
        /// <summary>
        /// Saves an indication of unsynchronized metadata in LastOffline to instruct client to start in connected mode next time
        /// </summary>
        internal void SaveUnsyncronizedMetadataFlagInLastOfflineFile()
        {
            String fileName = GetLastOfflineExecutionPropertiesFileName();
            String fileTime = HandleFiles.getFileTime(fileName);

            MgProperties offlineExecutionProps = LastOfflineExecutionProperties.Clone();

            offlineExecutionProps.Add(ConstInterface.MG_TAG_UNSYNCRONIZED_METADATA, "Y");

            String initialResponse = offlineExecutionProps[ConstInterface.INITIAL_RESPONSE];

            if (GetLastOfflineExecutionPropertyBool(ConstInterface.DISABLE_ENCRYPTION))
            {
                initialResponse = XMLConstants.CDATA_START + OSEnvironment.EolSeq + initialResponse + OSEnvironment.EolSeq + XMLConstants.CDATA_END;
                offlineExecutionProps[ConstInterface.INITIAL_RESPONSE] = initialResponse;
            }

            offlineExecutionProps.WriteToXMLFile(fileName);
            HandleFiles.setFileTime(fileName, fileTime);
        }
コード例 #7
0
        /// <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);
        }