Beispiel #1
0
        /// <summary>
        /// Saves documents from the specified composite contract to the Document Library.
        /// </summary>
        /// <param name="composite">The EnterpriseScenarioCompositeContract.</param>
        /// <returns>true if the operation completed successfully.</returns>
        public static bool ProcessCompositeContractFile(EnterpriseScenarioCompositeContract composite)
        {
            using (DocumentLibraryContext context = DbConnect.DocumentLibraryContext())
            {
                bool changesMade = false;

                foreach (DocumentContract documentContract in composite.Documents)
                {
                    if (CanInsertDocument(documentContract, context))
                    {
                        TestDocument documentEntity = ContractFactory.Create(context, documentContract);
                        WriteDocumentToServer(documentEntity, GlobalSettings.Items[Setting.DocumentLibraryServer], documentContract.Data);
                        context.TestDocuments.Add(documentEntity);
                        changesMade = true;
                    }
                }

                if (changesMade)
                {
                    context.SaveChanges();
                }
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Contract_List页面行为
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult Contract_List()
        {
            //获取往来客户信息
            ClientsFactory   clientsfactory = new ClientsFactory();
            List <IClientsB> lstclients     = clientsfactory.GetDataClients();
            List <ClientsM>  clientsm       = new List <ClientsM>();

            if (lstclients != null && lstclients.Count > 0)
            {
                lstclients.ForEach(p => clientsm.Add(p.Infomation_clients));
            }
            ViewBag.ClientsInfo = clientsm;

            //获取项目信息
            ProjectsFactory   projectsfactory = new ProjectsFactory();
            List <IProjectsB> lstprojects     = projectsfactory.GetDataProjects();
            List <ProjectsM>  projectsm       = new List <ProjectsM>();

            if (lstprojects != null && lstprojects.Count > 0)
            {
                lstprojects.ForEach(p => projectsm.Add(p.Infomation_projects));
            }
            ViewBag.ProjectsInfo = projectsm;

            //获取合同信息
            string          id = ViewMethods.GetForm(Request, "ID", CommonEnums.ValueEnum.vlGet).ToString();
            ContractFactory contractfactory = new ContractFactory();
            IContractB      lstContract     = contractfactory.GetDataByID(id);
            ContractM       contractm       = (lstContract != null ? lstContract.Infomation_contract : null);

            ViewBag.ContractInfo = contractm;
            return(View());
        }
Beispiel #3
0
        private void ResolveDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            var printer = resolveDataGridView.Rows[e.RowIndex].DataBoundItem as PrinterContract;

            if (printer != null)
            {
                using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                {
                    var entity = context.Assets.FirstOrDefault(x => x.AssetId.Equals(printer.AssetId));
                    if (entity == null)
                    {
                        context.Assets.Add(ContractFactory.Create(printer, context));
                    }
                    else
                    {
                        entity.Pool = context.AssetPools.FirstOrDefault(n => n.Name == printer.PoolName);
                    }

                    context.SaveChanges();
                }
            }

            CheckItemsResolved();
            resolveDataGridView.Invalidate();
        }
Beispiel #4
0
        /// <summary>
        /// This is a Multisignature contract that requires 2/3 + 1 of the validators signatures
        /// </summary>
        /// <returns>The validators contract.</returns>
        private static Contract GenesisValidatorsContract()
        {
            var genesisValidators = GenesisStandByValidators();
            var genesisContract   = ContractFactory.CreateMultiplePublicKeyRedeemContract(genesisValidators.Length / 2 + 1, genesisValidators);

            return(genesisContract);
        }
Beispiel #5
0
        /// <summary>
        /// 编辑业主信息(Contract_Edit页面)
        /// </summary>
        public ActionResult Edit_Contract()
        {
            ContractFactory contractfactory = new ContractFactory();
            //获取业主编号(id)信息
            string id = ViewMethods.GetForm(Request, "ID", CommonEnums.ValueEnum.vlGet).ToString();

            IContractB contractb = contractfactory.GetDataByID(id);
            ContractM  contractm = (contractb == null ? null : contractb.Infomation_contract);
            //编辑业主信息
            string contractname   = ViewMethods.GetForm(Request, "name", CommonEnums.ValueEnum.vlPost).ToString();
            string contractbelong = ViewMethods.GetForm(Request, "belong", CommonEnums.ValueEnum.vlPost).ToString();

            contractm.CTName   = contractname;
            contractm.CTBelong = contractbelong;
            contractfactory.Infomation_contract = contractm;
            ViewBag.ContractInfo = contractm;
            bool isSuccess = contractfactory.Update();

            if (isSuccess)
            {
                return(ViewMethods.AlertBack("修改成功", "../../Contract/Contract"));
            }
            else
            {
                return(ViewMethods.AlertBack("修改失败", "-1"));
            }
        }
Beispiel #6
0
        public void LoadPrinters(AssetContractCollection <PrinterContract> printers)
        {
            _printers = printers;

            bool changesMade = false;

            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                foreach (var printer in _printers)
                {
                    if (!context.Assets.Any(x => x.Pool.Name.Equals(printer.PoolName)))
                    {
                        if (context.AssetPools.Count() > 0)
                        {
                            printer.PoolName = context.AssetPools.First().Name;
                            if (!context.Assets.Any(x => x.AssetId.Equals(printer.AssetId)))
                            {
                                context.Assets.Add(ContractFactory.Create(printer, context));
                                changesMade = true;
                            }
                        }
                    }
                }

                if (changesMade)
                {
                    context.SaveChanges();
                }
            }

            resolveDataGridView.DataSource = _printers;

            CheckItemsResolved();
        }
