private void ParseOrigination() { var header = ParseHeader(); var managerID = ParseIdentityID(); var balance = ParseAmount(); var spendable = ParseBool(); var delegatable = ParseBool(); var hasDelegate = ParseBool(); if (hasDelegate) { var delegateID = ParseIdentityID(); } var hasScript = ParseBool(); if (hasScript) { throw new NotImplementedException("Scripts not implemented yet."); } Transfers.Add(new Transfer { Kind = "Origination", SourceID = header.SourceID, Amount = balance, Fee = header.Fee, }); }
public void AddTransfer(TransferBase transfer) { lock (_transferLock) { Steam.SteamBase.UiDispatcher.Invoke((Action)(() => Transfers.Add(transfer))); } }
/// <summary> /// Adds a newly created transfer object to the store. /// </summary> /// <param name="transfer">The transfer to be stored.</param> public virtual void AddTransfer(TTransfer transfer) { lock (SyncRoot) { Transfers.Add(transfer.Token.TransferId, transfer); } }
public void QueueTransfer(string fileName) { try { //We will create our upload queue. TransferQueue queue = TransferQueue.CreateUploadQueue(this, fileName); //Add the transfer to our transfer list. Transfers.Add(queue.ID, queue); //Now we will create and build our queue packet. PacketWriter pw = new PacketWriter(); pw.Write((byte)Headers.Queue); pw.Write(queue.ID); pw.Write(queue.Filename); pw.Write(queue.Length); Send(pw.GetBytes()); //Call queued if (Queued != null) { Queued(this, queue); } } catch { } }
private void AddUploadHandle(TransferHandle h) { Invoke(() => Transfers.Add(h)); h.PropertyChanged += (source, e) => { if (e.PropertyName == "Status") { if (((TransferHandle)source).Status == TransferHandleStatus.Uploading) { Status = ConnectivityStatus.Uploading; } else { if (Transfers.All(t => t.Status == TransferHandleStatus.Success || t.Status == TransferHandleStatus.Cancelled || t.Status == TransferHandleStatus.Error)) { Status = ConnectivityStatus.Online; } } } }; h.TransferEnded += (s1, e1) => { AppendNode(h.Node); }; }
public void AddTransfer(Transfer transfer) { if (transfer.Id == null) { transfer.SetId(); } Transfers.Add(transfer); }
internal void AddTransferCash(double value, DateTime date, Account accOut, Account accIn) { var transfer = new TransferCash(date, accOut, accIn, value); Transfers.Add(transfer); transfer.Move(value); SaveAccounts(); SaveTransfers(); }
private void AddDownloadHandle(TransferHandle h) { Invoke(() => Transfers.Add(h)); h.TransferEnded += (s1, e1) => { if (Transfers.All(t => t.Progress >= 100)) { Status = ConnectivityStatus.Online; } }; }
public TransactionRequest AddTransfer(string address, ulong value) { Transfers ??= new List <TransferDto>(); Transfers.Add(new TransferDto { Address = address, Value = value, }); return(this); }
private void tsbNewTransfer_Click(object sender, System.EventArgs e) { var frm = new TransferForm(_hotel); // создаем форму frm.Build(new Transfer(_hotel)); // создаём "пустую" услугу и заполняем контролы формы // показываем форму в диалоге if (frm.ShowDialog(this) == DialogResult.OK) { var transfer = frm.Data; _transfers.Add(transfer); // добавляем в список услуг FillTable(); // перестраиваем таблицу } }
private void AddTransfer(OneFileTransferModel fileTransferModel) { var fileTransferViewModel = new OneFileTransferViewModel(this, fileTransferModel); if (Transfers.Contains(fileTransferViewModel)) { return; } Transfers.Add(fileTransferViewModel); if (VisualStates.BlockState == FileTransfersVisualStates.TransfersBlockState.Invisible) { VisualStates.BlockState = FileTransfersVisualStates.TransfersBlockState.Open; } }
public void TransferTimber(Person person, Building building) { if (Settings.IsVerbose) { Console.WriteDebugLine("Transferring " + building.TimberPending + " timber from person to building."); } // TODO: Clean up //if (Context.Settings.OutputType == ConsoleOutputType.Debug // && Context.Settings.PlayerId == person.Id) { // Console.WriteDebugLine ("Transferring " + building.TimberPending + " timber from person to building."); //} Transfers.Add(new ItemTransfer(person, building, ItemType.Timber, building.TimberPending)); }
public void onTransferStart(MegaSDK api, MTransfer transfer) { TransferObjectModel megaTransfer = null; if (transfer.getType() == MTransferType.TYPE_DOWNLOAD) { // If is a public node MNode node = transfer.getPublicMegaNode(); if (node == null) // If not { node = api.getNodeByHandle(transfer.getNodeHandle()); } if (node != null) { megaTransfer = new TransferObjectModel(api, NodeService.CreateNew(api, App.AppInformation, node, ContainerType.CloudDrive), TransferType.Download, transfer.getPath()); } } else { megaTransfer = new TransferObjectModel(api, App.MainPageViewModel.CloudDrive.FolderRootNode, TransferType.Upload, transfer.getPath()); } if (megaTransfer != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { TransfersService.GetTransferAppData(transfer, megaTransfer); megaTransfer.Transfer = transfer; megaTransfer.Status = TransferStatus.Queued; megaTransfer.CancelButtonState = true; megaTransfer.TransferButtonIcon = new Uri("/Assets/Images/cancel transfers.Screen-WXGA.png", UriKind.Relative); megaTransfer.TransferButtonForegroundColor = new SolidColorBrush(Colors.White); megaTransfer.IsBusy = true; megaTransfer.TotalBytes = transfer.getTotalBytes(); megaTransfer.TransferedBytes = transfer.getTransferredBytes(); megaTransfer.TransferSpeed = transfer.getSpeed().ToStringAndSuffixPerSecond(); App.MegaTransfers.Add(megaTransfer); Transfers.Add(megaTransfer); }); } }
/// <summary> /// Requests a download token for a given resource. /// </summary> /// <param name="resourceIdentifier"></param> /// <param name="includeFileHash">Whether a file hash for the /// requested resource should be calculated and assigned to the /// <see cref="DownloadToken.Md5FileHash"/> property of the returned /// <see cref="DownloadToken"/>.</param> /// <returns></returns> public DownloadToken RequestDownloadToken(string resourceIdentifier, bool includeFileHash) { FileInfo fileInfo = FileResolveFunc(resourceIdentifier); if (!fileInfo.Exists) { string msg = String.Format("Resource [{0}] not found.", resourceIdentifier); throw new VirtualResourceNotFoundException(msg); } string transferId = Guid.NewGuid().ToString(); DownloadToken dt = new DownloadToken { TransferId = transferId, ResourceIdentifier = resourceIdentifier, CreationTime = SystemTime.Now(), ContentType = ContentUtil.ResolveContentType(fileInfo.Extension), DownloadBlockSize = 512 * 1024, //TODO configure block size and expiration ResourceName = fileInfo.Name, ResourceLength = fileInfo.Length, ExpirationTime = SystemTime.Now().AddHours(24), Status = TransferStatus.Starting }; //calculate number of blocks long count = dt.ResourceLength / dt.DownloadBlockSize.Value; if (dt.ResourceLength % dt.DownloadBlockSize != null) { count++; } dt.TotalBlockCount = count; if (includeFileHash) { dt.Md5FileHash = fileInfo.CalculateMd5Hash(); } var transfer = new DownloadTransfer(dt) { File = fileInfo }; Transfers.Add(transferId, transfer); return(dt); }
private void DetermineJournalModel(JournalModel journalNote) { switch (journalNote) { case TransferToAccountModel transferToAccountModel: Transfers.Add(transferToAccountModel); break; case CreditRepaymentModel creditRepaymentModel: CreditRepayments.Add(creditRepaymentModel); break; case NotificationModel notificationModel: Notifications.Add(notificationModel); break; } }
internal TokenTransferList(Address token, Address fromAddress, Address toAddress, long amount) : this() { if (fromAddress is null) { throw new ArgumentNullException(nameof(toAddress), "Account to transfer from is missing. Please check that it is not null."); } if (toAddress is null) { throw new ArgumentNullException(nameof(toAddress), "Account to transfer to is missing. Please check that it is not null."); } if (amount < 1) { throw new ArgumentOutOfRangeException(nameof(amount), "The amount to transfer must be non-negative."); } Token = new TokenID(token); Transfers.Add(new AccountAmount(fromAddress, -amount)); Transfers.Add(new AccountAmount(toAddress, amount)); }
// Transfers Context Menu private async void newToolStripMenuItem_Click(object sender, EventArgs e) { if (Clipboard.GetText().ToString().StartsWith("magnet:")) { string url = Clipboard.GetText().ToString(); var file = treeViewPutioFiles.SelectedNode.Tag as PutioFile; var option = MessageBox.Show(string.Format("Download {0} to {1}", magnet(url), file.name), "test", MessageBoxButtons.OKCancel); if (option == DialogResult.OK) { await trfrmgr.Add(url, file.id); GetTransfers(); } } else { MessageBox.Show("Copy a magnet link and try again", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Initialize() { if (!Transfers.Any()) { Transfers.Add(new Transfer { Carrying = 1000, Name = "Transfer 1", Status = 0 }); Transfers.Add(new Transfer { Carrying = 2000, Name = "Transfer 2", Status = 0 }); Transfers.Add(new Transfer { Carrying = 3000, Name = "Transfer 3", Status = 0 }); Transfers.Add(new Transfer { Carrying = 4000, Name = "Transfer 4", Status = 0 }); Transfers.Add(new Transfer { Carrying = 5000, Name = "Transfer 5", Status = 0 }); Transfers.Add(new Transfer { Carrying = 6000, Name = "Transfer 6", Status = 0 }); Transfers.Add(new Transfer { Carrying = 7000, Name = "Transfer 7", Status = 0 }); Transfers.Add(new Transfer { Carrying = 8000, Name = "Transfer 81", Status = 0 }); Transfers.Add(new Transfer { Carrying = 8000, Name = "Transfer 82", Status = 0 }); Transfers.Add(new Transfer { Carrying = 8000, Name = "Transfer 83", Status = 0 }); Transfers.Add(new Transfer { Carrying = 8000, Name = "Transfer 84", Status = 0 }); SaveChanges(); } }
private void AddTransfer(string path) { if (path != null && Path.GetExtension(path) != ".torrent") { IOService.ShowErrorMessage("Not a valid torrent file", "Only files with a .torrent extension are recognized as valid."); return; } try { string filePath = path == null?IOService.OpenFile("Torrent files|*.torrent") : path; string saveFolder = null; if (!string.IsNullOrEmpty(filePath)) { saveFolder = IOService.OpenFolder(Path.GetFileName(path)); } if (filePath != null && saveFolder != null) { var transfer = new Transfer(new TorrentTransfer(filePath, saveFolder)); if (!Transfers.Any(t => t.InfoHash == transfer.InfoHash)) { Transfers.Add(transfer); } else { IOService.ShowErrorMessage("Torrent transfer already exists", string.Format("{0} is already added and can not be added again.", path)); } } } catch (Exception e) { Trace.WriteLine("Exception when adding transfer " + e); IOService.ShowErrorMessage("Adding transfer failed", string.Format("Adding transfer failed due to: {0}", e.Message)); } }
private async Task UpdateTransfers(HostState hostState) { await hostState.BoincState.UpdateFileTransfers(); if (!_useObservableCollections) { return; } foreach (BoincRpc.FileTransfer fileTransfer in hostState.BoincState.FileTransfers) { ObservableTransfer transfer = Transfers.FirstOrDefault(tvm => tvm.HostId == hostState.Id && tvm.FileName == fileTransfer.Name); if (transfer == null) { transfer = new ObservableTransfer(hostState, fileTransfer); if (string.IsNullOrEmpty(SearchString)) { Transfers.Add(transfer); } else { foreach (var content in transfer.GetContentsForFiltering()) { if (content != null && content.IndexOf(SearchString, StringComparison.InvariantCultureIgnoreCase) != -1) { // The search string is found in any of the Models's property Transfers.Add(transfer); break; } } } } else { transfer.Update(fileTransfer); } } }
private void ParseTransaction() { var header = ParseHeader(); var amount = ParseAmount(); var destinationID = ParseAccountID(); var hasParameters = ParseBool(); if (hasParameters) { throw new NotImplementedException("Parameters not implemented yet."); } Transfers.Add(new Transfer { Kind = "Transfer", SourceID = header.SourceID, DestinationID = destinationID, Amount = amount, Fee = header.Fee, }); }
private void process() { PacketReader pr = new PacketReader(_Buffer); //Create our packet reader. Headers header = (Headers)pr.ReadByte(); //Read and cast our header. switch (header) { case Headers.Queue: { //Read the ID, Filename and length of the file (For progress) from the packet. int id = pr.ReadInt32(); string fileName = pr.ReadString(); long length = pr.ReadInt64(); //Create our download queue. TransferQueue queue = TransferQueue.CreateDownloadQueue(this, id, Path.Combine(OutputFolder, Path.GetFileName(fileName)), length); //Add it to our transfer list. Transfers.Add(id, queue); //Call queued. if (Queued != null) { Queued(this, queue); } } break; case Headers.Start: { //Read the ID int id = pr.ReadInt32(); //Start the upload. if (Transfers.ContainsKey(id)) { Transfers[id].Start(); } } break; case Headers.Stop: { //Read the ID int id = pr.ReadInt32(); if (Transfers.ContainsKey(id)) { //Get the queue. TransferQueue queue = Transfers[id]; //Stop and close the queue queue.Stop(); queue.Close(); //Call the stopped event. if (Stopped != null) { Stopped(this, queue); } //Remove the queue Transfers.Remove(id); } } break; case Headers.Pause: { int id = pr.ReadInt32(); //Pause the upload. if (Transfers.ContainsKey(id)) { Transfers[id].Pause(); } } break; case Headers.Chunk: { //Read the ID, index, size and buffer from the packet. int id = pr.ReadInt32(); long index = pr.ReadInt64(); int size = pr.ReadInt32(); byte[] buffer = pr.ReadBytes(size); //Get the queue. TransferQueue queue = Transfers[id]; //Write the newly transferred bytes to the queue based on the write index. queue.Write(buffer, index); //Get the progress of the current transfer with the formula //(AMOUNT_TRANSFERRED * 100) / COMPLETE SIZE queue.Progress = (int)((queue.Transferred * 100) / queue.Length); //This will prevent the us from calling progress changed multiple times. /* Such as * 2, 2, 2, 2, 2, 2 (Since the actual progress minus the decimals will be the same for a bit * It will be * 1, 2, 3, 4, 5, 6 * Instead*/ if (queue.LastProgress < queue.Progress) { queue.LastProgress = queue.Progress; if (ProgressChanged != null) { ProgressChanged(this, queue); } //If the transfer is complete, call the event. if (queue.Progress == 100) { queue.Close(); if (Complete != null) { Complete(this, queue); } } } } break; } pr.Dispose(); //Dispose the reader. }
public ColoredTransaction(uint256 txId, Transaction tx, ColoredCoin[] spentCoins, Script issuanceScriptPubkey) : this() { if (tx == null) { throw new ArgumentNullException("tx"); } if (spentCoins == null) { throw new ArgumentNullException("spentCoins"); } if (tx.IsCoinBase || tx.Inputs.Count == 0) { return; } txId = txId ?? tx.GetHash(); Queue <ColoredEntry> previousAssetQueue = new Queue <ColoredEntry>(); for (uint i = 0; i < tx.Inputs.Count; i++) { var txin = tx.Inputs[i]; var prevAsset = spentCoins.FirstOrDefault(s => s.Outpoint == txin.PrevOut); if (prevAsset != null) { var input = new ColoredEntry() { Index = i, Asset = prevAsset.Amount }; previousAssetQueue.Enqueue(input); Inputs.Add(input); } } uint markerPos = 0; var marker = ColorMarker.Get(tx, out markerPos); if (marker == null) { return; } Marker = marker; if (!marker.HasValidQuantitiesCount(tx)) { return; } AssetId issuedAsset = null; for (uint i = 0; i < markerPos; i++) { var entry = new ColoredEntry(); entry.Index = i; entry.Asset = new AssetMoney(entry.Asset.Id, i >= marker.Quantities.Length ? 0 : marker.Quantities[i]); if (entry.Asset.Quantity == 0) { continue; } if (issuedAsset == null) { var txIn = tx.Inputs.FirstOrDefault(); if (txIn == null) { continue; } if (issuanceScriptPubkey == null) { throw new ArgumentException("The transaction has an issuance detected, but issuanceScriptPubkey is null.", "issuanceScriptPubkey"); } issuedAsset = issuanceScriptPubkey.Hash.ToAssetId(); } entry.Asset = new AssetMoney(issuedAsset, entry.Asset.Quantity); Issuances.Add(entry); } long used = 0; for (uint i = markerPos + 1; i < tx.Outputs.Count; i++) { var entry = new ColoredEntry(); entry.Index = i; //If there are less items in the asset quantity list than the number of colorable outputs (all the outputs except the marker output), the outputs in excess receive an asset quantity of zero. entry.Asset = new AssetMoney(entry.Asset.Id, (i - 1) >= marker.Quantities.Length ? 0 : marker.Quantities[i - 1]); if (entry.Asset.Quantity == 0) { continue; } //If there are less asset units in the input sequence than in the output sequence, the transaction is considered invalid and all outputs are uncolored. if (previousAssetQueue.Count == 0) { Transfers.Clear(); Issuances.Clear(); return; } entry.Asset = new AssetMoney(previousAssetQueue.Peek().Asset.Id, entry.Asset.Quantity); var remaining = entry.Asset.Quantity; while (remaining != 0) { if (previousAssetQueue.Count == 0 || previousAssetQueue.Peek().Asset.Id != entry.Asset.Id) { Transfers.Clear(); Issuances.Clear(); return; } var assertPart = Math.Min(previousAssetQueue.Peek().Asset.Quantity - used, remaining); remaining = remaining - assertPart; used += assertPart; if (used == previousAssetQueue.Peek().Asset.Quantity) { previousAssetQueue.Dequeue(); used = 0; } } Transfers.Add(entry); } }
public void Default(TransferOutput output) { Transfers.Add(output); }
public void AddTransfer(Transfer newTransfer) { Transfers.Add(newTransfer); }
public void Standard(TransferOutput output) { Transfers.Add(output); }