public override void ExtractFeature()
        {
            int count = 0;

            while (reader.HasNext())
            {
                if (++count % 10000 == 0)
                {
                    Console.Clear();
                    Console.WriteLine("{0} has processed {1}", Thread.CurrentThread.Name, count);
                }
                var e = reader.GetNextEvent();
                try
                {
                    var feature = extractor.ExtractFeature(e);
                    writer.WriteEvent(new Event(e.Label, feature));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e);
                }
            }
            reader.Close();
            writer.Close();
        }
Beispiel #2
0
        public override void ExtractFeature()
        {
            var count = 0;
            var dic   = new Dictionary <string, int>();

            foreach (var type in types)
            {
                dic[type] = dic.Count;
            }

            while (reader.HasNext())
            {
                if (++count % 1000 == 0)
                {
                    Console.WriteLine("{0} has processed {1}", Thread.CurrentThread.Name, count);
                }
                var e = reader.GetNextEvent();
                try
                {
                    var feature = extractor.ExtractFeature(e);
                    writer.WriteEvent(new Event(new Label(dic[e.Label.StringLabel].ToString()), feature));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
            }
            reader.Close();
            writer.Close();
        }
Beispiel #3
0
    public string WriteEvent(int deviceId, int sessionId, double currentSeconds, string platform, float forceX, float forceY)
    {
        m_ForceX = forceX;
        m_ForceY = forceY;
        Dictionary <string, object> dict = GenerateDict();

        return(EventWriter.WriteEvent(name, dict, "device" + deviceId + "-DDDD-DDDD", "session" + sessionId + "-SSSS-SSSS", platform, currentSeconds * 1000, false) + "\n");
    }
Beispiel #4
0
        public Reader()
        {
            var eventWriter = new EventWriter("CounterResults");

            Receive <Shared.Event>(message =>
            {
                Console.WriteLine($"Message received by Reader {Self}");
                string paymentReference;
                switch ((MessageType)message.MessageType)
                {
                case MessageType.ApprovalStatusChanged:
                    paymentReference = JsonConvert.DeserializeObject <PaymentApprovalStatusChangedMessage>(message.Message).PaymentReference;
                    Console.WriteLine($"**ApprovalStatusChanged Event received for payment {paymentReference}");
                    break;

                case MessageType.PaymentStatusChanged:
                    var pscmessage = JsonConvert.DeserializeObject <PaymentStatusChangedMessage>(message.Message);
                    var calculator = new CustomerPaymentCounterCalculator();
                    var result     = calculator.GetPaymentChanges(pscmessage);

                    var eReader1    = new Hackathon.EventStore.Core.EventReader($"evt-{pscmessage.Payment.PaymentReference}");
                    var allMessages = eReader1.ReadAllMessages(pscmessage.Payment.PaymentReference);

                    var counterResult = new CounterResult
                    {
                        CustomerReference = pscmessage.Customer.CustomerReference,
                        PaymentReference  = pscmessage.Payment.PaymentReference,
                        Increment         = result
                    };

                    eventWriter.WriteEvent(counterResult.AsJsonString(), "IncrementCalculated");
                    Console.WriteLine($"**Event received for payment {pscmessage.Payment.PaymentReference}");
                    break;

                case MessageType.CustomerAccountChanged:
                    paymentReference = JsonConvert.DeserializeObject <PaymentCustomerAccountChangedMessage>(message.Message).PaymentReference;
                    Console.WriteLine($"**CustomerAccountChanged Event received for payment {paymentReference}");
                    break;

                case MessageType.WithdrawalChannelChanged:
                    paymentReference = JsonConvert.DeserializeObject <WithdrawalChannelChangedMessage>(message.Message).PaymentReference;
                    Console.WriteLine($"**WithdrawalChannelChanged Event received for payment {paymentReference}");
                    break;

                default:
                    Console.WriteLine("arrrrr");
                    return;
                }
            });
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            EventStoreLoader.SetupEventStore();
            var eventReader = new EventReader("Payments");
            var eventWriter = new EventWriter("CounterResults");

            eventReader.ConnectToPersistentSubscription("Payments", "Payments_Counter", (_, e) =>
            {
                var data = Encoding.ASCII.GetString(e.Event.Data);
                switch (e.Event.EventType)
                {
                case "PaymentStatusChanged":
                    var pscmessage    = data.ParseJson <PaymentStatusChangedMessage>();
                    var calculator    = new CustomerPaymentCounterCalculator();
                    var result        = calculator.GetPaymentChanges(pscmessage);
                    var eReader1      = new EventReader($"evt-{pscmessage.Payment.PaymentReference}");
                    var allMessages   = eReader1.ReadAllMessages(pscmessage.Payment.PaymentReference);
                    var counterResult = new CounterResult {
                        CustomerReference = pscmessage.Customer.CustomerReference, PaymentReference = pscmessage.Payment.PaymentReference, Increment = result
                    };
                    eventWriter.WriteEvent(counterResult.AsJsonString(), "IncrementCalculated");
                    Console.WriteLine($"**Event received for payment {pscmessage.Payment.PaymentReference}");
                    break;

                case "ApprovalStatusChanged":
                    var asmessage = data.ParseJson <PaymentApprovalStatusChangedMessage>();
                    break;

                case "CustomerAccountChanged":
                    var camessage = data.ParseJson <PaymentCustomerAccountChangedMessage>();
                    break;

                case "WithdrawalChannelChanged":
                    var wcmessage = data.ParseJson <WithdrawalChannelChangedMessage>();
                    break;

                default:
                    Console.WriteLine("Cannot parse event type");
                    return;
                }
            });

            Console.ReadLine();
        }
Beispiel #6
0
 /// <summary>
 /// Transmit the event
 /// </summary>
 protected static analyticsResultNamespace.AnalyticsResult Commit(string eventName)
 {
     analyticsResultNamespace.AnalyticsResult result;
     if (s_SaveToLocal)
     {
         string path = String.IsNullOrEmpty(s_LocalSavePath) ? System.IO.Path.Combine(Application.dataPath, "RawData") : s_LocalSavePath;
         result = analyticsResultNamespace.AnalyticsResult.Ok;
         using (var writer = new StreamWriter(path, true))
         {
             s_SessionId = (String.IsNullOrEmpty(s_SessionId)) ? System.Guid.NewGuid().ToString() : s_SessionId;
             double currentMilliseconds = Math.Floor((DateTime.UtcNow - UnityAnalytics.DateTimeUtils.s_Epoch).TotalMilliseconds);
             string evt = EventWriter.WriteEvent("Heatmap." + eventName, s_Dictionary, "TestDevice", s_SessionId, Application.platform.ToString(), currentMilliseconds, Debug.isDebugBuild);
             writer.WriteLine(evt);
         }
     }
     else
     {
         result = analyticsEventNamespace.CustomEvent("Heatmap." + eventName, s_Dictionary);
     }
     s_Dictionary.Clear();
     return(result);
 }
Beispiel #7
0
    public string WriteEvent(int deviceId, int sessionId, double currentSeconds, string platform, bool isDebug = false)
    {
        Dictionary <string, object> dict = GenerateDict();

        return(EventWriter.WriteEvent(name, dict, "device" + deviceId + "-DDDD-DDDD", "session" + sessionId + "-SSSS-SSSS", platform, currentSeconds * 1000, isDebug) + "\n");
    }