예제 #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;
        }
        public object FromEntry(DynamoDBEntry entry)
        {
            string valueAsString = entry.AsString();
            TEnum  valueAsEnum   = (TEnum)Enum.Parse(typeof(TEnum), valueAsString);

            return(valueAsEnum);
        }
예제 #3
0
        public object FromEntry(DynamoDBEntry entry)
        {
            var str  = entry.AsString();
            var list = string.IsNullOrWhiteSpace(str) ? new List <int>() : str.Split(',').Select(int.Parse).ToList();

            return(list);
        }
예제 #4
0
        public object FromEntry(DynamoDBEntry entry)
        {
            if (entry == null)
            {
                return(null);
            }
            var valueString = entry.AsString();

            return((TEnum)Enum.Parse(typeof(TEnum), valueString));
        }
예제 #5
0
        public object FromEntry(DynamoDBEntry entry)
        {
            if (entry is DynamoDBNull)
            {
                return(new ZonedDateTime?());
            }
            var s   = entry.AsString();
            var res = pattern.Parse(s);

            return(res.GetValueOrThrow());
        }
 public static string AsStringOrDefault(this DynamoDBEntry o)
 {
     if (o == null)
     {
         return(null);
     }
     else
     {
         return(o.AsString());
     }
 }
        public object FromEntry(DynamoDBEntry entry)
        {
            var value = entry.AsString();

            if (DateTime.TryParse(value, out var date))
            {
                return(date);
            }

            return(default(DateTime));
        }
예제 #8
0
        private static string GetValue(DynamoDBEntry attributeValue)
        {
            if (attributeValue is null)
            {
                return(null);
            }

            var value = attributeValue.AsString();

            return(value);
        }
예제 #9
0
        public object FromEntry(DynamoDBEntry entry)
        {
            var dateTime    = entry?.AsString();
            var returnValue = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc).Date;

            if (DateTime.TryParseExact(dateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime value))
            {
                returnValue = DateTime.SpecifyKind(value.Date, DateTimeKind.Utc).Date;
            }

            return(returnValue);
        }
예제 #10
0
        public void TestEnumConverterTo()
        {
            // ARRANGE
            DashboardEventStatus status = DashboardEventStatus.BLUE;
            EnumConverter <DashboardEventStatus> converter = new DDBConverters.EnumConverter <DashboardEventStatus>();

            // ACT
            DynamoDBEntry entry = converter.ToEntry(status);

            // ASSERT
            Assert.Equal("BLUE", entry.AsString());
        }
예제 #11
0
 public object FromEntry(DynamoDBEntry entry)
 {
     if (entry is null)
     {
         return(null);
     }
     if (entry is DynamoDBBool)
     {
         return(entry.AsBoolean());
     }
     return(bool.Parse(entry.AsString()));
 }
예제 #12
0
        public void TestDateTimeConverterTo()
        {
            // ARRANGE
            long               time      = 1525914401;
            DateTime           dt        = ServiceUtilities.ConvertFromUnixTimestamp(time);
            TimestampConverter converter = new TimestampConverter();

            // ACT
            DynamoDBEntry data = converter.ToEntry(time);

            // ASSERT
            Assert.Equal(dt, DateTime.Parse(data.AsString()).ToUniversalTime());
        }
        /// <summary>
        /// Converts the <c>entry</c> to <see cref="DateTime"/>.
        /// </summary>
        /// <param name="entry">The entry to convert.</param>
        /// <returns>The date time of the entry.</returns>
        public object FromEntry(DynamoDBEntry entry)
        {
            var entryString = entry.AsString();

            if (string.IsNullOrEmpty(entryString))
            {
                return(null);
            }
            else
            {
                return(DateTime.ParseExact(entryString, "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind));
            }
        }
        public object FromEntry(DynamoDBEntry entry)
        {
            var primitive = entry as Primitive;

            if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value))
            {
                throw new ArgumentOutOfRangeException();
            }

            var value = JsonSerializer.Deserialize <MoneyDTO>(entry.AsString(), JsonSerialisationOptions.Options);

            var name = new Money((int)value.Amount, value.Currency);

            return(name);
        }
예제 #15
0
        public void TestDictionaryConverterTo()
        {
            // ARRANGE
            Dictionary <string, long> dict = new Dictionary <string, long>()
            {
                { "1", 2 }, { "3", 4 }
            };
            DictionaryConverter <string, long> converter = new DictionaryConverter <string, long>();

            // ACT
            DynamoDBEntry entry = converter.ToEntry(dict);

            // ASSERT
            Assert.Equal("{\"1\":2,\"3\":4}", entry.AsString());
        }
