private void Subscriber_OnSubscriptionReply(Event eventObject, Session session) { Subscribe s = Subscribe.Create(eventObject); if (s != null) { foreach (var security in m_Securities) { foreach (var field in m_Fields) { if (String.IsNullOrEmpty(security) || String.IsNullOrEmpty(field)) { continue; } //Element element = s[security, field]; //string v = element != null ? element.GetValue().ToString() : string.Empty; object value = s[security, field]; //Utility.Log(this, "Update Value", field+ ":" +value); string v = value != null?value.ToString() : string.Empty; //Console.WriteLine("[" + security + "," + field + "] " + v); if (!String.IsNullOrEmpty(v)) { CellBase c = m_CellList.Values.FirstOrDefault(e => e.Name == security && e.Tag != null && e.Tag.ToString() == field); if (c != null) { c.SetValue(v); } } } } } }
private void OnSubscriptionReply(Event eventObject, Session session) { Subscribe s = Subscribe.Create(eventObject); if (s.HasError) { foreach (var err in s.Errors) { //txtMsg.AppendText(Response.ErrorElement(this, "SubscriptionERR", err)); txtMsg.AppendText(err); } } }
async Task <Subscribe> OnPayedAsync(Pay pay) //當付款成功紀錄後執行 { var bill = _billsService.GetById(pay.BillId); if (bill == null) { throw new BillNotFoundWhilePay($"bill id: {pay.BillId}"); } if (!bill.Payed) { throw new NotPayedAfterPay(bill, pay); } bill.DeadLine = null; var payWay = _paysService.FindPayWayByCode(pay.PayWay); if (payWay == null) { _logger.LogException(new PayWayNotFound(pay.PayWay)); } else { bill.PayWayId = payWay.Id; } await _billsService.UpdateAsync(bill); //建立 Subscribe var subscribe = _subscribesService.Find(bill); if (subscribe == null) { subscribe = await _subscribesService.CreateAsync(Subscribe.Create(bill)); } //加入角色 if (subscribe.Active) { await _usersService.AddSubscriberRoleAsync(subscribe.UserId); } return(subscribe); }
private void OnSubscriptionReply(Event eventObject, Session session) { //Console.WriteLine("1"); Subscribe s = Subscribe.Create(eventObject); if (s != null) { //Console.WriteLine("2"); if (tsPublish.Checked) { //Console.WriteLine("3"); foreach (var security in s.Collection.Securities.Values) { if (!m_Prices.ContainsKey(security.Name)) { m_Prices.Add(security.Name, new Publish(security)); } m_Prices[security.Name].Update(security); if (m_Prices[security.Name].MidP == 0) { continue; } foreach (var redis in Utility.REDIS) { redis.Publish(Utility.Load <string>("REDIS", "CHANNEL") + security.Name, m_Prices[security.Name].MidP.ToString()); } ////Console.WriteLine($"{security.Values["LAST_PRICE"]}; {security.Values["BID"]}; {security.Values["ASK"]}"); ////Console.WriteLine(value); //double last = !security.Values.ContainsKey("LAST_PRICE") ? 0D : Convert.ToDouble(security.Values["LAST_PRICE"]); //double bid = !security.Values.ContainsKey("BID") ? 0D : Convert.ToDouble(security.Values["BID"]); //double ask = !security.Values.ContainsKey("ASK") ? 0D : Convert.ToDouble(security.Values["ASK"]); //string value; //if (bid == 0 || ask == 0) //{ // if (last == 0) { continue; } // value = last.ToString(); //} //else //{ // value = ((ask + bid) / 2).ToString(); //} //foreach (var redis in Utility.REDIS) //{ // redis.Publish(Utility.Load<string>("REDIS", "CHANNEL") + security.Name, value); //} ////var value = security.Values["LAST_PRICE"]; ////if (value != null) ////{ //// foreach (var redis in Utility.REDIS) //// { //// //Console.WriteLine(m_Channel + security.Name+" "+ value.ToString()); //// redis.Publish(m_Channel + security.Name, value.ToString()); //// //Console.WriteLine("4"); //// } //// //Utility.REDIS.Publish(Utility.Load<string>("REDIS", "CHANNEL") + security.Name, value.ToString()); ////} } } Utility.PUB.Send("Subscription", s); } }