private List <PreparedTransfer> Stop(TransferBundle transferBundle) { if (TransferBundleState.Pended != transferBundle.State && TransferBundleState.Processed != transferBundle.State) { throw new InvalidOperationException("transferBundle.State == " + transferBundle.State); } transferBundle.State = TransferBundleState.Registered; transferBundle.UpdateTime = DateTime.UtcNow; var updatedTransfers = new List <PreparedTransfer>(); foreach (var transfer in transferBundle.Transfers) { if (PreparedTransferState.Pended != transfer.State) { continue; } transfer.State = PreparedTransferState.Registered; transfer.UpdateTime = DateTime.UtcNow; transferBundle.PendedCount--; transferBundle.PendedTotalAmount -= transfer.Amount; transferBundle.RegisteredCount++; transferBundle.RegisteredTotalAmount += transfer.Amount; updatedTransfers.Add(transfer); } return(updatedTransfers); }
public void SetItems(IEnumerable <Item> items) { //如果会话开始,不再允许赋值。 if (IsStarted) { throw new Exception("Conversation already started. Can not change sending items. Please call SuperDriveCore::Create to start another conversation"); } foreach (var v in items) { var o = (Item)v.Clone(); o.ConversationID = Id; o.Name = v.Name; o.RelativePath = ""; //全是顶层的item. o.AbsolutePath = System.IO.Path.Combine(Path, o.Name); o.IsRemote = true; TransferBundle.AddItem(o); } }
public TransferBundle GetTransferBundle(String apbnKey, String regionId) { //if (KawalDesaController.GetCurrentUser() == null &®ionId == "0") // return GetInScopeTransferBundle(apbnKey); var region = GetRegion(regionId); var result = new TransferBundle { Region = region }; if (region.Type < RegionType.DESA) { result.TransferRecapitulations = db.TransferRecapitulations .Where(r => r.ApbnKey == apbnKey && (r.RegionId == regionId || r.ParentRegionId == regionId)) .ToList(); } else { string syear = apbnKey; if (apbnKey.Length > 4) { syear = apbnKey.Substring(0, 4); } int year = Convert.ToInt32(syear); result.Transfers = db.Transfers .Include(e => e.SourceDocuments) .Where(e => e.Year == year && e.IsActivated && e.fkRegionId == regionId) .ToList(); } result.TransferProgress = db.TransferProgresses .Where(r => r.RegionId == regionId && r.ApbnKey == apbnKey) .ToList(); return(result); }
public TransferBundle GetInScopeTransferBundle(string apbnKey) { var region = GetRegion("0"); var result = new TransferBundle { Region = region, }; var scopedRegionIds = db.Regions.Where(r => r.IsInScope).Select(r => r.Id).ToList(); result.TransferRecapitulations = db.TransferRecapitulations .Where(r => r.ApbnKey == apbnKey && (scopedRegionIds.Contains(r.RegionId))) .ToList(); var total = new TransferRecapitulation { ApbnKey = apbnKey, RegionId = "0", RegionName = region.Name }; foreach (var recap in result.TransferRecapitulations) { total.BudgetedDd += recap.BudgetedDd; total.BudgetedAdd += recap.BudgetedAdd; total.BudgetedBhpr += recap.BudgetedBhpr; } result.TransferRecapitulations.Add(total); result.TransferProgress = db.TransferProgresses .Where(r => r.ApbnKey == apbnKey && (scopedRegionIds.Contains(r.RegionId))) .ToList(); result.TransferRecapitulations.Add(total); return(result); }
public TransferBundleNotification(TransferBundle transferBundle) { TransferBundle = transferBundle ?? throw new ArgumentNullException(nameof(transferBundle)); }
public int RegisterBundle(IEnumerable <IOriginalTransfer> transfers, string name) { if (null == transfers) { throw new ArgumentNullException(nameof(transfers)); } if (null == name) { throw new ArgumentNullException(nameof(name)); } var transferList = transfers.ToList(); if (0 == transferList.Count) { throw new ArgumentOutOfRangeException(nameof(transfers)); } if (!Session.AuthenticationService.HasConnectionSettings) { throw new InvalidOperationException("!Session.AuthenticationService.HasConnectionSettings"); } string sourceAccountName = transferList.First().SourcePurse; if (null == sourceAccountName) { throw new ArgumentException("null == sourceAccountName"); } foreach (var originalTransfer in transferList) { if (!sourceAccountName.Equals(originalTransfer.SourcePurse)) { throw new ArgumentException("!sourceAccountName.Equals(originalTransfer.SourcePurse)"); } } var preparedTransfers = transferList.Select( t => new PreparedTransfer(t.PaymentId, t.SourcePurse, t.TargetPurse, t.Amount, t.Description)) .ToList(); var totalAmount = preparedTransfers.Sum(t => t.Amount); var transferBundle = new TransferBundle(Session.CurrentIdentifier, name, sourceAccountName, transferList.Count, totalAmount) { Name = name }; transferBundle.Transfers.AddRange(preparedTransfers); using (var context = new DataContext(Session.AuthenticationService.GetConnectionSettings())) { context.TransferBundles.Add(transferBundle); context.SaveChanges(); } return(transferBundle.Id); }