Exemple #1
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="acDomain"></param>
            /// <param name="commandType"></param>
            /// <param name="record"></param>
            /// <returns></returns>
            internal static CommandRecord Create(IAcDomain acDomain, MessageTypeKind commandType, System.Data.IDataRecord record)
            {
                MessageType requestType;

                record.GetString(record.GetOrdinal("MessageType")).TryParse(out requestType);
                ClientType clientType;

                record.GetString(record.GetOrdinal("ClientType")).TryParse(out clientType);
                return(new CommandRecord(commandType,
                                         record.GetGuid(record.GetOrdinal("Id")),
                                         DataItemsTuple.Create(
                                             acDomain,
                                             record.GetNullableString("InfoId"),
                                             record.GetNullableString("InfoValue"),
                                             record.GetNullableString("QueryList"),
                                             record.GetString(record.GetOrdinal("InfoFormat"))))
                {
                    Verb = new Verb(record.GetString(record.GetOrdinal("Verb"))),
                    Ontology = record.GetString(record.GetOrdinal("Ontology")),
                    LocalEntityId = record.GetNullableString("LocalEntityId"),
                    CatalogCode = record.GetNullableString("CatalogCode"),
                    ClientId = record.GetString(record.GetOrdinal("ClientId")),
                    TimeStamp = record.GetDateTime(record.GetOrdinal("TimeStamp")),
                    ReceivedOn = record.GetDateTime(record.GetOrdinal("ReceivedOn")),
                    CreateOn = record.GetDateTime(record.GetOrdinal("CreateOn")),
                    ClientType = clientType,
                    MessageType = requestType,
                    MessageId = record.GetString(record.GetOrdinal("MessageId")),
                    Status = record.GetInt32(record.GetOrdinal("Status")),
                    ReasonPhrase = record.GetNullableString(record.GetOrdinal("ReasonPhrase")),
                    Description = record.GetNullableString(record.GetOrdinal("Description")),
                    EventSubjectCode = record.GetNullableString(record.GetOrdinal("EventSubjectCode")),
                    EventSourceType = record.GetNullableString(record.GetOrdinal("EventSourceType")),
                    UserName = record.GetNullableString("UserName"),
                    IsDumb = record.GetBoolean(record.GetOrdinal("IsDumb")),
                    Version = record.GetString(record.GetOrdinal("Version"))
                });
            }
 private static void WriteSingleRow(System.Data.IDataRecord rdr, string[] fieldNamesToUse, Type[] types, Utf8JsonWriter jsonWriter)
 {
     jsonWriter.WriteStartObject();
     for (int p = 0; p < fieldNamesToUse.Length; p++)
     {
         if (rdr.IsDBNull(p))
         {
             jsonWriter.WriteNull(fieldNamesToUse[p]);
         }
         else if (types[p] == typeof(string))
         {
             jsonWriter.WriteString(fieldNamesToUse[p], rdr.GetString(p));
         }
         else if (types[p] == typeof(DateTime))
         {
             jsonWriter.WriteString(fieldNamesToUse[p], rdr.GetDateTime(p));
         }
         else if (types[p] == typeof(DateTimeOffset))
         {
             jsonWriter.WriteString(fieldNamesToUse[p], (DateTimeOffset)rdr.GetValue(p));
         }
         else if (types[p] == typeof(bool))
         {
             jsonWriter.WriteBoolean(fieldNamesToUse[p], rdr.GetBoolean(p));
         }
         else if (types[p] == typeof(Guid))
         {
             jsonWriter.WriteString(fieldNamesToUse[p], rdr.GetGuid(p));
         }
         else if (types[p] == typeof(short))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetInt16(p));
         }
         else if (types[p] == typeof(int))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetInt32(p));
         }
         else if (types[p] == typeof(long))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetInt64(p));
         }
         else if (types[p] == typeof(float))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetFloat(p));
         }
         else if (types[p] == typeof(double))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetDouble(p));
         }
         else if (types[p] == typeof(decimal))
         {
             jsonWriter.WriteNumber(fieldNamesToUse[p], rdr.GetDecimal(p));
         }
         else if (types[p] == typeof(byte[]))
         {
             jsonWriter.WriteBase64String(fieldNamesToUse[p], (byte[])rdr.GetValue(p));
         }
         else
         {
             string?vl = rdr.GetValue(p)?.ToString();
             jsonWriter.WriteString(fieldNamesToUse[p], vl);
         }
     }
     jsonWriter.WriteEndObject();
 }