public void MergeNewStatements() { var statementLocations = this.Repository.GetStatementLocations(); bool isAnyMerged = false; foreach (var statementLocation in statementLocations) { if (this.LatestMerged.HasImportInfo(statementLocation.ImportInfo.Id)) { MessagePipe.SendMessage("Location {0} skipped".FormatEx(statementLocation.Address)); } else { var statementTransactions = this.Repository.TransactionsStorage.Load(statementLocation); var oldCount = this.LatestMerged.AllParentChildTransactions.Count(); this.LatestMerged.Merge(statementTransactions, false); isAnyMerged = true; MessagePipe.SendMessage("{0} transactions found ({1} new) in {2}".FormatEx(statementTransactions.AllParentChildTransactions.Count(), this.LatestMerged.AllParentChildTransactions.Count() - oldCount, statementLocation.Address)); } } if (isAnyMerged) { this.LatestMerged.MatchTransactions(); } }
public void Save(ILocation location, TransactionEdits transactions, ILocation auxilaryComponentLocation = null) { if (this.Exists(location)) { //Create backup var existingFileDateTime = File.GetLastWriteTimeUtc(location.Address); var newSuffix = existingFileDateTime.ToString("yyyyMMddHHmmssffff"); var ext = Path.GetExtension(location.Address); var archiveFilePath = Path.ChangeExtension(location.Address, string.Concat(newSuffix, ".", ext)); File.Copy(location.Address, archiveFilePath); } var serializedData = transactions.SerializeToJson(); File.WriteAllText(location.Address, serializedData); MessagePipe.SendMessage("Saved {0}".FormatEx(location.Address)); }
public void Save(ILocation location, Transactions transactions, ILocation auxilaryComponentLocation = null) { if (location != null) { var serializedData = transactions.SerializeToJson(); File.WriteAllText(location.Address, serializedData); MessagePipe.SendMessage("Saved {0}".FormatEx(location.Address)); } else { MessagePipe.SendMessage("Did not saved transaction because location was null"); } if (auxilaryComponentLocation != null) { var edits = transactions.GetClonedEdits(); this.editsStorage.Save(auxilaryComponentLocation, edits); } }
public void AddAccountConfig(AccountConfig accountConfig) { var accountFolder = Path.Combine(this.importFolderPath, accountConfig.AccountInfo.Id); if (!Directory.Exists(accountFolder)) { Directory.CreateDirectory(accountFolder); } var accountConfigFilePath = Path.Combine(accountFolder, AccountConfigFileName); if (File.Exists(accountConfigFilePath)) { throw new Exception("Account config file {0} already exist. Cannot add new account.".FormatEx(accountConfigFilePath)); } File.WriteAllText(accountConfigFilePath, accountConfig.SerializeToJson()); MessagePipe.SendMessage("Account added at {0}".FormatEx(accountConfigFilePath)); }