Beispiel #1
0
        public AdomdDataAdapter(AdomdCommand command)
        {
            Contract.Requires(command != null, "The command parameter must not be null");

            if (command.Connection.Type == AdomdType.AnalysisServices)
            {
                _obj = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter
                {
                    SelectCommand = (Microsoft.AnalysisServices.AdomdClient.AdomdCommand)command.UnderlyingCommand
                };
            }
            else
            {
                void f()
                {
                    _objExcel = new ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter
                    {
                        SelectCommand =
                            (ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdCommand)command.UnderlyingCommand
                    };
                }

                f();
            }
        }
        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();
        }
        public AdomdDataAdapter(AdomdCommand command)
        {
            Contract.Requires(command != null, "The command parameter must not be null");


            _obj = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter
            {
                SelectCommand = (Microsoft.AnalysisServices.AdomdClient.AdomdCommand)command.UnderlyingCommand
            };
        }
        public DataTable ForEachMeasureGroupInternal(string command, bool forEachPartition)
        {
            DataTable result = new DataTable();

            Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
            server.Connect("*");
            Database db = server.Databases.GetByName(Context.CurrentDatabaseName);

            foreach (Microsoft.AnalysisServices.Cube c in db.Cubes)
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = TimeoutUtility.ConnectAdomdClient("Data Source=" + server.Name + ";Initial Catalog=" + Context.CurrentDatabaseName + ";Cube=" + c.Name);

                foreach (Microsoft.AnalysisServices.MeasureGroup mg in c.MeasureGroups)
                {
                    if (forEachPartition)
                    {
                        foreach (Microsoft.AnalysisServices.Partition p in mg.Partitions)
                        {
                            //parameters don't appear to work with some DMV queries, so use string substitution
                            string sNewCommand = command;
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_NAME", p.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_ID", p.ID);
                            Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                            cmd.CommandTimeout = 0;
                            Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                            TimeoutUtility.FillAdomdDataAdapter(adp, result);
                        }
                    }
                    else
                    {
                        //parameters don't appear to work with some DMV queries, so use string substitution
                        string sNewCommand = command;
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                        Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                        cmd.CommandTimeout = 0;
                        Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                        TimeoutUtility.FillAdomdDataAdapter(adp, result);
                    }
                }

                conn.Close();
            }
            return(result);
        }
Beispiel #5
0
 public AdomdDataAdapter(AdomdCommand obj)
 {
     if (obj.Connection.Type == AdomdType.AnalysisServices)
     {
         _obj = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter();
         _obj.SelectCommand = (Microsoft.AnalysisServices.AdomdClient.AdomdCommand)obj.UnderlyingCommand;
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             _objExcel = new ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter();
             _objExcel.SelectCommand =
                 (ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdCommand)obj.UnderlyingCommand;
         };
         f();
     }
 }
 public AdomdDataAdapter(AdomdCommand obj)
 {
     if (obj.Connection.Type == AdomdType.AnalysisServices)
     {
         _obj = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter();
         _obj.SelectCommand = (Microsoft.AnalysisServices.AdomdClient.AdomdCommand) obj.UnderlyingCommand;
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             _objExcel = new ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter();
             _objExcel.SelectCommand =
                 (ExcelAdomdClientReference::Microsoft.AnalysisServices.AdomdClient.AdomdCommand) obj.UnderlyingCommand;
         };
         f();
     }
 }
Beispiel #7
0
        /// <summary>
        /// Fills a DataTable using the specified AdomdDataAdapter
        /// This is done on a background thread
        /// Helps ensure a sproc trying to fill a DataTable does not get deadlocked
        /// </summary>
        /// <param name="adp"></param>
        /// <param name="tbl"></param>
        public static void FillAdomdDataAdapter(Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp, System.Data.DataTable tbl)
        {
            FillAdomdDataAdapterInfo info = new FillAdomdDataAdapterInfo();

            info.adapter   = adp;
            info.table     = tbl;
            info.autoEvent = new System.Threading.AutoResetEvent(false);
            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(FillAdomdDataAdapterWorker), info);

            while (!info.autoEvent.WaitOne(1000, false))
            {
                Context.CheckCancelled(); //if the parent query has been cancelled (or the ForceCommitTimeout expires) then this will immediately exit
            }

            if (info.ex != null)
            {
                throw info.ex;
            }
        }
Beispiel #8
0
 public AdomdDataAdapter(Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter obj)
 {
     _obj = obj;
 }
Beispiel #9
0
 public AdomdDataAdapter(Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adapter)
 {
     _obj = adapter;
 }
        public DataTable ForEachMeasureGroupInternal(string command, bool forEachPartition)
        {
            DataTable result = new DataTable();

            Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
            server.Connect("*");
            Database db = server.Databases.GetByName(Context.CurrentDatabaseName);

            foreach (Microsoft.AnalysisServices.Cube c in db.Cubes)
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = TimeoutUtility.ConnectAdomdClient("Data Source=" + server.Name + ";Initial Catalog=" + Context.CurrentDatabaseName + ";Cube=" + c.Name);

                foreach (Microsoft.AnalysisServices.MeasureGroup mg in c.MeasureGroups)
                {
                    if (forEachPartition)
                    {
                        foreach (Microsoft.AnalysisServices.Partition p in mg.Partitions)
                        {
                            //parameters don't appear to work with some DMV queries, so use string substitution
                            string sNewCommand = command;
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_NAME", p.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_ID", p.ID);
                            Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                            cmd.CommandTimeout = 0;
                            Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                            TimeoutUtility.FillAdomdDataAdapter(adp, result);
                        }
                    }
                    else
                    {
                        //parameters don't appear to work with some DMV queries, so use string substitution
                        string sNewCommand = command;
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                        Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                        cmd.CommandTimeout = 0;
                        Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                        TimeoutUtility.FillAdomdDataAdapter(adp, result);
                    }
                }

                conn.Close();
            }
            return result;
        }
 public AdomdDataAdapter(Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter obj)
 {
     _obj = obj;
 }