public StreamMessage GetLogData(LogAggregatedDataParameterMessage logAggregatedDataParameterMessage) { return(Channel.GetLogData(logAggregatedDataParameterMessage)); }
public StreamMessage GetLogData(LogAggregatedDataParameterMessage logAggregatedDataParameterMessage) { string logFileFullPath = ""; FileStream fileStream = null; bool bSuccess = false; // close returned stream and delete sent file on completion OperationContext clientContext = OperationContext.Current; clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { if (fileStream != null) { // truncate file. there is a probability that the Log Aggregator Windows service will lock that file // just before deleting it, so make sure the file is empty. fileStream.SetLength(0); fileStream.Dispose(); } if (logFileFullPath != "" && bSuccess) { try { File.Delete(logFileFullPath); } catch (Exception ex) { _eventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error); } } }); if (logAggregatedDataParameterMessage.SystemPassPhrase != _systemPassPhrase) { return(null); } // aggregate logs' path: <path from root>\machineGUID\ // and then search for an available aggregated log file string logPartialPath = _aggregatedLogsPath; switch (logAggregatedDataParameterMessage.LogTypeAggregated) { case LogTypeAggregated.AdvertWeightedClicksPerChannel: logPartialPath += "a_c_c_p_"; break; case LogTypeAggregated.AdvertWeightedImpressionsPerChannel: logPartialPath += "a_c_i_p_"; break; case LogTypeAggregated.ClicksPerDatePerAsset: logPartialPath += "c_d_a_"; break; case LogTypeAggregated.ImpressionsPerDatePerAsset: logPartialPath += "s_d_a_"; break; } // if file exists, just read it. No need to check for checksum as file will be deleted // when transfer is complete bSuccess = TryGetAndLockFile(ref fileStream, logPartialPath, ref logFileFullPath); return(new StreamMessage(fileStream)); }