public QldbService()
        {
            AmazonQLDBSessionConfig amazonQldbSessionConfig = new AmazonQLDBSessionConfig();

            this.driver = QldbDriver.Builder()
                          .WithQLDBSessionConfig(amazonQldbSessionConfig)
                          .WithLedger(LedgerName)
                          .Build();
        }
 public List <List <KeyValuePair <string, string> > > ReadData(string statement)
 {
     try
     {
         IQldbDriver driver = this.GetDriver();
         new AmazonQLDBSessionConfig().RegionEndpoint = Global.Region;
         using (IQldbSession session = driver.GetSession())
             return(this.BuildData(session.Execute(statement, (List <IIonValue>)null, (Action <int>)null)));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public List <List <KeyValuePair <string, string> > > WriteData(
            string tableName,
            string statement)
        {
            string documentID = string.Empty;

            try
            {
                IQldbDriver driver = this.GetDriver();
                new AmazonQLDBSessionConfig().RegionEndpoint = Global.Region;
                List <List <KeyValuePair <string, string> > > keyValuePairListList;
                using (IQldbSession session = driver.GetSession())
                {
                    keyValuePairListList = this.BuildData(session.Execute(statement, (List <IIonValue>)null, (Action <int>)null));
                    keyValuePairListList[0].ForEach((Action <KeyValuePair <string, string> >)(x =>
                    {
                        if (string.IsNullOrEmpty(x.Key) || !(x.Key.ToLower() == "documentid"))
                        {
                            return;
                        }
                        documentID = x.Value;
                    }));
                }
                if (!string.IsNullOrEmpty(documentID))
                {
                    string[] strArray = new string[9];
                    strArray[0] = "SELECT * from history(";
                    strArray[1] = tableName;
                    strArray[2] = ", `";
                    DateTime dateTime1 = DateTime.UtcNow;
                    dateTime1   = dateTime1.AddMinutes(-1.0);
                    strArray[3] = dateTime1.ToString("o");
                    strArray[4] = "`, `";
                    DateTime dateTime2 = DateTime.UtcNow;
                    dateTime2   = dateTime2.AddSeconds(0.7);
                    strArray[5] = dateTime2.ToString("o");
                    strArray[6] = "`) AS h WHERE h.metadata.id = '";
                    strArray[7] = documentID;
                    strArray[8] = "'";
                    string statement1 = string.Concat(strArray);
                    keyValuePairListList.AddRange((IEnumerable <List <KeyValuePair <string, string> > >) this.ReadData(statement1));
                }
                return(keyValuePairListList);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public AddSecondaryOwnerFunction()
 {
     this.qldbDriver           = new QldbService().GetDriver();
     this.tableMetadataService = new MetadataService();
     this.valueFactory         = new ValueFactory();
 }
 public QueryVehicleRegistrationHistoryFunction()
 {
     this.qldbDriver           = new QldbService().GetDriver();
     this.tableMetadataService = new MetadataService();
     this.valueFactory         = new ValueFactory();
 }
 public AddVehicleFunction()
 {
     this.qldbDriver           = new QldbService().GetDriver();
     this.tableMetadataService = new MetadataService();
     this.valueFactory         = new ValueFactory();
 }
Пример #7
0
 public IAmazonQldbProviderTableConfigurator WithQldbDriver(IQldbDriver driver)
 {
     _driverFactory = new Lazy <IQldbDriver>(() => driver);
     return(_tableConfigurator);
 }
 /// <summary>
 /// Creates a new AmazonQLDB data provider using the given driver.
 /// </summary>
 /// <param name="driver">The Amazon QLDB driver instance.</param>
 public AmazonQldbDataProvider(IQldbDriver driver)
 {
     QldbDriver = new Lazy <IQldbDriver>(() => driver);
 }