public async Task LoadCompleteModel(AzLogModel azlm) { AzLogEntry[] rgazle = new AzLogEntry[s_cChunkSize]; // do 1k log entry chunks using (StreamReader sr = File.OpenText(m_sFilename)) { int iLine = 0; int cChunk = 0; int iFirst, iLast; while (!sr.EndOfStream) { string s = sr.ReadLine(); AzLogEntry azle = null; try { azle = AzleFromLine(s, iLine++); } catch { } if (azle == null) { continue; } DateTime dttm = AzLogModel.DttmFromPartition(azle.Partition); if (m_dttmFirst > dttm) { m_dttmFirst = dttm; } if (m_dttmLast < dttm) { m_dttmLast = dttm; } rgazle[cChunk++] = azle; if (cChunk >= s_cChunkSize) { azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast); cChunk = 0; } } if (cChunk > 0) { azlm.AddSegment(rgazle, cChunk, out iFirst, out iLast); } } }
/* F E T C H P A R T I T I O N F O R D A T E */ /*---------------------------------------------------------------------------- * %%Function: FetchPartitionForDateAsync * %%Qualified: AzLog.AzLogModel.FetchPartitionForDateAsync * %%Contact: rlittle * * Fetch the partition for the given dttm (assumes that the hour is also * filled in) * ----------------------------------------------------------------------------*/ public async Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm) { TableQuery <AzLogEntryEntity> tq = new TableQuery <AzLogEntryEntity>().Where( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, AzLogModel.SPartitionFromDate(dttm, dttm.Hour))); TableQuerySegment <AzLogEntryEntity> azleSegment = null; azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending); foreach (AzLogView azlv in azlm.Listeners) { azlv.BeginAsyncData(); } while (azleSegment == null || azleSegment.ContinuationToken != null) { azleSegment = await m_azt.Table.ExecuteQuerySegmentedAsync(tq, azleSegment?.ContinuationToken); int iFirst, iLast; azlm.AddSegment(azleSegment, out iFirst, out iLast); azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Complete); } foreach (AzLogView azlv in azlm.Listeners) { azlv.CompleteAsyncData(); } return(true); }
/* F E T C H P A R T I T I O N F O R D A T E */ /*---------------------------------------------------------------------------- * %%Function: FetchPartitionForDateAsync * %%Qualified: AzLog.AzLogModel.FetchPartitionForDateAsync * %%Contact: rlittle * * Fetch the partition for the given dttm (assumes that the hour is also * filled in) * ----------------------------------------------------------------------------*/ public async Task <bool> FetchPartitionForDateAsync(AzLogModel azlm, DateTime dttm) { List <Uri> pluri = GetBlobList(dttm); azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending); foreach (AzLogView azlv in azlm.Listeners) { azlv.BeginAsyncData(); } foreach (Uri uri in pluri) { ICloudBlob icb = m_azcc.BlobClient.GetBlobReferenceFromServer(uri); string sTempFile = TCore.Util.Filename.SBuildTempFilename(null, null); icb.DownloadToFile(sTempFile, FileMode.Create); // at this point, we have the file } // now we can download the blobs -- create CloudBlob for each URI, then DownloadToFile... // need to do this async.... #if no TableQuery <AzLogEntryEntity> tq = new TableQuery <AzLogEntryEntity>().Where( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, AzLogModel.SPartitionFromDate(dttm, dttm.Hour))); TableQuerySegment <AzLogEntryEntity> azleSegment = null; azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Pending); foreach (AzLogView azlv in azlm.Listeners) { azlv.BeginAsyncData(); } while (azleSegment == null || azleSegment.ContinuationToken != null) { azleSegment = await m_azc.Container.ExecuteQuerySegmentedAsync(tq, azleSegment?.ContinuationToken); int iFirst, iLast; azlm.AddSegment(azleSegment, out iFirst, out iLast); azlm.UpdatePart(dttm, dttm.AddHours(1.0), AzLogParts.GrfDatasourceForIDatasource(m_iDatasource), AzLogPartState.Complete); } foreach (AzLogView azlv in azlm.Listeners) { azlv.CompleteAsyncData(); } #endif return(true); }