예제 #16
0
        public object FromEntry(DynamoDBEntry entry)
        {
            var primitive = entry as Primitive;

            if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value))
            {
                throw new ArgumentOutOfRangeException();
            }

            var value = JObject.Parse(entry.AsString());

            var name = new Money((int)value[Amount], (string)value[Currency]);

            return(name);
        }
예제 #17
0
        public object FromEntry(DynamoDBEntry entry)
        {
            string valueAsString = entry.AsString();

            if (String.IsNullOrEmpty(valueAsString))
            {
                return(default(TEnum));
            }

            if (Enum.TryParse <TEnum>(valueAsString, true, out TEnum valueAsEnum) && Enum.IsDefined(typeof(TEnum), valueAsEnum))
            {
                return(valueAsEnum);
            }

            return(default(TEnum));
        }
        public object FromEntry(DynamoDBEntry entry)
        {
            var dateTime = entry?.AsString();

            if (string.IsNullOrEmpty(dateTime))
            {
                return(null);
            }

            if (!DateTime.TryParse(dateTime, out DateTime value))
            {
                throw new ArgumentException("The entry parameter is not a valid DateTime value.", nameof(entry));
            }

            return(value);
        }
예제 #19
0
        public object FromEntry(DynamoDBEntry entry)
        {
            var dateTime = entry?.AsString();

            if (string.IsNullOrEmpty(dateTime))
            {
                return(null);
            }

            try
            {
                return(TimeZoneInfo.ConvertTime(DateTimeOffset.Parse(dateTime), TZConvert.GetTimeZoneInfo("Tokyo Standard Time")).DateTime);
            }
            catch
            {
                return(null);
            }
        }
예제 #20
0
        private static void DynamoDbEntryAsString(StringBuilder sb, DynamoDBEntry entry)
        {
            var list = entry as PrimitiveList;

            if (list == null)
            {
                sb.Append(entry == null ? "NULL" : entry.AsString());
                return;
            }

            string s = list.AsListOfPrimitive().Aggregate
                       (
                string.Empty,
                (c, p) => c == string.Empty ? p.AsString() : c + "," + p.AsString()
                       );

            sb.Append("(");
            sb.Append(s);
            sb.Append(")");
        }
예제 #21
0
        public object FromEntry(DynamoDBEntry entry)
        {
            Primitive primitive = entry as Primitive;

            if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value))
            {
                throw new ArgumentOutOfRangeException();
            }

            string entryString = entry.AsString();

            foreach (KudosStatus status in Enum.GetValues <KudosStatus>())
            {
                if (status.ToString() == entryString)
                {
                    return(status);
                }
            }

            return(KudosStatus.Unknown);
        }
예제 #22
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);
 }
예제 #23
0
 /// <inheritdoc/>
 public object FromEntry(DynamoDBEntry entry)
 => Enum.Parse <TEnum>(entry.AsString());
        public object FromEntry(DynamoDBEntry entry)
        {
            string dateTimeString = entry.AsString();

            return(DateTime.Parse(dateTimeString));
        }
예제 #25
0
 public object FromEntry(DynamoDBEntry entry)
 {
     return(new Guid(entry.AsString()));
 }
예제 #26
0
 public object FromEntry(DynamoDBEntry entry)
 {
     return(Enum.Parse(typeof(Stars), entry.AsString()));
 }
예제 #27
0
 public object FromEntry(DynamoDBEntry entry)
 {
     return(DateTimeOffset.ParseExact(entry.AsString(), "o", null));
 }
예제 #28
0
            public object?FromEntry(DynamoDBEntry entry)
            {
                string json = entry.AsString();

                return(Serializer.Deserialize(json, this.type));
            }
        public object FromEntry(DynamoDBEntry entry)
        {
            var dateTime = entry.AsString();

            return(DateTime.ParseExact(dateTime, "O", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal));
        }
예제 #30
0
 /// <summary>
 /// Converts the <c>entry</c> to <see cref="DateTime"/>.
 /// </summary>
 /// <param name="entry">The entry to convert.</param>
 /// <returns>The date time of the entry.</returns>
 public object FromEntry(DynamoDBEntry entry)
 {
     return(DateTime.ParseExact(entry.AsString(), "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind));
 }