Esempio n. 1
0
 public EntityClassGraph(InformationServiceConnection connection)
 {
     string query = "SELECT FullName, BaseType FROM Metadata.Entity";
     using (var command = new InformationServiceCommand(query, connection))
     using (InformationServiceDataReader dataReader = command.ExecuteReader())
     {
         //Enumerate the rows.
         LoadRows(dataReader);
     }
 }
Esempio n. 2
0
        private void ProcessDataReader()
        {
            CheckConnection();
            using (var connection = new InformationServiceConnection((IInformationService)SwisConnection))
            {
                connection.Open();
                using (var command = new InformationServiceCommand(Query, connection))
                {
                    command.CommandTimeout = timeOut;
                    command.ApplicationTag = "SwisPowerShell";

                    if (Parameters != null)
                    {
                        foreach (var paramName in Parameters.Keys)
                        {
                            command.Parameters.AddWithValue(paramName.ToString(),
                                                            PropertyBagFromDictionary(Parameters[paramName]));
                        }
                    }

                    using (var reader = command.ExecuteReader())
                    {
                        var factory = new DataReaderObjectFactory(reader);
                        var enumerator = factory.GetEnumerator();
                        while (enumerator.MoveNext())
                            WriteObject(enumerator.Current);
                        
                        if (reader.Errors != null)
                        {
                            StringBuilder sbWarningMessages = new StringBuilder();
                            sbWarningMessages.AppendLine("Warning :: Partial results returned");
                            foreach (var errorMessage in reader.Errors)
                            {
                                sbWarningMessages.AppendLine(string.Format("ErrorType : {0}", errorMessage.ErrorType));
                                sbWarningMessages.AppendLine(string.Format("Context : {0}", errorMessage.Context));
                                sbWarningMessages.AppendLine(string.Format("Message : {0}", errorMessage.Message));
                                sbWarningMessages.AppendLine("-------------------------------------------------");
                            }
                            WriteWarning(sbWarningMessages.ToString());
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected override void InternalProcessRecord()
        {
            if (returnClauses.Any(s => Query.Trim().EndsWith(s, StringComparison.OrdinalIgnoreCase)))
            {
                using (var connection = new InformationServiceConnection((IInformationService)SwisConnection))
                {
                    InformationServiceXmlReader reader = new InformationServiceXmlReader(connection) {ApplicationTag = "SwisPowerShell"};

                    PropertyBag bag = new PropertyBag();
                    if (Parameters != null)
                    {
                        bag = PropertyBagFromHashtable(Parameters);
                    }
                    XmlDictionaryReader xmlReader = reader.GetXmlData(Query, bag);
                    WriteObject(xmlReader.ReadOuterXml());
                }
            }
            else
                ProcessDataReader();
        }
Esempio n. 4
0
 public InformationServiceXmlReader(InformationServiceConnection connection)
 {
     this.connection = connection;
 }
 public InformationServiceCommand(string statement, InformationServiceConnection connection)
     : this(statement)
 {
     this.connection = connection;
 }
        internal InformationServiceCommand(InformationServiceConnection connection)
            : this(string.Empty, connection)
        {

        }
 public InformationServiceCommand(string statement, InformationServiceConnection connection)
     : this(statement)
 {
     this.connection = connection;
 }
 internal InformationServiceCommand(InformationServiceConnection connection)
     : this(string.Empty, connection)
 {
 }
 public InformationServiceXmlReader(InformationServiceConnection connection)
 {
     this.connection = connection;
 }