private static string GetCostMasterEntityDate() { // TableOperation tableOperation; string storageConnectionString = SourceConnection; //log.LogInformation("**** In Test Method ****"); CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString); CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient(); string tableName = "CostsMaster"; CloudTable cloudTable = tableClient.GetTableReference(tableName); TableResult retrieverResult = RetrieveRecord(cloudTable, "2020", "1"); CostMasterEntity costMasterEntity = (CostMasterEntity)retrieverResult.Result; //DateTime costMasterEntityDate = DateTime.Parse(retrieverResult.ToString()); return(costMasterEntity.LastProcessedDate); }
private static string UpdateCostMasterLastProcessedDateWithTodaysDate(ILogger log) { TableOperation tableOperation; string storageConnectionString = SourceConnection; log.LogInformation("**** In Test Method ****"); CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString); CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient(); string tableName = "CostsMaster"; CloudTable cloudTable = tableClient.GetTableReference(tableName); CostMasterEntity costMasterEntity = new CostMasterEntity("2020", "1"); costMasterEntity.LastProcessedDate = DateTime.Now.ToString("dd'/'MM'/'yyyy"); // retrieve record var retrieverResult = RetrieveRecord(cloudTable, "2020", "1"); if (retrieverResult == null) { // if not found tableOperation = TableOperation.Insert(costMasterEntity); } else { // update costMasterEntity.ETag = "*"; tableOperation = TableOperation.Replace(costMasterEntity); } var result = cloudTable.ExecuteAsync(tableOperation); //CreateNewTable(cloudTable, log); return(result.Status.ToString()); }