초기커밋
This commit is contained in:
59
ServerBase/DB/DynamoDb/DynamoDbConfig.cs
Normal file
59
ServerBase/DB/DynamoDb/DynamoDbConfig.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
|
||||
|
||||
namespace ServerBase;
|
||||
|
||||
public partial class DynamoDbClient
|
||||
{
|
||||
public class ConfigParam : IConfigParam
|
||||
{
|
||||
public string ServiceType { get; set; } = string.Empty;
|
||||
public bool IsLocalDynamoDB { get; set; } = false;
|
||||
public string UrlOfDynamoDb { get; set; } = string.Empty;
|
||||
public string AccessKeyOfAws { get; set; } = string.Empty;
|
||||
public string SecretKeyOfAws { get; set; } = string.Empty;
|
||||
public string RegionOfAws { get; set; } = string.Empty;
|
||||
|
||||
public Result tryReadFromJsonOrDefault(JObject jObject)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
ServiceType = jObject["ServiceType"]?.Value<string>() ?? ServiceType;
|
||||
UrlOfDynamoDb = jObject["Dynamodb"]?.Value<string>() ?? UrlOfDynamoDb;
|
||||
var aws = jObject["AWS"];
|
||||
NullReferenceCheckHelper.throwIfNull(aws, () => $"aws is null !!!");
|
||||
IsLocalDynamoDB = aws["LocalDynamoDB"]?.Value<bool>() ?? IsLocalDynamoDB;
|
||||
AccessKeyOfAws = aws["AccessKey"]?.Value<string>() ?? AccessKeyOfAws;
|
||||
SecretKeyOfAws = aws["SecretKey"]?.Value<string>() ?? SecretKeyOfAws;
|
||||
RegionOfAws = aws["Region"]?.Value<string>() ?? RegionOfAws;
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var error_code = ServerErrorCode.TryCatchException;
|
||||
err_msg = $"Exception !!!, Failed to perform in tryReadFromJsonOrDefault() !!! : errorCode:{error_code}, exception:{e} - {this.getTypeName()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public string toBasicString()
|
||||
{
|
||||
return $"ConfigParam: ServiceType:{ServiceType}, UrlOfDynamoDb:{UrlOfDynamoDb}, isLocalDynamoDb:{IsLocalDynamoDB}, RegionOfAWS:{RegionOfAws}";
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user