Beispiel #7
0
        /// <summary>
        /// 添加合同信息(Contract_Add页面)
        /// </summary>
        public ActionResult Add_Contract()
        {
            string          prid            = ViewMethods.GetForm(Request, "PRID");
            ContractFactory contractfactory = new ContractFactory();
            //添加业主信息
            ContractM contractm    = new ContractM();
            string    contractname = ViewMethods.GetForm(Request, "name", CommonEnums.ValueEnum.vlPost).ToString();
            string    ctbelong     = ViewMethods.GetForm(Request, "belong", CommonEnums.ValueEnum.vlPost).ToString();
            string    ctno         = ViewMethods.GetForm(Request, "ctno", CommonEnums.ValueEnum.vlPost).ToString();
            decimal   ctmoney      = ViewMethods.GetForm(Request, "money", CommonEnums.ValueEnum.vlPost).ConvertToDecimal();
            string    contractdate = ViewMethods.GetForm(Request, "time_contract", CommonEnums.ValueEnum.vlPost).ToString();

            bool isExist = contractfactory.IsExist_contractname(contractname);

            if (isExist)
            {
                return(ViewMethods.AlertBack("合同已存在,请重新确认", "-1"));
            }
            contractm.CTName   = contractname;
            contractm.CTBelong = ctbelong;
            contractm.CTNo     = ctno;
            contractm.CTMoney  = ctmoney;
            contractm.CTDate   = contractdate.ConvertToDateTime();
            contractm.CTPrid   = prid.ConvertToInt32();
            contractfactory.Infomation_contract = contractm;
            contractfactory.Save();
            return(ViewMethods.AlertBack("添加合同成功!", "../../Contract/Contract?PRID=" + prid));
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ClientDto obj       = ((FrameworkElement)sender).DataContext as ClientDto;
            var       contracts = ContractFactory.GetContractsByClientsName(obj.FullName);

            Switcher.Switch(new ContractsPage(contracts));
        }
        public void ReadFactoryTest()
        {
            var factoryDefinition = @"
_type: ContractFactory
name: androidMarketApplication
category: applicationContract
title: ""Make a market app in Android for $contractor""
description: ""The mobile world is growing, and $contractor has decided they should sell things in the Internet. They want someone to build an Android application for them.""
abundance: [
    [0, 40]
    [30, 25]
    [100, 12]
]
duration: [
    [0, 50400]
    [30, 86400]
    [100, 288000]
]
workload: [
    [0, 200]
    [50, 500],
    [100, 1250]
]
requirements: {
    programming-language: {
        _in: [java, kotlin, csharp, dart]
    }
}
reward: {
    deposit: {
        fund: 12000
        reputation: 1
    }
    finish: {
        fund: 100000
        reputation: 15
    }
    abort: {
        fund: -12000
        reputation: -3
    }
}
difficulty-multiplier: {
    method: exponential
    workload: 1.06
    fund: 1.08
    reputation: 1.21
}";
            var factory           = new ContractFactory();

            factory.ReadFromHocon(Hocon.Parser.Parse(factoryDefinition).Value);
            Assert.That(factory.name, Is.EqualTo("androidMarketApplication"));
            Assert.That(factory.abundanceCurve, Is.EqualTo(new AnimationCurve(new Keyframe[] {
                new Keyframe(0, 40),
                new Keyframe(30, 25),
                new Keyframe(100, 12),
            }
                                                                              )));
            // The ContractFactory#ReadFromHocon method actually does not need testing. It's extremely simple and if anything goes wrong it's the Hocon package's fault.
        }
