public bool Receive(Point16 location, Item item)
        {
            TransferAgent agent = ModContent.GetInstance <TransferAgent>();

            Tile tile = Main.tile[location.X, location.Y];

            if (tile.frameX == 0)
            {
                int decrement = agent.StartTransfer(location.X + 1, location.Y, item);
                item.stack -= decrement;
                if (decrement != 0)
                {
                    agent.TripWireDelayed(location.X, location.Y, 2, 1);
                    return(true);
                }
            }
            else if (tile.frameX == 54)
            {
                int decrement = agent.StartTransfer(location.X - 1, location.Y, item);
                item.stack -= decrement;
                if (decrement != 0)
                {
                    agent.TripWireDelayed(location.X - 1, location.Y, 2, 1);
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Write the file to the destination server, using FTP (if WebDAV isn't available)
        /// </summary>
        public void CreatePoint_FTP()
        {
            var dest = new Uri(Server, PublishPointName);

            dest = new Uri(dest.ToString().Replace("http://", "ftp://"));
            var ms = new MemoryStream(Generate());

            TransferAgent.Transfer(ms, dest);
        }
Exemple #3
0
        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Synchronization);
            Assert.IsNotNull(Synchronization.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Synchronization.StorageAccountType);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

            Models.AmazonS3Account s3account = dao.GetForReadOnly(Synchronization.StorageAccount.Id);

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (SyncAgent != null)
            {
                SyncAgent.Dispose();
            }

            //
            // Setup agents.
            //
            AWSCredentials       awsCredentials = new BasicAWSCredentials(s3account.AccessKey, s3account.SecretKey);
            TransferAgentOptions options        = new TransferAgentOptions
            {
                UploadChunkSizeInBytes = Teltec.Everest.Settings.Properties.Current.UploadChunkSize * 1024 * 1024,
            };

            TransferAgent = new S3TransferAgent(options, awsCredentials, s3account.BucketName, CancellationTokenSource.Token);
            TransferAgent.RemoteRootDir = TransferAgent.PathBuilder.CombineRemotePath("TELTEC_BKP", s3account.Hostname);

            RemoteObjects = new List <ListingObject>(4096);            // Avoid small resizes without compromising memory.
            SyncAgent     = new CustomSynchronizationAgent(TransferAgent);

            RegisterEventHandlers(Synchronization);

            Report.PlanType    = "synchronization";
            Report.PlanName    = "No plan";
            Report.BucketName  = s3account.BucketName;
            Report.HostName    = Synchronization.StorageAccount.Hostname;
            Report.SyncResults = SyncAgent.Results;

            //
            // Start the sync.
            //
            DoSynchronization(SyncAgent, Synchronization, Options);
        }
Exemple #4
0
        /// <summary>
        /// Creates a thread that runs the delivey process
        /// </summary>
        /// <param name="mta">message transer agent to take care of sending</param>
        /// <param name="provider">message provider</param>
        /// <returns>spawned thread</returns>
        static Thread SpawnDeliveryAgent(TransferAgent.MessageTransferAgent mta, TransferAgent.MessageProvider provider)
        {
            var messenger = new TransferAgent.RoundRobinMessenger(mta, provider);
            var t = new Thread(() => messenger.Deliver());
            t.Start();

            // We do not want the delivery thread to stop the termination of the application
            t.IsBackground = true;

            return t;
        }
Exemple #5
0
        /// <summary>
        /// 查询转账信息
        /// </summary>
        /// <param name="site">商户</param>
        /// <param name="game">游戏配置</param>
        /// <param name="orderId">商户的转账订单号</param>
        /// <returns></returns>
        public QueryTransferResult QueryTransfer(Site site, GameSetting game, string orderId)
        {
            // 加锁,不允许对同一个订单号进行并发查询
            lock (LockHelper.GetLoker($"{game.ID}-{orderId}"))
            {
                UserTransfer order = TransferAgent.Instance().GetUserTransfer(site.ID, game.ID, orderId);
                if (order == null)
                {
                    return(new QueryTransferResult(ResultStatus.NoOrder));
                }
                if (order.Status == TransferStatus.Paying)
                {
                    return(new QueryTransferResult(ResultStatus.OrderPaying));
                }

                if (order.Status == TransferStatus.Exception)
                {
                    UserGame user = UserAgent.Instance().GetUserGameInfo(order.UserID, game.ID);
                    // 调用API接口
                    ResultStatus status = game.Setting.QueryTransfer(new QueryTransferInfo()
                    {
                        UserName = user.Account,
                        OrderID  = orderId,
                        Currency = site.Currency
                    });
                    if (status == ResultStatus.Exception)
                    {
                        return(new QueryTransferResult(ResultStatus.Exception));
                    }

                    order.Status = status == ResultStatus.Success ? TransferStatus.Success : TransferStatus.Faild;
                    this.WriteDB.Update(order, t => t.Status);
                }

                if (order.Status == TransferStatus.Success)
                {
                    return(new QueryTransferResult(order.Money, order.CreateAt, UserAgent.Instance().GetUserName(order.UserID), order.Action, site.Currency));
                }

                return(new QueryTransferResult(ResultStatus.OrderFaild));
            }
        }
Exemple #6
0
 public override void DoImplementation(IVersionedFile file, object userData)
 {
     TransferAgent.DownloadVersionedFile(file.Path, file.Version, userData);
 }
Exemple #7
0
 public override void DoImplementation(string prefix, bool recursive, object userData)
 {
     TransferAgent.List(prefix, recursive, userData);
 }
Exemple #8
0
        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Restore);
            Assert.IsNotNull(Restore.RestorePlan.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Restore.RestorePlan.StorageAccountType);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

            Models.AmazonS3Account s3account = dao.GetForReadOnly(Restore.RestorePlan.StorageAccount.Id);

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (RestoreAgent != null)
            {
                RestoreAgent.Dispose();
            }
            if (Versioner != null)
            {
                Versioner.Dispose();
            }

            //
            // Setup agents.
            //
            AWSCredentials       awsCredentials = new BasicAWSCredentials(s3account.AccessKey, s3account.SecretKey);
            TransferAgentOptions options        = new TransferAgentOptions
            {
                UploadChunkSizeInBytes = Teltec.Everest.Settings.Properties.Current.UploadChunkSize * 1024 * 1024,
            };

            TransferAgent = new S3TransferAgent(options, awsCredentials, s3account.BucketName, CancellationTokenSource.Token);
            TransferAgent.RemoteRootDir = TransferAgent.PathBuilder.CombineRemotePath("TELTEC_BKP",
                                                                                      Restore.RestorePlan.StorageAccount.Hostname);

            RestoreAgent = new CustomRestoreAgent(TransferAgent);
            RestoreAgent.Results.Monitor = TransferListControl;

            Versioner = new RestoreFileVersioner(CancellationTokenSource.Token);

            RegisterResultsEventHandlers(Restore, RestoreAgent.Results);

            Report.PlanType        = "restore";
            Report.PlanName        = Restore.RestorePlan.Name;
            Report.BucketName      = s3account.BucketName;
            Report.HostName        = Restore.RestorePlan.StorageAccount.Hostname;
            Report.TransferResults = RestoreAgent.Results;

            Helper = new BaseOperationHelper(Restore.RestorePlan);

            //
            // Start the restore.
            //
            DoRestore(RestoreAgent, Restore, Options);
        }
Exemple #9
0
 public void DeleteVersionedFile(string sourcePath, IFileVersion version, object identifier)
 {
     TransferAgent.DeleteVersionedFile(sourcePath, version, identifier);
 }