Exemplo n.º 1
0
        static void Msg(object sender, MessageEventArgs e)
        {
            try {
                //Log.Info($"Message: {e.Data}");
                #region ParseType
                if (e.Data == "pong")
                {
                    return;
                }
                string         type            = string.Empty;
                string         data            = string.Empty;
                JsonTextReader reader          = new JsonTextReader(new StringReader(e.Data));
                string         currentProperty = string.Empty;
                while (reader.Read())
                {
                    if (reader.Value != null)
                    {
                        if (reader.TokenType == JsonToken.PropertyName)
                        {
                            currentProperty = reader.Value.ToString();
                        }
                        else if (reader.TokenType == JsonToken.String)
                        {
                            if (currentProperty == "type")
                            {
                                type = reader.Value.ToString();
                            }
                            else
                            {
                                data = reader.Value.ToString();
                            }
                        }
                    }
                }
                #endregion
                switch (type)
                {
                case "newitems_go":
                    NewItem newItem = new NewItem(data);
                    newItemRpsKeeper.Tick();
                    if (newItem.i_market_name == "")
                    {
                        Log.Warn("Socket item has no market name");
                    }
                    else
                    {
                        NewItemAppeared(null, newItem);
                    }
                    break;

                case "history_go":
                    try {
                        NewHistoryItem historyItem = new NewHistoryItem(data);
                        ProcessItem(historyItem);
                    } catch (Exception ex) {
                        Log.Error($"Some error occured during history parse. [{data}] Message: " + ex.Message + "\nTrace: " + ex.StackTrace);
                    }
                    break;

                default:
                    //Log.Info(JObject.Parse(e.Message).ToString(Formatting.Indented));
                    //Console.WriteLine(x.type);
                    //data = DecodeEncodedNonAsciiCharacters(data);
                    //Log.Info(data);
                    break;
                }
            } catch (Exception ex) {
                Log.Error("Some error occured. Message: " + ex.Message + "\nTrace: " + ex.StackTrace);
            } finally {
            }
        }
Exemplo n.º 2
0
 public void Add(NewHistoryItem item)
 {
     collection.InsertOne(
         new MongoHistoryItem(item)
         );
 }
Exemplo n.º 3
0
 static private void ProcessItem(NewHistoryItem item)
 {
     mongoHistoryCSGO.Add(item);
 }
Exemplo n.º 4
0
 public MongoHistoryItem(NewHistoryItem item) : base(item)
 {
     id = ObjectId.GenerateNewId(DateTime.Now);
 }