Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.SQLiteEventStore.PutEvent C# (CSharp) Метод

PutEvent() приватный Метод

private PutEvent ( string eventString, string appID ) : void
eventString string
appID string
Результат void
        public void PutEvent(string eventString, string appID)
        {
            long currentDatabaseSize = this.DatabaseSize;

            if (currentDatabaseSize >= _maConfig.MaxDBSize)
            {
                InvalidOperationException e = new InvalidOperationException();
                _logger.Error(e, "The database size has exceeded the threshold limit. Unable to insert any new events");
            }
            else if ((double)currentDatabaseSize / (double)_maConfig.MaxDBSize >= _maConfig.DBWarningThreshold)
            {
                _logger.InfoFormat("The database size is almost full");
            }
            else
            {
                string sqlCommand = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0}  ({1},{2},{3}) values(@event,@id,@appID)", TABLE_NAME, EVENT_COLUMN_NAME, EVENT_ID_COLUMN_NAME, MA_APP_ID_COLUMN_NAME);
                lock (_lock)
                {
                    using (var connection = new SQLiteConnection("Data Source=" + this.DBfileFullPath + ";Version=3;"))
                    {
                        try
                        {
                            connection.Open();
                            using (var command = new SQLiteCommand(sqlCommand, connection))
                            {
                                command.Parameters.Add(new SQLiteParameter("@event", eventString));
                                command.Parameters.Add(new SQLiteParameter("@id", Guid.NewGuid().ToString()));
                                command.Parameters.Add(new SQLiteParameter("@appID", appID));
                                command.ExecuteNonQuery();
                            }
                        }
                        finally
                        {
                            if (null != connection)
                                connection.Close();
                        }
                    }
                }
            }
        }