Beispiel #10
0
        static async Task PerformContractTransactions(LocalTestNet localTestNet, EntryPointContract entryContract, SolcBytecodeInfo contractBytecode, Abi entryFunction)
        {
            // Perform the contract deployment transaction
            var deployParams = new TransactionParams
            {
                From     = localTestNet.Accounts[0],
                Gas      = ArbitraryDefaults.DEFAULT_GAS_LIMIT,
                GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE
            };
            var contractAddress = await ContractFactory.Deploy(localTestNet.RpcClient, HexUtil.HexToBytes(contractBytecode.Bytecode), deployParams);

            var contractInstance = new ContractInstance(
                entryContract.ContractPath, entryContract.ContractName,
                localTestNet.RpcClient, contractAddress, localTestNet.Accounts[0]);


            // If entry function is specified then send transasction to it.
            if (entryFunction != null)
            {
                var callData     = EncoderUtil.GetFunctionCallBytes($"{entryFunction.Name}()");
                var ethFunc      = EthFunc.Create(contractInstance, callData);
                var funcTxParams = new TransactionParams
                {
                    From     = localTestNet.Accounts[0],
                    Gas      = ArbitraryDefaults.DEFAULT_GAS_LIMIT,
                    GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE
                };
                await ethFunc.SendTransaction(funcTxParams);
            }
        }
Beispiel #11
0
        // GET: Ower
        public ActionResult Contract()
        {
            string prid = ViewMethods.GetForm(Request, "PRID");

            int    pageSize = 12; //每页要显示的行数
            string belong   = ViewMethods.GetForm(Request, "BELONG");
            string orderby  = ViewMethods.GetForm(Request, "OrderBy", CommonEnums.ValueEnum.vlGet);

            if (string.IsNullOrEmpty(orderby))
            {
                orderby = "CT_ID";
            }
            int desc        = ViewMethods.GetForm(Request, "Desc", CommonEnums.ValueEnum.vlGet).ConvertToInt32();
            int pagecurrent = ViewMethods.GetForm(Request, "Page", CommonEnums.ValueEnum.vlGet).ConvertToInt32();//分页

            pagecurrent = (pagecurrent == 0 ? 1 : pagecurrent);
            object objkeys = ViewMethods.GetForm(Request, "keys", CommonEnums.ValueEnum.vlGet);//搜索内容
            string keys    = "";

            if (objkeys != null)
            {
                keys = objkeys.ToString();
            }

            long      start    = (pagecurrent - 1) * pageSize;
            string    order    = orderby;
            OrderType orderway = (desc == 0 ? OrderType.otDesc : OrderType.otAsc);
            long      count    = 0;

            ContractFactory   contractfactory = new ContractFactory();
            List <IContractB> lstcontract     = contractfactory.GetPageData(ref count, start, pageSize, keys, order, orderway, belong, prid);
            List <ContractM>  contractinfo    = new List <ContractM>();

            if (lstcontract != null && lstcontract.Count > 0)
            {
                lstcontract.ForEach(p => contractinfo.Add(p.Infomation_contract));
            }
            int totalpages = 0;

            if ((count % pageSize) > 0)
            {
                totalpages = (int)Math.Ceiling((float)((count / pageSize) + 1));
            }
            else
            {
                totalpages = (int)Math.Ceiling((float)(count / pageSize));//算出分页的总数
            }
            ViewBag.TotalPages      = totalpages;
            ViewBag.Contract        = contractinfo;
            TempData["OrderBy"]     = desc;
            TempData["CurrentPage"] = pagecurrent;
            TempData["keys"]        = objkeys;
            TempData["belong"]      = belong;
            if (prid != null || prid != "")
            {
                TempData["prid"] = prid;
            }
            return(View());
        }
