Beispiel #1
0
 public AccountSummary()
 {
     this.Id          = new AccountID();
     this.Currency    = new Currency();
     this.Balance     = new AccountUnits();
     this.CreatedTime = new DateTime();
     this.GuaranteedStopLossOrderMode = new GuaranteedStopLossOrderMode();
     this.PL                          = new AccountUnits();
     this.ResettablePL                = new AccountUnits();
     this.ResettablePLTime            = new DateTime();
     this.Financing                   = new AccountUnits();
     this.Commission                  = new AccountUnits();
     this.GuaranteedExecutionFees     = new AccountUnits();
     this.MarginCallEnterTime         = new DateTime();
     this.LastMarginCallExtensionTime = new DateTime();
     this.UnrealizedPL                = new AccountUnits();
     this.NAV                         = new AccountUnits();
     this.MarginUsed                  = new AccountUnits();
     this.MarginAvailable             = new AccountUnits();
     this.PositionValue               = new AccountUnits();
     this.MarginCloseoutUnrealizedPL  = new AccountUnits();
     this.MarginCloseoutNAV           = new AccountUnits();
     this.MarginCloseoutMarginUsed    = new AccountUnits();
     this.WithdrawalLimit             = new AccountUnits();
     this.MarginCallMarginUsed        = new AccountUnits();
     this.LastTransactionID           = new TransactionID();
 }
        /// <summary>
        /// Get a range of Transactions for an Account based on the Transaction IDs.
        /// </summary>
        /// <param name="from">The starting Transacion ID (inclusive) to fetch. [required].</param>
        /// <param name="to">The ending Transacion ID (inclusive) to fetch. [required].</param>
        /// <param name="type">The filter that restricts the types of Transactions to retreive.</param>
        /// <returns></returns>
        public async Task <List <Transaction> > GetTransactionsFromIdRange(TransactionID from, TransactionID to, List <TransactionFilter> type = null)
        {
            #region queryNVC
            NameValueCollection queryNVC = new NameValueCollection()
            {
                { "from", from },
                { "to", to }
            };
            if (type != null)
            {
                queryNVC.Add("type", string.Join(",", type));
            }
            #endregion

            string path     = string.Format("accounts/{0}/transactions/idrange", AccountID);
            string query    = null;
            string jsonBody = QueryFromNVC(queryNVC);

            using (HttpResponseMessage response = await RequestAsync(EHostAPIType.REST, HttpMethod.Get, path, query, jsonBody))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new HttpRequestException(JObject.Parse(await response.Content.ReadAsStringAsync())["errorMessage"].ToString());
                }

                using (Stream stream = await response.Content.ReadAsStreamAsync())
                {
                    string jsonString = JObject.Parse(await new StreamReader(stream).ReadToEndAsync())["transactions"].ToString();
                    return(JsonConvert.DeserializeObject <List <Transaction> >(jsonString, ErrorHandlingSetting));
                }
            }
        }
