private void CastRollBackEvent(TransactionEntry entry) { if (onRollBack != null) { onRollBack(this, new RollInformationEventArgs(entry)); } }
private void SignalTransactionLogChanged(TransactionEntry entry) { if (onTransactionLogChanged != null) { onTransactionLogChanged(this, new TransactionsEventArgs(entry)); } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { // get selected row and decide what to show/not to show Point p = gridControl1.PointToClient(Cursor.Position); GridHitInfo hitinfo = gridView1.CalcHitInfo(p); int[] selectedrows = gridView1.GetSelectedRows(); if (hitinfo.InRow) { int grouplevel = gridView1.GetRowLevel((int)selectedrows.GetValue(0)); if (grouplevel >= gridView1.GroupCount) { //Console.WriteLine("In row"); if (gridView1.GetFocusedRow() is TransactionEntry) { TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow(); if (sh.IsRolledBack) { rollForwardToolStripMenuItem.Enabled = true; rolllBackToolStripMenuItem.Enabled = false; } else { rollForwardToolStripMenuItem.Enabled = false; rolllBackToolStripMenuItem.Enabled = true; } } } } }
/// <summary> /// Creation of a transaction instance with all information needed to provide cancellation and management operation. /// </summary> /// <param name="transactionEntry">Transaction entry used in the authorization process.</param> /// <param name="cardInfo">Card information obtained from the authorization process.</param> /// <param name="rawApprovedTransaction">Transaction information returned from STONE authorization service.</param> /// <returns>A transaction model.</returns> public static TransactionModel Create(TransactionEntry transactionEntry, ICard cardInfo, AuthorizationResponse rawApprovedTransaction) { TransactionModel transaction = new TransactionModel(); // Mapeando informações da transação: transaction.Amount = transactionEntry.Amount; transaction.DateTime = DateTime.Now; transaction.InitiatorTransactionKey = transactionEntry.InitiatorTransactionKey; transaction.InstallmentCount = transactionEntry.Installment.Number; // Mapeando informações direto do retorno do autorizador da Stone. transaction.AuthorizationTransactionKey = rawApprovedTransaction.AcquirerTransactionKey; transaction.ResponseCode = (int)(rawApprovedTransaction.OriginalResponse as AcceptorAuthorisationResponse).Data.AuthorisationResponse.TransactionResponse.AuthorisationResult.ResponseToAuthorisation.Response; transaction.ResponseReason = (rawApprovedTransaction.OriginalResponse as AcceptorAuthorisationResponse).Data.AuthorisationResponse.TransactionResponse.AuthorisationResult.ResponseToAuthorisation.ResponseReason; transaction.TransactionType = transactionEntry.Type; // Mapeando informações do cartão: transaction.Aid = cardInfo.ApplicationId; transaction.BrandName = cardInfo.BrandName; transaction.CardholderName = cardInfo.CardholderName; transaction.BrandId = cardInfo.BrandId; transaction.Arqc = cardInfo.ApplicationCryptogram; transaction.MaskedPan = cardInfo.MaskedPrimaryAccountNumber; return(transaction); }
private void TestSerialization(SerializerType serializerType, bool dontSetSerializerType = false) { const int intData = 123; const string stringData = "sjkdnfkjsdnf"; var entry = new TransactionEntry(); if (!dontSetSerializerType) { entry.ReqResSerializerType = serializerType; } entry.RequestObject = new TestSerializableData() { IntData = intData, StringData = stringData }; var serialized = entry.Request; var deserialized = Deserialize <TestSerializableData>(serialized, serializerType); Assert.IsNotNull(deserialized); Assert.AreEqual(intData, deserialized.IntData); Assert.AreEqual(stringData, deserialized.StringData); }
private void InitiateTransaction() { // Limpa o log: this.uxLog.Items.Clear(); // Cria uma transação: // Tipo da transação inválido significa que o pinpad vai perguntar ao usuário o tipo da transação. AccountType AccountType; Installment installment = this.GetInstallment(out AccountType); // Pega o valor da transação decimal amount; decimal.TryParse(this.uxTbxTransactionAmount.Text, out amount); if (amount == 0) { this.Log("Valor da transaçào inválido."); return; } // Cria e configura a transação: TransactionEntry transaction = new TransactionEntry(AccountType, amount); transaction.Installment = installment; transaction.InitiatorTransactionKey = this.uxTbxItk.Text; transaction.CaptureTransaction = true; // Envia para o autorizador: IAuthorizationReport report = this.SendRequest(transaction); this.UpdateTransactions(); }
public TransactionEntry AddSymbol(string exchange, string symbol, PortfolioEntry entry) { PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details())); TransactionEntry transactionEntry = new TransactionEntry() { TransactionData = new TransactionData() { Type = TransactionTypes.BUY } }; PositionEntry positionEntry = new PositionEntry() { Symbol = new Symbol() { StockSymbol = symbol, Exchange = exchange } }; Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS); try { return(FinanceService.Insert(uri, transactionEntry)); } catch (Exception ex) { Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1}", symbol + ":" + exchange, entry.Title.Text); Console.WriteLine("Exception: {0}", ex.Message); return(null); } }
private void CastNoteChangedEvent(TransactionEntry entry) { if (onNoteChanged != null) { onNoteChanged(this, new RollInformationEventArgs(entry)); } }
private void CastRollForwardEvent(TransactionEntry entry) { if (onRollForward != null) { onRollForward(this, new RollInformationEventArgs(entry)); } }
public async Task ExecuteInTransactionAsync(DbContext dbContext, Func <CancellationToken, Task> operation, CancellationToken token = default) { _contexts.ValidateContext(dbContext); /* Connection Resilience Strategy: "Manually track the transaction" * * reference: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency */ var connection = dbContext.Database.GetDbConnection(); using (_db = CreateTransactionContext(connection)) { var strategy = _db.Database.CreateExecutionStrategy(); var transaction = new TransactionEntry(SequentialGuid.NewGuid()); _db.Transactions.Add(transaction); await operation(token); await strategy.ExecuteInTransactionAsync( operation : async() => await _contexts.SaveChangesAsync(token), verifySucceeded : async() => await _db.Transactions.AsNoTracking() .AnyAsync(t => t.Id == transaction.Id, cancellationToken: token)); _contexts.AcceptAllChanges(); _db.Transactions.Remove(transaction); await _db.SaveChangesAsync(token); } _db = null; }
public void OpenReceiptEntryExecute(Transaction trans) { var win = new SaveWindow(); var winVm = new SaveWindowVM(); var control = new TransactionEntry(); var exists = Repository.Transactions.Contains(trans); var vm = new TransactionEntryVM(trans, Repository.Accounts.OrderBy(t => t.Name), Repository.Accounts.OrderBy(t => t.Name)); winVm.IsSaveVisible = !exists; winVm.Save += (s, e) => { if (!exists) { Repository.Add(trans); } Repository.UpdateAccountBalances(DateTime.Now.Date); win.Close(); }; win.SizeToContent = SizeToContent.WidthAndHeight; win.DataContext = winVm; control.DataContext = vm; win.WindowContents = control; win.ShowDialog(); }
private void UpdateButtons() { int[] selectedrows = gridView1.GetSelectedRows(); if (selectedrows.Length == 0) { simpleButton3.Enabled = false; simpleButton4.Enabled = false; } else { if (gridView1.GetFocusedRow() is TransactionEntry) { TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow(); if (sh.IsRolledBack) { simpleButton4.Enabled = true; simpleButton3.Enabled = false; } else { simpleButton4.Enabled = false; simpleButton3.Enabled = true; } } } }
public void Call() { this._transactions = TransactionEntry.Load(this._parent.MobilePaywallDatabase, this.PrepareQuery()); if (this._transactions == null) { this._transactions = new List <TransactionEntry>(); } }
public static ITransactionEntry GetTransactionLogEntry() { var entry = new TransactionEntry(); FillEntry(entry); return(entry); }
public override ITransactionGroup Modify(params TransactionDto <NonInvestmentTransaction>[] parameters) { if (parameters == null || parameters.Length <= 0) { throw new ArgumentNullException("No parameters given"); } var dto = parameters[0]; var result = new TransactionModel(); var categories = dto.Transactions.OrderByDescending(o => o.Date).GroupBy(o => o.Category).ToList(); foreach (var dtoCat in categories) { var cat = new Category(); FillCategory(cat, dtoCat.Key); result.Categories.Add(cat); var accounts = dtoCat.GroupBy(o => o.PayeeAccount).OrderBy(o => o.Key); foreach (var dtoAccount in accounts) { var transactionGroup = new TransactionEntryGroup { Title = dtoAccount.Key }; if (!string.IsNullOrEmpty(dtoAccount.Key)) { transactionGroup.ShortName = dtoAccount.Key[0]; } cat.TransactionGroups.Add(transactionGroup); //var account = new Account { Name = dtoAccount.Key }; //cat.Accounts.Add(account); foreach (var dtoTransaction in dtoAccount) { var transaction = new TransactionEntry { Date = dtoTransaction.Date, Amount = dtoTransaction.Amount, SplitAmount = dtoTransaction.SplitAmount, SplitAmounts = dtoTransaction.SplitAmounts, IsCleared = dtoTransaction.IsCleared, Num = dtoTransaction.Num, PayeeLines = dtoTransaction.PayeeLines, Memo = dtoTransaction.Memo, SplitMemo = dtoTransaction.SplitMemo, AddressLines = dtoTransaction.AddressLines, Category = dtoTransaction.Category, SplitCategory = dtoTransaction.SplitCategory, Type = dtoTransaction.Type, Address = dtoTransaction.Address, Payee = dtoTransaction.Payee, PayeeAccount = dtoTransaction.PayeeAccount, PayeeName = dtoTransaction.PayeeName }; transactionGroup.Add(transaction); } } } result.Categories = result.Categories.OrderBy(c => c.Id).ToList(); return(result); }
public static List <TransactionEntry> LoadTransactionEntries() { var transactionlines = new List <TransactionEntry>(); var audit = Globals.AuditFile; var journals = audit ?.GeneralLedgerEntries ?.Journal; foreach (var j in journals ?? new List <Journal>()) { foreach (var t in j.Transaction ?? new List <Transaction>()) { foreach (var l in t?.Lines?.DebitLine ?? new List <DebitLine>()) { var line = new TransactionEntry { JournalID = j.JournalID, JournalDescription = j.Description, TransactionID = t.TransactionID, Period = t.Period, TransactionDate = DateTime.Parse(t.TransactionDate), SourceID = t.SourceID, TransactionDescription = t.Description, DocArchivalNumber = t.DocArchivalNumber, TransactionType = t.TransactionType, CustomerID = t.CustomerID, AccountID = l.AccountID, LineDescription = l.Description, DebitAmount = l.DebitAmount.ToFloat() }; transactionlines.Add(line); } foreach (var l in t?.Lines?.CreditLine ?? new List <CreditLine>()) { var line = new TransactionEntry { JournalID = j.JournalID, JournalDescription = j.Description, TransactionID = t.TransactionID, Period = t.Period, TransactionDate = DateTime.Parse(t.TransactionDate), SourceID = t.SourceID, TransactionDescription = t.Description, DocArchivalNumber = t.DocArchivalNumber, TransactionType = t.TransactionType, CustomerID = t.CustomerID, AccountID = l.AccountID, LineDescription = l.Description, CreditAmount = l.CreditAmount.ToFloat() }; transactionlines.Add(line); } } } return(transactionlines); }
public void AddToTransactionLog(TransactionEntry entry) { entry.TransactionNumber = _transCollection.Count + 1; _transCollection.Add(entry); //SaveTransactionLog(); AddTransactionToFile(entry, true); //UpdateNumberOfTransActions(); //UpdateChecksum(); }
public Automation(AutomationGroup parent, AutomationEntry entry) { this._group = parent; this._transaction = new TransactionEntry(); this._transaction.Count = 0; this._transaction.Created = DateTime.Now; this._entry = entry; }
private void simpleButton4_Click(object sender, EventArgs e) { // cast roll forward if (gridView1.GetFocusedRow() is TransactionEntry) { TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow(); CastRollForwardEvent(sh); gridView1.FocusedRowHandle++; } }
public TransactionEntry AddSymbol(string exchange, string symbol, TransactionDataArgs args, PortfolioEntry entry) { PositionFeed positionFeed = FinanceService.Query(new PositionQuery(entry.EditUri.Content + FinanceNamespace.POSITIONAPPENDQUERY + Details())); TransactionEntry transactionEntry = new TransactionEntry() { TransactionData = new TransactionData() { Type = args.TransactionType, Date = args.Date.ToString(), Shares = args.Shares, Notes = args.Notes, Commission = new Commission(), Price = new Price() } }; PositionEntry positionEntry = new PositionEntry() { Symbol = new Symbol() { StockSymbol = symbol, Exchange = exchange } }; transactionEntry.TransactionData.Commission.Money.Add(new Money() { Amount = args.Commission, CurrencyCode = args.CurrencyCode }); transactionEntry.TransactionData.Price.Money.Add(new Money() { Amount = args.Price, CurrencyCode = args.CurrencyCode }); Uri uri = new Uri(positionFeed.Feed + "/" + positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol + "/" + FinanceNamespace.TRANSACTIONS); try { return(FinanceService.Insert(uri, transactionEntry)); } catch (Exception ex) { Console.WriteLine("Exception while trying to add symbol={0} to portfolio={1} and transaction: ", positionEntry.Symbol.Exchange + ":" + positionEntry.Symbol.StockSymbol, entry.Title.Text); Console.WriteLine("Type={0}, Date={1}, Shares={2}, Notes={3}, Commission={4}, Price={5}", transactionEntry.TransactionData.Type, transactionEntry.TransactionData.Date, transactionEntry.TransactionData.Shares, transactionEntry.TransactionData.Notes, transactionEntry.TransactionData.Commission, transactionEntry.TransactionData.Price); Console.WriteLine("Exception: {0}", ex.Message); return(null); } }
/// <summary> /// Authorizes a payment. /// </summary> /// <param name="transaction">Transaction to authorize.</param> /// <returns>The report returned from Stone Authorizer, or null if something /// went wrong.</returns> public IAuthorizationReport Authorize(TransactionOption transaction) { // Verify if the authorizer is eligible to do something: if (this.IsUsable == false) { return(null); } // Setup transaction data: ITransactionEntry transactionEntry = new TransactionEntry { Amount = transaction.Amount, CaptureTransaction = true, InitiatorTransactionKey = transaction.Itk, Type = transaction.AccountType }; IAuthorizationReport authReport = null; try { // Authorize the transaction setup and return it's value: ResponseStatus authorizationStatus; authReport = this.StoneAuthorizer.Authorize(transactionEntry, out authorizationStatus); // Show result on console: if (authReport.WasSuccessful == true) { authReport.ShowTransactionOnScreen(); this.Transactions.Add(new TransactionTableEntry(authReport, false)); } else { authReport.ShowErrorOnTransaction(); this.Transactions.Add(new TransactionTableEntry(authReport, true)); } } catch (CardHasChipException) { Console.WriteLine("O cartao possui chip. For favor, insira-o."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } catch (ExpiredCardException) { Console.WriteLine("Cartão expirado."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } catch (Exception) { Console.WriteLine("Ocorreu um erro na transacao."); this.Transactions.Add(new TransactionTableEntry(transactionEntry, true)); } return(authReport); }
private void simpleButton3_Click(object sender, EventArgs e) { // cast rollback if (gridView1.GetFocusedRow() is TransactionEntry) { TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow(); CastRollBackEvent(sh); // move the selected cursor one row up, if possible gridView1.FocusedRowHandle--; } }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { // note was edited? if (e.Column.Name == gcNote.Name) { // save the transaction log again (and reload?) TransactionEntry sh = (TransactionEntry)gridView1.GetRow(e.RowHandle); //MessageBox.Show("You changed the note into: " + sh.Note); CastNoteChangedEvent(sh); } }
private void UpdateTransactions() { TransactionEntry transaction = (from t in this._group.Manager.TransactionManager.Transaction where t.ServiceID == this.ID select t).FirstOrDefault(); if (transaction == null) { return; } if (transaction.Count > this._transaction.Count) { this._transaction = transaction; this._lastTransaction = DateTime.Now; } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } TransactionEntry = await _context.Transactions .Include(t => t.ApplicationUser).SingleOrDefaultAsync(m => m.ID == id); if (TransactionEntry == null) { return(NotFound()); } return(Page()); }
public void CummulativeGrowthTest() { var bTransactionEntry = new TransactionEntry() { Saldo = 248, Date = new DateTime(2018, 06, 01).ToString("o") }; var eTransactionEntry = new TransactionEntry() { Saldo = 100, Date = new DateTime(2018, 01, 01).ToString("o") }; var change = OperationsService.CompoundGrowthRate(bTransactionEntry, eTransactionEntry); Assert.IsTrue(Math.Abs(change - 20) < 1); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TransactionEntry = await _context.Transactions.FindAsync(id); if (TransactionEntry != null) { _context.Transactions.Remove(TransactionEntry); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void rollForwardToolStripMenuItem_Click(object sender, EventArgs e) { // cast rollforward event to the main form // and reload the list int[] selectedrows = gridView1.GetSelectedRows(); int grouplevel = gridView1.GetRowLevel((int)selectedrows.GetValue(0)); if (grouplevel >= gridView1.GroupCount) { //Console.WriteLine("In row"); if (gridView1.GetFocusedRow() is TransactionEntry) { TransactionEntry sh = (TransactionEntry)gridView1.GetFocusedRow(); CastRollForwardEvent(sh); } } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } TransactionEntry = await _context.Transactions .Include(t => t.ApplicationUser).SingleOrDefaultAsync(m => m.ID == id); if (TransactionEntry == null) { return(NotFound()); } ViewData["ApplicationUserID"] = new SelectList(_context.Set <ApplicationUser>(), "Id", "Id"); return(Page()); }
private GetTransactionResponse GetTransactionInfo(TransactionEntry tx, bool colored, BlockInformation block) { var response = new GetTransactionResponse() { TransactionId = tx.TransactionId, Transaction = tx.Transaction, IsCoinbase = tx.Transaction.IsCoinBase, Fees = tx.Fees, Block = block, FirstSeen = tx.FirstSeen }; for (int i = 0; i < tx.Transaction.Outputs.Count; i++) { var txout = tx.Transaction.Outputs[i]; NBitcoin.ICoin coin = new NBitcoin.Coin(new NBitcoin.OutPoint(tx.TransactionId, i), txout); if (colored) { var entry = tx.ColoredTransaction.GetColoredEntry((uint)i); if (entry != null) { coin = new NBitcoin.ColoredCoin(entry.Asset, (NBitcoin.Coin)coin); } } response.ReceivedCoins.Add(coin); } if (!response.IsCoinbase) { for (int i = 0; i < tx.Transaction.Inputs.Count; i++) { NBitcoin.ICoin coin = new NBitcoin.Coin(tx.SpentCoins[i].OutPoint, tx.SpentCoins[i].TxOut); if (colored) { var entry = tx.ColoredTransaction.Inputs.FirstOrDefault(ii => ii.Index == i); if (entry != null) { coin = new NBitcoin.ColoredCoin(entry.Asset, (NBitcoin.Coin)coin); } } response.SpentCoins.Add(coin); } } return(response); }
//ImportFilename = "C:\\Repos\\RentParser\\Rental-3JUN2017-to-3JUN2019.csv" private Transaction ConvertToTransaction(TransactionEntry entry) { Transaction transaction = new Transaction(); transaction.Amount = float.Parse(entry.Amount, System.Globalization.NumberStyles.Currency); transaction.Date = DateTime.Parse(entry.Date); transaction.Payee = null; transaction.PayeeLabel = entry.Payee; transaction.Particulars = entry.Particulars; transaction.TransactionCodeType = entry.TranType; transaction.OurAccount = entry.ThisPartyAccount; //TODO: String formatting transaction.TheirAccount = entry.OtherPartyAccount; transaction.BatchNumber = entry.BatchNumber; transaction.OriginatingBank = entry.OriginatingBank; transaction.ProcessedDate = DateTime.Parse(entry.ProcessedDate); return(transaction); }
public int IndexOf(TransactionEntry value) { return (List.IndexOf(value)); }
public void Insert(int index, TransactionEntry value) { List.Insert(index, value); }
public void Remove(TransactionEntry value) { List.Remove(value); }
public void SetEntryNote(TransactionEntry ChangedEntry) { foreach (TransactionEntry entry in _transCollection) { if (entry.TransactionNumber == ChangedEntry.TransactionNumber) { entry.Note = ChangedEntry.Note; } } SaveTransactionLog(); }
public TransactionsEventArgs(TransactionEntry entry) { this._entry = entry; }
public RollInformationEventArgs(TransactionEntry entry) { this._entry = entry; }
public override bool WriteData(byte[] data, uint offset, string note) { if (File.Exists(m_currentFile)) { byte[] beforedata = readdatafromfile(m_currentFile, (int)offset, data.Length); for (int i = 0; i < data.Length; i++) { writebyteinfile(m_currentFile, (int)offset + i, (byte)data.GetValue(i)); } //SetMemorySyncCounter(GetMemorySyncCounter() + 1); SetMemorySyncDate(DateTime.Now); if (m_transactionLog != null) { TransactionEntry tentry = new TransactionEntry(DateTime.Now, (int)offset, data.Length, beforedata, data, 0, 0, note); m_transactionLog.AddToTransactionLog(tentry); SignalTransactionLogChanged(tentry); // versiebeheer bijhouden <GS-16032010> } if (m_autoUpdateChecksum) UpdateChecksum(); return true; } return false; }
public void ReadTransactionFile() { _transCollection = new TransactionCollection(); if (VerifyChecksum()) { FileInfo fi = new FileInfo(m_fileName); Int32 _entryCount = readInt32FromFile(m_fileName, 4); FileStream fs = new FileStream(m_fileName, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { // byte[] allBytes = br.ReadBytes((int)fi.Length - 8); //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 NoteLength = br.ReadInt16(); byte[] notedata = br.ReadBytes(NoteLength); string note = string.Empty; for (int i = 0; i < notedata.Length; i += 2) { string Hex = string.Empty; Hex += Convert.ToChar(notedata[i]); Hex += Convert.ToChar(notedata[i + 1]); int value = Convert.ToInt32(Hex, 16); note += Convert.ToChar(value); } Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, note); _transCollection.Add(entry); } } fs.Close(); } }
private void AddTransactionToFile(TransactionEntry entry, bool updateChecksum) { // append at the end of the file //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after AppendInt32ToFile(entry.TransactionNumber); AppendByteToFile(Convert.ToByte(entry.IsRolledBack)); // not rolled back AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Day)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Month)); AppendInt16ToFile(Convert.ToInt16(entry.EntryDateTime.Year)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Hour)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Minute)); AppendByteToFile(Convert.ToByte(entry.EntryDateTime.Second)); AppendInt32ToFile(entry.SymbolAddress); AppendInt16ToFile(Convert.ToInt16(entry.Note.Length * 2)); // now add double hex all characters for (int i = 0; i < entry.Note.Length; i++) { byte curByte = Convert.ToByte(entry.Note[i]); string Hex = curByte.ToString("X2"); AppendByteToFile(Convert.ToByte(Hex[0])); AppendByteToFile(Convert.ToByte(Hex[1])); } AppendInt16ToFile(Convert.ToInt16(entry.SymbolLength)); AppendDataToFile(entry.DataBefore); AppendDataToFile(entry.DataAfter); // update number of entries Int32 _entryCount = readInt32FromFile(m_fileName, 4); _entryCount++; if (updateChecksum) { writeInt32ToFile(m_fileName, 4, _entryCount); UpdateChecksum(); } // update checksum }
private void RollForwardOnFile(IECUFile file2Rollback, TransactionEntry entry) { int addressToWrite = entry.SymbolAddress; while (addressToWrite > file2Rollback.GetFileInfo().Filelength) addressToWrite -= file2Rollback.GetFileInfo().Filelength; file2Rollback.WriteDataNoLog(entry.DataAfter, (uint)addressToWrite); }
public bool Contains(TransactionEntry value) { // If value is not of type Int16, this will return false. return (List.Contains(value)); }
private void RollForward(TransactionEntry entry) { int addressToWrite = entry.SymbolAddress; while (addressToWrite > m_trionicFileInformation.Filelength) addressToWrite -= m_trionicFileInformation.Filelength; m_trionicFile.WriteDataNoLog(entry.DataAfter, (uint)addressToWrite); m_ProjectTransactionLog.SetEntryRolledForward(entry.TransactionNumber); if (m_CurrentWorkingProject != string.Empty) { m_ProjectLog.WriteLogbookEntry(LogbookEntryType.TransactionRolledforward, m_trionicFileInformation.GetSymbolNameByAddress(entry.SymbolAddress) + " " + entry.Note + " " + entry.TransactionNumber.ToString()); } UpdateRollbackForwardControls(); }
public int Add(TransactionEntry value) { return (List.Add(value)); }
// Implement addition to changelog here (write data to binary file) public override bool WriteDataNoCounterIncrease(byte[] data, uint offset) { if (File.Exists(m_currentFile)) { byte[] beforedata = readdatafromfile(m_currentFile, (int)offset, data.Length); for (int i = 0; i < data.Length; i++) { writebyteinfile(m_currentFile, (int)offset + i, (byte)data.GetValue(i)); } if(m_transactionLog != null) { TransactionEntry tentry = new TransactionEntry(DateTime.Now, (int)offset, data.Length, beforedata, data, 0, 0, ""); m_transactionLog.AddToTransactionLog(tentry); SignalTransactionLogChanged(tentry); // versiebeheer bijhouden <GS-16032010> //m_fileInfo.getSymbolNameByAddress((int)offset); } if (m_autoUpdateChecksum) UpdateChecksum(); return true; } return false; }
public TransactionCollection ReadTransactionFileVersion1(string filename) { TransactionCollection m_transCollection = new TransactionCollection(); Int32 _entryCount = readInt32FromFile(filename, 4); FileStream fs = new FileStream(filename, FileMode.Open); fs.Seek(8, SeekOrigin.Begin); using (BinaryReader br = new BinaryReader(fs)) { //1 byte hex day, 1 byte hex month, 2 bytes hex year, 1 byte hex hour 1 byte hex minute, 1 byte hex second, 4 bytes hex address, 2 bytes hex length, x bytes hex (data) before, x bytes (data) after for (int t = 0; t < _entryCount; t++) { Int32 transActionNumber = br.ReadInt32(); byte isRolledBack = br.ReadByte(); byte day = br.ReadByte(); byte month = br.ReadByte(); Int16 year = br.ReadInt16(); byte hour = br.ReadByte(); byte minute = br.ReadByte(); byte second = br.ReadByte(); DateTime entryDateTime = new DateTime(year, Convert.ToInt16(month), Convert.ToInt16(day), Convert.ToInt16(hour), Convert.ToInt16(minute), Convert.ToInt16(second)); Int32 address = br.ReadInt32(); Int16 length = br.ReadInt16(); byte[] beforeData = br.ReadBytes(length); byte[] afterData = br.ReadBytes(length); // read day TransactionEntry entry = new TransactionEntry(entryDateTime, address, length, beforeData, afterData, isRolledBack, transActionNumber, ""); m_transCollection.Add(entry); } } fs.Close(); return m_transCollection; }