Beispiel #12
0
        /// <summary>
        /// Privates the key to address.
        /// </summary>
        /// <returns>The key to address.</returns>
        /// <param name="privateKey">Private key.</param>
        private string privateKeyToAddress(byte[] privateKey)
        {
            var pubKeyInBytes   = Crypto.Default.ComputePublicKey(privateKey, true);
            var pubkey          = new ECPoint(pubKeyInBytes);
            var accountContract = ContractFactory.CreateSinglePublicKeyRedeemContract(pubkey);

            return(accountContract.ScriptHash.ToAddress());
        }
        public void SetUp()
        {
            _contractRepositoryMock = new Mock <IContractRepository>();
            _contractFactory        = new ContractFactory();
            _workscheduleFactory    = new WorkscheduleFactory();

            _contractService = new ContractService(_contractRepositoryMock.Object, _contractFactory, _workscheduleFactory);
        }
        public static IEnumerable <EmployeeDTO> ListEmployeesDTOs()
        {
            var listEmployee = LoadEmployees();
            var listDTO      = from emp in listEmployee
                               select ContractFactory.BuildContract(emp).GenerateDTO();

            return(listDTO);
        }
Beispiel #15
0
        /// <summary>
        /// Projects_List页面
        /// </summary>
        /// <returns>页面</returns>
        public ActionResult Projects_List()
        {
            //获取项目编号(id)数据信息
            string id = ViewMethods.GetForm(Request, "PRID", CommonEnums.ValueEnum.vlGet).ToString();

            //根据项目编号(id)获取项目信息
            ProjectsFactory projectsfactory = new ProjectsFactory();
            IProjectsB      lstProjects     = projectsfactory.GetDataByID(id);
            ProjectsM       projectsm       = (lstProjects != null ? lstProjects.Infomation_projects : null);

            ViewBag.ProjectsInfo = projectsm;

            //获取往来客户信息
            ClientsFactory   clientsFactory = new ClientsFactory();
            List <IClientsB> lstClients     = clientsFactory.GetDataClients();
            List <ClientsM>  clientsm       = new List <ClientsM>();

            if (lstClients != null && lstClients.Count > 0)
            {
                lstClients.ForEach(p => clientsm.Add(p.Infomation_clients));
            }
            ViewBag.ClientsInfo = clientsm;

            //获取收付款信息
            FinanceFactory   financeFactory = new FinanceFactory();
            List <IFinanceB> lstFinance     = financeFactory.GetDataFinance();
            List <FinanceM>  financem       = new List <FinanceM>();

            if (lstFinance != null && lstFinance.Count > 0)
            {
                lstFinance.ForEach(p => financem.Add(p.Infomation_finance));
            }
            ViewBag.FinanceInfo = financem;

            //获取工程量信息
            QuantityFactory   quantityFactory = new QuantityFactory();
            List <IQuantityB> lstQuantity     = quantityFactory.GetDataQuantity();
            List <QuantityM>  quantity        = new List <QuantityM>();

            if (lstQuantity != null && lstQuantity.Count > 0)
            {
                lstQuantity.ForEach(p => quantity.Add(p.Infomation_Quantity));
            }
            ViewBag.QuantityInfo = quantity;

            //获取合同信息
            ContractFactory   contractFactory = new ContractFactory();
            List <IContractB> lstContract     = contractFactory.GetDataContract();
            List <ContractM>  contracts       = new List <ContractM>();

            if (lstContract != null && lstContract.Count > 0)
            {
                lstContract.ForEach(p => contracts.Add(p.Infomation_contract));
            }
            ViewBag.ContractInfo = contracts;

            return(View());
        }
        public static IEnumerable <EmployeeDTO> SearchEmployeesDTOs(List <ParamEmployeeId> paramEmployeeIds)
        {
            var listEmployee = LoadEmployees();
            var listDTO      = from emp in listEmployee
                               where EmployeeUtils.BelongsToIds(emp, paramEmployeeIds)
                               select ContractFactory.BuildContract(emp).GenerateDTO();

            return(listDTO);
        }