Beispiel #3
0
 static ConsensusMessageChunkInfo createChunkInfo(TransactionID transactionId, TxId?parentTx, int segmentIndex, int segmentTotalCount)
 {
     if (segmentTotalCount < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(SubmitMessageParams.TotalSegmentCount), "Total Segment Count must be a positive number.");
     }
     if (segmentIndex > segmentTotalCount || segmentIndex < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(SubmitMessageParams.Index), "Segment index must be between one and the total segment count inclusively.");
     }
     if (segmentIndex == 1)
     {
         if (!(parentTx is null))
         {
             throw new ArgumentOutOfRangeException(nameof(SubmitMessageParams.ParentTxId), "The Parent Transaction cannot be specified (must be null) when the segment index is one.");
         }
         return(new ConsensusMessageChunkInfo
         {
             Total = segmentTotalCount,
             Number = segmentIndex,
             InitialTransactionID = transactionId
         });
     }
     if (parentTx is null)
     {
         throw new ArgumentNullException(nameof(SubmitMessageParams.ParentTxId), "The parent transaction id is required when segment index is greater than one.");
     }
     return(new ConsensusMessageChunkInfo
     {
         Total = segmentTotalCount,
         Number = segmentIndex,
         InitialTransactionID = new TransactionID(parentTx)
     });
 }
        /// <summary>
        /// Retrieves all records having the given transaction ID, including duplicates
        /// that were rejected or produced errors during execution.  Typically there is
        /// only one record per transaction, but in some cases, deliberate or accidental
        /// there may be more than one for a given transaction ID.
        /// </summary>
        /// <param name="transaction">
        /// Transaction identifier of the record
        /// </param>
        /// <param name="configure">
        /// Optional callback method providing an opportunity to modify
        /// the execution configuration for just this method call.
        /// It is executed prior to submitting the request to the network.
        /// </param>
        /// <returns>
        /// An collection of all the transaction records known to the system
        /// at the time of query having the identified transaction id.
        /// </returns>
        public async Task <ReadOnlyCollection <TransactionRecord> > GetAllTransactionRecordsAsync(TxId transaction, Action <IContext>?configure = null)
        {
            await using var context = CreateChildContext(configure);
            var transactionId = new TransactionID(transaction);

            // For the public version of this method, we do not know
            // if the transaction in question has come to consensus so
            // we need to get the receipt first (and wait if necessary).
            // The Receipt status returned does notmatter in this case.
            // We may be retrieving a failed record (the status would not equal OK).
            await WaitForConsensusReceipt(context, transactionId).ConfigureAwait(false);

            var response = await ExecuteQueryInContextAsync(new TransactionGetRecordQuery(transactionId, true), context, 0).ConfigureAwait(false);

            // Note if we are retrieving the list, Not found is OK too.
            var precheckCode = response.ResponseHeader?.NodeTransactionPrecheckCode ?? ResponseCodeEnum.Unknown;

            if (precheckCode != ResponseCodeEnum.Ok && precheckCode != ResponseCodeEnum.RecordNotFound)
            {
                throw new TransactionException("Unable to retrieve transaction record.", transactionId.AsTxId(), (ResponseCode)precheckCode);
            }
            var record = response.TransactionGetRecord;

            return(TransactionRecordExtensions.Create(record.DuplicateTransactionRecords, record.TransactionRecord));
        }
 public void PreProcess(RestSharp.IRestRequest request)
 {
     request.AddParameterExclusiveOrThrow("t", "item");
     request.AddParameterExclusive("ti", TransactionID.Truncate(500));
     request.AddParameterExclusive("in", Name.Truncate(500));
     if (Price.HasValue)
     {
         request.AddParameterExclusive("ip", Price.Value);
     }
     if (Quantity.HasValue)
     {
         request.AddParameterExclusive("iq", Quantity.Value);
     }
     if (!Code.IsNullOrWhitespace())
     {
         request.AddParameterExclusive("ic", Code.Truncate(500));
     }
     if (!Category.IsNullOrWhitespace())
     {
         request.AddParameterExclusive("iv", Category.Truncate(500));
     }
     if (!CurrencyCode.IsNullOrWhitespace())
     {
         request.AddParameterExclusive("cu", CurrencyCode.Truncate(10));
     }
 }
 public StopLossOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, double guaranteedExecutionPremium, TradeID tradeID, ClientID clientTradeID, PriceValue price, double distance, TimeInForce timeInForce, DateTime gtdTime, OrderTriggerCondition triggerCondition, bool guaranteed, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime, OrderID replacesOrderID, OrderID replacedByOrderID)
 {
     this.Id                         = id;
     this.CreateTime                 = createTime;
     this.State                      = state;
     this.ClientExtensions           = clientExtensions;
     this.Type                       = type;
     this.GuaranteedExecutionPremium = guaranteedExecutionPremium;
     this.TradeID                    = tradeID;
     this.ClientTradeID              = clientTradeID;
     this.Price                      = price;
     this.Distance                   = distance;
     this.TimeInForce                = timeInForce;
     this.GtdTime                    = gtdTime;
     this.TriggerCondition           = triggerCondition;
     this.Guaranteed                 = guaranteed;
     this.FillingTransactionID       = fillingTransactionID;
     this.FilledTime                 = filledTime;
     this.TradeOpenedID              = tradeOpenedID;
     this.TradeReducedID             = tradeReducedID;
     this.TradeClosedIDs             = tradeClosedIDs;
     this.CancellingTransactionID    = cancellingTransactionID;
     this.CancelledTime              = cancelledTime;
     this.ReplacesOrderID            = replacesOrderID;
     this.ReplacedByOrderID          = replacedByOrderID;
 }
