Ejemplo n.º 1
0
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            try
            {
                TISMutex = new Mutex();

                TISLogConfiguration getCfgData = new TISLogConfiguration();

                outputFile = Path.Combine(filePath, getCfgData.LogFileName);

                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 Exception(String.Format("Failed to Create/Open Log File [{0}]", outputFile), exc);
            }
        }
Ejemplo n.º 2
0
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            try
            {
                // the logger initialize this class automatically
                mmfData    = new TIS_SMData();
                TIS_MMF    = new TISSharedMemory <byte>("TIS_MMF", (int)TIS_APPENDER.MMFSIZE);
                getCfgData = new TISLogConfiguration();

                TIS_MMF.OutPutFile = Path.Combine(filePath, getCfgData.LogFileName);

                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 Exception("Failed to Create MMF object]");
                }
            }
            catch
            {
                TIS_MMF      = null;
                TIS_MMF_INDX = null;
            }
        }