예제 #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()
                 {
                     Name = accountNameTextbox.Text,
                     Id = accountIdTextbox.Text,
                     LicenseType = "paying",
                     LicenseRenewal = DateTime.UtcNow.ToString("yyyy-MM-dd")
                 },
                 Event = new Preact.ActionEvent()
                 {
                     Name = eventNameTextbox.Text,
                     Revenue = 99
                 },
                 Person = new Preact.Person()
                 {
                     Email = emailTextbox.Text,
                     Name = personNameTextbox.Text,
                     Uid = uidTextbox.Text,
                     CreatedAt = DateTime.Now,
                     Properties = new Dictionary<string, object>()
                         {
                            {"created_at", (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds},
                            {"is_paying", true},
                            {"account_level", 2},
                            {"account_level_name", "Pro"}
                         }
                 }
             };
         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 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()
             {
                 Name           = accountNameTextbox.Text,
                 Id             = accountIdTextbox.Text,
                 LicenseType    = "paying",
                 LicenseRenewal = DateTime.UtcNow.ToString("yyyy-MM-dd")
             },
             Event = new Preact.ActionEvent()
             {
                 Name    = eventNameTextbox.Text,
                 Revenue = 99
             },
             Person = new Preact.Person()
             {
                 Email      = emailTextbox.Text,
                 Name       = personNameTextbox.Text,
                 Uid        = uidTextbox.Text,
                 CreatedAt  = DateTime.Now,
                 Properties = new Dictionary <string, object>()
                 {
                     { "created_at", (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds },
                     { "is_paying", true },
                     { "account_level", 2 },
                     { "account_level_name", "Pro" }
                 }
             }
         };
         outputTextbox.AppendText(JsonConvert.SerializeObject(request, Formatting.Indented) + "\n");
         api.LogEvent(request);
     }
     catch (Exception ex)
     {
         outputTextbox.AppendText("Log failure:" + ex.Message);
         outputTextbox.AppendText(ex.StackTrace);
     }
 }
예제 #3
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 {
                Preact.BackgroundSignalRequest request = new Preact.BackgroundSignalRequest()
                    {
                        AccountId = accountIdTextbox.Text,
                        Name = signalNameTextbox.Text,
                        Value = int.Parse(signalValueTextbox.Text),
                        Timestamp = (DateTime.UtcNow - new DateTime(1970, new Random().Next(1, 3), new Random().Next(1, 30))).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);
            }
        }
예제 #4
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 {
                Preact.BackgroundSignalRequest request = new Preact.BackgroundSignalRequest()
                {
                    AccountId = accountIdTextbox.Text,
                    Name      = signalNameTextbox.Text,
                    Value     = int.Parse(signalValueTextbox.Text),
                    Timestamp = (DateTime.UtcNow - new DateTime(1970, new Random().Next(1, 3), new Random().Next(1, 30))).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);
            }
        }