Пример #1
0
        public override DataReader EnumerateObjects(string typeName, object[] items,
                                                    object[] restrictions, string sort, object[] parameters)
        {
            DataConnectionWrapper connectionWrapper = new DataConnectionWrapper(Connection);
            string spName = String.Format("{0}.{1}", restrictions[1], restrictions[2]);

            DbConnection c = connectionWrapper.GetOpenConnection();

            try
            {
                string[] parmRest = new string[5];
                parmRest[1] = (string)restrictions[1];
                parmRest[2] = (string)restrictions[2];
                parmRest[3] = (string)restrictions[3];
                DataTable parmTable = c.GetSchema("Procedure Parameters", parmRest);

                DbCommand cmd = c.CreateCommand();
                cmd.CommandText = spName;
                cmd.CommandType = CommandType.StoredProcedure;

                foreach (DataRow row in parmTable.Rows)
                {
                    if (row["IS_RESULT"].Equals("YES"))
                    {
                        continue;
                    }

                    DbParameter p = cmd.CreateParameter();
                    p.ParameterName = row["PARAMETER_NAME"].ToString();
                    p.Value         = GetDefaultValue(row["DATA_TYPE"].ToString());
                    cmd.Parameters.Add(p);
                }

                using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly))
                {
                    DataTable dt = reader.GetSchemaTable();

                    dt.Columns.Add(new DataColumn("RoutineName", typeof(string)));
                    foreach (DataRow row in dt.Rows)
                    {
                        row["RoutineName"] = restrictions[2];
                    }

                    return(new AdoDotNetDataTableReader(dt));
                }
            }
            finally
            {
                connectionWrapper.ReleaseConnection();
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor stores DataViewHierarchyAccessor reference in the private variable.
        /// </summary>
        /// <param name="hierarchy">DataViewHierarchyAccessor reference.</param>
        public ServerExplorerFacade(DataViewHierarchyAccessor hierarchy)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException("hierarchy");
            }
            if (hierarchy.Connection == null)
            {
                throw new ArgumentException(Resources.Error_InvalidAccessorNoConnection, "hierarchy");
            }

            // Store hierarchy accessor reference
            hierarchyAccessor = hierarchy;
            //Extract connection wrapper
            connectionWrapper = new DataConnectionWrapper(hierarchy.Connection);

            // Get UI shell object
            uiShell = Package.GetGlobalService(typeof(IVsUIShell)) as IVsUIShell;
            Debug.Assert(uiShell != null, "Unable to get UI shell");
            if (uiShell == null)
            {
                throw new Exception(Resources.Error_UnableToGetUIShell);
            }

            // Retrieve IVsUIShellOpenDocument interface
            shell = Package.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
            Debug.Assert(shell != null, "Unable to get IVsUIShellOpenDocument reference!");
            if (shell == null)
            {
                throw new Exception(Resources.Error_UnableToGetOpenDocumentShell);
            }

            // Get RDT interface
            rdt = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            Debug.Assert(rdt != null, "Unable to get Running Document Table interface reference!");
            if (rdt == null)
            {
                throw new Exception(Resources.Error_UnableToGetRdt);
            }

            // Get RDT2 interface
            rdt2 = rdt as IVsRunningDocumentTable2;
            Debug.Assert(rdt2 != null, "Unable to get Running Document Table extended interface reference!");
            if (rdt2 == null)
            {
                throw new Exception(Resources.Error_UnableToGetRdt);
            }
        }
        public override DataReader EnumerateObjects(string typeName, object[] items, 
            object[] restrictions, string sort, object[] parameters)
        {
            DataConnectionWrapper connectionWrapper = new DataConnectionWrapper(Connection);
            string spName = String.Format("{0}.{1}", restrictions[1], restrictions[2]);

            DbConnection c = connectionWrapper.GetOpenConnection();
            try
            {
                string[] parmRest = new string[5];
                parmRest[1] = (string)restrictions[1];
                parmRest[2] = (string)restrictions[2];
                parmRest[3] = (string)restrictions[3];
                DataTable parmTable = c.GetSchema("Procedure Parameters", parmRest);

                DbCommand cmd = c.CreateCommand();
                cmd.CommandText = spName;
                cmd.CommandType = CommandType.StoredProcedure;

                foreach (DataRow row in parmTable.Rows)
                {
                    if (row["IS_RESULT"].Equals("YES")) continue;

                    DbParameter p = cmd.CreateParameter();
                    p.ParameterName = row["PARAMETER_NAME"].ToString();
                    p.Value = GetDefaultValue(row["DATA_TYPE"].ToString());
                    cmd.Parameters.Add(p);
                }

                using (IDataReader reader = cmd.ExecuteReader(CommandBehavior.SchemaOnly))
                {
                    DataTable dt = reader.GetSchemaTable();

                    dt.Columns.Add(new DataColumn("RoutineName", typeof(string)));
                    foreach (DataRow row in dt.Rows)
                        row["RoutineName"] = restrictions[2];

                    return new AdoDotNetDataTableReader(dt);
                }
            }
            finally
            {
                connectionWrapper.ReleaseConnection();
            }
        }
Пример #4
0
        /// <summary>
        /// Constructor stores DataViewHierarchyAccessor reference in the private variable.
        /// </summary>
        /// <param name="hierarchy">DataViewHierarchyAccessor reference.</param>
        public ServerExplorerFacade(DataViewHierarchyAccessor hierarchy)
        {
            if (hierarchy == null)
                throw new ArgumentNullException("hierarchy");
            if (hierarchy.Connection == null)
                throw new ArgumentException(Resources.Error_InvalidAccessorNoConnection, "hierarchy");
            
            // Store hierarchy accessor reference
            hierarchyAccessor = hierarchy;
            //Extract connection wrapper
            connectionWrapper = new DataConnectionWrapper(hierarchy.Connection);

            // Get UI shell object
            uiShell = Package.GetGlobalService(typeof(IVsUIShell)) as IVsUIShell;
            Debug.Assert(uiShell != null, "Unable to get UI shell");
            if (uiShell == null)
                throw new Exception(Resources.Error_UnableToGetUIShell);

            // Retrieve IVsUIShellOpenDocument interface
            shell = Package.GetGlobalService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
            Debug.Assert(shell != null, "Unable to get IVsUIShellOpenDocument reference!");
            if (shell == null)
                throw new Exception(Resources.Error_UnableToGetOpenDocumentShell);

            // Get RDT interface
            rdt = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            Debug.Assert(rdt != null, "Unable to get Running Document Table interface reference!");
            if (rdt == null)
                throw new Exception(Resources.Error_UnableToGetRdt);

            // Get RDT2 interface
            rdt2 = rdt as IVsRunningDocumentTable2;
            Debug.Assert(rdt2 != null, "Unable to get Running Document Table extended interface reference!");
            if (rdt2 == null)
                throw new Exception(Resources.Error_UnableToGetRdt);
        }