Ejemplo n.º 1
0
        public static List <Document> GetAllDocumentsWithFilter(string tableName, string columnName, string filterValue)
        {
            try
            {
                AmazonDynamoDBClient client = new AmazonDynamoDBClient(MyAWSConfigs.DynamodbRegion);

                Table table = Table.LoadTable(client, tableName);

                ScanFilter scanFilter = new ScanFilter();
                scanFilter.AddCondition(columnName, ScanOperator.Equal, filterValue);

                Search          search = table.Scan(scanFilter);
                List <Document> docs   = new List <Document>();
                do
                {
                    docs.AddRange(search.GetNextSet().ToList <Document>());
                } while (!search.IsDone);

                var temp = docs.ToList <Document>();

                client.Dispose();

                return(temp);
            }
            catch (AmazonDynamoDBException e)
            {
                Console.WriteLine("AmazonDynamoDBException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(null);
        }
Ejemplo n.º 2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // Dispose managed resources.

                    if (context != null)
                    {
                        context.Dispose();
                        context = null;
                    }

                    if (client != null)
                    {
                        client.Dispose();
                        client = null;
                    }
                }

                // There are no unmanaged resources to release, but
                // if we add them, they need to be released here.
            }
            disposed = true;
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (_client != null)
     {
         _client.Dispose();
     }
 }
Ejemplo n.º 4
0
        public static IEnumerable <Reader> GetReadersData()
        {
            try
            {
                AmazonDynamoDBClient client = new AmazonDynamoDBClient(MyAWSConfigs.DynamodbRegion);

                DynamoDBContext context = new DynamoDBContext(client);

                IEnumerable <Reader> readerData = context.Scan <Reader>();

                var tempReader = readerData.ToList <Reader>();

                client.Dispose();

                return(tempReader);
            }
            catch (AmazonDynamoDBException e)
            {
                Console.WriteLine("AmazonDynamoDBException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(null);
        }
 /*
  * I am not sure this is  good;
  */
 public void Disconnect()
 {
     if (client != null)
     {
         client.Dispose();
     }
 }
Ejemplo n.º 6
0
        public static IEnumerable <Camera> GetAllCamers()
        {
            try
            {
                AmazonDynamoDBClient client = new AmazonDynamoDBClient(MyAWSConfigs.DynamodbRegion);

                DynamoDBContext      context     = new DynamoDBContext(client);
                IEnumerable <Camera> camerasData = context.Scan <Camera>();

                var temp = camerasData.ToList();

                client.Dispose();

                return(temp);
            }
            catch (AmazonDynamoDBException e)
            {
                Console.WriteLine("AmazonDynamoDBException: " + e);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
            }

            return(null);
        }
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (null != DynamoDbClient)
         {
             DynamoDbClient.Dispose();
             DynamoDbClient = null;
         }
     }
 }
Ejemplo n.º 8
0
        private bool disposedValue; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _client?.Dispose();
                }

                disposedValue = true;
            }
        }
Ejemplo n.º 9
0
        public void Dispose()
        {
            try
            {
                AmazonDynamoDBClient client = GetAmazonDynamoDbClient();

                client.Dispose();
            }

            catch (AmazonDynamoDBException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// </summary>
        /// <param name="disposing">Is disposing.</param>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!_disposed)
            {
                if (disposing)
                {
                    // Dispose managed state (managed objects).
                    if (_client != null)
                    {
                        _client.Dispose();
                    }
                }

                // Free unmanaged resources (unmanaged objects) and override a finalizer below.

                _disposed = true;
                _client   = null;
            }
        }
Ejemplo n.º 11
0
        public void Dispose()
        {
            if (_subscriptionToken != null)
            {
                this.EventAggregator.GetEvent <Events.ApplicationSettingChangedEvent>().Unsubscribe(_subscriptionToken);
                _subscriptionToken.Dispose();
                _subscriptionToken = null;
            }

            if (_client != null)
            {
                _client.Dispose();
                _client = null;
            }

            if (_table != null)
            {
                _table = null;
            }
        }
Ejemplo n.º 12
0
        private static void InsertDocInDynamoDB()
        {
            DataTable dt = GetExcelData();

            client = GetAWSClient();
            try
            {
                string tableName = "Zeus";

                Table tbl = Table.LoadTable(client, tableName);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var rowDoc = new Document();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        //if (dt.Columns[j].ToString() == "Id")
                        //    rowDoc[dt.Columns[j].ToString()] = Convert.ToInt32(dt.Rows[i][j]);
                        //else
                        rowDoc[dt.Columns[j].ToString()] = dt.Rows[i][j].ToString();
                    }
                    tbl.PutItem(rowDoc);
                    rowDoc = null;
                }

                LogEvent(dt.Rows.Count + " rows inserted in AWSDynamoDB");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                dt = null;
                client.Dispose();
            }
        }
Ejemplo n.º 13
0
 public void Dispose()
 {
     _client?.Dispose();
 }
 protected override void Close()
 {
     base.Close();
     _dynamoDbContext?.Dispose();
     _amazonDynamoDbClient?.Dispose();
 }
Ejemplo n.º 15
0
        public void Dispose()
        {
            dbClient?.Dispose();

            GC.SuppressFinalize(this);
        }
Ejemplo n.º 16
0
 public void Dispose()
 {
     _context?.Dispose();
     _client?.Dispose();
 }
Ejemplo n.º 17
0
 internal void Close()
 {
     mDynamoDB.Dispose();
 }
 /// <inheritdoc />
 public void Dispose()
 {
     _Client?.Dispose();
     _Context?.Dispose();
 }
 public void Dispose()
 {
     dbClient?.Dispose();
 }
Ejemplo n.º 20
0
        public async ValueTask DisposeAsync()
        {
            await _dynamoDbClient.DeleteTableAsync(BillingAlertStoreTableName);

            _dynamoDbClient?.Dispose();
        }