Exemplo n.º 1
0
        public async Task List()
        {
            Console.WriteLine("Entering List");
            var description = await DescribeTable();

            Console.WriteLine($"Table name: {description.TableName}" + "  " + $"Table status: {description.TableStatus}");

            Table QTable = Table.LoadTable(client, ClientTableName);
            //get the RequestQ items for the ClientGuid
            ScanFilter scanFilter = new ScanFilter();

            scanFilter.AddCondition("ClientID", ScanOperator.GreaterThan, " ");
            ScanOperationConfig config = new ScanOperationConfig()
            {
                Filter = scanFilter,
            };

            Search          search   = QTable.Scan(scanFilter);
            List <Document> allItems = await search.GetRemainingAsync();

            Console.WriteLine("================================================================================");
            foreach (Document doc in allItems)
            {
                foreach (string itemkey in doc.Keys)
                {
                    DynamoDBEntry dbEntry = doc[itemkey];

                    if (itemkey == "ClientID")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("ClientID:         " + val);
                    }
                    if (itemkey == "ClientGuid")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("ClientGuid:       " + val);
                    }
                    if (itemkey == "ActiveStatus")
                    {
                        bool val = dbEntry.AsBoolean(); Console.WriteLine("ActiveStatus:     " + val);
                    }
                    if (itemkey == "secret")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("secret:           " + val);
                    }
                    if (itemkey == "amazn_link_time")
                    {
                        string val = dbEntry.AsString(); Console.WriteLine("amazn_link_time:  " + val);
                    }
                    if (itemkey == "Appliance")
                    {
                        int i = 0; foreach (string device in dbEntry.AsListOfString())
                        {
                            Console.WriteLine("Appliance(" + i + "):     " + device); i++;
                        }
                    }
                }// end foreach key

                Console.WriteLine("================================================================================");
            }
            return;
        }
Exemplo n.º 2
0
 public static object AsType(this DynamoDBEntry entry, Type type)
 {
     if (type == stringType)
     {
         return(entry.AsString());
     }
     else if (type == intType)
     {
         return(entry.AsInt());
     }
     else if (type == boolType)
     {
         return(entry.AsBoolean());
     }
     else if (type == longType)
     {
         return(entry.AsLong());
     }
     else if (type == dateTimeType)
     {
         return(entry.AsDateTime());
     }
     else if (type == doubleType)
     {
         return(entry.AsDouble());
     }
     else if (type == floatType)
     {
         return(entry.AsSingle());
     }
     else if (type == listOfStringType)
     {
         return(entry.AsListOfString());
     }
     else if (type == listOfByteArrayType)
     {
         return(entry.AsListOfString());
     }
     return(null);
 }
Exemplo n.º 3
0
            public object FromEntry(DynamoDBEntry entry)
            {
                if ((entry == null) || (entry is DynamoDBNull))
                {
                    return(null);
                }

                var list       = entry.AsListOfString();
                var dictionary = new Dictionary <string, TimeSpan>();

                foreach (var record in list)
                {
                    var split = record.Split('@');

                    var key   = split[0];
                    var value = TimeSpan.Parse(split[1]);

                    dictionary.Add(key, value);
                }

                return(dictionary);
            }