コード例 #1
0
ファイル: Thunderbird.cs プロジェクト: ArsenShnurkov/beagle-1
        public static string GetRelativePath(string mork_file)
        {
            string        path   = null;
            AccountReader reader = null;

            foreach (string root in Thunderbird.GetProfilePaths(Thunderbird.GetRootPath()))
            {
                try {
                    reader = new AccountReader(root);

                    foreach (Account account in reader)
                    {
                        if (!mork_file.StartsWith(account.Path))
                        {
                            continue;
                        }

                        path = String.Format("{0}/{1}",
                                             account.Server, mork_file.Substring(account.Path.Length + 1));
                        break;
                    }
                } catch {
                    continue;
                }
            }

            return(path);
        }
コード例 #2
0
        public async Task <Report> GenerateAsync(int userId, int portfolioId)
        {
            var connections        = ConnectionReader.ReadByUserIdAsync(userId);
            var allocations        = AllocationReader.ReadByPortfolioIdAsync(portfolioId);
            var cashAssetClass     = AssetClassReader.ReadCashByPortfolioIdAsync(portfolioId);
            var equityAssetClasses = AssetClassReader.ReadEquityByPortfolioIdAsync(portfolioId);
            var currencies         = CurrencyReader.ReadAllAsync();
            var exclude            = await ExcludeReader.ReadByPortfolioIdAsync(portfolioId);

            var accounts = new List <AccountReport>();

            foreach (var connection in await connections)
            {
                accounts.AddRange(
                    (await AccountReader.ReadByConnectionIdAsync(connection.Id))
                    .Select(a => new AccountReport(
                                exclude.Accounts.Any(e => e.Id == a.Id),
                                a.Id,
                                a.Number,
                                a.Name,
                                a.Balances.Select(b => new BalanceReport(false, b)), // TODO: In the future, get exclude value from database
                                a.Positions.Select(p => new PositionReport(
                                                       exclude.Symbols.Any(s => s.AccountId == a.Id && s.SymbolId == p.Symbol.Id), p)))));
            }

            return(new Report(
                       accounts.OrderBy(a => a.Name).ToList(),
                       await allocations,
                       await cashAssetClass,
                       await equityAssetClasses,
                       await currencies,
                       (await currencies).First(c => c.Code == "CAD")));
        }
コード例 #3
0
 public IndexModel(
     ILogger <IndexModel> logger,
     AccountReader accountService
     )
 {
     _logger        = logger;
     AccountService = accountService;
 }
コード例 #4
0
 public IEnumerable <Account> Read()
 {
     using (var ar = new AccountReader(new FileStream(_filename, FileMode.OpenOrCreate)))
     {
         while (!ar.IsEnd())
         {
             Account account = ar.Read();
             yield return(account);
         }
     }
 }
コード例 #5
0
 public AccountsController(AccountReader accountService)
 {
     AccountService = accountService;
 }
コード例 #6
0
ファイル: Thunderbird.cs プロジェクト: ArsenShnurkov/beagle-1
		public static string GetRelativePath (string mork_file)
		{
			string path = null;
			AccountReader reader = null;
			
			foreach (string root in Thunderbird.GetProfilePaths (Thunderbird.GetRootPath ())) {
				try { 
					reader = new AccountReader (root);
					
					foreach (Account account in reader) {
						if (!mork_file.StartsWith (account.Path))
							continue;
						
						path = String.Format ("{0}/{1}",
							account.Server, mork_file.Substring (account.Path.Length+1));
						break;
					}
				} catch {
					continue;
				}
			}
			
			return path;
		}