public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteStartElement("role"); writer.WriteElementString("rolename", RoleName); writer.WriteElementString("description", Description); writer.WriteElementString("billingfrequency", BillingFrequency); writer.WriteElementString("billingperiod", BillingPeriod.ToString()); writer.WriteElementString("servicefee", ServiceFee.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("trialfrequency", TrialFrequency); writer.WriteElementString("trialperiod", TrialPeriod.ToString()); writer.WriteElementString("trialfee", TrialFee.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("ispublic", IsPublic.ToString().ToLowerInvariant()); writer.WriteElementString("autoassignment", AutoAssignment.ToString().ToLowerInvariant()); writer.WriteElementString("rsvpcode", RSVPCode); writer.WriteElementString("iconfile", IconFile); switch (RoleType) { case RoleType.Administrator: writer.WriteElementString("roletype", "adminrole"); break; case RoleType.RegisteredUser: writer.WriteElementString("roletype", "registeredrole"); break; case RoleType.Subscriber: writer.WriteElementString("roletype", "subscriberrole"); break; case RoleType.None: writer.WriteElementString("roletype", "none"); break; } writer.WriteEndElement(); }
public ActionResult Edit(ServiceFeeModel feeModel) { var ServiceDataList = _context.Services.Select(m => new { ServiceId = m.ServiceId, ServiceName = m.ServiceDari + " - " + m.ServicePashto + " - " + m.ServiceEn }).ToList(); var PrintDetails = new TblPrintDetails(); PrintDetails.PrintedBy = Serenity.Authorization.Username; PrintDetails.FeeId = feeModel.FeeId; PrintDetails.DateTimePrinted = DateTime.Now; ServiceFee serviceFee = _context.ServiceFees.Find(TempData["FeeId"]); serviceFee.Times = serviceFee.Times + 1; if (ModelState.IsValid) { if (feeModel.Print == true) { _context.TblPrintDetails.Add(PrintDetails); } _context.Entry(serviceFee).State = EntityState.Modified; _context.SaveChanges(); return(Redirect("/FM/UFPatients#edit/" + serviceFee.Mrid)); //return RedirectToAction(nameof(Edit)); } ViewBag.ServiceList = new SelectList(ServiceDataList, "ServiceId", "ServiceName", serviceFee.ServiceId); return(View(serviceFee)); }
public bool VerifyRequest() { if (!State.HasFlag(ConsensusState.RequestReceived)) { return(false); } if (!Blockchain.GetConsensusAddress(snapshot.GetValidators(Transactions.Values).ToArray()).Equals(NextConsensus)) { return(false); } Transaction tx_gen = Transactions.Values.FirstOrDefault(p => p.Type == TransactionType.MinerTransaction); Fixed8 amount_netfee = Block.CalculateNetFee(Transactions.Values); Fixed8 amount_servicefee = ServiceFee.CalcuServiceFee(Transactions.Values.ToList()); //if (tx_gen?.Outputs.Sum(p => p.Value) != amount_netfee) return false; //挖矿交易和手续费单独计算 By BHP if (tx_gen?.Outputs.Where(p => p.AssetId == Blockchain.UtilityToken.Hash).Sum(p => p.Value) != amount_netfee) { return(false); } if (tx_gen?.Outputs.Where(p => p.AssetId == Blockchain.GoverningToken.Hash).Sum(p => p.Value) - MiningSubsidy.GetMiningSubsidy(BlockIndex) != amount_servicefee) { return(false); } return(true); }
/* * public void Fill() * { * IEnumerable<Transaction> mem_pool = Blockchain.Singleton.GetMemoryPool(); * foreach (IPolicyPlugin plugin in Plugin.Policies) * mem_pool = plugin.FilterForBlock(mem_pool); * List<Transaction> transactions = mem_pool.ToList(); * Fixed8 amount_netfee = Block.CalculateNetFee(transactions); * TransactionOutput[] outputs = amount_netfee == Fixed8.Zero ? new TransactionOutput[0] : new[] { new TransactionOutput * { * AssetId = Blockchain.UtilityToken.Hash, * Value = amount_netfee, * ScriptHash = wallet.GetChangeAddress() * } }; * while (true) * { * ulong nonce = GetNonce(); * MinerTransaction tx = new MinerTransaction * { * Nonce = (uint)(nonce % (uint.MaxValue + 1ul)), * Attributes = new TransactionAttribute[0], * Inputs = new CoinReference[0], * Outputs = outputs, * Witnesses = new Witness[0] * }; * if (!snapshot.ContainsTransaction(tx.Hash)) * { * Nonce = nonce; * transactions.Insert(0, tx); * break; * } * } * TransactionHashes = transactions.Select(p => p.Hash).ToArray(); * Transactions = transactions.ToDictionary(p => p.Hash); * NextConsensus = Blockchain.GetConsensusAddress(snapshot.GetValidators(transactions).ToArray()); * Timestamp = Math.Max(TimeProvider.Current.UtcNow.ToTimestamp(), PrevHeader.Timestamp + 1); * } */ public void Fill() { IEnumerable <Transaction> mem_pool = Blockchain.Singleton.GetMemoryPool(); foreach (IPolicyPlugin plugin in Plugin.Policies) { mem_pool = plugin.FilterForBlock(mem_pool); } List <Transaction> transactions = mem_pool.ToList(); Fixed8 amount_netfee = Block.CalculateNetFee(transactions); //By BHP Fixed8 amount_servicefee = ServiceFee.CalcuServiceFee(transactions); while (true) { ulong nonce = GetNonce(); //By BHP MinerTransaction tx = new MiningTransaction().MakeMinerTransaction(wallet, BlockIndex, nonce, amount_servicefee, amount_netfee); if (!snapshot.ContainsTransaction(tx.Hash)) { Nonce = nonce; transactions.Insert(0, tx); break; } } TransactionHashes = transactions.Select(p => p.Hash).ToArray(); Transactions = transactions.ToDictionary(p => p.Hash); NextConsensus = Blockchain.GetConsensusAddress(snapshot.GetValidators(transactions).ToArray()); Timestamp = Math.Max(TimeProvider.Current.UtcNow.ToTimestamp(), PrevHeader.Timestamp + 1); }
public ActionResult Add(ServiceFee serviceFee) { string userName = Serenity.Authorization.Username; var servicePrice = _context.Services.Where(m => m.ServiceId == serviceFee.ServiceId).Select(n => new { ServicePrice = n.ServicePrice }).FirstOrDefault(); var ServiceDataList = _context.Services.Select(m => new { ServiceId = m.ServiceId, ServiceName = m.ServiceDari + " - " + m.ServicePashto + " - " + m.ServiceEn }).ToList(); var myServiceFee = new ServiceFee(); DateTime dateTime; dateTime = DateTime.Now.Date; if (ModelState.IsValid) { try { myServiceFee.Mrid = Convert.ToInt64(TempData["Mrid"]); myServiceFee.ServiceId = serviceFee.ServiceId; myServiceFee.ServiceFees = (int)servicePrice.ServicePrice; myServiceFee.DateCreated = DateTime.Now; myServiceFee.UserName = userName; myServiceFee.LastUpdated = DateTime.Now; myServiceFee.Times = 0; _context.ServiceFees.Add(myServiceFee); _context.SaveChanges(); return(Redirect("/FM/UFPatients#edit/" + TempData["Mrid"])); } catch (Exception) { throw; } } ViewBag.ServiceList = new SelectList(ServiceDataList, "ServiceId", "ServiceName", serviceFee.ServiceId); return(View()); }
public override string ToString() { //Creates a variable to be used to convert the myStringBuilder into a string String StringVar; //instatiates an object of the StringBuilder class StringBuilder myStringBuilder = new StringBuilder(); //Adding to String myStringBuilder.Append("\n"); myStringBuilder.Append("Customer Type: EVENT \n"); myStringBuilder.Append("Customer Code: " + CustomerCode + "\n"); myStringBuilder.Append("Total Items: " + TotalItem + "\n"); myStringBuilder.Append("Adult Subtotal: " + AdultSubtotal.ToString("c") + "\n"); myStringBuilder.Append("Child Subtotal: " + ChildSubtotal.ToString("c") + "\n"); myStringBuilder.Append("Subtotal: " + Subtotal.ToString("c") + "\n"); myStringBuilder.Append("Service Fee:" + ServiceFee.ToString("c") + "\n"); myStringBuilder.Append("Grand Total: " + Total.ToString("c") + "\n"); StringVar = myStringBuilder.ToString(); return(StringVar); }
public AuthorizationRequestMessage(IAuthorizationRequest authorizationRequest, Guid serviceFeeId = default(Guid), IConfiguration configuration = null) { //Missing custom fields for now MerchantCode = authorizationRequest.MerchantCode; MerchantAccountCode = authorizationRequest.MerchantAccountCode; PaymentAccountNumber = authorizationRequest.PaymentAccountNumber; ExpirationDate = authorizationRequest.ExpirationDate; SecurityCode = authorizationRequest.SecurityCode; Amount = (uint)authorizationRequest.Amount; TransactionType = authorizationRequest.TransactionType; TransIndustryType = authorizationRequest.TransIndustryType; TransCatCode = authorizationRequest.TransCatCode; AcctType = authorizationRequest.AcctType; InvoiceNum = authorizationRequest.InvoiceNum; PONum = authorizationRequest.PONum; CustomerAccountCode = authorizationRequest.CustomerAccountCode; AccountHolderName = authorizationRequest.AccountHolderName; HolderType = authorizationRequest.HolderType; AccountStreet = authorizationRequest.AccountStreet; AccountZip = authorizationRequest.AccountZip; Token = authorizationRequest.Token; ContractId = authorizationRequest.ContractId; SettlementDelay = authorizationRequest.SettlementDelay; FeeAmount = authorizationRequest.FeeAmount; PartialAuthorization = authorizationRequest.PartialAuthorization; if (authorizationRequest.ServiceFeeAmount.HasValue) { ServiceFee = new ServiceFee() { Amount = authorizationRequest.ServiceFeeAmount.Value, ServiceUser = configuration["userName"], ServicePassword = configuration["password"], ServiceFeeID = serviceFeeId }; } }
/// ----------------------------------------------------------------------------- /// <summary> /// Writes a RoleInfo to an XmlWriter /// </summary> /// <param name="writer">The XmlWriter to use</param> /// ----------------------------------------------------------------------------- public void WriteXml(XmlWriter writer) { //Write start of main elemenst writer.WriteStartElement("role"); //write out properties writer.WriteElementString("rolename", RoleName); writer.WriteElementString("description", Description); writer.WriteElementString("billingfrequency", BillingFrequency); writer.WriteElementString("billingperiod", BillingPeriod.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("servicefee", ServiceFee.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("trialfrequency", TrialFrequency); writer.WriteElementString("trialperiod", TrialPeriod.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("trialfee", TrialFee.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("ispublic", IsPublic.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()); writer.WriteElementString("autoassignment", AutoAssignment.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()); writer.WriteElementString("rsvpcode", RSVPCode); writer.WriteElementString("iconfile", IconFile); writer.WriteElementString("issystemrole", IsSystemRole.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()); switch (RoleType) { case RoleType.Administrator: writer.WriteElementString("roletype", "adminrole"); break; case RoleType.RegisteredUser: writer.WriteElementString("roletype", "registeredrole"); break; case RoleType.Subscriber: writer.WriteElementString("roletype", "subscriberrole"); break; case RoleType.UnverifiedUser: writer.WriteElementString("roletype", "unverifiedrole"); break; case RoleType.None: writer.WriteElementString("roletype", "none"); break; } switch (SecurityMode) { case SecurityMode.SecurityRole: writer.WriteElementString("securitymode", "securityrole"); break; case SecurityMode.SocialGroup: writer.WriteElementString("securitymode", "socialgroup"); break; case SecurityMode.Both: writer.WriteElementString("securitymode", "both"); break; } switch (Status) { case RoleStatus.Pending: writer.WriteElementString("status", "pending"); break; case RoleStatus.Disabled: writer.WriteElementString("status", "disabled"); break; case RoleStatus.Approved: writer.WriteElementString("status", "approved"); break; } //Write end of main element writer.WriteEndElement(); }
/* * public virtual bool Verify(Snapshot snapshot, IEnumerable<Transaction> mempool) * { * if (Size > MaxTransactionSize) return false; * for (int i = 1; i < Inputs.Length; i++) * for (int j = 0; j < i; j++) * if (Inputs[i].PrevHash == Inputs[j].PrevHash && Inputs[i].PrevIndex == Inputs[j].PrevIndex) * return false; * if (mempool.Where(p => p != this).SelectMany(p => p.Inputs).Intersect(Inputs).Count() > 0) * return false; * if (snapshot.IsDoubleSpend(this)) * return false; * foreach (var group in Outputs.GroupBy(p => p.AssetId)) * { * AssetState asset = snapshot.Assets.TryGet(group.Key); * if (asset == null) return false; * if (asset.Expiration <= snapshot.Height + 1 && asset.AssetType != AssetType.GoverningToken && asset.AssetType != AssetType.UtilityToken) * return false; * foreach (TransactionOutput output in group) * if (output.Value.GetData() % (long)Math.Pow(10, 8 - asset.Precision) != 0) * return false; * } * TransactionResult[] results = GetTransactionResults()?.ToArray(); * if (results == null) return false; * TransactionResult[] results_destroy = results.Where(p => p.Amount > Fixed8.Zero).ToArray(); * if (results_destroy.Length > 1) return false; * if (results_destroy.Length == 1 && results_destroy[0].AssetId != Blockchain.UtilityToken.Hash) * return false; * if (SystemFee > Fixed8.Zero && (results_destroy.Length == 0 || results_destroy[0].Amount < SystemFee)) * return false; * TransactionResult[] results_issue = results.Where(p => p.Amount < Fixed8.Zero).ToArray(); * switch (Type) * { * case TransactionType.MinerTransaction: * case TransactionType.ClaimTransaction: * if (results_issue.Any(p => p.AssetId != Blockchain.UtilityToken.Hash)) * return false; * break; * case TransactionType.IssueTransaction: * if (results_issue.Any(p => p.AssetId == Blockchain.UtilityToken.Hash)) * return false; * break; * default: * if (results_issue.Length > 0) * return false; * break; * } * if (Attributes.Count(p => p.Usage == TransactionAttributeUsage.ECDH02 || p.Usage == TransactionAttributeUsage.ECDH03) > 1) * return false; * if (!VerifyReceivingScripts()) return false; * return this.VerifyWitnesses(snapshot); * } */ public virtual bool Verify(Snapshot snapshot, IEnumerable <Transaction> mempool) { if (Size > MaxTransactionSize) { return(false); } for (int i = 1; i < Inputs.Length; i++) { for (int j = 0; j < i; j++) { if (Inputs[i].PrevHash == Inputs[j].PrevHash && Inputs[i].PrevIndex == Inputs[j].PrevIndex) { return(false); } } } if (mempool.Where(p => p != this).SelectMany(p => p.Inputs).Intersect(Inputs).Count() > 0) { return(false); } if (snapshot.IsDoubleSpend(this)) { return(false); } foreach (var group in Outputs.GroupBy(p => p.AssetId)) { AssetState asset = snapshot.Assets.TryGet(group.Key); if (asset == null) { return(false); } if (asset.Expiration <= snapshot.Height + 1 && asset.AssetType != AssetType.GoverningToken && asset.AssetType != AssetType.UtilityToken) { return(false); } foreach (TransactionOutput output in group) { if (output.Value.GetData() % (long)Math.Pow(10, 8 - asset.Precision) != 0) { return(false); } } } TransactionResult[] results = GetTransactionResults()?.ToArray(); if (results == null) { return(false); } TransactionResult[] results_destroy = results.Where(p => p.Amount > Fixed8.Zero).ToArray(); if (ServiceFee.Verify(this, results_destroy, SystemFee) == false) { return(false); //By BHP } if (SystemFee > Fixed8.Zero && (results_destroy.Length == 0 || results_destroy[0].Amount < SystemFee)) { return(false); } TransactionResult[] results_issue = results.Where(p => p.Amount < Fixed8.Zero).ToArray(); switch (Type) { //By BHP case TransactionType.MinerTransaction: if (VerifyMiningTransaction.Verify(Outputs, Attributes) == false) { return(false); } break; case TransactionType.ClaimTransaction: if (results_issue.Any(p => p.AssetId != Blockchain.UtilityToken.Hash)) { return(false); } break; case TransactionType.IssueTransaction: if (results_issue.Any(p => p.AssetId == Blockchain.UtilityToken.Hash)) { return(false); } break; default: if (results_issue.Length > 0) { return(false); } break; } if (Attributes.Count(p => p.Usage == TransactionAttributeUsage.ECDH02 || p.Usage == TransactionAttributeUsage.ECDH03) > 1) { return(false); } if (!VerifyReceivingScripts()) { return(false); } if (VerifyTransactionContract.Verify(snapshot, this) == false) { return(false); //By BHP } return(this.VerifyWitnesses(snapshot)); }
public ActionResult Main(ServiceFeeModel feeModel) { ServiceFee serviceFee = _context.ServiceFees.Find(TempData["FeeId"]); return(Redirect("/FM/UFPatients#edit/" + serviceFee.Mrid)); }