private static void DynamicQueryParser(
            string serverAddress,
            string database,
            string UserId,
            string Password,
            string Query,
            bool outputToCsv)
        {
            string ConnectionString = @"Data Source=" + serverAddress + ";Initial catalog=" + database + ";User ID=" +
                                      UserId + ";Password="******";Persist Security Info=True;Impersonation Level=Impersonate";

            var query = Query;

            Console.WriteLine("About to connect to Analysis Services");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            var adocon = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();

            adocon.ConnectionString = ConnectionString;
            var table = new System.Data.DataTable();

            adocon.Open();
            Console.WriteLine("Successfully Connected to Analysis Services");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            var adoadapter = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(query, adocon);

            adoadapter.Fill(table);
            var str = "";

            foreach (System.Data.DataRow row in table.Rows)
            {
                var cnt = row.ItemArray.Count();
                for (int i = 0; i < cnt; i++)
                {
                    if (i == (cnt - 1))
                    {
                        str += row.ItemArray[i].ToString() + "\n";
                    }
                    else
                    {
                        str += row.ItemArray[i].ToString() + ",";
                    }
                }
            }
            Console.WriteLine("Creating Stream Bytes");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            byte[] bytes = Encoding.ASCII.GetBytes(str);
            Console.WriteLine("Successfully created Stream Bytes");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());
            var connectionstring = ConfigurationManager.ConnectionStrings["BlobStorage"].ConnectionString;
            var dest             = ConfigurationManager.AppSettings["dest"];

            Task.Run(async() => await SaveTextAsBlobHelper(bytes, connectionstring)).Wait();
            adocon.Close();
            adocon.Dispose();
        }
Exemple #2
0
 public void Dispose()
 {
     if (_type == AdomdType.AnalysisServices)
     {
         if (_conn != null)
         {
             _conn.Dispose();
             _conn = null;
         }
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             if (_connExcel != null)
             {
                 _connExcel.Dispose();
                 _connExcel = null;
             }
         };
         f();
     }
 }
Exemple #3
0
        public void Dispose()
        {
            if (_type == AdomdType.AnalysisServices)
            {
                if (_conn != null)
                {
                    _conn.Dispose();
                    _conn = null;
                }
            }
            else
            {
                void f()
                {
                    if (_connExcel != null)
                    {
                        _connExcel.Dispose();
                        _connExcel = null;
                    }
                }

                f();
            }
        }