Beispiel #17
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ContractDto obj       = ((FrameworkElement)sender).DataContext as ContractDto;
            var         contracts = ContractFactory.GetContractDetails(obj);

            Switcher.Switch(new ContractDetailsPage(new List <ContractDetailsDto> {
                contracts
            }));
        }
        /// <summary>
        /// Deploys the contract.  <para/>
        /// </summary>

        /// <param name = "rpcClient">The RPC client to be used for this contract instance.</param>
        /// <param name = "defaultFromAccount">If null then the first account returned by eth_accounts will be used.</param>
        /// <returns>An contract instance pointed at the deployed contract address.</returns>
        public static async Task <aclContract> Deploy(Meadow.JsonRpc.Client.IJsonRpcClient rpcClient, Meadow.JsonRpc.Types.TransactionParams transactionParams = null, Meadow.Core.EthTypes.Address?defaultFromAccount = null)
        {
            transactionParams      = transactionParams ?? new Meadow.JsonRpc.Types.TransactionParams();
            defaultFromAccount     = defaultFromAccount ?? transactionParams.From ?? (await rpcClient.Accounts())[0];
            transactionParams.From = transactionParams.From ?? defaultFromAccount;
            var encodedParams = Array.Empty <byte>();
            var contractAddr  = await ContractFactory.Deploy(rpcClient, BYTECODE_BYTES.Value, transactionParams, encodedParams);

            return(new aclContract(rpcClient, contractAddr, defaultFromAccount.Value));
        }
        /// <summary>
        /// Deploys the contract.  <para/>
        /// </summary>
        /// <param name = "total"><c>uint256</c></param>
        /// <param name = "rpcClient">The RPC client to be used for this contract instance.</param>
        /// <param name = "defaultFromAccount">If null then the first account returned by eth_accounts will be used.</param>
        /// <returns>An contract instance pointed at the deployed contract address.</returns>
        public static async Task <ERC20Basic> Deploy(Meadow.Core.EthTypes.UInt256 total, Meadow.JsonRpc.Client.IJsonRpcClient rpcClient, Meadow.JsonRpc.Types.TransactionParams transactionParams = null, Meadow.Core.EthTypes.Address?defaultFromAccount = null)
        {
            transactionParams      = transactionParams ?? new Meadow.JsonRpc.Types.TransactionParams();
            defaultFromAccount     = defaultFromAccount ?? transactionParams.From ?? (await rpcClient.Accounts())[0];
            transactionParams.From = transactionParams.From ?? defaultFromAccount;
            var encodedParams = Meadow.Core.AbiEncoding.EncoderUtil.Encode(EncoderFactory.LoadEncoder("uint256", total));
            var contractAddr  = await ContractFactory.Deploy(rpcClient, BYTECODE_BYTES.Value, transactionParams, encodedParams);

            return(new ERC20Basic(rpcClient, contractAddr, defaultFromAccount.Value));
        }
Beispiel #20
0
        public void GetAddressForContract()
        {
            Transaction transaction = new Transaction();

            transaction.SenderPubKey = "0246E7178DC8253201101E18FD6F6EB9972451D121FC57AA2A06DD5C111E58DC6A";
            transaction.Nonce        = "19";
            String address = ContractFactory.GetAddressForContract(transaction);

            Assert.AreEqual(address.ToLower(), "8f14cb1735b2b5fba397bea1c223d65d12b9a887");
        }
        public bool Contract([FromBody] ContractRequetDto contractRequetDto)
        {
            var user              = new User();
            var goods             = new Goods();
            var company           = new Company();
            var contract          = ContractFactory.CreateInstance(contractRequetDto.ContractType);
            var contractProcessor = new ContractProcessor(contract, user, goods, company);

            contractProcessor.Process();
            return(true);
        }
 public void ImportData(IEnumerable <ContractDto> contracts = null)
 {
     if (contracts == null)
     {
         myDataGrid.ItemsSource = ContractFactory.GetContracts();
     }
     else
     {
         myDataGrid.ItemsSource = contracts;
     }
 }
