コード例 #1
0
 private void ProcessPriceAlertEvent(Protocal.Commands.AlertType alertType, IEnumerable <PriceAlert.Alert> alerts)
 {
     try
     {
         Broadcaster.Default.Add(BroadcastBLL.CommandFactory.CreatePriceAlertCommand(alerts, alertType));
         Logger.InfoFormat("broadcast price alert command alertType = {0}", alertType);
     }
     catch (Exception ex)
     {
         Logger.Error(string.Format("ProcessPriceAlertEvent alertType = {0}", alertType), ex);
     }
 }
コード例 #2
0
ファイル: CommandFactory.cs プロジェクト: dreamsql/Outter
        internal static Protocal.TradingCommand CreatePriceAlertCommand(IEnumerable <PriceAlert.Alert> alerts, Protocal.Commands.AlertType alertType)
        {
            Dictionary <Guid, Protocal.Commands.UserPriceAlertData> alertDict = new Dictionary <Guid, Protocal.Commands.UserPriceAlertData>();

            foreach (var eachAlert in alerts)
            {
                eachAlert.Process(alertDict, alertType);
            }
            return(new Protocal.Commands.TradingPriceAlertCommand
            {
                Type = alertType,
                UserPriceAlerts = alertDict.Values.ToList()
            });
        }
コード例 #3
0
ファイル: CommandFactory.cs プロジェクト: dreamsql/Outter
 private static Protocal.Commands.PriceAlertData CreatePriceAlertData(this PriceAlert.Alert alert, Protocal.Commands.AlertType alertType)
 {
     return(new Protocal.Commands.PriceAlertData
     {
         Id = alert.Id,
         State = alert.State,
         HitPrice = alertType == Protocal.Commands.AlertType.Hit ? (string)alert.HitPrice : null,
         HitTime = alertType == Protocal.Commands.AlertType.Hit ? alert.HitPriceTimestamp : (DateTime?)null
     });
 }
コード例 #4
0
ファイル: CommandFactory.cs プロジェクト: dreamsql/Outter
 private static void Process(this PriceAlert.Alert alert, Dictionary <Guid, Protocal.Commands.UserPriceAlertData> alertDict, Protocal.Commands.AlertType alertType)
 {
     Protocal.Commands.UserPriceAlertData userPriceAlerts;
     if (!alertDict.TryGetValue(alert.UserId, out userPriceAlerts))
     {
         userPriceAlerts = new Protocal.Commands.UserPriceAlertData
         {
             UserId      = alert.UserId,
             PriceAlerts = new List <Protocal.Commands.PriceAlertData>()
         };
         alertDict.Add(userPriceAlerts.UserId, userPriceAlerts);
     }
     userPriceAlerts.PriceAlerts.Add(alert.CreatePriceAlertData(alertType));
 }