private async IAsyncEnumerable <EthereumTransactionHash> ListAddressHashesAsync( EthereumAddress address, Symbol symbol, string indexName, string attributeName) { var key = dataKeyProvider.GetKey(symbol); var lastEvaluatedKey = new Dictionary <string, AttributeValue>(); while (!CancellationToken.IsCancellationRequested) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, IndexName = indexName, Select = Select.ALL_PROJECTED_ATTRIBUTES, KeyConditionExpression = string.Format( "#{0} = :{0}Val AND #{1} = :{1}Val", attributeName, nameof(DataOperation.ContractAddress)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{attributeName}"] = attributeName, [$"#{nameof(DataOperation.ContractAddress)}"] = nameof(DataOperation.ContractAddress) }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{attributeName}Val"] = new AttributeValue(address), [$":{nameof(DataOperation.ContractAddress)}Val"] = new AttributeValue(key) }, ExclusiveStartKey = lastEvaluatedKey.Any() ? lastEvaluatedKey : null }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else { lastEvaluatedKey = response.LastEvaluatedKey; } foreach (var attributes in response.Items) { if (attributes.ContainsKey(nameof(DataOperation.Hash))) { yield return(new EthereumTransactionHash(attributes[nameof(DataOperation.Hash)].S)); } } if (!lastEvaluatedKey.Any()) { break; } } }
private async Task <DataStakingPower> GetByBoundsAsync(EthereumAddress contractAddress, bool latest) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, ScanIndexForward = !latest, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = $"#{nameof(DataStakingPower.Address)} = :{nameof(DataStakingPower.Address)}Val", ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataStakingPower.Address)}"] = nameof(DataStakingPower.Address), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataStakingPower.Address)}Val"] = new AttributeValue(contractAddress) }, Limit = 1 }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Items.Count == 1) { return(Map(response.Items.Single())); } return(null); }
public async Task <DataOperation> GetOperationAsync(EthereumTransactionHash hash, int order) { var response = await DynamoDB.GetItemAsync( TableName, new Dictionary <string, AttributeValue>() { [nameof(DataOperation.Hash)] = new AttributeValue(hash), [nameof(DataOperation.Order)] = new AttributeValue() { N = order.ToString() } }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Item.Any()) { return(Map(response.Item)); } return(null); }
public async Task <DataTransaction> GetTransactionAsync(Symbol symbol, EthereumTransactionHash hash) { var key = dataKeyProvider.GetKey(symbol); var response = await DynamoDB.GetItemAsync( TableName, new Dictionary <string, AttributeValue>() { [nameof(DataTransaction.Address)] = new AttributeValue(key), [nameof(DataTransaction.Hash)] = new AttributeValue(hash) }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Item.Any()) { return(Map(response.Item)); } return(null); }
private async Task <long> GetBlockNumberAsync(EthereumAddress address, bool latest) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, IndexName = BlockNumberIndexName, ScanIndexForward = !latest, Select = Select.ALL_PROJECTED_ATTRIBUTES, KeyConditionExpression = $"#{nameof(DataTransaction.Address)} = :{nameof(DataTransaction.Address)}Val", ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataTransaction.Address)}"] = nameof(DataTransaction.Address), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataTransaction.Address)}Val"] = new AttributeValue(address.Address) }, Limit = 1 }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Items.Count == 1 && response.Items.Single().ContainsKey(nameof(DataTransaction.BlockNumber)) && long.TryParse(response.Items.Single()[nameof(DataTransaction.BlockNumber)].N, out long blockNumber)) { return(blockNumber); } return(default);
public async Task <DataFundPerformance> GetPerformanceAsync(Symbol symbol, DateTime timeStamp) { var key = dataKeyProvider.GetKey(symbol); var response = await DynamoDB.GetItemAsync( TableName, new Dictionary <string, AttributeValue>() { [nameof(DataFundPerformance.Address)] = new AttributeValue(key), [nameof(DataFundPerformance.Date)] = new AttributeValue(timeStamp.ToISO8601String()) }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Item.Any()) { return(Map(response.Item)); } return(null); }
public async IAsyncEnumerable <DataFundPerformance> ListPerformancesAsync(Symbol symbol, DateTime from, DateTime to) { var key = dataKeyProvider.GetKey(symbol); var lastEvaluatedKey = new Dictionary <string, AttributeValue>(); while (!CancellationToken.IsCancellationRequested) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, ScanIndexForward = false, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = string.Format( "#{0} = :{0}Val AND #{1} >= :{2}Val", nameof(DataFundPerformance.Address), nameof(DataFundPerformance.Date), nameof(from)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataFundPerformance.Address)}"] = nameof(DataFundPerformance.Address), [$"#{nameof(DataFundPerformance.Date)}"] = nameof(DataFundPerformance.Date), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataFundPerformance.Address)}Val"] = new AttributeValue(key), [$":{nameof(from)}Val"] = new AttributeValue(from.ToISO8601String()) }, ExclusiveStartKey = lastEvaluatedKey }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else { lastEvaluatedKey = response.LastEvaluatedKey; } foreach (var perf in response.Items .Select(Map) .OrderBy(p => p.Date)) { if (perf.Date > to) { break; } yield return(perf); } if (!lastEvaluatedKey.Any()) { break; } } }
protected override void onLoad() { var newBtn = Document.GetElementById <ButtonElement>("newBtn"); newBtn.OnClick = (ev) => { Navigation <New> .Go(); }; var dynamodb = new DynamoDB(); var param = new ScanParams { TableName = "stock", ProjectionExpression = "product, quantity" }; dynamodb.scan(param, (err, data) => { if (err != null) { Toast.Error(err.stack.ToString()); // an error occurred } else { foreach (var item in data.Items) { var row = new TableRowElement(); var productTD = new TableDataCellElement(); productTD.InnerHTML = item.produto.S; row.AppendChild(productTD); var quantityTD = new TableDataCellElement(); quantityTD.InnerHTML = item.quantidade.N; row.AppendChild(quantityTD); var editBtn = new ButtonElement(); editBtn.ClassName = "btn btn-default"; editBtn.InnerHTML = "Edit"; var editTD = new TableDataCellElement(); editTD.AppendChild(editBtn); editBtn.OnClick = (ev) => { Navigation <Edit> .Go(item.produto.S, int.Parse(item.quantidade.N)); }; row.AppendChild(editTD); var tbody = Document.GetElementById <TableSectionElement>("table-body"); tbody.AppendChild(row); } } }); }
protected void CopyDesignToProduction_Click(object sender, EventArgs e) { Util util = new Util(); Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID]; if (util.CheckSessionTimeout(State, Response, "../../Default.aspx")) return; util.CopyStagingDesignToProduction(State); CopyDesignMessage.Text = "Done."; ProductionDesignExists.Visible = true; //reset Dynamo DB so that a new production design is saved during high volume downloads DynamoDB ddb = new DynamoDB(); ddb.DeleteItem(State, "apps", State["Username"].ToString(), util.GetProductionAppName(State)); }
public async IAsyncEnumerable <DataOperation> ListOperationsAsync(EthereumTransactionHash hash) { var lastEvaluatedKey = new Dictionary <string, AttributeValue>(); while (!CancellationToken.IsCancellationRequested) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = string.Format("#{0} = :{0}Val", nameof(DataOperation.Hash)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataOperation.Hash)}"] = nameof(DataOperation.Hash), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataOperation.Hash)}Val"] = new AttributeValue { S = hash }, }, ExclusiveStartKey = lastEvaluatedKey.Any() ? lastEvaluatedKey : null }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else { lastEvaluatedKey = response.LastEvaluatedKey; } foreach (var attributes in response.Items) { yield return(Map(attributes)); } if (!lastEvaluatedKey.Any()) { break; } } }
private async Task <DateTime?> GetDateAsync(Symbol symbol, bool latest) { var key = dataKeyProvider.GetKey(symbol); var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, ScanIndexForward = !latest, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = $"#{nameof(DataFundPerformance.Address)} = :{nameof(DataFundPerformance.Address)}Val", ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataFundPerformance.Address)}"] = nameof(DataFundPerformance.Address), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataFundPerformance.Address)}Val"] = new AttributeValue(key) }, Limit = 1 }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Items.Count == 1 && response.Items.Single().ContainsKey(nameof(DataFundPerformance.Date)) && DateTimeOffset.TryParse( response.Items.Single()[nameof(DataFundPerformance.Date)].S, null, DateTimeStyles.AssumeUniversal, out DateTimeOffset date)) { return(date.UtcDateTime); } return(null); }
public async Task <bool> DeletePerformanceAsync(EthereumAddress contractAddress, DateTime date) { var response = await DynamoDB.DeleteItemAsync( new DeleteItemRequest() { TableName = TableName, Key = new Dictionary <string, AttributeValue>() { [nameof(DataFundPerformance.Address)] = new AttributeValue(contractAddress), [nameof(DataFundPerformance.Date)] = new AttributeValue(date.ToISO8601String()) }, ReturnValues = ReturnValue.ALL_OLD }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } return(response.Attributes.Any()); }
public async Task <DataStakingPower> GetStakingPowerAsync(EthereumAddress stakeAddress, DateTime timeStamp) { var response = await DynamoDB.GetItemAsync( TableName, new Dictionary <string, AttributeValue>() { [nameof(DataStakingPower.Address)] = new AttributeValue(stakeAddress), [nameof(DataStakingPower.Date)] = new AttributeValue(timeStamp.ToISO8601String()) }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } if (response.Item.Any()) { return(Map(response.Item)); } return(null); }
public void UpdateSessionLog(Hashtable State, string use, string page) { try { DynamoDB ddb = new DynamoDB(); Document DDBDoc = new Document(); DDBDoc["username"] = State["Username"].ToString(); DDBDoc["session_date_time"] = DateTime.UtcNow.ToString("s") + "Z"; DDBDoc["use"] = use; DDBDoc["page"] = page; int n_current_users = GetNumberOfCurrentUsers(State); DDBDoc["n_current_users"] = n_current_users.ToString(); ddb.PutItem(State, "studio_usage", DDBDoc); } catch{} //if there is an error keep going }
public async IAsyncEnumerable <DataTransaction> ListTransactionsAsync( Symbol symbol, EthereumTransactionHash?startHash, DateTime?offset, DateTime from, DateTime to) { var key = dataKeyProvider.GetKey(symbol); var lastEvaluatedKey = offset.HasValue && startHash.HasValue ? new Dictionary <string, AttributeValue>() { [nameof(DataTransaction.Address)] = new AttributeValue(key), [nameof(DataTransaction.Hash)] = new AttributeValue(startHash.Value), [nameof(DataTransaction.ConfirmedAt)] = new AttributeValue(offset.Value.ToISO8601String()) } : null; var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, ScanIndexForward = true, IndexName = DateIndexName, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = string.Format( "#{0} = :{0}Val AND #{1} >= :{2}Val", nameof(DataTransaction.Address), nameof(DataTransaction.ConfirmedAt), nameof(from)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataTransaction.Address)}"] = nameof(DataTransaction.Address), [$"#{nameof(DataTransaction.ConfirmedAt)}"] = nameof(DataTransaction.ConfirmedAt), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataTransaction.Address)}Val"] = new AttributeValue(key), [$":{nameof(from)}Val"] = new AttributeValue { S = from.ToISO8601String() } }, Limit = PageSize, ExclusiveStartKey = lastEvaluatedKey }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else if ( response.LastEvaluatedKey.Any() && DateTime.Parse(response.LastEvaluatedKey[nameof(DataTransaction.ConfirmedAt)].S) <= to) { httpContextAccessor.HttpContext.Response.Headers.Add( Headers.PaginationId, response.LastEvaluatedKey[nameof(DataTransaction.Hash)].S); httpContextAccessor.HttpContext.Response.Headers.Add( Headers.PaginationOffset, response.LastEvaluatedKey[nameof(DataTransaction.ConfirmedAt)].S); } foreach (var transaction in response.Items .Select(Map) .Where(t => t.ConfirmedAt <= to) .OrderBy(t => t.ConfirmedAt)) { yield return(transaction); } }
public async IAsyncEnumerable <DataStakingPower> ListStakingPowersAsync( EthereumAddress contractAddress, DateTime from, DateTime to) { var lastEvaluatedKey = new Dictionary <string, AttributeValue>(); while (!CancellationToken.IsCancellationRequested) { var response = await DynamoDB.QueryAsync( new QueryRequest() { TableName = TableName, ScanIndexForward = false, Select = Select.SPECIFIC_ATTRIBUTES, KeyConditionExpression = string.Format( "#{0} = :{0}Val AND #{1} >= :{2}Val", nameof(DataStakingPower.Address), nameof(DataStakingPower.Date), nameof(from)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{nameof(DataStakingPower.Address)}"] = nameof(DataStakingPower.Address), [$"#{nameof(DataStakingPower.Date)}"] = nameof(DataStakingPower.Date), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{nameof(DataStakingPower.Address)}Val"] = new AttributeValue(contractAddress), [$":{nameof(from)}Val"] = new AttributeValue(from.ToISO8601String()) }, ProjectionExpression = string.Join(",", new List <string>() { $"#{nameof(DataStakingPower.Address)}", $"#{nameof(DataStakingPower.Date)}", $"{nameof(DataStakingPower.Power)}", $"{nameof(DataStakingPower.Summary)}" }), Limit = PageSize, ExclusiveStartKey = lastEvaluatedKey }, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else { lastEvaluatedKey = response.LastEvaluatedKey; } foreach (var power in response.Items .Select(Map) .OrderBy(p => p.Date)) { if (power.Date > to) { break; } yield return(power); } if (!lastEvaluatedKey.Any()) { break; } } }
private async IAsyncEnumerable <DataTransaction> ListAddressTransactionsAsync( Symbol symbol, EthereumAddress address, bool outbound, EthereumAddress?filterAddress = null, DateTime?from = null, DateTime?to = null) { var key = dataKeyProvider.GetKey(symbol); var lastEvaluatedKey = new Dictionary <string, AttributeValue>(); var attributeName = outbound ? nameof(DataTransaction.Sender) : nameof(DataTransaction.Recipient); var filterAttributeName = outbound ? nameof(DataTransaction.Recipient) : nameof(DataTransaction.Sender); while (!CancellationToken.IsCancellationRequested) { var request = new QueryRequest() { TableName = TableName, IndexName = outbound ? OutboundIndexName : InboundIndexName, Select = Select.ALL_ATTRIBUTES, KeyConditionExpression = string.Format( "#{0} = :{0}Val AND #{1} = :{1}Val", attributeName, nameof(DataTransaction.Address)), ExpressionAttributeNames = new Dictionary <string, string>() { [$"#{attributeName}"] = attributeName, [$"#{nameof(DataTransaction.Address)}"] = nameof(DataTransaction.Address), }, ExpressionAttributeValues = new Dictionary <string, AttributeValue>() { [$":{attributeName}Val"] = new AttributeValue(address), [$":{nameof(DataTransaction.Address)}Val"] = new AttributeValue(key) }, Limit = PageSize, ExclusiveStartKey = lastEvaluatedKey.Any() ? lastEvaluatedKey : null }; var response = await DynamoDB.QueryAsync(request, CancellationToken); if (response.HttpStatusCode != HttpStatusCode.OK) { throw new HttpRequestException($"Response code did not indicate success: {response.HttpStatusCode}"); } else { lastEvaluatedKey = response.LastEvaluatedKey; } foreach (var attributes in response.Items .Where(x => !filterAddress.HasValue || filterAddress.Value.Address.Equals(x[filterAttributeName].S, StringComparison.OrdinalIgnoreCase))) { var transaction = Map(attributes); if (!from.HasValue || !to.HasValue || (from.HasValue && to.HasValue && from <= transaction.ConfirmedAt && to >= transaction.ConfirmedAt)) { yield return(transaction); } } if (!lastEvaluatedKey.Any()) { break; } } }
protected override void onLoad() { var productP = Document.GetElementById("productP"); productP.InnerHTML = product; var quantityTxt = Document.GetElementById <InputElement>("quantityTxt"); quantityTxt.Value = quantity.ToString(); quantityTxt.OnChange = (ev) => { quantity = int.Parse(quantityTxt.Value); }; var toDownBtn = Document.GetElementById <ButtonElement>("toDownBtn"); toDownBtn.OnClick = (ev) => { if (quantity > 0) { quantity--; quantityTxt.Value = quantity.ToString(); } }; var toUpBtn = Document.GetElementById <ButtonElement>("toUpBtn"); toUpBtn.OnClick = (ev) => { quantity++; quantityTxt.Value = quantity.ToString(); }; var backBtn = Document.GetElementById <ButtonElement>("backBtn"); backBtn.OnClick = (ev) => { Navigation <Main> .Go(); }; var saveBtn = Document.GetElementById <ButtonElement>("saveBtn"); saveBtn.OnClick = (ev) => { var param = new ItemParams { TableName = "stock", Item = new { product = new DynamoItem { S = product }, quantity = new DynamoItem { N = quantity.ToString() } } }; var dynamodb = new DynamoDB(); dynamodb.putItem(param, (err, data) => { if (err != null) { Toast.Error("Error on edit the product!"); } else { Toast.Success("Success on edit the product!"); } }); }; var excludeBtn = Document.GetElementById <ButtonElement>("excludeBtn"); excludeBtn.OnClick = (ev) => { var param = new DeleteParams { TableName = "stock", Key = new { product = new DynamoItem { S = product } } }; var dynamodb = new DynamoDB(); dynamodb.deleteItem(param, (err, data) => { if (err != null) { Toast.Error("Error on exclude the product!"); } else { Toast.Error("Success on exclude the product!"); Navigation <Main> .Go(); } }); }; }
public void GetProductionAccountInfo(Hashtable State, string username) { DynamoDB ddb = new DynamoDB(); Hashtable item = ddb.GetItem(State, "customers", username); if (item.Count > 0) { State["Username"] = item["username"]; State["Password"] = item["password"]; State["CustomerID"] = item["customer_id"]; State["AccountStatus"] = item["status"]; return; } else { DB db = new DB(); string sql = "SELECT password,customer_id,status FROM customers WHERE username='******'"; DataRow[] rows = db.ViziAppsExecuteSql(State, sql); db.CloseViziAppsDatabase(State); if (rows.Length == 0) { State["Username"] = null; State["Password"] = null; State["CustomerID"] = null; State["AccountStatus"] = null; return; } else { DataRow row = rows[0]; State["Username"] = username; State["Password"] = row["password"].ToString(); State["CustomerID"] = row["customer_id"].ToString(); State["AccountStatus"] = row["status"].ToString(); Document DDBDoc = new Document(); DDBDoc["username"] = username; DDBDoc["password"] = row["password"].ToString(); DDBDoc["customer_id"] = row["customer_id"].ToString(); DDBDoc["status"] = row["status"].ToString(); ddb.PutItem(State, "customers", DDBDoc); } } }
public void GetProductionAppInfo(Hashtable State, string app_name) { DynamoDB ddb = new DynamoDB(); Hashtable item = ddb.GetItem(State, "apps", State["Username"].ToString(), app_name); if (item != null) { State["AppID"] = item["app_id"]; State["IsProductionAppPaid"] = item["is_production_app_paid"]; string expiration = null; if (item["free_production_expiration_date_time"] != null) expiration = item["free_production_expiration_date_time"].ToString(); if (expiration == null || expiration.Length == 0) { State["IsFreeProductionValid"] = "false"; } else { DateTime expirationDateTime = DateTime.Parse(expiration); State["IsFreeProductionValid"] = (DateTime.Now.ToUniversalTime() <= expirationDateTime) ? "true" : "false"; } State["Use1UserCredential"] = item["use_1_user_credential"]; State["AppDesignURL"] = item["app_design_url"]; State["DateTimeModified"] = item["date_time_modified"]; State["HasUnlimitedUsers"] = item["has_unlimited_users"]; return; } else { DB db = new DB(); string sql = "SELECT application_id,free_production_expiration_date_time, production_date_time, has_unlimited_users FROM applications WHERE production_app_name='" + app_name + "' AND customer_id='" + State["CustomerID"].ToString() + "'"; DataRow[] rows = db.ViziAppsExecuteSql(State, sql); db.CloseViziAppsDatabase(State); if (rows.Length == 0) { State["IsProductionAppPaid"] = null; State["IsFreeProductionValid"] = null; State["Use1UserCredential"] = null; State["AppDesignURL"] = null; State["AppID"] = null; State["DateTimeModified"] = null; State["HasUnlimitedUsers"] = null; return; } else { DataRow row = rows[0]; State["AppID"] = row["application_id"].ToString(); Hashtable features = IsProductionAppPaid(State, row["application_id"].ToString()); State["IsProductionAppPaid"] = (features != null) ? "true" : "false"; string expiration = row["free_production_expiration_date_time"].ToString(); State["FreeProductionExpirationDateTime"] = expiration; if (expiration == null || expiration.Length == 0) { State["IsFreeProductionValid"] = "false"; } else { DateTime expirationDateTime = DateTime.Parse(expiration); State["IsFreeProductionValid"] = (DateTime.Now.ToUniversalTime() <= expirationDateTime) ? "true" : "false"; } State["Use1UserCredential"] = (GetUse1UserCredential(State, row["application_id"].ToString())) ? "true" : "false"; DateTime DateTimeModified = DateTime.Parse(row["production_date_time"].ToString()); State["DateTimeModified"] = DateTimeModified.ToString("s") + "Z"; State["HasUnlimitedUsers"] = (row["has_unlimited_users"] != null && row["has_unlimited_users"].ToString().ToLower() == "true") ? "true" : "false"; } } }
private void SaveReport(Hashtable State, String application_id, String app_status, String customer_id, String user_id, String device_id, String device_model, String device_version, String viziapps_version, String latitude, String longitude, String app_use) { if (device_id == null) return; Document DDBDoc = new Document(); DDBDoc["report_id"] = Guid.NewGuid().ToString(); DDBDoc["app_use"] = app_use; DDBDoc["report_date_time"] = DateTime.UtcNow.ToString("s") + "Z"; DDBDoc["app_id"] = application_id; DDBDoc["app_status"] = app_status; DDBDoc["customer_id"] = customer_id; DDBDoc["user_id"] = user_id; DDBDoc["device_id"] = device_id; DDBDoc["device_model"] = device_model; DDBDoc["device_version"] = device_version; DDBDoc["viziapps_version"] = viziapps_version; if (latitude != null && latitude.Length > 0) DDBDoc["gps_latitude"] = latitude; if (longitude != null && longitude.Length > 0) DDBDoc["gps_longitude"] = longitude; DynamoDB ddb = new DynamoDB(); if (device_id != null && device_id.Length > 0) ddb.PutItem(State, "mobile_app_usage", DDBDoc); if (customer_id != null && customer_id.Length > 0) ddb.PutItem(State, "customer_usage", DDBDoc); if (application_id != null && application_id.Length > 0) ddb.PutItem(State, "app_usage", DDBDoc); /*StringBuilder sb_sql = new StringBuilder("INSERT INTO reports SET "); sb_sql.Append("report_id='" + Guid.NewGuid().ToString() + "'"); DateTime now = DateTime.Now.ToUniversalTime(); sb_sql.Append(",report_date_time='" + now.ToString("u").Replace("Z", "") + "'"); sb_sql.Append(",application_id='" + application_id + "'"); sb_sql.Append(",app_status='" + app_status + "'"); sb_sql.Append(",customer_id='" + customer_id + "'"); sb_sql.Append(",user_id='" + user_id + "'"); sb_sql.Append(",device_id='" + device_id + "'"); sb_sql.Append(",device_model='" + device_model + "'"); sb_sql.Append(",device_version='" + device_version + "'"); sb_sql.Append(",mobiflex_version='" + mobiflex_version + "'"); if (latitude != null && latitude.Length > 0) sb_sql.Append(",gps_latitude='" + latitude + "'"); if (longitude != null && longitude.Length > 0) sb_sql.Append(",gps_longitude='" + longitude + "'"); db.ViziAppsExecuteNonQuery(State, sb_sql.ToString()); db.CloseViziAppsDatabase(State);*/ }
private void MainButtonB_Click(object sender, RoutedEventArgs e) { // DynamoDbDemoService service = new DynamoDbDemoService(); DynamoDB.GetTablesDetails(); }
public void ResetAppInDynamoDB(Hashtable State) { DynamoDB ddb = new DynamoDB(); ddb.DeleteItem(State, "apps", State["Username"].ToString(), State["SelectedApp"].ToString()); }
public void SaveProductionAppInfo(Hashtable State, string app_name, XmlDocument Design) { //save design in a file DynamoDB ddb = new DynamoDB(); string file_name = app_name.Replace(" ", "_") + ".xml"; string file_path = HttpRuntime.Cache["TempFilesPath"].ToString() + State["Username"].ToString() + "." + file_name; Design.Save(file_path); //save design in S3 string key = State["Username"].ToString() + "/" + app_name.Replace(" ", "_") + "/" + file_name; AmazonS3 s3 = new AmazonS3(); State["AppDesignURL"] = s3.UploadFileWithKey(State, file_name, file_path, key); try { File.Delete(file_path); } catch (Exception ex) { }//in case there is a problem with deleting the file Document DDBDoc = new Document(); DDBDoc["username"] = State["Username"].ToString(); DDBDoc["appname"] = app_name; DDBDoc["app_id"] = State["AppID"].ToString(); DDBDoc["is_production_app_paid"] = State["IsProductionAppPaid"].ToString(); if (State["FreeProductionExpirationDateTime"] != null && State["FreeProductionExpirationDateTime"].ToString().Length > 0) DDBDoc["free_production_expiration_date_time"] = State["FreeProductionExpirationDateTime"].ToString(); DDBDoc["use_1_user_credential"] = State["Use1UserCredential"].ToString(); DDBDoc["app_design_url"] = State["AppDesignURL"].ToString(); DDBDoc["date_time_modified"] = State["DateTimeModified"].ToString(); DDBDoc["has_unlimited_users"] = State["HasUnlimitedUsers"].ToString(); ddb.PutItem(State, "apps", DDBDoc); }
protected override void onLoad() { var productTxt = Document.GetElementById <InputElement>("productTxt"); productTxt.Focus(); var quantityTxt = Document.GetElementById <InputElement>("quantityTxt"); quantityTxt.Value = "0"; quantityTxt.OnChange = (ev) => { Quantity = int.Parse(quantityTxt.Value); }; var toDownBtn = Document.GetElementById <ButtonElement>("toDownBtn"); toDownBtn.OnClick = (ev) => { if (Quantity > 0) { Quantity--; quantityTxt.Value = Quantity.ToString(); } }; var toUpBtn = Document.GetElementById <ButtonElement>("toUpBtn"); toUpBtn.OnClick = (ev) => { Quantity++; quantityTxt.Value = Quantity.ToString(); }; var backBtn = Document.GetElementById <ButtonElement>("backBtn"); backBtn.OnClick = (ev) => { Navigation <Main> .Go(); }; var saveBtn = Document.GetElementById <ButtonElement>("saveBtn"); saveBtn.OnClick = (ev) => { var dynamodb = new DynamoDB(); var paramGet = new GetParams { TableName = "stock", Key = new { product = new DynamoItem { S = productTxt.Value } } }; dynamodb.getItem(paramGet, (errGet, dataGet) => { if (dataGet.Item == null) { var paramPut = new ItemParams { TableName = "stock", Item = new { product = new DynamoItem { S = productTxt.Value }, quantity = new DynamoItem { N = Quantity.ToString() } } }; dynamodb.putItem(paramPut, (errPut, dataPut) => { if (errPut != null) { Toast.Error("A Error ocorred on include the product!"); } else { productTxt.Value = String.Empty; quantityTxt.Value = "0"; Quantity = 0; productTxt.Focus(); Toast.Success("Sucess included product!"); } }); } else { Toast.Error("Product alredy exist!"); } }); }; }
private void MainButtonA_Click(object sender, RoutedEventArgs e) { // DynamoDB.CreateNewTableDemo("SteveBob"); DynamoDB.InsertPeopleByDocumentModel("SteveBob"); }