Beispiel #23
0
        /// <summary>
        /// Contract_Edit页面行为
        /// </summary>
        /// <returns>视图</returns>
        public ActionResult Contract_Edit()
        {
            //获取往来客户(id)数据信息
            string          id = ViewMethods.GetForm(Request, "ID", CommonEnums.ValueEnum.vlGet).ToString();
            ContractFactory contractfactory = new ContractFactory();
            IContractB      lstContract     = contractfactory.GetDataByID(id);
            ContractM       contractm       = (lstContract != null ? lstContract.Infomation_contract : null);

            ViewBag.ContractInfo = contractm;
            return(View());
        }
Beispiel #24
0
        static void Main(string[] args)
        {
            string xmlString = File.ReadAllText(@"DasContract.Blockchain.Solidity.Test/example.dascontract");
            var    contract  = ContractFactory.FromDasFile(xmlString);
            var    generator = new ProcessConverter(contract);

            var code = generator.GenerateSolidity();

            Console.WriteLine(code);

            File.WriteAllText(@"./code.sol", code);
        }
        public void SetUpFactory()
        {
            factory = new ContractFactory();
            var factoryDefinition = @"
_type: ContractFactory
name: androidMarketApplication
category: applicationContract
title: ""Make a market app in Android for $contractor""
description: ""The mobile world is growing, and $contractor has decided they should sell things in the Internet. They want someone to build an Android application for them.""
abundance: [
    [0, 40]
    [30, 25]
    [100, 12]
]
duration: [
    [0, 2100]
    [30, 3600]
    [100, 12000]
]
workload: [
    [0, 200]
    [50, 500],
    [100, 1250]
]
requirements: {
    programming-language: {
        _in: [java, kotlin, csharp, dart]
    }
}
reward: {
    deposit: {
        fund: 12000
        reputation: 1
    }
    finish: {
        fund: 100000
        reputation: 15
    }
    abort: {
        fund: -12000
        reputation: -3
    }
}
difficulty-multiplier: {
    method: exponential
    workload: 1.06
    fund: 1.08
    reputation: 1.21
}";

            factory.ReadFromHocon(Hocon.Parser.Parse(factoryDefinition).Value);
        }
Beispiel #26
0
        public async Task <ActionResult> getEmployees(int id)
        {
            EmployeesController a = new EmployeesController();
            List <Contract>     listEmployeesContract = new List <Contract>();

            if (id == 0)
            {
                var ListEmployees = await a.Get();

                ContractFactory factory = null;

                foreach (var i in ListEmployees.Value.ToList())
                {
                    if (i.contractTypeName == "HourlySalaryEmployee")
                    {
                        factory = new HourlyFactory(i.name, i.roleName, i.roleDescription, i.hourlySalary);
                    }
                    if (i.contractTypeName == "MonthlySalaryEmployee")
                    {
                        factory = new MonthlyFactory(i.name, i.roleName, i.roleDescription, i.monthlySalary);
                    }

                    listEmployeesContract.Add(factory.GetContract());
                }
            }
            else
            {
                var ListEmployees = await a.Get(id);

                ContractFactory factory = null;

                if (ListEmployees.Value.contractTypeName == "HourlySalaryEmployee")
                {
                    factory = new HourlyFactory(ListEmployees.Value.name, ListEmployees.Value.roleName, ListEmployees.Value.roleDescription, ListEmployees.Value.hourlySalary);
                }
                if (ListEmployees.Value.contractTypeName == "MonthlySalaryEmployee")
                {
                    factory = new MonthlyFactory(ListEmployees.Value.name, ListEmployees.Value.roleName, ListEmployees.Value.roleDescription, ListEmployees.Value.monthlySalary);
                }

                listEmployeesContract.Add(factory.GetContract());
            }

            var model = new ResultModel
            {
                ListEmployeesContract = listEmployeesContract,
            };

            return(View("~/Views/Home/Result.cshtml", model));
        }
