public void Execute() { var sourceAccountingSubjectRepository = new AccountingSubjectRepository(this.sourceMongoDBOptions); var targetAccountingSubjectRepository = new AccountingSubjectRepository(this.targetMongoDBOptions); var accountingSubjects = sourceAccountingSubjectRepository.FetchAll().Result; targetAccountingSubjectRepository.CreateAll(accountingSubjects).Wait(); var sourceDetailRepository = new DetailRepository(this.sourceMongoDBOptions); var targetDetailRepository = new DetailRepository(this.targetMongoDBOptions); var details = sourceDetailRepository.FetchAll().Result; targetDetailRepository.CreateAll(details).Wait(); }
public Dictionary <AccountingSubjectType, IList <dynamic> > GraphBy([FromBody] Condition condition) { if (condition.TradingDayBegin.HasValue) { condition.TradingDayBegin = condition.TradingDayBegin.Value.ToLocalTime(); } if (condition.TradingDayEnd.HasValue) { condition.TradingDayEnd = condition.TradingDayEnd.Value.ToLocalTime().AddDays(1).AddMilliseconds(-1); } var details = this.detailRepository.FetchBy(condition); var accountingSubjects = accountingSubjectRepository.FetchAll().Result; var graphEntrys = new List <GraphEntry>(); foreach (var detail in details) { foreach (var entry in detail.Entrys) { if (string.IsNullOrEmpty(condition.AccountingSubjectCode) || condition.AccountingSubjectCode.Contains(entry.AccountingSubjectCode)) { graphEntrys.Add(new GraphEntry() { TradingDay = detail.TradingDay.Value, Entry = entry }); } } } var result = new Dictionary <AccountingSubjectType, IList <dynamic> >(); result.Add(AccountingSubjectType.Assets, new List <dynamic>()); result.Add(AccountingSubjectType.Liabilities, new List <dynamic>()); result.Add(AccountingSubjectType.Revenues, new List <dynamic>()); result.Add(AccountingSubjectType.Expenses, new List <dynamic>()); var date = condition.TradingDayBegin.Value; var tradingDayBegin = new DateTime(date.Year, date.Month, 1); var tradingDayEnd = tradingDayBegin.AddMonths(condition.MonthInterval); this.graphBy(AccountingSubjectType.Assets, condition.TradingDayBegin.Value, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Liabilities, condition.TradingDayBegin.Value, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Revenues, tradingDayBegin, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Expenses, tradingDayBegin, tradingDayEnd, graphEntrys, accountingSubjects, result); while (condition.TradingDayEnd >= tradingDayEnd) { tradingDayBegin = tradingDayEnd; tradingDayEnd = tradingDayBegin.AddMonths(condition.MonthInterval); this.graphBy(AccountingSubjectType.Assets, condition.TradingDayBegin.Value, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Liabilities, condition.TradingDayBegin.Value, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Revenues, tradingDayBegin, tradingDayEnd, graphEntrys, accountingSubjects, result); this.graphBy(AccountingSubjectType.Expenses, tradingDayBegin, tradingDayEnd, graphEntrys, accountingSubjects, result); } return(result); }
public void Execution(string[] args) { logger.Debug($"this.localMongoDBOptions.ConnectionString: {this.localMongoDBOptions.ConnectionString}"); logger.Debug($"this.remoteMongoDBOptions.ConnectionString: {this.remoteMongoDBOptions.ConnectionString}"); var localAccountingSubjectRepository = new AccountingSubjectRepository(this.localMongoDBOptions); var remoteAccountingSubjectRepository = new AccountingSubjectRepository(this.remoteMongoDBOptions); var accountingSubjects = remoteAccountingSubjectRepository.FetchAll().Result; logger.Debug($"accountingSubjects.Count(): {accountingSubjects.Count()}"); localAccountingSubjectRepository.DeleteAll().Wait(); logger.Debug($"localAccountingSubjectRepository.DeleteAll().Wait();"); localAccountingSubjectRepository.CreateAll(accountingSubjects).Wait(); logger.Debug($"localAccountingSubjectRepository.CreateAll(accountingSubjects).Wait();"); var localAuthorizationRepository = new AuthorizationRepository(this.localMongoDBOptions); var remoteAuthorizationRepository = new AuthorizationRepository(this.remoteMongoDBOptions); var authorizations = remoteAuthorizationRepository.FetchAll().Result; logger.Debug($"authorizations.Count(): {authorizations.Count()}"); localAuthorizationRepository.DeleteAll().Wait(); logger.Debug($"localAuthorizationRepository.DeleteAll().Wait();"); localAuthorizationRepository.CreateAll(authorizations).Wait(); logger.Debug($"localAuthorizationRepository.CreateAll(authorizations).Wait();"); var localBookRepository = new BookRepository(this.localMongoDBOptions); var remoteBookRepository = new BookRepository(this.remoteMongoDBOptions); var books = remoteBookRepository.FetchAll().Result; logger.Debug($"books.Count(): {books.Count()}"); if (books.Count() > 0) { localBookRepository.DeleteAll().Wait(); logger.Debug($"localBookRepository.DeleteAll().Wait();"); localBookRepository.CreateAll(books).Wait(); logger.Debug($"localBookRepository.CreateAll(books).Wait();"); } var localDetailRepository = new DetailRepository(this.localMongoDBOptions); var remoteDetailRepository = new DetailRepository(this.remoteMongoDBOptions); var packageInformationIds = localDetailRepository.GetPackageInformationIds(); logger.Debug($"packageInformationIds.Count(): {packageInformationIds.Count()}"); var details = remoteDetailRepository.FetchAll(item => !packageInformationIds.Contains(item.PackageInformation.Id)).Result; logger.Debug($"details.Count(): {details.Count()}"); foreach (var detail in details) { if (localDetailRepository.Exist(detail.Id)) { localDetailRepository.Update(detail); } else { localDetailRepository.Create(detail).Wait(); } } logger.Debug($"localDetailRepository.CreateAll(details).Wait();"); }