Beispiel #7
0
        public override byte[] GetBytes()
        {
            StringBuilder builder = new StringBuilder(128);

            builder.Append(Command);

            if (noTransactionIDCommands.IndexOf(Command) == -1)
            {
                if (TransactionID != -1)
                {
                    builder.Append(' ');
                    builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
                }
            }

            foreach (string val in CommandValues)
            {
                builder.Append(' ');
                builder.Append(val);
            }

            if (InnerMessage != null)
            {
                builder.Append(' ');
                builder.Append(InnerMessage.GetBytes().Length);
                builder.Append("\r\n");
                return(AppendArray(System.Text.Encoding.UTF8.GetBytes(builder.ToString()), InnerMessage.GetBytes()));
            }
            else
            {
                builder.Append("\r\n");
                return(System.Text.Encoding.UTF8.GetBytes(builder.ToString()));
            }
        }
 public TransferFundsTransaction(
     TransactionID id,
     DateTime time,
     int userID,
     AccountID accountID,
     TransactionID batchID,
     RequestID requestID,
     TransactionType type,
     AccountUnits amount,
     FundingReason fundingReason,
     string comment,
     AccountUnits accountBalance
     )
 {
     this.Id             = id;
     this.Time           = time;
     this.UserID         = userID;
     this.AccountID      = accountID;
     this.BatchID        = batchID;
     this.RequestID      = requestID;
     this.Type           = type;
     this.Amount         = amount;
     this.FundingReason  = fundingReason;
     this.Comment        = comment;
     this.AccountBalance = accountBalance;
 }
Beispiel #9
0
 public MarketOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.MARKET);
     this.Instrument              = new InstrumentName();
     this.TimeInForce             = new TimeInForce(ETimeInForce.FOK);
     this.PriceBound              = new PriceValue();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TradeClose              = new MarketOrderTradeClose();
     this.LongPositionCloseout    = new MarketOrderPositionCloseout();
     this.ShortPositionCloseout   = new MarketOrderPositionCloseout();
     this.MarginCloseout          = new MarketOrderMarginCloseout();
     this.DelayedTradeClose       = new MarketOrderDelayedTradeClose();
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
 }
Beispiel #10
0
        /// <summary>
        /// Get the debug string representation of the message
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// To futher developers:
        /// You cannot simply apply Encoding.UTF8.GetString(GetByte()) in this function
        /// since the InnerMessage of MSNMessage may contain binary data.
        /// </remarks>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(128);

            builder.Append(Command);

            if (noTransactionIDCommands.IndexOf(Command) == -1)
            {
                if (TransactionID != -1)
                {
                    builder.Append(' ');
                    builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
                }
            }

            foreach (string val in CommandValues)
            {
                builder.Append(' ');
                builder.Append(val);
            }

            if (InnerMessage != null)
            {
                builder.Append(' ');
                builder.Append(InnerMessage.GetBytes().Length);
            }

            //For toString, we do not return the inner message's string.
            return(builder.ToString());
        }
Beispiel #11
0
 public LimitOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.LIMIT);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.TimeInForce             = new TimeInForce(ETimeInForce.GTC);
     this.GtdTime                 = new DateTime();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TriggerCondition        = new OrderTriggerCondition(EOrderTriggerCondition.DEFAULT);
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
     this.ReplacesOrderID         = new OrderID();
     this.ReplacedByOrderID       = new OrderID();
 }
Beispiel #12
0
 public LimitOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, PriceValue price, TimeInForce timeInForce, DateTime gtdTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime, OrderID replacesOrderID, OrderID replacedByOrderID)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.TimeInForce             = timeInForce;
     this.GtdTime                 = gtdTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
     this.ReplacesOrderID         = replacesOrderID;
     this.ReplacedByOrderID       = replacedByOrderID;
 }
