public TISAppender() { try { // the logger initialize this class automatically mmfData = new TIS_SMData(); TIS_MMF = new TISSharedMemory <byte>("TIS_MMF", (int)TIS_APPENDER.MMFSIZE); getCfgData = new LogConfiguration(); TIS_MMF.OutPutFile = getCfgData.getLogFile(); if (!TIS_MMF.Open()) { return; } byte[] indxBuff = TIS_MMF.StructureToByteArray(mmfData); TIS_MMF_INDX = new TISSharedMemory <byte>("TIS_MMF_INDX", indxBuff.Length); TIS_MMF_INDX.EnableOffset(false); if (TIS_MMF_INDX.Open()) { indxBuff = TIS_MMF_INDX.ReadArray(); TIS_SMData mmfIndex = (TIS_SMData)TIS_MMF_INDX.ByteArrayToStructure(indxBuff); if (mmfIndex.currentOff <= 0) { TIS_MMF_INDX.WriteArray(indxBuff); } else { TIS_MMF.MMFOffset = (int)mmfIndex.currentOff; } } else { throw new TisException("Failed to Create MMF object]"); } } catch { TIS_MMF = null; TIS_MMF_INDX = null; } }
public TISQueueAppender() { try { TISMutex = new Mutex(); LogConfiguration getCfgData = new LogConfiguration(); outputFile = getCfgData.getLogFile(); if (File.Exists(outputFile)) { fileS = new FileStream(outputFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); } else { fileS = new FileStream(outputFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite); } } catch (Exception exc) { throw new TisException(exc, "Failed to Create/Open Log File [{0}]", outputFile); } }