Beispiel #27
0
        /// <summary>
        /// Creates the NEP6Account with private key.
        /// </summary>
        /// <returns>The NEP6Account</returns>
        /// <param name="privateKey">Private key.</param>
        private NEP6Account CreateAccountWithPrivateKey(byte[] privateKey, SecureString passphrase, string label = null)
        {
            var publicKeyInBytes   = Crypto.Default.ComputePublicKey(privateKey, true);
            var publicKeyInEcPoint = new ECPoint(publicKeyInBytes);
            var contract           = ContractFactory.CreateSinglePublicKeyRedeemContract(publicKeyInEcPoint);

            var account = new NEP6Account(contract)
            {
                Label = label
            };

            account.Key = _walletHelper.EncryptWif(privateKey, passphrase);
            UnlockAccount(account.Key, publicKeyInEcPoint, privateKey);
            return(account);
        }
Beispiel #28
0
        private void TimedEvent(DateTime currentTime)
        {
            if (currentTime.Minute != _minuteOfContractGeneration)
            {
                return;
            }
            var contract = ContractFactory.CreateContractFor(this);

            if (contract == null)
            {
                return;
            }
            Contracts.Add(contract);
            _gameController.LogGameEvent($"{Name} announced a contract to {contract.ContractType} {contract.Target.TargetName} that belongs to {contract.Target.TargetOwner.Name}");
        }
Beispiel #29
0
        /// <summary>
        /// 删除业主信息(Contract页面)
        /// </summary>
        /// <returns></returns>
        public ActionResult Delete_Contract()
        {
            //获取业主编号(id)信息
            string    uid       = ViewMethods.GetForm(Request, "uid", CommonEnums.ValueEnum.vlPost).ToString();
            ContractM contractm = new ContractM();

            contractm.CTID = uid.ConvertToInt32();
            ContractFactory contractfactory = new ContractFactory();

            contractfactory.Infomation_contract = contractm;
            contractfactory.Del_Contract();
            return(new JsonResult()
            {
                Data = PublicMethods.JSonHelper <string> .ObjectToJson(new { status = "0", msg = "删除成功" }), ContentType = "json"
            });
        }
        public static EmployeeDTO GetEmployeeDTOById(int id)
        {
            var listEmployee = LoadEmployees();
            var listDTO      = from emp in listEmployee
                               where emp.Id == id
                               select ContractFactory.BuildContract(emp).GenerateDTO();

            if (listDTO.Any())
            {
                var dto = listDTO.First();
                return(dto);
            }
            else
            {
                return(null);
            }
        }
Beispiel #31
0
    public Simulation()
    {
        Floor = new Floor(this, floorWidth, floorHeight);
        machineFactory = new MachineFactory(this);
        supplyContractFactory = new ContractFactory(false);
        deliveryContractFactory = new ContractFactory(true);

        //Populate machine shop
        for(int i = 0; i < machineShopSizeLimit; i++)
        {
            MachineShop.Add (machineFactory.GetMachineForShop());
        }

        //Populate contracts
        for(int i = 0; i < contractShopSizeLimit; i++)
        {
            SupplyShop.Add(supplyContractFactory.GetContractForShop());
            DeliveryShop.Add(deliveryContractFactory.GetContractForShop());
        }

        //Create contract slots
        Vector2[] slotPositions = new Vector2[]
        {
            new Vector2(1, -0.666f),
            new Vector2(3, -0.666f),
            new Vector2(5, -0.666f),
            new Vector2(7, -0.666f),
            new Vector2(1, 8.666f),
            new Vector2(3, 8.666f),
            new Vector2(5, 8.666f),
            new Vector2(7, 8.666f)
        };
        for (int i = 0; i < contractSlotLimit; i++)
        {
            ContractSlot slot = new ContractSlot();
            slot.FloorPosition = slotPositions[i];
            ContractSlots.Add(slot);
        }
    }