private void SaveDeposit() { depositManager = new DepositManager(this); original_deposit = depositManager.GetDeposit(Convert.ToInt32(Page.ViewState["DepositId"])); deposit = new Deposit(); if (original_deposit != null) { deposit.CopyPropertiesFrom(original_deposit); } deposit.Name = txtName.Text; deposit.CompanyId = Company.CompanyId; deposit.PostalCode = ucDepositAddress.PostalCode; deposit.AddressComp = ucDepositAddress.AddressComp; deposit.AddressNumber = ucDepositAddress.AddressNumber; if (ucCurrFieldFirstWeekGoal.CurrencyValue.HasValue) { deposit.FirstWeekGoal = ucCurrFieldFirstWeekGoal.CurrencyValue.Value; } if (ucCurrFieldSecondWeekGoal.CurrencyValue.HasValue) { deposit.SecondWeekGoal = ucCurrFieldSecondWeekGoal.CurrencyValue.Value; } if (ucCurrFieldThirdWeekGoal.CurrencyValue.HasValue) { deposit.ThirdWeekGoal = ucCurrFieldThirdWeekGoal.CurrencyValue.Value; } if (ucCurrFieldForthWeekGoal.CurrencyValue.HasValue) { deposit.ForthWeekGoal = ucCurrFieldForthWeekGoal.CurrencyValue.Value; } if (ucCurrFieldFirstWeekGoal.CurrencyValue.HasValue) { deposit.FifthWeekGoal = ucCurrFieldFifthWeekGoal.CurrencyValue.Value; } if (ucCurrFieldMonthlyGoal.CurrencyValue.HasValue) { deposit.MonthlyGoal = ucCurrFieldMonthlyGoal.CurrencyValue.Value; } if (original_deposit != null) { depositManager.Update(original_deposit, deposit); } else { depositManager.Insert(deposit); } Response.Redirect("Deposits.aspx"); }
protected void cboDeposit_SelectedIndexChanged(object sender, EventArgs e) { using (var depositManager = new DepositManager(null)) { Deposit deposit = depositManager.GetDeposit(Convert.ToInt32(cboDeposit.SelectedValue)); Address1.PostalCode = deposit.PostalCode; Address1.AddressNumber = deposit.AddressNumber; Address1.AddressComp = deposit.AddressComp; } }
public static bool DeleteDeposit(Int32 companyId, Int32 depositId) { bool result = true; using (DepositManager depositManager = new DepositManager(null)) { try { depositManager.Delete(depositManager.GetDeposit(depositId)); } catch (System.Data.SqlClient.SqlException e) { result = false; } } return result; }
public static bool DeleteDeposit(Int32 companyId, Int32 depositId) { bool result = true; using (DepositManager depositManager = new DepositManager(null)) { try { depositManager.Delete(depositManager.GetDeposit(depositId)); } catch (System.Data.SqlClient.SqlException e) { result = false; } } return(result); }
private void GetGrouByDepositAmountList() { string date = DateTime.Now.Month.ToString(); DepositManager aDepositManager = new DepositManager(); List <MemberWithDeposit> memberWithDeposits = aDepositManager.GetMemberWithDepositAmountGroupByName(date); int sno = 1; int subTotal = 0; foreach (var deposit in memberWithDeposits) { ListViewItem item = new ListViewItem(); item.Text = sno++.ToString(); item.SubItems.Add(deposit.MemberName); item.SubItems.Add(deposit.Amount.ToString()); item.SubItems.Add((subTotal = subTotal + deposit.Amount).ToString()); depositListView.Items.Add(item); } }
public DepositCrystalReportUI(string month) { InitializeComponent(); DepositManager aDepositManager = new DepositManager(); HelperClass helper = new HelperClass(); List <MemberWithDeposit> depositList = aDepositManager.GetMemberWithDepositList(month); DepositCrystalReport depositCrystalReport = new DepositCrystalReport(); depositCrystalReport.SetDataSource(depositList); //depositCrystalReport.SetParameterValue("Month", helper.CurrentMonthAsString()); //shopingCrystalReportViewer.ReportSource = shopingCrystalReport; depositCrystalReportViewer.ReportSource = depositCrystalReport; }
private void SaveDeposit() { depositManager = new DepositManager(this); original_deposit = depositManager.GetDeposit(Convert.ToInt32(Page.ViewState["DepositId"])); deposit = new Deposit(); if (original_deposit != null) deposit.CopyPropertiesFrom(original_deposit); deposit.Name = txtName.Text; deposit.CompanyId = Company.CompanyId; deposit.PostalCode = ucDepositAddress.PostalCode; deposit.AddressComp = ucDepositAddress.AddressComp; deposit.AddressNumber = ucDepositAddress.AddressNumber; if (ucCurrFieldFirstWeekGoal.CurrencyValue.HasValue) deposit.FirstWeekGoal = ucCurrFieldFirstWeekGoal.CurrencyValue.Value; if (ucCurrFieldSecondWeekGoal.CurrencyValue.HasValue) deposit.SecondWeekGoal = ucCurrFieldSecondWeekGoal.CurrencyValue.Value; if (ucCurrFieldThirdWeekGoal.CurrencyValue.HasValue) deposit.ThirdWeekGoal = ucCurrFieldThirdWeekGoal.CurrencyValue.Value; if (ucCurrFieldForthWeekGoal.CurrencyValue.HasValue) deposit.ForthWeekGoal = ucCurrFieldForthWeekGoal.CurrencyValue.Value; if (ucCurrFieldFirstWeekGoal.CurrencyValue.HasValue) deposit.FifthWeekGoal = ucCurrFieldFifthWeekGoal.CurrencyValue.Value; if(ucCurrFieldMonthlyGoal.CurrencyValue.HasValue) deposit.MonthlyGoal = ucCurrFieldMonthlyGoal.CurrencyValue.Value; if (original_deposit != null) depositManager.Update(original_deposit, deposit); else depositManager.Insert(deposit); Response.Redirect("Deposits.aspx"); }
public void Setup() { DataAssetProvider provider = new DataAssetProvider(_providerAddress, "provider"); _asset = new DataAsset(Keccak.Compute("1"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Published); _closedAsset = new DataAsset(Keccak.Compute("2"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Closed); _assetUnderMaintenance = new DataAsset(Keccak.Compute("3"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.UnderMaintenance); _withKyc = new DataAsset(Keccak.Compute("4"), "name", "desc", 1, DataAssetUnitType.Unit, 1000, 10000, new DataAssetRules(new DataAssetRule(1)), provider, state: DataAssetState.Published, kycRequired: true); _deposit = new Deposit(Keccak.Zero, 1, 2, 3); _details = new DepositDetails(_deposit, _asset, Address.Zero, new byte[0], 1, new TransactionInfo[0]); INdmBlockchainBridge blockchainBridge = BlockchainBridgeBuilder.BuildABridge(); _wallet = new DevWallet(new WalletConfig(), LimboLogs.Instance); DepositService depositService = new DepositService(blockchainBridge, new AbiEncoder(), _wallet, Address.Zero); IConsumerSessionRepository sessionRepository = new ConsumerSessionInMemoryRepository(); DepositUnitsCalculator unitsCalculator = new DepositUnitsCalculator(sessionRepository, Timestamper.Default); DepositsInMemoryDb depositsInMemoryDb = new DepositsInMemoryDb(); depositsInMemoryDb.Add(_details); IProviderRepository providerRepository = new ProviderInMemoryRepository(depositsInMemoryDb); IConsumerNotifier notifier = new ConsumerNotifier(Substitute.For <INdmNotifier>()); DataAssetService dataAssetService = new DataAssetService(providerRepository, notifier, LimboLogs.Instance); IDepositUnitsCalculator depositUnitsCalculator = Substitute.For <IDepositUnitsCalculator>(); INdmPeer peer = Substitute.For <INdmPeer>(); peer.NodeId.Returns(TestItem.PublicKeyB); peer.ProviderAddress.Returns(_providerAddress); dataAssetService.AddDiscovered(_asset, peer); dataAssetService.AddDiscovered(_closedAsset, peer); dataAssetService.AddDiscovered(_assetUnderMaintenance, peer); dataAssetService.AddDiscovered(_withKyc, peer); _kycVerifier = Substitute.For <IKycVerifier>(); ProviderService providerService = new ProviderService(providerRepository, notifier, LimboLogs.Instance); providerService.Add(peer); _depositManager = new DepositManager(depositService, unitsCalculator, dataAssetService, _kycVerifier, providerService, new AbiEncoder(), new CryptoRandom(), _wallet, Substitute.For <IGasPriceService>(), new DepositDetailsInMemoryRepository(depositsInMemoryDb, depositUnitsCalculator), Timestamper.Default, LimboLogs.Instance, 6, false); }
private void searchButton_Click(object sender, EventArgs e) { depositReportListView.Items.Clear(); int row = 1; int subTotal = 0; DepositManager aDepositManager = new DepositManager(); int memberId = (int)nameComboBox.SelectedValue; string date = DateTime.Now.Month.ToString(); List <MemberWithDeposit> memberWithDeposit = aDepositManager.MemberdDeposits(memberId, date); foreach (var deposit in memberWithDeposit) { ListViewItem item = new ListViewItem(); item.Text = row++.ToString(); item.SubItems.Add(deposit.Date.ToString()); item.SubItems.Add(deposit.Amount.ToString()); item.SubItems.Add((subTotal = subTotal + deposit.Amount).ToString()); depositReportListView.Items.Add(item); } }
protected void btnAddSale_Click(object sender, ImageClickEventArgs e) { SaleManager sManager = new SaleManager(this); //PaymentMethodManager pManager = new PaymentMethodManager(this); DepositManager dManager = new DepositManager(this); Sale sale = sManager.GetSale((int)Company.MatrixId, Convert.ToInt32("0" + txtSaleNumber.Text.Replace("_",""))); // // Verifica o número da nota, ele precisa existir, e ter o mesmo matrix ID // if (sale == null) { ShowError(Resources.Exception.nonExistentSale); pnlExchange.Visible = false; } //else //{ // // // // Preenche as Grids de Pagamento e Produtos // // // //pnlExchange.Visible = true; // ViewState["SaleId"] = sale.SaleId; // //DataTable payment = pManager.GetPaymentBySale(sale.CompanyId, sale.SaleId); // DataTable productData = sManager.GetSaleProducts(sale.CompanyId, sale.SaleId); // grdSaleItems.DataSource = productData; // grdSaleItems.DataBind(); // //grdPaymentMethod.DataSource = payment; // grdPaymentMethod.DataBind(); // // // // Preenche a Combo com os Produtos disponíveis na nota // // // cboProducts.DataSource = productData; // cboProducts.DataTextField = "Name"; // cboProducts.DataValueField = "ProductId"; // cboProducts.DataBind(); // // // // Preenche as Informações na tela // // // lblSaleDate.Text = sale.SaleDate.ToString(); // lblDiscount.Text = sale.Discount.ToString(); // //lblUserName.Text = payment.Rows[0]["Name2"].ToString(); // // // // Verifica o depósito de origem // // Foi utilizado o try, pois essa coluna não havia no banco, e esse try, // // evita uma tela amarela // // // try // { // lblSourceStore.Text = dManager.GetDeposit((int)sale.DepositId).Name; // } // catch // { // lblSourceStore.Text = "Dado não disponível"; // } // // // // Calcula o total da venda // // // Decimal total = (decimal)0; // //for (int i = 0; i < payment.Rows.Count; i++) // //{ // // total += Convert.ToDecimal(payment.Rows[i]["Amount"]); // // lblSaleTotal.Text = total.ToString(); // //} // // // // Reseta a Grid de Devolução // // // lblDevoltionValue.Visible = false; // txtDevolutionValue.Text = "0,00"; // txtDevolutionValue.Visible = false; // ViewState["Devolution"] = CreateDevolution(); // BindGrid(); //} }
public INdmConsumerServices Init(INdmServices services) { AddDecoders(); var logManager = services.RequiredServices.LogManager; var logger = logManager.GetClassLogger(); var disableSendingDepositTransaction = HasEnabledVariable("SENDING_DEPOSIT_TRANSACTION_DISABLED"); var instantDepositVerificationEnabled = HasEnabledVariable("INSTANT_DEPOSIT_VERIFICATION_ENABLED"); var backgroundServicesDisabled = HasEnabledVariable("BACKGROUND_SERVICES_DISABLED"); if (disableSendingDepositTransaction) { if (logger.IsWarn) { logger.Warn("*** NDM sending deposit transaction is disabled ***"); } } if (instantDepositVerificationEnabled) { if (logger.IsWarn) { logger.Warn("*** NDM instant deposit verification is enabled ***"); } } if (backgroundServicesDisabled) { if (logger.IsWarn) { logger.Warn("*** NDM background services are disabled ***"); } } var ndmConfig = services.RequiredServices.NdmConfig; var configId = ndmConfig.Id; var dbConfig = services.RequiredServices.ConfigProvider.GetConfig <IDbConfig>(); var contractAddress = string.IsNullOrWhiteSpace(ndmConfig.ContractAddress) ? Address.Zero : new Address(ndmConfig.ContractAddress); var rocksDbProvider = new ConsumerRocksDbProvider(services.RequiredServices.BaseDbPath, dbConfig, logManager); var depositDetailsRlpDecoder = new DepositDetailsDecoder(); var depositApprovalRlpDecoder = new DepositApprovalDecoder(); var receiptRlpDecoder = new DataDeliveryReceiptDetailsDecoder(); var sessionRlpDecoder = new ConsumerSessionDecoder(); var receiptRequestValidator = new ReceiptRequestValidator(logManager); IDepositDetailsRepository depositRepository; IConsumerDepositApprovalRepository depositApprovalRepository; IProviderRepository providerRepository; IReceiptRepository receiptRepository; IConsumerSessionRepository sessionRepository; switch (ndmConfig.Persistence?.ToLowerInvariant()) { case "mongo": var database = services.RequiredServices.MongoProvider.GetDatabase(); depositRepository = new DepositDetailsMongoRepository(database); depositApprovalRepository = new ConsumerDepositApprovalMongoRepository(database); providerRepository = new ProviderMongoRepository(database); receiptRepository = new ReceiptMongoRepository(database, "consumerReceipts"); sessionRepository = new ConsumerSessionMongoRepository(database); break; case "memory": if (logger.IsWarn) { logger.Warn("*** NDM is using in memory database ***"); } var depositsDatabase = new DepositsInMemoryDb(); depositRepository = new DepositDetailsInMemoryRepository(depositsDatabase); depositApprovalRepository = new ConsumerDepositApprovalInMemoryRepository(); providerRepository = new ProviderInMemoryRepository(depositsDatabase); receiptRepository = new ReceiptInMemoryRepository(); sessionRepository = new ConsumerSessionInMemoryRepository(); break; default: depositRepository = new DepositDetailsRocksRepository(rocksDbProvider.DepositsDb, depositDetailsRlpDecoder); depositApprovalRepository = new ConsumerDepositApprovalRocksRepository( rocksDbProvider.ConsumerDepositApprovalsDb, depositApprovalRlpDecoder); providerRepository = new ProviderRocksRepository(rocksDbProvider.DepositsDb, depositDetailsRlpDecoder); receiptRepository = new ReceiptRocksRepository(rocksDbProvider.ConsumerReceiptsDb, receiptRlpDecoder); sessionRepository = new ConsumerSessionRocksRepository(rocksDbProvider.ConsumerSessionsDb, sessionRlpDecoder); break; } var requiredBlockConfirmations = ndmConfig.BlockConfirmations; var abiEncoder = services.CreatedServices.AbiEncoder; var blockchainBridge = services.CreatedServices.BlockchainBridge; var blockProcessor = services.RequiredServices.BlockProcessor; var configManager = services.RequiredServices.ConfigManager; var consumerAddress = services.CreatedServices.ConsumerAddress; var cryptoRandom = services.RequiredServices.CryptoRandom; var depositService = services.CreatedServices.DepositService; var gasPriceService = services.CreatedServices.GasPriceService; var ecdsa = services.RequiredServices.Ecdsa; var ethRequestService = services.RequiredServices.EthRequestService; var jsonRpcNdmConsumerChannel = services.CreatedServices.JsonRpcNdmConsumerChannel; var ndmNotifier = services.RequiredServices.Notifier; var nodePublicKey = services.RequiredServices.Enode.PublicKey; var timestamper = services.RequiredServices.Timestamper; var wallet = services.RequiredServices.Wallet; var httpClient = services.RequiredServices.HttpClient; var jsonRpcClientProxy = services.RequiredServices.JsonRpcClientProxy; var ethJsonRpcClientProxy = services.RequiredServices.EthJsonRpcClientProxy; var transactionService = services.CreatedServices.TransactionService; var monitoringService = services.RequiredServices.MonitoringService; monitoringService?.RegisterMetrics(typeof(Metrics)); var dataRequestFactory = new DataRequestFactory(wallet, nodePublicKey); var transactionVerifier = new TransactionVerifier(blockchainBridge, requiredBlockConfirmations); var depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, timestamper); var depositProvider = new DepositProvider(depositRepository, depositUnitsCalculator, logManager); var kycVerifier = new KycVerifier(depositApprovalRepository, logManager); var consumerNotifier = new ConsumerNotifier(ndmNotifier); var dataAssetService = new DataAssetService(providerRepository, consumerNotifier, logManager); var providerService = new ProviderService(providerRepository, consumerNotifier, logManager); var dataRequestService = new DataRequestService(dataRequestFactory, depositProvider, kycVerifier, wallet, providerService, timestamper, sessionRepository, consumerNotifier, logManager); var sessionService = new SessionService(providerService, depositProvider, dataAssetService, sessionRepository, timestamper, consumerNotifier, logManager); var dataConsumerService = new DataConsumerService(depositProvider, sessionService, consumerNotifier, timestamper, sessionRepository, logManager); var dataStreamService = new DataStreamService(dataAssetService, depositProvider, providerService, sessionService, wallet, consumerNotifier, sessionRepository, logManager); var depositApprovalService = new DepositApprovalService(dataAssetService, providerService, depositApprovalRepository, timestamper, consumerNotifier, logManager); var depositConfirmationService = new DepositConfirmationService(blockchainBridge, consumerNotifier, depositRepository, depositService, logManager, requiredBlockConfirmations); IDepositManager depositManager = new DepositManager(depositService, depositUnitsCalculator, dataAssetService, kycVerifier, providerService, abiEncoder, cryptoRandom, wallet, gasPriceService, depositRepository, timestamper, logManager, requiredBlockConfirmations, disableSendingDepositTransaction); if (instantDepositVerificationEnabled) { depositManager = new InstantDepositManager(depositManager, depositRepository, timestamper, logManager, requiredBlockConfirmations); } var depositReportService = new DepositReportService(depositRepository, receiptRepository, sessionRepository, timestamper); var receiptService = new ReceiptService(depositProvider, providerService, receiptRequestValidator, sessionService, timestamper, receiptRepository, sessionRepository, abiEncoder, wallet, ecdsa, nodePublicKey, logManager); var refundService = new RefundService(blockchainBridge, abiEncoder, wallet, depositRepository, contractAddress, logManager); var refundClaimant = new RefundClaimant(refundService, blockchainBridge, depositRepository, transactionVerifier, gasPriceService, timestamper, logManager); var accountService = new AccountService(configManager, dataStreamService, providerService, sessionService, consumerNotifier, wallet, configId, consumerAddress, logManager); var proxyService = new ProxyService(jsonRpcClientProxy, configManager, configId, logManager); var consumerService = new ConsumerService(accountService, dataAssetService, dataRequestService, dataConsumerService, dataStreamService, depositManager, depositApprovalService, providerService, receiptService, refundService, sessionService, proxyService); var ethPriceService = new EthPriceService(httpClient, timestamper, logManager); var consumerTransactionsService = new ConsumerTransactionsService(transactionService, depositRepository, timestamper, logManager); var gasLimitService = new ConsumerGasLimitsService(depositService, refundService); IPersonalBridge personalBridge = services.RequiredServices.EnableUnsecuredDevWallet ? new PersonalBridge(ecdsa, wallet) : null; services.RequiredServices.RpcModuleProvider.Register( new SingletonModulePool <INdmRpcConsumerModule>(new NdmRpcConsumerModule(consumerService, depositReportService, jsonRpcNdmConsumerChannel, ethRequestService, ethPriceService, gasPriceService, consumerTransactionsService, gasLimitService, personalBridge, timestamper), true)); if (!backgroundServicesDisabled) { var useDepositTimer = ndmConfig.ProxyEnabled; var consumerServicesBackgroundProcessor = new ConsumerServicesBackgroundProcessor(accountService, refundClaimant, depositConfirmationService, ethPriceService, gasPriceService, blockProcessor, depositRepository, consumerNotifier, logManager, useDepositTimer, ethJsonRpcClientProxy); consumerServicesBackgroundProcessor.Init(); } return(new NdmConsumerServices(accountService, consumerService)); }
public async Task Init() { AddDecoders(); ILogManager logManager = _api.LogManager; ILogger logger = logManager.GetClassLogger(); bool disableSendingDepositTransaction = HasEnabledVariable("SENDING_DEPOSIT_TRANSACTION_DISABLED"); bool instantDepositVerificationEnabled = HasEnabledVariable("INSTANT_DEPOSIT_VERIFICATION_ENABLED"); bool backgroundServicesDisabled = HasEnabledVariable("BACKGROUND_SERVICES_DISABLED"); if (disableSendingDepositTransaction) { if (logger.IsWarn) { logger.Warn("*** NDM sending deposit transaction is disabled ***"); } } if (instantDepositVerificationEnabled) { if (logger.IsWarn) { logger.Warn("*** NDM instant deposit verification is enabled ***"); } } if (backgroundServicesDisabled) { if (logger.IsWarn) { logger.Warn("*** NDM background services are disabled ***"); } } INdmConfig ndmConfig = _api.NdmConfig; string configId = ndmConfig.Id; IDbConfig dbConfig = _api.ConfigProvider.GetConfig <IDbConfig>(); Address contractAddress = string.IsNullOrWhiteSpace(ndmConfig.ContractAddress) ? Address.Zero : new Address(ndmConfig.ContractAddress); DepositDetailsDecoder depositDetailsRlpDecoder = new DepositDetailsDecoder(); DepositApprovalDecoder depositApprovalRlpDecoder = new DepositApprovalDecoder(); DataDeliveryReceiptDetailsDecoder receiptRlpDecoder = new DataDeliveryReceiptDetailsDecoder(); ConsumerSessionDecoder sessionRlpDecoder = new ConsumerSessionDecoder(); ReceiptRequestValidator receiptRequestValidator = new ReceiptRequestValidator(logManager); IDepositDetailsRepository depositRepository; IConsumerDepositApprovalRepository depositApprovalRepository; IProviderRepository providerRepository; IReceiptRepository receiptRepository; IConsumerSessionRepository sessionRepository; IDepositUnitsCalculator depositUnitsCalculator; switch (ndmConfig.Persistence?.ToLowerInvariant()) { case "mongo": IMongoDatabase?database = _api.MongoProvider.GetDatabase(); if (database == null) { throw new ApplicationException("Failed to initialize Mongo DB."); } sessionRepository = new ConsumerSessionMongoRepository(database); depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, _api.Timestamper); depositRepository = new DepositDetailsMongoRepository(database, depositUnitsCalculator); depositApprovalRepository = new ConsumerDepositApprovalMongoRepository(database); providerRepository = new ProviderMongoRepository(database); receiptRepository = new ReceiptMongoRepository(database, "consumerReceipts"); break; case "memory": if (logger.IsWarn) { logger.Warn("*** NDM is using in memory database ***"); } DepositsInMemoryDb depositsDatabase = new DepositsInMemoryDb(); sessionRepository = new ConsumerSessionInMemoryRepository(); depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, _api.Timestamper); depositRepository = new DepositDetailsInMemoryRepository(depositsDatabase, depositUnitsCalculator); depositApprovalRepository = new ConsumerDepositApprovalInMemoryRepository(); providerRepository = new ProviderInMemoryRepository(depositsDatabase); receiptRepository = new ReceiptInMemoryRepository(); break; default: var dbInitializer = new ConsumerNdmDbInitializer(_api.DbProvider, ndmConfig, _api.RocksDbFactory, _api.MemDbFactory); await dbInitializer.InitAsync(); sessionRepository = new ConsumerSessionRocksRepository(_api.Db <IDb>(ConsumerNdmDbNames.ConsumerSessions), sessionRlpDecoder); depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, _api.Timestamper); depositRepository = new DepositDetailsRocksRepository(_api.Db <IDb>(ConsumerNdmDbNames.Deposits), depositDetailsRlpDecoder, depositUnitsCalculator); depositApprovalRepository = new ConsumerDepositApprovalRocksRepository( _api.Db <IDb>(ConsumerNdmDbNames.ConsumerDepositApprovals), depositApprovalRlpDecoder); providerRepository = new ProviderRocksRepository(_api.Db <IDb>(ConsumerNdmDbNames.Deposits), depositDetailsRlpDecoder); receiptRepository = new ReceiptRocksRepository(_api.Db <IDb>(ConsumerNdmDbNames.ConsumerReceipts), receiptRlpDecoder); break; } uint requiredBlockConfirmations = ndmConfig.BlockConfirmations; IAbiEncoder abiEncoder = _api.AbiEncoder; INdmBlockchainBridge blockchainBridge = _api.BlockchainBridge; IBlockProcessor blockProcessor = _api.MainBlockProcessor; IConfigManager configManager = _api.ConfigManager; Address consumerAddress = _api.ConsumerAddress; ICryptoRandom cryptoRandom = _api.CryptoRandom; IDepositService depositService = _api.DepositService; gasPriceService = _api.GasPriceService; IEthereumEcdsa ecdsa = _api.EthereumEcdsa; ethRequestService = _api.EthRequestService; jsonRpcNdmConsumerChannel = _api.JsonRpcNdmConsumerChannel; INdmNotifier ndmNotifier = _api.NdmNotifier; PublicKey nodePublicKey = _api.Enode.PublicKey; timestamper = _api.Timestamper; IWallet wallet = _api.Wallet; IHttpClient httpClient = _api.HttpClient; IJsonRpcClientProxy? jsonRpcClientProxy = _api.JsonRpcClientProxy; IEthJsonRpcClientProxy?ethJsonRpcClientProxy = _api.EthJsonRpcClientProxy; TransactionService transactionService = _api.TransactionService; IMonitoringService monitoringService = _api.MonitoringService; IWebSocketsModule ndmWebSocketsModule = _api.WebSocketsManager.GetModule("ndm"); monitoringService?.RegisterMetrics(typeof(Metrics)); DataRequestFactory dataRequestFactory = new DataRequestFactory(wallet, nodePublicKey); TransactionVerifier transactionVerifier = new TransactionVerifier(blockchainBridge, requiredBlockConfirmations); DepositProvider depositProvider = new DepositProvider(depositRepository, depositUnitsCalculator, logManager); KycVerifier kycVerifier = new KycVerifier(depositApprovalRepository, logManager); ConsumerNotifier consumerNotifier = new ConsumerNotifier(ndmNotifier); DataAssetService dataAssetService = new DataAssetService(providerRepository, consumerNotifier, logManager); ProviderService providerService = new ProviderService(providerRepository, consumerNotifier, logManager); DataRequestService dataRequestService = new DataRequestService(dataRequestFactory, depositProvider, kycVerifier, wallet, providerService, timestamper, sessionRepository, consumerNotifier, logManager); SessionService sessionService = new SessionService(providerService, depositProvider, dataAssetService, sessionRepository, timestamper, consumerNotifier, logManager); DataConsumerService dataConsumerService = new DataConsumerService(depositProvider, sessionService, consumerNotifier, timestamper, sessionRepository, logManager); DataStreamService dataStreamService = new DataStreamService(dataAssetService, depositProvider, providerService, sessionService, wallet, consumerNotifier, sessionRepository, logManager); DepositApprovalService depositApprovalService = new DepositApprovalService(dataAssetService, providerService, depositApprovalRepository, timestamper, consumerNotifier, logManager); DepositConfirmationService depositConfirmationService = new DepositConfirmationService(blockchainBridge, consumerNotifier, depositRepository, depositService, logManager, requiredBlockConfirmations); IDepositManager depositManager = new DepositManager(depositService, depositUnitsCalculator, dataAssetService, kycVerifier, providerService, abiEncoder, cryptoRandom, wallet, gasPriceService, depositRepository, timestamper, logManager, requiredBlockConfirmations, disableSendingDepositTransaction); if (instantDepositVerificationEnabled) { depositManager = new InstantDepositManager(depositManager, depositRepository, timestamper, logManager, requiredBlockConfirmations); } depositReportService = new DepositReportService(depositRepository, depositUnitsCalculator, receiptRepository, sessionRepository, timestamper); ReceiptService receiptService = new ReceiptService(depositProvider, providerService, receiptRequestValidator, sessionService, timestamper, receiptRepository, sessionRepository, abiEncoder, wallet, ecdsa, nodePublicKey, logManager); RefundService refundService = new RefundService(blockchainBridge, abiEncoder, depositRepository, contractAddress, logManager, wallet); RefundClaimant refundClaimant = new RefundClaimant(refundService, blockchainBridge, depositRepository, transactionVerifier, gasPriceService, timestamper, logManager); _api.AccountService = new AccountService(configManager, dataStreamService, providerService, sessionService, consumerNotifier, wallet, configId, consumerAddress, logManager); _api.NdmAccountUpdater = new NdmAccountUpdater(ndmWebSocketsModule, consumerAddress, _api.MainBlockProcessor, _api.ChainHeadStateProvider); ProxyService proxyService = new ProxyService(jsonRpcClientProxy, configManager, configId, logManager); _api.ConsumerService = new ConsumerService(_api.AccountService, dataAssetService, dataRequestService, dataConsumerService, dataStreamService, depositManager, depositApprovalService, providerService, receiptService, refundService, sessionService, proxyService); ethPriceService = new EthPriceService(httpClient, timestamper, logManager); daiPriceService = new DaiPriceService(httpClient, timestamper, logManager); consumerTransactionsService = new ConsumerTransactionsService(transactionService, depositRepository, timestamper, logManager); gasLimitsService = new ConsumerGasLimitsService(depositService, refundService); if (!backgroundServicesDisabled) { bool useDepositTimer = ndmConfig.ProxyEnabled; ConsumerServicesBackgroundProcessor consumerServicesBackgroundProcessor = new ConsumerServicesBackgroundProcessor( _api.AccountService, refundClaimant, depositConfirmationService, ethPriceService, daiPriceService, _api.GasPriceService, _api.MainBlockProcessor, depositRepository, consumerNotifier, logManager, useDepositTimer, ethJsonRpcClientProxy); consumerServicesBackgroundProcessor.Init(); } }
protected void cboDeposit_SelectedIndexChanged(object sender, EventArgs e) { using (var depositManager = new DepositManager(null)) { Deposit deposit = depositManager.GetDeposit(Convert.ToInt32(cboDeposit.SelectedValue)); Address1.PostalCode = deposit.PostalCode; Address1.AddressNumber = deposit.AddressNumber; Address1.AddressComp = deposit.AddressComp; } }
public INdmConsumerServices Init(INdmServices services) { AddDecoders(); var ndmConfig = services.RequiredServices.NdmConfig; var dbConfig = services.RequiredServices.ConfigProvider.GetConfig <IDbConfig>(); var contractAddress = string.IsNullOrWhiteSpace(ndmConfig.ContractAddress) ? Address.Zero : new Address(ndmConfig.ContractAddress); var logManager = services.RequiredServices.LogManager; var rocksDbProvider = new ConsumerRocksDbProvider(services.RequiredServices.BaseDbPath, dbConfig, logManager); var depositDetailsRlpDecoder = new DepositDetailsDecoder(); var depositApprovalRlpDecoder = new DepositApprovalDecoder(); var receiptRlpDecoder = new DataDeliveryReceiptDetailsDecoder(); var sessionRlpDecoder = new ConsumerSessionDecoder(); var receiptRequestValidator = new ReceiptRequestValidator(logManager); IDepositDetailsRepository depositRepository; IConsumerDepositApprovalRepository depositApprovalRepository; IProviderRepository providerRepository; IReceiptRepository receiptRepository; IConsumerSessionRepository sessionRepository; switch (ndmConfig.Persistence?.ToLowerInvariant()) { case "mongo": var database = services.RequiredServices.MongoProvider.GetDatabase(); depositRepository = new DepositDetailsMongoRepository(database); depositApprovalRepository = new ConsumerDepositApprovalMongoRepository(database); providerRepository = new ProviderMongoRepository(database); receiptRepository = new ReceiptMongoRepository(database, "consumerReceipts"); sessionRepository = new ConsumerSessionMongoRepository(database); break; default: depositRepository = new DepositDetailsRocksRepository(rocksDbProvider.DepositsDb, depositDetailsRlpDecoder); depositApprovalRepository = new ConsumerDepositApprovalRocksRepository( rocksDbProvider.ConsumerDepositApprovalsDb, depositApprovalRlpDecoder); providerRepository = new ProviderRocksRepository(rocksDbProvider.DepositsDb, depositDetailsRlpDecoder); receiptRepository = new ReceiptRocksRepository(rocksDbProvider.ConsumerReceiptsDb, receiptRlpDecoder); sessionRepository = new ConsumerSessionRocksRepository(rocksDbProvider.ConsumerSessionsDb, sessionRlpDecoder); break; } var requiredBlockConfirmations = ndmConfig.BlockConfirmations; var abiEncoder = services.CreatedServices.AbiEncoder; var blockchainBridge = services.CreatedServices.BlockchainBridge; var blockProcessor = services.RequiredServices.BlockProcessor; var configManager = services.RequiredServices.ConfigManager; var consumerAddress = services.CreatedServices.ConsumerAddress; var cryptoRandom = services.RequiredServices.CryptoRandom; var ecdsa = services.RequiredServices.Ecdsa; var ethRequestService = services.RequiredServices.EthRequestService; var jsonRpcNdmConsumerChannel = services.CreatedServices.JsonRpcNdmConsumerChannel; var ndmNotifier = services.RequiredServices.Notifier; var nodePublicKey = services.RequiredServices.Enode.PublicKey; var timestamper = services.RequiredServices.Timestamper; var txPool = services.RequiredServices.TransactionPool; var wallet = services.RequiredServices.Wallet; var dataRequestFactory = new DataRequestFactory(wallet, nodePublicKey); var transactionVerifier = new TransactionVerifier(blockchainBridge, requiredBlockConfirmations); var depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, timestamper); var depositProvider = new DepositProvider(depositRepository, depositUnitsCalculator, logManager); var kycVerifier = new KycVerifier(depositApprovalRepository, logManager); var consumerNotifier = new ConsumerNotifier(ndmNotifier); var dataAssetService = new DataAssetService(providerRepository, consumerNotifier, logManager); var providerService = new ProviderService(providerRepository, consumerNotifier, logManager); var dataRequestService = new DataRequestService(dataRequestFactory, depositProvider, kycVerifier, wallet, providerService, timestamper, sessionRepository, consumerNotifier, logManager); var depositService = new DepositService(blockchainBridge, txPool, abiEncoder, wallet, contractAddress, logManager); var sessionService = new SessionService(providerService, depositProvider, dataAssetService, sessionRepository, timestamper, consumerNotifier, logManager); var dataConsumerService = new DataConsumerService(depositProvider, sessionService, consumerNotifier, timestamper, sessionRepository, logManager); var dataStreamService = new DataStreamService(dataAssetService, depositProvider, providerService, sessionService, wallet, consumerNotifier, sessionRepository, logManager); var depositApprovalService = new DepositApprovalService(dataAssetService, providerService, depositApprovalRepository, timestamper, consumerNotifier, logManager); var depositConfirmationService = new DepositConfirmationService(blockchainBridge, consumerNotifier, depositRepository, depositService, logManager, requiredBlockConfirmations); var depositManager = new DepositManager(depositService, depositUnitsCalculator, dataAssetService, kycVerifier, providerService, abiEncoder, cryptoRandom, wallet, depositRepository, sessionRepository, timestamper, logManager, requiredBlockConfirmations); var depositReportService = new DepositReportService(depositRepository, receiptRepository, sessionRepository, timestamper); var receiptService = new ReceiptService(depositProvider, providerService, receiptRequestValidator, sessionService, timestamper, receiptRepository, sessionRepository, abiEncoder, wallet, ecdsa, nodePublicKey, logManager); var refundService = new RefundService(blockchainBridge, txPool, abiEncoder, wallet, depositRepository, contractAddress, logManager); var refundClaimant = new RefundClaimant(refundService, blockchainBridge, depositRepository, transactionVerifier, logManager); var accountService = new AccountService(configManager, dataStreamService, providerService, sessionService, consumerNotifier, wallet, ndmConfig.Id, consumerAddress, logManager); var consumerService = new ConsumerService(accountService, dataAssetService, dataRequestService, dataConsumerService, dataStreamService, depositManager, depositApprovalService, providerService, receiptService, refundService, sessionService); IPersonalBridge personalBridge = services.RequiredServices.EnableUnsecuredDevWallet ? new PersonalBridge(ecdsa, wallet) : null; services.RequiredServices.RpcModuleProvider.Register( new SingletonModulePool <INdmRpcConsumerModule>(new NdmRpcConsumerModule(consumerService, depositReportService, jsonRpcNdmConsumerChannel, ethRequestService, personalBridge, timestamper))); var consumerServicesBackgroundProcessor = new ConsumerServicesBackgroundProcessor(accountService, refundClaimant, depositConfirmationService, blockProcessor, depositRepository, consumerNotifier, logManager); consumerServicesBackgroundProcessor.Init(); return(new NdmConsumerServices(accountService, consumerService)); }
public IHttpActionResult Post(CreditCardDepositRequest model) { GeneralResponse oResponse = new GeneralResponse(); DepositManager oDepositManager = new DepositManager(); AccountManager oAccountManager = new AccountManager(); FieldsService oFieldsService = new FieldsService(); try { Dictionary <string, string> oErrors = oFieldsService.ValidateModel(ModelState); if (oErrors.Count != 0) { oResponse.Success = 0; oResponse.Message = "Error, campos invalidos"; oResponse.Data = oErrors; return(Content(HttpStatusCode.BadRequest, oResponse)); } var claims = ClaimsPrincipal.Current.Identities.First().Claims.ToList(); string UserId = claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.Sid, StringComparison.OrdinalIgnoreCase))?.Value; List <Account> oAccounts = oAccountManager.GetUserAccountsByUserId(Convert.ToInt32(UserId)); if (!oAccounts.Where(m => m.AccountId == model.DebitAccountId).Select(c => c).Any()) { throw new ArgumentException("La cuenta a la que desea depositar no pertenece al usuario logeado"); } ; CreditCardDetector detector = new CreditCardDetector(model.CreditCardNumber); if (!detector.IsValid()) { throw new ArgumentException("Los datos de la tarjeta de credito no son valdios"); } oDepositManager.DepositWithCreditCard(model.Amount, model.DebitAccountId, model.FullName, model.CreditCardNumber.Substring(model.CreditCardNumber.Length - 4), model.DocumentNumber, model.ExpirationDate); oAccountManager.UpdateAccountBalance(model.DebitAccountId, model.Amount); oResponse.Success = 1; oResponse.Message = "Exito - se ha realizado el deposito correctamente"; return(Content(HttpStatusCode.OK, oResponse)); } catch (ArgumentException ex) { oResponse.Success = 0; oResponse.Message = "Error - no se ha podido realizar el deposito"; oResponse.Data = ex.Message; return(Content(HttpStatusCode.BadRequest, oResponse)); } catch (Exception ex) { oResponse.Success = 0; oResponse.Message = "Error - no se ha podido realizar el deposito"; oResponse.Data = ex.Message; return(Content(HttpStatusCode.BadRequest, oResponse)); } }
public DepositController() { depositManager = new DepositManager(); accountManager = new AccountManager(); }
protected void btnAddSale_Click(object sender, ImageClickEventArgs e) { SaleManager sManager = new SaleManager(this); //PaymentMethodManager pManager = new PaymentMethodManager(this); DepositManager dManager = new DepositManager(this); Sale sale = sManager.GetSale((int)Company.MatrixId, Convert.ToInt32("0" + txtSaleNumber.Text.Replace("_", ""))); // // Verifica o número da nota, ele precisa existir, e ter o mesmo matrix ID // if (sale == null) { ShowError(Resources.Exception.nonExistentSale); pnlExchange.Visible = false; } //else //{ // // // // Preenche as Grids de Pagamento e Produtos // // // //pnlExchange.Visible = true; // ViewState["SaleId"] = sale.SaleId; // //DataTable payment = pManager.GetPaymentBySale(sale.CompanyId, sale.SaleId); // DataTable productData = sManager.GetSaleProducts(sale.CompanyId, sale.SaleId); // grdSaleItems.DataSource = productData; // grdSaleItems.DataBind(); // //grdPaymentMethod.DataSource = payment; // grdPaymentMethod.DataBind(); // // // // Preenche a Combo com os Produtos disponíveis na nota // // // cboProducts.DataSource = productData; // cboProducts.DataTextField = "Name"; // cboProducts.DataValueField = "ProductId"; // cboProducts.DataBind(); // // // // Preenche as Informações na tela // // // lblSaleDate.Text = sale.SaleDate.ToString(); // lblDiscount.Text = sale.Discount.ToString(); // //lblUserName.Text = payment.Rows[0]["Name2"].ToString(); // // // // Verifica o depósito de origem // // Foi utilizado o try, pois essa coluna não havia no banco, e esse try, // // evita uma tela amarela // // // try // { // lblSourceStore.Text = dManager.GetDeposit((int)sale.DepositId).Name; // } // catch // { // lblSourceStore.Text = "Dado não disponível"; // } // // // // Calcula o total da venda // // // Decimal total = (decimal)0; // //for (int i = 0; i < payment.Rows.Count; i++) // //{ // // total += Convert.ToDecimal(payment.Rows[i]["Amount"]); // // lblSaleTotal.Text = total.ToString(); // //} // // // // Reseta a Grid de Devolução // // // lblDevoltionValue.Visible = false; // txtDevolutionValue.Text = "0,00"; // txtDevolutionValue.Visible = false; // ViewState["Devolution"] = CreateDevolution(); // BindGrid(); //} }