Example #1
0
        internal static void PushSingleRecordResult(object result, System.Data.SqlDbType sqlDBType)
        {
            //SqlContext.Pipe.Send("Response output:\n");
            //SqlContext.Pipe.Send(result.ToString());

            SqlDataRecord record = null;

            switch (sqlDBType)
            {
                case System.Data.SqlDbType.NVarChar:
                case System.Data.SqlDbType.VarChar:
                    record = new SqlDataRecord(new SqlMetaData[] { new SqlMetaData("Result", sqlDBType, -1) });
                    record.SetString(0, result.ToString());
                    break;
                case System.Data.SqlDbType.Xml:
                    record = new SqlDataRecord(new SqlMetaData[] { new SqlMetaData("Result", sqlDBType) });

                    SqlXml xml;
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader(result.ToString())))
                    {
                        xml = new SqlXml(reader);
                    }

                    record.SetSqlXml(0, xml);
                    break;
                case System.Data.SqlDbType.Int:
                    record = new SqlDataRecord(new SqlMetaData[] { new SqlMetaData("Result", sqlDBType) });
                    record.SetInt32(0, (Int32)result);
                    break;
                default:
                    throw new ArgumentException("SqlDbType " + sqlDBType.ToString() + " is not supported by PushSingleRecordResult.");
            }

            SqlContext.Pipe.SendResultsStart(record);
            SqlContext.Pipe.SendResultsRow(record);
            SqlContext.Pipe.SendResultsEnd();
        }
 private SqlDataRecord ToSqlDataRecord(Guid aggregateId, int expectedVersion, int snapshotVersion, object @event, ref int currentVersion)
 {
     using (var serializedData = this.serializationMethod.Serialize(@event))
     {
         var record = new SqlDataRecord(
             new SqlMetaData("EventStreamId", SqlDbType.UniqueIdentifier),
             new SqlMetaData("ExpectedVersion", SqlDbType.Int),
             new SqlMetaData("SnapshotVersion", SqlDbType.Int),
             new SqlMetaData("Version", SqlDbType.Int),
             new SqlMetaData("EventTypeId", SqlDbType.UniqueIdentifier),
             new SqlMetaData("Payload", SqlDbType.Xml));
         var column = 0;
         record.SetGuid(column++, aggregateId);
         record.SetInt32(column++, expectedVersion);
         record.SetInt32(column++, snapshotVersion);
         record.SetInt32(column++, ++currentVersion);
         record.SetGuid(column++, serializedData.TypeId);
         record.SetSqlXml(column++, new SqlXml(((XmlSerializedData)serializedData).Reader)); // TODO: May be a memory leak here.
         return record;
     }
 }
Example #3
0
        public static void ListQueuesProc(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString prefix,
            SqlBoolean IncludeMetadata,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            ITPCfSQL.Azure.AzureQueueService aqs = new AzureQueueService(accountName.Value, sharedKey.Value, useHTTPS.Value);

            //SqlContext.Pipe.Send("Created " + aqs);

            List<ITPCfSQL.Azure.Queue> lQueues = aqs.ListQueues(
                prefix != null ? prefix.Value : null,
                IncludeMetadata.Value,
                timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            for (int i = 0; i < lQueues.Count; i++)
            {
                SqlDataRecord record = new SqlDataRecord(new SqlMetaData[] {
                new SqlMetaData("Name", System.Data.SqlDbType.NVarChar, 4000),
                new SqlMetaData("Url", System.Data.SqlDbType.NVarChar, 4000),
                new SqlMetaData("Metadata", System.Data.SqlDbType.Xml)
                });

                record.SetString(0, lQueues[i].Name);
                record.SetString(1, lQueues[i].Url.ToString());

                if (IncludeMetadata)
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();

                    using (System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(ms))
                    {
                        wr.WriteStartElement("MetadataList");

                        foreach (string s in lQueues[i].Metadata.Keys)
                        {
                            wr.WriteStartElement(s);
                            wr.WriteString(lQueues[i].Metadata[s]);
                            wr.WriteEndElement();
                        }

                        wr.WriteEndElement();

                        wr.Flush();
                        wr.Close();
                    }

                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    record.SetSqlXml(2, new SqlXml(ms));
                }
                if (i == 0)
                    SqlContext.Pipe.SendResultsStart(record);

                SqlContext.Pipe.SendResultsRow(record);

                if ((i + 1) >= lQueues.Count)
                    SqlContext.Pipe.SendResultsEnd();
            }
        }