/// <summary> /// Method for executing the source code /// </summary> /// <param name="startPartitionKey"></param> /// <param name="startRowKey"></param> /// <param name="endPartitionKey"></param> /// <param name="endRowKey"></param> /// <param name="fileName"></param> public static List <LogEntity> Exec(string startPartitionKey, string startRowKey, string endPartitionKey, string endRowKey, string fileName) { //TODO: add UI for the below 3 fields. string tableName = "table1"; AzureTableConnection storage = new AzureTableConnection(tableName); AzureLog result = new AzureLog(); CloudTable table = storage.GetTable(); //If table is null return error to the user. Abort the query List <TableQuery <LogEntity> > listOfQueries = result.GetAllQueries(startPartitionKey, startRowKey, endPartitionKey, endRowKey); List <LogEntity> allLogs = new List <LogEntity>(); foreach (TableQuery <LogEntity> aQuery in listOfQueries) { aQuery.TakeCount = 100; TableContinuationToken token = null; bool first = true; do { ResultPair pair = result.GetResultsAsync(aQuery, table, token, first).Result; first = false; token = pair.token; allLogs.AddRange(pair.logs); }while (token != null); } //List<LogEntity> logs = await result.StartQueryAsync("2016-03-18 15:41", "16", "2016-03-18 15:41", "20"); //List<LogEntity> logs = result.StartQueryAsync(startPartitionKey, startRowKey, endPartitionKey, endRowKey).Result; //WriteLogToFile(startPartitionKey, startRowKey, endPartitionKey, endRowKey, fileName, allLogs); return(allLogs); }
// Insert into table. public void Insert(AzureLog objAzureLog) { // Create the new insert table operation. TableOperation insertOperation = TableOperation.Insert(objAzureLog); // Execute the insert statement. table.Execute(insertOperation); }
public override void OnActionExecuting(HttpActionContext context) { var cert = context.Request.GetClientCertificate(); if (cert != null) { AzureLog.Info("Certificate found:" + cert.FriendlyName); AzureLog.Info(cert.ToString()); } else { AzureLog.Info("Certificate cannot be found."); } }
protected override void Append(LoggingEvent loggingEvent) { try { //Intilize AzureLog object. AzureLog objAzureLog = new AzureLog { RoleInstance = "1", DeploymentId = "100", Message = loggingEvent.RenderedMessage, Level = loggingEvent.Level.Name, }; //Insert the log. objLogger.Insert(objAzureLog); } catch (Exception ex) { //Handle exception here. } }