public BalanceInfo StatisticsBalance(int supplierId) { StringBuilder stringBuilder = new StringBuilder("select Balance"); stringBuilder.Append(",(select isnull(SUM(Amount), 0) from dbo.Hishop_SupplierBalanceDrawRequest r where r.SupplierId = s.SupplierId and IsPass is null) as BalanceForzen"); stringBuilder.Append(",(select isnull(SUM(Amount), 0) from dbo.Hishop_SupplierBalanceDrawRequest r where r.SupplierId = s.SupplierId and IsPass = 1) as BalanceOut"); stringBuilder.AppendFormat(" from dbo.Hishop_Supplier s where SupplierId = {0}", supplierId); BalanceInfo balanceInfo = new BalanceInfo(); DbCommand sqlStringCommand = base.database.GetSqlStringCommand(stringBuilder.ToString()); try { using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand)) { if (dataReader.Read()) { balanceInfo.Balance = (decimal)((IDataRecord)dataReader)["Balance"]; balanceInfo.BalanceForzen = (decimal)((IDataRecord)dataReader)["BalanceForzen"]; balanceInfo.BalanceOut = (decimal)((IDataRecord)dataReader)["BalanceOut"]; } } } catch (Exception) { } return(balanceInfo); }
public void ShouldCheckPermissionToSell() { //Arrange var balanceTableRepository = Substitute.For <IBalanceTableRepository>(); ValidationOfTransactionService validationService = new ValidationOfTransactionService(balanceTableRepository); var args = new BalanceInfo(); args.Balance = 100; args.UserID = 22; BalanceEntity balanceEntity = new BalanceEntity() { Balance = 1000, BalanceID = "2201", CreatedAt = DateTime.Now, StockID = 2, StockAmount = 2, UserID = 22 }; balanceTableRepository.GetAll(22).Returns(new List <BalanceEntity>() { balanceEntity }); //Act validationService.CheckPermissionToSell(args.UserID); //Average balanceTableRepository.Received(1).GetAll(Arg.Is <int>(args.UserID)); balanceTableRepository.Received(1); }
public string CreateBalance(BalanceInfo args) { int balancesCount; try { List <BalanceEntity> userBalanceEntities = this.balanceTableRepository.GetAll(args.UserID); balancesCount = userBalanceEntities.Count; } catch { throw new ArgumentException($"Can't count balances for this user {args.UserID}. It might be not exists"); } var entityToAdd = new BalanceEntity() { CreatedAt = DateTime.Now, UserID = args.UserID, BalanceID = args.UserID.ToString() + "0" + balancesCount.ToString(), Balance = args.Balance, StockID = args.StockID, StockAmount = args.StockAmount, }; if (this.balanceTableRepository.Contains(entityToAdd)) { throw new ArgumentException("Balance with that number is already exists. Can't continue"); } this.balanceTableRepository.Add(entityToAdd); this.balanceTableRepository.SaveChanges(); return(entityToAdd.BalanceID); }
private void UserRegistrate(string name, string surname, string phoneNumber) { UserRegistrationInfo newUser = new UserRegistrationInfo() { Name = name, Surname = surname, PhoneNumber = phoneNumber, }; try { usersService.RegisterNewUser(newUser); int ID = usersService.GetUserId(newUser); int stockID = r.Next(1, 10); int stockAmount = r.Next(1, 5); BalanceInfo balance = new BalanceInfo() { UserID = ID, StockID = stockID, StockAmount = stockAmount, Balance = stocksService.GetStock(stockID).Price *stockAmount }; balancesService.CreateBalance(balance); Logger.Log.Info($"User registration success. New user is {name} {surname} ID: {ID}"); Console.WriteLine("Registration successful!"); } catch (ArgumentException e) { Logger.Log.Error($"Registration failed. Message: {e.Message}"); } }
/// <summary> /// Faz a leitura do ranking do webservice /// </summary> /// <returns></returns> public IEnumerator LoadBalanceValues() { WWW www = new WWW(HOST_URL + "api/gamebalance?format=json"); yield return(www); if (www.error != null) { Debug.LogWarning(www.error); Debug.LogWarning(www.text); updated = false; } else { BalanceInfo info = BalanceInfo.CreateFromJSON(www.text); Debug.Log("BalanceInfo:" + info); PlayerHorizontalSpeed = info.playerHorizontalSpeed; BrainSpawDeltaY = info.brainSpawDeltaY; BananaSpawDeltaY = info.bananaSpawDeltaY; JumpForce = info.jumpForce; StartJumpForce = info.startJumpForce; loading = false; updated = true; } }
protected static void Read(XmlReader reader, BalanceInfo aInfo, string aEndTag) { string lastName = String.Empty; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { lastName = reader.Name; } if (reader.NodeType == XmlNodeType.Text) { string value = reader.Value.Trim(); try { switch (lastName) { case "BALAMT": aInfo.BALAMT = ParseAmount(value); break; case "DTASOF": aInfo.DTASOF = ParseDateTime(value); break; } } catch (FormatException ex) { throw new PXException(Messages.OFXParsingErrorValueHasInvalidFormat, lastName, ex.Message); } } if (reader.NodeType == XmlNodeType.EndElement && reader.Name == aEndTag) { return; } } }
public Player( ) { PAccount = new AccountInfo(); PBalance = new BalanceInfo(); PEnergy = new EnergyInfo(); PCharacters = new CharacterInfo(); PTactis = new Tactics(); }
private void LoadParameters() { BalanceInfo supplierBalance = BalanceHelper.GetSupplierBalance(HiContext.Current.Manager.StoreId); this.litAccountAmount.Money = supplierBalance.Balance - supplierBalance.BalanceForzen; this.litRequestBalance.Money = supplierBalance.BalanceForzen; this.litOutBalance.Money = supplierBalance.BalanceOut; }
void IBLL.IBalance.Modify(BalanceInfo balance) { if (balance == null) { throw new Exception(); } dal.Modify(balance); }
void IBLL.IBalance.Remove(BalanceInfo balance) { if (balance == null) { throw new Exception(); } dal.Remove(balance); }
void IBLL.IBalance.Add(BalanceInfo balance) { if (balance == null) { throw new Exception(); } dal.Add(balance); }
public void CreateNPC(GameObject prefab, Character.BalanceInfo balanceInfo, BalanceInfo tileInfo) { npc = Instantiate(prefab, transform).GetComponentInChildren <Character>(); npc.InitBalancing(balanceInfo); npc.transform.parent.localPosition = new Vector3(.8f, 1.0f, -1.0f); this.tileInfo = tileInfo; }
void IDAL.IBalance.Add(BalanceInfo balance) { DataContext ctx = new DataContext(connection); ITable balances = ctx.GetTable <BalanceInfo>(); balances.InsertOnSubmit(balance); ctx.SubmitChanges(); }
void Client_NewPortfolio(BalanceInfo balance) { lock (_locker) { if (_portfolios == null) { _portfolios = new List <Portfolio>(); } var cryptoPortfolio = new Portfolio(); cryptoPortfolio.Number = balance.Name; var positionsOnBoard = new List <PositionOnBoard>(); foreach (var portfolio in balance.Balances) { var needPos = positionsOnBoard.Find(p => p.SecurityNameCode == portfolio.currency); if (needPos == null) { needPos = new PositionOnBoard(); needPos.SecurityNameCode = portfolio.currency; if (portfolio.type == "available") { needPos.ValueCurrent = ParseDecimal(portfolio.value); } else if (portfolio.type == "trade") { needPos.ValueBlocked = ParseDecimal(portfolio.value); } if (needPos.ValueCurrent != 0 || needPos.ValueBlocked != 0) { positionsOnBoard.Add(needPos); } } else { if (portfolio.type == "available") { needPos.ValueCurrent = ParseDecimal(portfolio.value); } else if (portfolio.type == "trade") { needPos.ValueBlocked = ParseDecimal(portfolio.value); } } } foreach (var pos in positionsOnBoard) { cryptoPortfolio.SetNewPosition(pos); } _portfolios.Add(cryptoPortfolio); PortfolioEvent?.Invoke(_portfolios); } }
public GracefulPreemptionHandler(IDispatcherManager dispatcherManager, string sessionId, Action <string> finishRunawayTaskCallback) { // Initialize it to the max value to not preempt until get an actual number from scheduler. this.BalanceInfo = new BalanceInfo(int.MaxValue); this.dispatcherManager = dispatcherManager; this.sessionId = sessionId; this.finishRunawayTaskCallback = finishRunawayTaskCallback; }
/// <remarks/> public void NotifyBalanceChangedAsync(BalanceInfo info, object userState) { if ((this.NotifyBalanceChangedOperationCompleted == null)) { this.NotifyBalanceChangedOperationCompleted = new System.Threading.SendOrPostCallback(this.OnNotifyBalanceChangedOperationCompleted); } this.InvokeAsync("NotifyBalanceChanged", new object[] { info }, this.NotifyBalanceChangedOperationCompleted, userState); }
public IvrBalanceInfo(BalanceInfo info, BalanceType type) { Amount = info.Amount; if (type == BalanceType.Available) Type = IvrBalanceType.Available; else if(type == BalanceType.Phone) Type = IvrBalanceType.Phone // here you have to handle the other values and set the default // values for the Type Property or it will take the default value // if you not set it }
public BalanceInfo CreateBalanceInfo(CreateBalanceDTO createBalanceDTO) { var balance = new BalanceInfo(); balance.BlongAccount = createBalanceDTO.BlongAccount; balance.IsValid = createBalanceDTO.IsValid; balance.MerchantId = createBalanceDTO.MerchantId; balance.MoneyInfo = new MoneyInfo().GenerateMonryInfo(createBalanceDTO.Money, createBalanceDTO.ServiceRate); balance.PersonInfo = new PersonInfo().GeneratePersonInfo(createBalanceDTO.Name, createBalanceDTO.IdCard, createBalanceDTO.PhoneNum, createBalanceDTO.BankCard); _balanceRespository.CreateBalanceInfo(balance); _unitOfWork.Commit(); return(balance); }
//点击对话 事件 protected void ChatButton_Command(object sender, CommandEventArgs e) { BalanceInfo balance = bllBalance.GetbyTidSid(Convert.ToInt32(e.CommandArgument), Convert.ToInt32(stdID)); if (balance == null || System.DateTime.Now > balance.Bal_Time) //对应该老师没有余额,则跳到购买界面 { Response.Redirect(String.Format("../Purchase/TeachersPurchase.aspx?tid={0}", e.CommandArgument)); } else //有余额,直接跳到对话界面 { Response.Redirect(String.Format("~/TeacherMemRobot.aspx?tid={0}", e.CommandArgument)); } }
//检查余额 protected void Check() { HttpCookie cookie = Request.Cookies["usr"]; int stdID = Convert.ToInt32(cookie.Values["ID"]); BalanceInfo balance = bllBalance.GetbyTidSid(Convert.ToInt32(teaid), stdID); if (System.DateTime.Now > balance.Bal_Time) { string strMsg = "余额不足,请购买时长"; Response.Write(strMsg); } Response.End(); }
void IDAL.IBalance.Remove(BalanceInfo balance) { try { DataContext ctx = new DataContext(connection); ITable balances = ctx.GetTable <BalanceInfo>(); balances.Attach(balance); balances.DeleteOnSubmit(balance); ctx.SubmitChanges(); } finally { } }
public void GetPortfolios() { string endPoint = "payment/balances"; var res = SendQuery(true, endPoint, _pubKey, _secKey); List <Balance> balances = JsonConvert.DeserializeAnonymousType(res, new List <Balance>()); BalanceInfo balanceInfo = new BalanceInfo(); balanceInfo.Balances = balances; balanceInfo.Name = _portfolioName; NewPortfolio?.Invoke(balanceInfo); }
/// <summary> /// Poll the scheduler for the newly published graceful preemption info. /// </summary> /// <param name="schedulerAdapter">the scheduler adapter</param> public async Task <bool> RefreshGracefulPreemptionInfo(ISchedulerAdapter schedulerAdapter) { BrokerTracing.TraceVerbose( "[GracefulPreemptionHandler].RefreshPreemptionRequest: query scheduler adapter"); bool result; List <string> taskIds; List <string> runningTaskIds; BalanceInfo balanceInfo; (result, balanceInfo, taskIds, runningTaskIds) = await schedulerAdapter.GetGracefulPreemptionInfoAsync(this.sessionId); if (result) { BrokerTracing.TraceVerbose( "[GracefulPreemptionHandler].RefreshPreemptionRequest: get new request taskIds count = {0}, running taskIds count = {1}, maxAllowedCoreCount = {2}, fastBalance = {3}", taskIds.Count, runningTaskIds.Count, balanceInfo.AllowedCoreCount, balanceInfo.UseFastBalance); BrokerTracing.TraceVerbose( "[GracefulPreemptionHandler].RefreshPreemptionRequest: replace old request taskIds count = {0}, maxAllowedCoreCount = {1}, fastBalance = {2}", this.exitingTaskIds == null ? 0 : this.exitingTaskIds.Count, this.BalanceInfo.AllowedCoreCount, this.BalanceInfo.UseFastBalance); foreach (var request in balanceInfo.BalanceRequests) { if (request.AllowedCoreCount <= NoPreemptionCores) { request.AllowedCoreCount = int.MaxValue; } } this.BalanceInfo = balanceInfo; this.exitingTaskIds = new HashSet <string>(taskIds); this.runningTaskIds = new HashSet <string>(runningTaskIds); return(true); } else { BrokerTracing.TraceVerbose( "[GracefulPreemptionHandler].RefreshPreemptionRequest: Refresh failed."); return(false); } }
//下载完整版 点击事件 protected void DownloadAll_Command(object sender, CommandEventArgs e) { object[] arguments = e.CommandArgument.ToString().Split(','); string viewUrl = Convert.ToString(arguments[0]); int teaId = Convert.ToInt32(arguments[1]); BalanceInfo balance = bllBalance.GetbyTidSid(teaId, Convert.ToInt32(stuId)); if (null != cookie) { stuId = cookie.Values["ID"]; } else { Response.Redirect("~/Student/Login.aspx"); //未登录时点击,跳转带登录页面 } if (!stuId.Equals("-1")) { try { StudentInfo stuInfo = bllStudent.Get(Convert.ToInt32(stuId)); } catch { Response.Redirect("~/Student/Login.aspx"); //未找到该学生id时,跳转到登录界面 } } //余额不足时,跳转到购买界面 if (null == balance || System.DateTime.Now > balance.Bal_Time) { Response.Redirect(String.Format("../Purchase/TeachersPurchase.aspx?tid={0}", teaId)); } //有余额时,下载完整版 else { string filename = MapPath(viewUrl); Response.Clear(); Response.ContentType = "application/octet-stream "; Response.AppendHeader("Content-Disposition ", "attachment; Filename = " + System.Convert.ToChar(34) + filename + System.Convert.ToChar(34)); Response.Charset = " "; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Flush(); Response.WriteFile(viewUrl); } }
internal void NotifyBalanceChanged(Account account, DateTime time, string currencyCode, decimal balance) { BalanceInfo balanceInfo = new BalanceInfo { AccountCode = account.Code, AccountID = account.Id, TradeDay = time, Amount = (double)Math.Abs(balance), CurrencyCode = currencyCode, ClientName = account.CustomerName, ChangeSubject = balance > 0 ? BalanceChangeSubject.Deposit : BalanceChangeSubject.Withdrawal }; lock (this._ToBeSendEntitiesLock) { this._ToBeSendEntities.Enqueue(balanceInfo); } this._HasToBeSendEntityEvent.Set(); }
/// <summary> /// 查询账户余额 /// </summary> /// <param name="brid">病人ID</param> /// <param name="brlx">病人类型 1:门诊 2:住院</param> /// <returns></returns> public XmlDocument QueryBalance(string brid, string brlx) { XmlDocument doc = new XmlDocument(); try { string error_msg = ""; BalanceInfo info = new BalanceInfo(); PaymentDB pdb = new PaymentDB(); int ret = pdb.DB_QueryBalance(brid, brlx, out info, out error_msg); if (ret == 0) { XmlElement root = doc.CreateElement(AppUtils.Tag_REXML_Root); doc.AppendChild(root); XmlElement eleResult = doc.CreateElement(AppUtils.Tag_REXML_Result); eleResult.InnerText = AppUtils.Value_Return_Success; root.AppendChild(eleResult); XmlElement eleMsg = doc.CreateElement(AppUtils.Tag_REXML_Message); root.AppendChild(eleMsg); XmlElement eleValue = doc.CreateElement(AppUtils.Tag_REXML_Value); eleMsg.AppendChild(eleValue); XmlElement eleZhye = doc.CreateElement(AppUtils.Tag_Balance_Zhye); eleValue.AppendChild(eleZhye); eleZhye.InnerText = info.zhye.ToString(); } else { doc = ErrorReturnXml(ret, error_msg); } } catch (Exception ex) { doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex); } return(doc); }
public void OnAddBalance(BalanceInfo info) { if (info.amount == 0) { return; } float duration = 1f; if (info.amount < 0) { assets.audioPay.Play(); Util.Emit(assets.particlePay, 3); } else { if (info.hitInfo != null) { if (info.hitInfo.hitChains <= 3) { assets.audioEarnSmall.Play(); } else { assets.audioEarnBig.Play(); } duration = slot.effects.GetHitEffect(info.hitInfo).duration *0.8f; } else { assets.audioEarnSmall.Play(); } } Util.InstantiateAt <ElosEffectMoney>(assets.effectMoney, transform).SetText(info.amount, info.hitInfo == null ? "" : info.hitInfo.hitChains + " in a row!").Play(100, 3f); if (_moneyTween != null && _moneyTween.IsPlaying()) { _moneyTween.Complete(); } _moneyTween = DOTween.To(() => lastBalance, x => lastBalance = x, slot.gameInfo.balance, duration).OnComplete(() => { _moneyTween = null; }); }
public void ShouldNotCreateNewBalanceIfItExists() { //Arrange var balanceTableRepository = Substitute.For <IBalanceTableRepository>(); BalancesService balanceService = new BalancesService(balanceTableRepository); BalanceInfo args = new BalanceInfo(); args.UserID = 22; args.Balance = 1000; args.StockID = 1; args.StockAmount = 1; //Act balanceService.CreateBalance(args); balanceTableRepository.Contains(Arg.Is <BalanceEntity>(w => w.UserID == args.UserID && w.Balance == args.Balance && w.StockID == args.StockID && w.StockAmount == args.StockAmount)).Returns(true); balanceService.CreateBalance(args); }
public void ShouldCreateBalance() { //Arrange var balanceTableRepository = Substitute.For <IBalanceTableRepository>(); BalancesService balanceService = new BalancesService(balanceTableRepository); BalanceInfo args = new BalanceInfo(); args.UserID = 22; args.Balance = 1000; args.StockID = 1; args.StockAmount = 1; //Act balanceService.CreateBalance(args); //Assert balanceTableRepository.Received(1).Add(Arg.Is <BalanceEntity>(w => w.UserID == args.UserID && w.Balance == args.Balance && w.StockID == args.StockID && w.StockAmount == args.StockAmount)); balanceTableRepository.Received(1).SaveChanges(); }
void IDAL.IBalance.Modify(BalanceInfo balance) { try { DataContext ctx = new DataContext(connection); ITable <BalanceInfo> balances = ctx.GetTable <BalanceInfo>(); IQueryable <BalanceInfo> query = from o in balances where o.Bal_ID == balance.Bal_ID select o; foreach (BalanceInfo o in query) { o.Bal_Time = balance.Bal_Time; o.Stu_ID = balance.Stu_ID; o.Tea_ID = balance.Tea_ID; } ctx.SubmitChanges(); } finally { } }
protected static void Read(XmlReader reader, BalanceInfo aInfo, string aEndTag) { string lastName = String.Empty; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { lastName = reader.Name; } if (reader.NodeType == XmlNodeType.Text) { string value = reader.Value.Trim(); try { switch (lastName) { case "BALAMT": aInfo.BALAMT = ParseAmount(value); break; case "DTASOF": aInfo.DTASOF = ParseDateTime(value); break; } } catch (FormatException ex) { throw new PXException(Messages.OFXParsingErrorValueHasInvalidFormat, lastName,ex.Message); } } if (reader.NodeType == XmlNodeType.EndElement && reader.Name == aEndTag) { return; } } }