1 Reply Latest reply on Dec 26, 2019 11:48 AM by Vikram Gokhale

    Getting error on HyperAPI for c# when creating hyper extract

    Fatih Duzenli

      Hello,

       

      I am trying to create a hyper extract using HyperAPI for .net, however i am getting an error like below:

       

           System.ObjectDisposedException: 'Inserter object has been closed

           Object name: 'inserter'.'

       

      This is happening when i try to loop through a list of objects and try to add values at the 5th column with inserter.Add method.

       

      Somehow inserter.IsOpen property is set to False by itself.

       

      public void ExtractAsTableauHyper()
              {
                  string pathToHyper = @"..\Desktop\LifeOfS.hyper";
      
                  if (File.Exists(pathToHyper))
                  {
                      File.Delete(pathToHyper);
                  }
      
                  using (var hyper = new HyperProcess(Telemetry.SendUsageDataToTableau, "myapp"))
                  {
                      using (var connection = new Connection(hyper.Endpoint, pathToHyper, CreateMode.Create))
                      {
                          connection.Catalog.CreateSchema("Extract");
      
                          var tableSchema = new TableDefinition(new TableName("Extract", "Extract"))
                              .AddColumn("ID", SqlType.Int(), Nullability.NotNullable)
                              .AddColumn("Department", SqlType.Text())
                              .AddColumn("A Sticky", SqlType.Text())
                              .AddColumn("A TS", SqlType.Date())
                              .AddColumn("Completed TS", SqlType.Date())
                              .AddColumn("Created", SqlType.Date())
                              .AddColumn("PCR created TS", SqlType.Date())
                              .AddColumn("D Declined TS", SqlType.Date())
                              .AddColumn("D Huddle Board TS", SqlType.Date())
                              .AddColumn("D PSS", SqlType.Date())
                              .AddColumn("In Progress TS", SqlType.Date())
                              .AddColumn("M Declined TS", SqlType.Date())
                              .AddColumn("M Huddle Board TS", SqlType.Date())
                              .AddColumn("M PSS TS", SqlType.Date())
                              .AddColumn("Request ID", SqlType.Text(), "en_us_ci")
                              .AddColumn("Site", SqlType.Text(), "en_us_ci")
                              .AddColumn("Stage", SqlType.Text(), "en_us_ci")
                              .AddColumn("Status", SqlType.Text(), "en_us_ci")
                              .AddColumn("Under Implementation TS", SqlType.Date())
                              .AddColumn("VP Huddle Board TS", SqlType.Date())
                              .AddColumn("VP PSS TS", SqlType.Date());
      
                          connection.Catalog.CreateTable(tableSchema);
                          Inserter inserter = new Inserter(connection, tableSchema); 
                          for (int i = 0; i < this.lifeOfObjList.Count; i++)
                          {
      
                              inserter.Add(this.lifeOfObjList[i].ID);
                              inserter.Add(this.lifeOfObjList[i].Department);
                              inserter.Add(this.lifeOfObjList[i].ASticky);
                              inserter.Add(this.lifeOfObjList[i].AStickyTS);
                               //Right below i am getting the error--------------
                              inserter.Add(this.lifeOfObjList[i].CompletedTS);
                              inserter.Add(this.lifeOfObjList[i].Created);
                              inserter.Add(this.lifeOfObjList[i].PCRCreatedTS);
                              inserter.Add(this.lifeOfObjList[i].DDeclinedTS);
                              inserter.Add(this.lifeOfObjList[i].DHuddleBoardTS);
                              inserter.Add(this.lifeOfObjList[i].DPSS);
                              inserter.Add(this.lifeOfObjList[i].InProgressTS);
                              inserter.Add(this.lifeOfObjList[i].MTS);
                              inserter.Add(this.lifeOfObjList[i].MHuddleBoardTS);
                              inserter.Add(this.lifeOfObjList[i].MPSSTS);
                              inserter.Add(this.lifeOfObjList[i].RequestID);
                              inserter.Add(this.lifeOfObjList[i].Site);
                              inserter.Add(this.lifeOfObjList[i].Stage);
                              inserter.Add(this.lifeOfObjList[i].Status);
                              inserter.Add(this.lifeOfObjList[i].UnderImplementationTS);
                              inserter.Add(this.lifeOfObjList[i].VPTS);
                              inserter.Add(this.lifeOfObjList[i].VPPSSTS);
                              inserter.EndRow();
      
      
                          }
      
                          inserter.Execute();
      
                      }
                  }
      
      
      
      
              }