示例#1
0
 private void CreateLogEvent()
 {
     outputTextbox.AppendText("Logging event\n");
     Preact.Api api = new Preact.Api(codeTextbox.Text, secretTextbox.Text);
     try
     {
         Preact.ActionEventCreateRequest request = new Preact.ActionEventCreateRequest()
             {
                 Account = new Preact.Account()
                 {
                     Id = accountIdTextbox.Text,
                     Name = accountNameTextbox.Text,
                     Properties = new Dictionary<string, object> {{"Lifetime Sent Emails",1000}}
                 },
                 Event = new ActionEvent
                 {
                     Name = eventNameTextbox.Text
                 }
             };
         outputTextbox.AppendText(JsonConvert.SerializeObject(request,Formatting.Indented) + "\n");
         api.LogEvent(request);
     }
     catch (Exception ex)
     {
         outputTextbox.AppendText("Log failure:" + ex.Message);
         outputTextbox.AppendText(ex.StackTrace);
     }
 }
示例#2
0
        private void btnLogBackgroundSignal_Click(object sender, EventArgs e)
        {
            outputTextbox.AppendText("Logging signal\n");
            Preact.Api api = new Preact.Api(codeTextbox.Text, secretTextbox.Text);

            try {
                var month = 1;
                var day = 1;
                var timeSpan = DateTime.UtcNow.AddDays(-3) - new DateTime(1970, month, day);

                Preact.BackgroundSignalRequest request = new Preact.BackgroundSignalRequest()
                    {
                        AccountId = accountIdTextbox.Text,
                        Name = signalNameTextbox.Text,
                        Value = int.Parse(signalValueTextbox.Text),
                        Timestamp = timeSpan.TotalSeconds
                    };
                outputTextbox.AppendText(JsonConvert.SerializeObject(request, Formatting.Indented) + "\n");
                api.LogBackgroundSignal(request);
            }
            catch (Exception ex)
            {
                outputTextbox.AppendText("Log failure:" + ex.Message);
                outputTextbox.AppendText(ex.StackTrace);
            }
        }