public string ChangeSeatingOffline(string privateKey, bool canSend, string newSeatingNumber)
        {
            var changeSeatingLimitFunction = contract.GetFunction("changeSeatingLimit");
            var data = changeSeatingLimitFunction.GetData(newSeatingNumber);

            var potentialGasCost = ServiceSync.Sync(changeSeatingLimitFunction.EstimateGasAsync(69));

            var    txCount   = ContractHelper.Instance.GetTransactionCount();
            string encodedTx = ContractHelper.Instance.SignTransactionOffline(privateKey, contractAddress, txCount, data);

            if (ContractHelper.Instance.VerifyTransaction(encodedTx))
            {
                Console.WriteLine("OK");
            }

            if (canSend)
            {
                var offlineTransactionHash = ContractHelper.Instance.SendRawTx(encodedTx);
                return(ContractHelper.Instance.GetReceiptHash(offlineTransactionHash));
            }
            else
            {
                return(encodedTx);
            }
        }
        public string BuyTicket()
        {
            var buyTicketFunction = contract.GetFunction("buyTicket");
            var transactionHash   = ServiceSync.Sync(buyTicketFunction.SendTransactionAsync(Constants.AddressFrom, Constants.MaxGas, new HexBigInteger(5)));

            return(ContractHelper.Instance.GetReceiptHash(transactionHash));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Инициализация сетевых сервисов контроллера
        /// </summary>
        private void InitNetworkServices()
        {
            Service service;

            // Инициализируем список сетевых сервисов
            this._NetworkServices = new NetworkServicesCollection(this);

            service = new ServiceBootUp(this);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServiceNodeGuard(this);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServiceNmt(this);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServiceSdoUpload(this);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServicePdoTransmit(this);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServiceSync(this, 5000);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            service = new ServicePdoReceive(this, 5);
            service.TotalAttempts = this.TotalAttempts;
            this._NetworkServices.Add(service);

            //service = new ServiceEmcy(this);
            //service.TotalAttempts = this.TotalAttempts;
            //this._NetworkServices.Add(service);

            return;
        }
        public long GetAmountCustomerPaid(string customerAcc)
        {
            var customerPaidFunc = contract.GetFunction("customerPaid");

            return(ServiceSync.Sync(customerPaidFunc.CallAsync <long>(customerAcc)));
        }
 private void createFilters()
 {
     depositEvent  = contract.GetEvent("Deposit");
     depositFilter = ServiceSync.Sync(depositEvent.CreateFilterAsync());
 }
 public long GetSeatingLimit()
 {
     return(ServiceSync.Sync(contract.GetFunction("seatingLimit").CallAsync <long>()));
 }
 public long GetCustomerAmount()
 {
     return(ServiceSync.Sync(contract.GetFunction("numCustomers").CallAsync <long>()));
 }
        public string ShowAllDepositEvent()
        {
            var log = ServiceSync.Sync(depositEvent.GetAllChanges <DepositEvent>(depositFilter));

            return(UtilityHelper.Dump(log));
        }
        public void SyncTablasBasicas()
        {
            var serviceSync = PdmContext.ServiceSyncs.FirstOrDefault();

            if (serviceSync != null && !serviceSync.MustSync)
            {
                return;
            }

            if (serviceSync == null)
            {
                serviceSync = new ServiceSync
                {
                    CreateDate = DateTime.Now,
                    Enabled    = true,
                    CreatedBy  = UsuarioLogged
                };

                PdmContext.ServiceSyncs.Add(serviceSync);
            }

            serviceSync.LastBaseTablesSync = DateTime.Now;

            var tarifas = FCMediosClient.Get <IList <TarifaFcMedios> >(GetTarifasAction);

            #region Base

            var actualMedios    = PdmContext.Medios.ToList();
            var actualPlazas    = PdmContext.Plazas.ToList();
            var actualVehiculos = PdmContext.Vehiculos.ToList();

            var serviceMedios    = tarifas.Select(e => new { Codigo = e.cod_medio, Descripcion = e.des_medio }).Distinct().ToList();
            var servicePlazas    = tarifas.Select(e => new { Codigo = e.cod_plaza, Descripcion = e.des_plaza }).Distinct().ToList();
            var serviceVehiculos = tarifas.Select(e => new { Codigo = e.cod_vehiculo, Descripcion = e.des_vehiculo }).Distinct().ToList();

            #region Medios

            serviceMedios.ForEach(t =>
            {
                var medio = actualMedios.FirstOrDefault(e => e.Codigo == t.Codigo);

                if (medio == null)
                {
                    medio = new Entities.Medio
                    {
                        Codigo      = t.Codigo,
                        Descripcion = t.Descripcion,
                        Nombre      = t.Descripcion,
                        CreateDate  = DateTime.Now,
                        CreatedBy   = App.ImportUser,
                        Enabled     = true
                    };

                    PdmContext.Medios.Add(medio);
                }
                else
                {
                    medio.Descripcion = t.Descripcion;
                    medio.UpdateDate  = DateTime.Now;
                    medio.UpdatedBy   = App.ImportUser;
                }
            });

            #endregion

            #region Plazas

            servicePlazas.ForEach(t =>
            {
                var plaza = actualPlazas.FirstOrDefault(e => e.Codigo == t.Codigo);

                if (plaza == null)
                {
                    plaza = new Entities.Plaza
                    {
                        Codigo      = t.Codigo,
                        Descripcion = t.Descripcion,
                        CreateDate  = DateTime.Now,
                        CreatedBy   = App.ImportUser,
                        Enabled     = true
                    };

                    PdmContext.Plazas.Add(plaza);
                }
                else
                {
                    plaza.Descripcion = t.Descripcion;
                    plaza.UpdateDate  = DateTime.Now;
                    plaza.UpdatedBy   = App.ImportUser;
                }
            });

            #endregion

            #region Vehiculos

            serviceVehiculos.ForEach(t =>
            {
                var vehiculo = actualVehiculos.FirstOrDefault(e => e.Codigo == t.Codigo);

                if (vehiculo == null)
                {
                    vehiculo = new Entities.Vehiculo
                    {
                        Codigo      = t.Codigo,
                        Descripcion = t.Descripcion,
                        CreateDate  = DateTime.Now,
                        CreatedBy   = App.ImportUser,
                        Enabled     = true,
                        Nombre      = t.Descripcion
                    };

                    PdmContext.Vehiculos.Add(vehiculo);
                }
                else
                {
                    vehiculo.Nombre      = t.Descripcion;
                    vehiculo.Descripcion = t.Descripcion;
                    vehiculo.UpdateDate  = DateTime.Now;
                    vehiculo.UpdatedBy   = App.ImportUser;
                }
            });

            #endregion

            #endregion

            PdmContext.Configuration.AutoDetectChangesEnabled = false;
            PdmContext.SaveChanges();
            PdmContext.Configuration.AutoDetectChangesEnabled = true;
            PdmContext = new PDMContext();
        }
Exemplo n.º 10
0
        private void btnGetTxinBlock_Click(object sender, EventArgs e)
        {
            var blockService = ContractHelper.Instance.Web3.Eth.Blocks;

            txtBinary.Text = UtilityHelper.Dump(ServiceSync.Sync(blockService.GetBlockWithTransactionsByNumber.SendRequestAsync(new BlockParameter(ulong.Parse(txtBlockNumber.Text)))));
        }