Пример #1
0
 public AdomdDataReader ExecuteReader()
 {
     if (_obj != null)
     {
         _obj.Parameters.Clear();
         foreach (AdomdParameter param in _parameters)
         {
             _obj.Parameters.Add(new AsAdomdClient.AdomdParameter(param.Name, param.Value));
         }
         return(new AdomdDataReader(_obj.ExecuteReader()));
     }
     else
     {
         ExcelAdoMdConnections.ReturnDelegate <AdomdDataReader> f = delegate
         {
             _objExcel.Parameters.Clear();
             foreach (AdomdParameter param in _parameters)
             {
                 _objExcel.Parameters.Add(new ExcelAdomdClient.AdomdParameter(param.Name, param.Value));
             }
             return(new AdomdDataReader(_objExcel.ExecuteReader()));
         };
         return(f());
     }
 }
Пример #2
0
        public ADOMD.AdomdDataReader ExecuteReader(string qry, ADOMD.AdomdConnection cnn)
        {
            var cmd = new ADOMD.AdomdCommand(qry, cnn);

            ADOMD.AdomdDataReader reader = cmd.ExecuteReader();
            return(reader);
        }
        internal MiningValueCollectionInternal(MiningModelColumn column)
        {
            this.internalObjectCollection = new ArrayList();
            if (column.IsTable)
            {
                return;
            }
            AdomdCommand adomdCommand = new AdomdCommand();

            adomdCommand.CommandText = string.Format(CultureInfo.InvariantCulture, "SELECT DISTINCT {0} FROM [{1}]", new object[]
            {
                column.FullyQualifiedName,
                column.ParentMiningModel.Name
            });
            adomdCommand.Connection = column.ParentMiningModel.ParentConnection;
            AdomdDataReader adomdDataReader = adomdCommand.ExecuteReader();
            int             num             = -1;

            while (adomdDataReader.Read())
            {
                num++;
                object          objValue  = adomdDataReader[0];
                string          content   = column.Content;
                MiningValueType valueType = MiningValueType.Missing;
                if (num == 0 && content.IndexOf("key", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    valueType = MiningValueType.Missing;
                }
                else if (string.Compare(content, "discrete", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(content, "key", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    valueType = MiningValueType.Discrete;
                }
                else if (content.IndexOf("discretized", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    valueType = MiningValueType.Discretized;
                }
                else if (string.Compare(content, "continuous", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    valueType = MiningValueType.Continuous;
                }
                MiningValue newValue = new MiningValue(valueType, num, objValue);
                this.Add(newValue);
            }
            adomdDataReader.Close();
            adomdDataReader.Dispose();
            adomdCommand.Dispose();
        }
        private void LoadExistingMemoryDimensionSignatures()
        {
            Microsoft.AnalysisServices.AdomdServer.Context.TraceEvent(0, 1, "Starting LoadExistingMemoryDimensionSignatures");

            //retrieve all the existing dimension members
            AdomdClient.AdomdCommand cmd = new AdomdClient.AdomdCommand("with member [Measures].[Must Have A Measure] as null select [Measures].[Must Have A Measure] on 0, Leaves([Memory]) properties MEMBER_CAPTION, [Memory].[Memory Name].[Key0] on 1 from [$Memory]");
            try
            {
                cmd.Connection = new AdomdClient.AdomdConnection("Data Source=" + AdomdServer.Context.CurrentServerID + ";Initial Catalog=" + DATABASE_NAME);
                cmd.Connection.Open();
                cmd.Properties.Add("ReturnCellProperties", true);
                AdomdClient.AdomdDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["[Memory].[Memory Name].[Memory Name].[Key]"])) //SSAS Unknown member will have null key
                    {
                        DateTime dt;
                        string signature = ObjToString(dr["[Memory].[Memory Name].[Memory Name].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[User].[User].[MEMBER_CAPTION]"]) + "\r\n"
                         + (string.IsNullOrEmpty(ObjToString(dr["[Memory].[Creation Time].[Creation Time].[MEMBER_CAPTION]"])) || !DateTime.TryParse(Convert.ToString(dr["[Memory].[Creation Time].[Creation Time].[MEMBER_CAPTION]"]), out dt) ? "" : Convert.ToDateTime(dr["[Memory].[Creation Time].[Creation Time].[MEMBER_CAPTION]"]).ToString("s")) + "\r\n"
                         + ObjToString(dr["[Memory].[Shrinkable].[Shrinkable].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Folder 1].[Folder 1].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Level 1].[Level 1].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Folder 2].[Folder 2].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Level 2].[Level 2].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Folder 3].[Folder 3].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Level 3].[Level 3].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Folder 4].[Folder 4].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[Level 4].[Level 4].[MEMBER_CAPTION]"]) + "\r\n"
                         + ObjToString(dr["[Memory].[File Extension].[File Extension].[MEMBER_CAPTION]"]);
                        long key = Convert.ToInt64(dr["[Memory].[Memory Name].[Memory Name].[Key]"]);
                        if (!dictExistingMemoryRowID.ContainsKey(signature))
                        {
                            dictExistingMemoryRowID.Add(signature, key);
                        }
                    }
                }
                dr.Close();
            }
            catch
            {
                Microsoft.AnalysisServices.AdomdServer.Context.TraceEvent(0, 2, "Caught error in LoadExistingMemoryDimensionSignatures");
            }
            finally
            {
                try
                {
                    cmd.Connection.Close();
                }
                catch { }
            }
            Microsoft.AnalysisServices.AdomdServer.Context.TraceEvent(0, 3, "Finishing LoadExistingMemoryDimensionSignatures");
        }
Пример #5
0
        /*
         * Return results from query
         */
        public AdomdDataReader GetQueryResult(string sQuery)
        {
            try
            {
                string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);
                objConn.Open();
                Microsoft.AnalysisServices.AdomdClient.AdomdCommand objCmd = objConn.CreateCommand();
                objCmd.CommandText = sQuery;

                //Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objReader = objCmd.ExecuteReader();
                //Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter objDataAdaptor = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(objCmd);

                Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection);

                /*
                 * try
                 * {
                 *  for (int i = 0; i < objDataReader.FieldCount; i++)
                 *  {
                 *      Console.Write(objDataReader.GetName(i) + "\t");
                 *  }
                 *  Console.WriteLine();
                 *  while (objDataReader.Read())
                 *  {
                 *      for (int i = 0; i < objDataReader.FieldCount; i++)
                 *      {
                 *          object value = objDataReader.GetValue(i);
                 *          string strValue = (value == null) ?
                 *          string.Empty : value.ToString();
                 *          Console.Write(strValue + "\t");
                 *      }
                 *      Console.WriteLine();
                 *  }
                 * }
                 * finally
                 * {
                 *  objDataReader.Close();
                 * }
                 */

                return(objDataReader);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return(null);
        }