/// <summary> /// Used to get global entites /// </summary> /// <returns></returns> public GlobalVariables GetGlobalEntity() { GlobalVariables global = new GlobalVariables(); try { // Retrieve storage account from connection string CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(Constatns.StorageAccountConnectionString)); // Create the table client CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("globalvariables"); // Get the data service context TableServiceContext serviceContext = tableClient.GetTableServiceContext(); //// Specify a partition query global = (from e in serviceContext.CreateQuery<GlobalVariables>("globalvariables") select e).FirstOrDefault(); } catch (Exception ex) { string Message = ex.Message; } return global; }
/// <summary> /// Used to add UniqueId /// </summary> public void AddUniqueGuid() { try { // Retrieve the storage account from the connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(Constatns.StorageAccountConnectionString)); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable globalTable = tableClient.GetTableReference("globalvariables"); globalTable.CreateIfNotExists(); ////insert the unique id in table GlobalVariables global = new GlobalVariables(Guid.NewGuid().ToString(), true); global.UniqueId = Guid.NewGuid().ToString(); global.isTrue = true; TableOperation insetOperationGlobal = TableOperation.Insert(global); globalTable.Execute(insetOperationGlobal); } catch (Exception ex) { string message = ex.Message; } }