コード例 #1
0
        /// <summary>
        /// File transmission completed.
        /// </summary>
        /// <param name="transferingProject">transfering project</param>
        void FileReceivingEvents_FileTransCompleted(TransferingProject transferingProject)
        {
            try
            {
                mFileCountAlreadyUpdated++;
                if (mFileCountAlreadyUpdated < mFileCountNeedUpdated)
                {
                    DownloadNextFile();
                    return;
                }

                string destinationPath = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName + "\\";
                string sourcePath      = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
                if (!Directory.Exists(sourcePath))
                {
                    Directory.CreateDirectory(sourcePath);
                }

                foreach (string fileRelativePath in mFileRelativePathListNeedDownloaded)
                {
                    string destinationFile = destinationPath + fileRelativePath;
                    string sourceFile      = sourcePath + fileRelativePath;
                    if (File.Exists(sourceFile))
                    {
                        File.Copy(sourceFile, destinationFile, true);
                    }
                }
                FileHelper.DeleteDirectory(sourcePath);

                foreach (FileUnit file in mFileListNeedRemoved)
                {
                    FileHelper.DeleteFile(destinationPath + file.FileRelativePath);
                }

                mUpdateConfiguration.Save();
                Event_UpdateCompleted?.Invoke();
            }
            catch (Exception e)
            {
                mLogger.Log(e, "Upgrade.Updater.UdpateThread", ErrorLevel.High);
                Event_UpdateDisruptted?.Invoke(FileTransDisrupttedType.InnerError.ToString());
            }
        }
コード例 #2
0
        public T ForceGet(int i_Id)
        {
            T      result;
            string key = i_Id.ToString();

            r_ReadWritelock.AcquireReaderLock(Timeout.Infinite);
            bool wasCached = m_CachedData.TryGetValue(key, out result);

            try
            {
                var    response = r_Repository.Get(i_Id);
                string obj      = response.Content;
                if (!response.Success || response.Content == null)
                {
                    throw new Exception(response.ErrorMessage);
                }

                result = r_Serializer.Deserialize <T>(obj);
                m_CachedData[result.Id.ToString()] = result;
            }
            finally
            {
                r_ReadWritelock.ReleaseReaderLock();
            }

            if (wasCached)
            {
                Event_UpdateCompleted?.Invoke(this, new CacheEventArgs()
                {
                    Key = key
                });
            }
            else
            {
                Event_GetCompleted?.Invoke(this, new CacheEventArgs()
                {
                    Key = key
                });
            }

            return(deepCopy(result));
        }
コード例 #3
0
        /// <summary>
        /// Update thread.
        /// </summary>
        private void UdpateThread()
        {
            try
            {
                mRapidPassiveEngine.FileOutter.FileRequestReceived += new ESPlus.Application.FileTransfering.CbFileRequestReceived(FileOutter_FileRequestReceived);
                mRapidPassiveEngine.FileOutter.FileReceivingEvents.FileTransStarted    += new CbGeneric <TransferingProject>(FileReceivingEvents_FileTransStarted);
                mRapidPassiveEngine.FileOutter.FileReceivingEvents.FileTransCompleted  += new CbGeneric <TransferingProject>(FileReceivingEvents_FileTransCompleted);
                mRapidPassiveEngine.FileOutter.FileReceivingEvents.FileTransDisruptted += new CbGeneric <TransferingProject, FileTransDisrupttedType>(FileReceivingEvents_FileTransDisruptted);
                mRapidPassiveEngine.FileOutter.FileReceivingEvents.FileTransProgress   += new CbFileSendedProgress(FileReceivingEvents_FileTransProgress);

                if (mFileRelativePathListNeedDownloaded.Count <= 0)
                {
                    if (mFileListNeedRemoved.Count > 0)
                    {
                        foreach (FileUnit file in mFileListNeedRemoved)
                        {
                            FileHelper.DeleteFile(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName
                                                  + "\\" + file.FileRelativePath);
                        }
                        mUpdateConfiguration.Save();
                        Event_UpdateCompleted?.Invoke();
                    }
                    return;
                }

                DownloadFileContract downLoadFileContract = new DownloadFileContract
                {
                    FileName = mFileRelativePathListNeedDownloaded[0]
                };
                mRapidPassiveEngine.CustomizeOutter.Send(InformationTypes.DownloadFiles, CompactPropertySerializer.Default.Serialize(downLoadFileContract));
            }
            catch (Exception e)
            {
                mLogger.Log(e, "Upgrade.Updater.UdpateThread", ErrorLevel.High);
                Event_UpdateDisruptted?.Invoke(FileTransDisrupttedType.InnerError.ToString());
            }
        }
コード例 #4
0
        public void Update(T i_Obj)
        {
            r_ReadWritelock.AcquireWriterLock(Timeout.Infinite);
            try
            {
                string json     = r_Serializer.Serialize(i_Obj);
                string key      = i_Obj.Id.ToString();
                var    response = r_Repository.Update(key, json);
                if (!response.Success)
                {
                    throw new Exception(response.ErrorMessage);
                }

                m_CachedData[key] = deepCopy(i_Obj);
                Event_UpdateCompleted?.Invoke(this, new CacheEventArgs()
                {
                    Key = key
                });
            }
            finally
            {
                r_ReadWritelock.ReleaseWriterLock();
            }
        }