Beispiel #13
0
 public LimitOrderRejectTransaction(TransactionID id, DateTime time, int userID, AccountID accountID, TransactionID batchID, RequestID requestID, TransactionType type, InstrumentName instrument, double units, PriceValue price, TimeInForce timeInForce, DateTime gTDTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, LimitOrderReason reason, ClientExtensions clientExtensions, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, OrderID intendedReplacesOrderID, TransactionRejectReason rejectReason)
 {
     this.Id                      = id;
     this.Time                    = time;
     this.UserID                  = userID;
     this.AccountID               = accountID;
     this.BatchID                 = batchID;
     this.RequestID               = requestID;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.TimeInForce             = timeInForce;
     this.GTDTime                 = gTDTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.Reason                  = reason;
     this.ClientExtensions        = clientExtensions;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.IntendedReplacesOrderID = intendedReplacesOrderID;
     this.RejectReason            = rejectReason;
 }
Beispiel #14
0
 public MarketOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, TimeInForce timeInForce, PriceValue priceBound, OrderPositionFill positionFill, MarketOrderTradeClose tradeClose, MarketOrderPositionCloseout longPositionCloseout, MarketOrderPositionCloseout shortPositionCloseout, MarketOrderMarginCloseout marginCloseout, MarketOrderDelayedTradeClose delayedTradeClose, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.TimeInForce             = timeInForce;
     this.PriceBound              = priceBound;
     this.PositionFill            = positionFill;
     this.TradeClose              = tradeClose;
     this.LongPositionCloseout    = longPositionCloseout;
     this.ShortPositionCloseout   = shortPositionCloseout;
     this.MarginCloseout          = marginCloseout;
     this.DelayedTradeClose       = delayedTradeClose;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
 }
Beispiel #15
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int Quantity            = 0;
            BackgroundWorker worker = sender as BackgroundWorker;

            System.Threading.Thread.Sleep(2000);

            t.NewTransaction(DateTime.Now, Action, AdminID);
            foreach (DataGridViewRow row in dgvTransaction.Rows)
            {
                t.NewBorrowed(TransactionID, g.GetGENID(Borrower), Convert.ToInt32(row.Cells[0].Value), DateTime.Now, Convert.ToInt32(row.Cells[2].Value), false);
                t.BorrowableEditQuantity(Convert.ToInt32(row.Cells[0].Value), g.GetEquipmentBorrowableQuantity(Convert.ToInt32(row.Cells[0].Value)) + Convert.ToInt32(row.Cells[2].Value));
                Quantity = Quantity + Convert.ToInt32(row.Cells[2].Value);
            }
            s.GenerateBarcode(TransactionID.ToString());

            db.sp_UserBorrowAdd(g.GetGENID(Borrower), g.GetTotalAmountBorrowed(g.GetGENID(Borrower)) + Quantity);

            String strBLOBFilePath = s.SavePath;//Modify this path as needed.

            //Read jpg into file stream, and from there into Byte array.
            FileStream fsBLOBFile = new FileStream(strBLOBFilePath, FileMode.Open, FileAccess.Read);

            Byte[] bytBLOBData = new Byte[fsBLOBFile.Length];
            fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length);
            fsBLOBFile.Close();

            db.sp_NewBorrowBarcodeInsert(TransactionID, bytBLOBData, s.SavePath);
        }
Beispiel #16
0
 public CreateTransaction(
     TransactionID id,
     DateTime time,
     int userID, AccountID accountID,
     TransactionID batchID,
     RequestID requestID,
     TransactionType type,
     int divisionID,
     int siteID,
     int accountUserID,
     int accountNumber,
     Currency homeCurrency
     )
 {
     this.Id            = id;
     this.Time          = time;
     this.UserID        = userID;
     this.AccountID     = accountID;
     this.BatchID       = batchID;
     this.RequestID     = requestID;
     this.Type          = type;
     this.DivisionID    = divisionID;
     this.SiteID        = siteID;
     this.AccountUserID = accountUserID;
     this.AccountNumber = accountNumber;
     this.HomeCurrency  = homeCurrency;
 }
