Beispiel #1
0
        public IActionResult InsertBQData(string username, string userplan, string customerId)
        {
            try
            {
                string   projectId = "task8-imagerecognition-281418";
                DateTime now       = DateTime.Now;
                Console.WriteLine("email: " + username);
                Console.WriteLine("plan: " + userplan);

                BigQueryClient client = BigQueryClient.Create(projectId);

                // Create the dataset if it doesn't exist.
                BigQueryDataset dataset = client.GetOrCreateDataset("mydata");

                // Create the table if it doesn't exist.
                BigQueryTable table = dataset.GetOrCreateTable("customer", new TableSchemaBuilder
                {
                    { "email", BigQueryDbType.String },
                    { "subscriptionStarted", BigQueryDbType.Timestamp },
                    { "planType", BigQueryDbType.String } //BigQueryDbType.Int64
                }.Build());

                //Insert data into table
                table.InsertRow(new BigQueryInsertRow
                {
                    { "email", username },
                    { "subscriptionStarted", DateTimeOffset.UtcNow.ToUnixTimeSeconds() },
                    { "planType", userplan }
                });
                Console.WriteLine("Inserted: " + username + " successfully");
                return(Redirect("/Home/Main/" + username + "/" + userplan + "/" + customerId + "?Msg=Success"));
            }// End of try
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return(Redirect("/Home/Main/" + username + "/" + userplan + "/" + customerId + "?Msg=Failed"));
            }
        }// End of insertBQData
Beispiel #2
0
        private bool BuildTable()
        {
            var tableName = ComputerName == "CH-J7TMTZ1" ? "CCChinaTable" : "CCTable";

#if DEBUG
            tableName = "CCChinaTable";
#endif
            try {
                _client  = BigQueryClient.Create("booming-pride-278623");
                _dataset = _client.GetOrCreateDataset("CCDataset");
                _table   = _dataset.GetOrCreateTable(tableName, new TableSchemaBuilder
                {
                    { "CycleNumber", BigQueryDbType.Int64 },
                    { "LogTime_Timestamp", BigQueryDbType.Timestamp },
                    { "TotalTest_Hours", BigQueryDbType.Float64 },
                    { "MinutesIntoCycle", BigQueryDbType.Float64 },
                    { "CurrentBiasIsOn", BigQueryDbType.String },
                    { "SampleName", BigQueryDbType.String },
                    { "Current_Amps", BigQueryDbType.Float64 },
                    { "Voltage_Volts", BigQueryDbType.Float64 },
                    { "NumCells", BigQueryDbType.Int64 },
                    { "CellVoc_Volts", BigQueryDbType.Float64 },
                    { "TempSensorNumber", BigQueryDbType.Int64 },
                    { "SetCurrent_Amps", BigQueryDbType.Float64 },
                    { "EstimatedRs_mOhms", BigQueryDbType.Float64 },
                    { "Temp1_C", BigQueryDbType.Float64 },
                    { "Temp2_C", BigQueryDbType.Float64 },
                    { "Temp3_C", BigQueryDbType.Float64 },
                    { "Temp4_C", BigQueryDbType.Float64 },
                    { "Temp5_C", BigQueryDbType.Float64 },
                    { "Temp6_C", BigQueryDbType.Float64 },
                    { "Temp7_C", BigQueryDbType.Float64 },
                    { "Temp8_C", BigQueryDbType.Float64 },
                    { "Temp9_C", BigQueryDbType.Float64 },
                    { "Temp10_C", BigQueryDbType.Float64 },
                    { "Temp11_C", BigQueryDbType.Float64 },
                    { "Temp12_C", BigQueryDbType.Float64 },
                    { "Temp13_C", BigQueryDbType.Float64 },
                    { "Temp14_C", BigQueryDbType.Float64 },
                    { "Temp15_C", BigQueryDbType.Float64 },
                    { "Temp16_C", BigQueryDbType.Float64 },
                    { "SmokeLevel1_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel2_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel3_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel4_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel5_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel6_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel7_Volts", BigQueryDbType.Float64 },
                    { "SmokeLevel8_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage1_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage2_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage3_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage4_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage5_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage6_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage7_Volts", BigQueryDbType.Float64 },
                    { "SmokeVoltage8_Volts", BigQueryDbType.Float64 },
                }.Build());
                return(true);
            }
            catch {
                return(false);
            }
        }
        private void CriarTabela()
        {
            string nome = typeof(T).Name;

            _tabela = _dataSet.GetOrCreateTable(nome, new FabricaDeEsquemasDeTabela().CriarEsquema(nome).Build());
        }