コード例 #1
0
        public ActionResult SaveBy([FromBody] dynamic data)
        {
            AccountingSubject        conditionForFilter           = JsonConvert.DeserializeObject <AccountingSubject>(JsonConvert.SerializeObject(data.conditionForFilter));
            List <AccountingSubject> accountingSubjectsFromClient = JsonConvert.DeserializeObject <List <AccountingSubject> >(JsonConvert.SerializeObject(data.accountingSubjects));

            var accountingSubjectsFromEmpty = accountingSubjectsFromClient.Where(item => item.IsEmptyInstance()).ToList();

            foreach (var accountingSubjectFromEmpty in accountingSubjectsFromEmpty)
            {
                accountingSubjectsFromClient.Remove(accountingSubjectFromEmpty);
            }

            var accountingSubjectsFromDB = this.FetchBy(conditionForFilter);

            try
            {
                accountingSubjectRepository.Delete(conditionForFilter);

                if (accountingSubjectsFromClient.Count() > 0)
                {
                    accountingSubjectRepository.CreateAll(accountingSubjectsFromClient).Wait();
                }
            }
            catch (Exception exception)
            {
                logger.LogError(JsonConvert.SerializeObject(accountingSubjectsFromDB));
                throw exception;
            }

            return(Ok(new ValidResult()));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();");
        }