Beispiel #17
0
        private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            t.NewTransaction(DateTime.Now, Action, AdminID);
            foreach (DataGridViewRow row  in dgvReservation.Rows)
            {
                t.NewEquipmentReservation(TransactionID, ReserveeID, Convert.ToInt32(row.Cells[0].Value), ReservationDate, Convert.ToInt32(row.Cells[2].Value), false);
                t.BorrowableEditQuantity(Convert.ToInt32(row.Cells[0].Value), g.GetEquipmentBorrowableQuantity(Convert.ToInt32(row.Cells[0].Value)) + Convert.ToInt32(row.Cells[2].Value));
            }
            s.GenerateBarcode(TransactionID.ToString());

            String strBLOBFilePath = s.SavePath;//Modify this path as needed.

            //Read jpg into file stream, and from there into Byte array.
            FileStream fsBLOBFile = new FileStream(strBLOBFilePath, FileMode.Open, FileAccess.Read);

            Byte[] bytBLOBData = new Byte[fsBLOBFile.Length];
            fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length);
            fsBLOBFile.Close();

            db.sp_NewBorrowBarcodeInsert(TransactionID, bytBLOBData, s.SavePath);
            MetroMessageBox.Show(this, "Transaction Complete", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            frmReservationSlip f = new frmReservationSlip(TransactionID, AdminID, ReserveeID, ReservationDate);

            f.ShowDialog();
            this.Close();
        }
        /// <summary>
        /// Get a range of Transactions for an Account starting at (but not including) a provided Transaction ID.
        /// </summary>
        /// <param name="id">The ID of the last Transacion fetched. This query will return all Transactions newer than the TransactionID. [required].</param>
        /// <returns></returns>
        public async Task <List <Transaction> > GetTransactionsSinceID(TransactionID id)
        {
            #region queryNVC
            NameValueCollection queryNVC = new NameValueCollection()
            {
                { "id", id }
            };
            #endregion

            string path     = string.Format("accounts/{0}/transactions/sinceid", AccountID);
            string query    = null;
            string jsonBody = QueryFromNVC(queryNVC);

            using (HttpResponseMessage response = await RequestAsync(EHostAPIType.REST, HttpMethod.Get, path, query, jsonBody))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new HttpRequestException(JObject.Parse(await response.Content.ReadAsStringAsync())["errorMessage"].ToString());
                }

                using (Stream stream = await response.Content.ReadAsStreamAsync())
                {
                    string jsonString = JObject.Parse(await new StreamReader(stream).ReadToEndAsync())["transactions"].ToString();
                    return(JsonConvert.DeserializeObject <List <Transaction> >(jsonString, ErrorHandlingSetting));
                }
            }
        }
Beispiel #19
0
 internal static void PreCheck(TransactionID transactionId, TransactionResponse response)
 {
     if (response.NodeTransactionPrecheckCode == Proto.ResponseCodeEnum.Ok)
     {
         return;
     }
     throw new PrecheckException($"Transaction Failed Pre-Check: {response.NodeTransactionPrecheckCode}", Protobuf.FromTransactionId(transactionId), (ResponseCode)response.NodeTransactionPrecheckCode, response.Cost);
 }
Beispiel #20
0
 public Transaction()
 {
     this.Id        = new TransactionID();
     this.Time      = new DateTime();
     this.AccountID = new AccountID();
     this.BatchID   = new TransactionID();
     this.RequestID = new RequestID();
 }
Beispiel #21
0
 internal static void PreCheck(TransactionID transactionId, ResponseCodeEnum code)
 {
     if (code == Proto.ResponseCodeEnum.Ok)
     {
         return;
     }
     throw new PrecheckException($"Transaction Failed Pre-Check: {code}", Protobuf.FromTransactionId(transactionId), (ResponseCode)code);
 }
Beispiel #22
0
 public AnnouncePeerQuery(TransactionID transactionId, NodeID senderNodeId, InfoHash infoHash, PeerToken token, int port, bool impliedPort)
 {
     TransactionID = transactionId;
     SenderNode    = senderNodeId;
     InfoHash      = infoHash;
     Port          = port;
     Token         = token;
     ImpliedPort   = impliedPort;
 }
 public ReopenTransaction()
 {
     this.Id        = new TransactionID();
     this.Time      = new DateTime();
     this.AccountID = new AccountID();
     this.BatchID   = new TransactionID();
     this.RequestID = new RequestID();
     this.Type      = new TransactionType(ETransactionType.REOPEN);
 }
Beispiel #24
0
    void INetworkQuery.CheckResponse(TransactionID transactionId, Response response)
    {
        var precheckCode = response.ResponseHeader?.NodeTransactionPrecheckCode ?? ResponseCodeEnum.Unknown;

        if (precheckCode != ResponseCodeEnum.Ok)
        {
            throw new TransactionException("Unable to retrieve transaction records.", transactionId, precheckCode);
        }
    }
Beispiel #25
0
 public MarginCallExtendTransaction()
 {
     this.Id        = new TransactionID();
     this.Time      = new DateTime();
     this.AccountID = new AccountID();
     this.BatchID   = new TransactionID();
     this.RequestID = new RequestID();
     this.Type      = new TransactionType(ETransactionType.MARGIN_CALL_EXTEND);
 }
Beispiel #26
0
 internal static TxId FromTransactionId(TransactionID transactionId)
 {
     return(new TxId
     {
         Address = FromAccountID(transactionId.AccountID),
         ValidStartSeconds = transactionId.TransactionValidStart.Seconds,
         ValidStartNanos = transactionId.TransactionValidStart.Nanos
     });
 }
        public TransactionType Type; // RESET_RESETTABLE_PL

        public ResetResettablePLTransaction()
        {
            this.Id        = new TransactionID();
            this.Time      = new DateTime();
            this.AccountID = new AccountID();
            this.BatchID   = new TransactionID();
            this.RequestID = new RequestID();
            this.Type      = new TransactionType(ETransactionType.RESET_RESETTABLE_PL);
        }
Beispiel #28
0
 public CloseTransaction()
 {
     this.Id        = new TransactionID();
     this.Time      = new DateTime();
     this.AccountID = new AccountID();
     this.BatchID   = new TransactionID();
     this.RequestID = new RequestID();
     this.Type      = new TransactionType(ETransactionType.CLOSE);
 }
 public ClientConfigureTransaction()
 {
     this.Type      = new TransactionType(ETransactionType.CLIENT_CONFIGURE);
     this.Id        = new TransactionID();
     this.Time      = new DateTime();
     this.AccountID = new AccountID();
     this.BatchID   = new TransactionID();
     this.RequestID = new RequestID();
     this.Type      = new TransactionType(ETransactionType.CLIENT_CONFIGURE);
 }
Beispiel #30
0
        internal static void PreCheck(TransactionID transactionId, TransactionResponse response)
        {
            if (response.NodeTransactionPrecheckCode == Proto.ResponseCodeEnum.Ok)
            {
                return;
            }
            var responseCode = (ResponseCode)response.NodeTransactionPrecheckCode;

            throw new PrecheckException($"Transaction Failed Pre-Check: {responseCode}", transactionId.ToTxId(), responseCode, response.Cost);
        }
        /**
         * Creates a client transaction
         * @param providerCallback the provider that created us.
         * @param request the request that we are living for.
         * @param requestDestination the destination of the request.
         * @param apDescriptor the access point through which we are supposed to
         * @param responseCollector the instance that should receive this request's
         * response.
         * retransmit.
         */
        public StunClientTransaction(StunProvider            providerCallback,
			Request                  request,
			StunAddress              requestDestination,
			NetAccessPointDescriptor apDescriptor,
			ResponseCollector        responseCollector)
        {
            this.providerCallback  = providerCallback;
            this.request           = request;
            this.apDescriptor      = apDescriptor;
            this.responseCollector = responseCollector;
            this.requestDestination = requestDestination;

            this.transactionID = TransactionID.CreateTransactionID();

            request.SetTransactionID(transactionID.GetTransactionID());

            runningThread = new Thread(new ThreadStart(this.Run));
        }
Beispiel #32
0
 /// <summary>
 /// Creates a new transaction token
 /// </summary>
 /// <param name="myTransactionID">The ID of the token</param>
 public TransactionToken(Int64 myTransactionID)
 {
     _iID = new TransactionID(myTransactionID);
 }