protected void fLogging(String Msg, int Category = 0x01, EventLogEntryType EntryType = EventLogEntryType.Information, int Instance = 0x01)
 {
     if (!(fFileLog == null))
     {
         fFileLog.WriteLog(Msg);
     }
     if (!(fEvtLog == null))
     {
         fEvtLog.Category = Category; fEvtLog.EntryType = EntryType; fEvtLog.Instance = Instance; fEvtLog.WriteToLog(Msg);
     }
 }
Beispiel #2
0
 protected void fLogging(String Msg, int Category = 0x01, EventLogEntryType EntryType = EventLogEntryType.Information, int Instance = 0x01)
 {
     if (!(fFileLog == null))
     {
         try
         {
             fFileLog.WriteLog(Msg);
         }
         catch (LogATMServer.ServiceExceptions.EWriteToLogFileException e)
         {
             { LogATM_Server.fEvtLog.Category = Category; LogATM_Server.fEvtLog.EntryType = EventLogEntryType.Error; LogATM_Server.fEvtLog.Instance = Instance; LogATM_Server.fEvtLog.WriteToLog("Error write to file log\nMsg - " + e.WriteToLogFileMessage + "\nCode - " + Convert.ToString(e.WriteToLogFileCode)); }
         }
     }
     if (!(LogATM_Server.fEvtLog == null))
     {
         LogATM_Server.fEvtLog.Category = Category; LogATM_Server.fEvtLog.EntryType = EntryType; LogATM_Server.fEvtLog.Instance = Instance; LogATM_Server.fEvtLog.WriteToLog(Msg);
     }
 }
        public void ReadIniMain()
        {
            fFileLog.WriteLog("ReadIniMain Started");
//			if (!File.Exists(sIniFileName))
            if (!File.Exists(LogATM_Server.cIniFileName))
            {
                throw new ServiceExceptions.EIniFileException("Ini file not found - " + LogATM_Server.cIniFileName, 0x01);
            }
            IniReader IniMain;

            try
            {
                IniMain = new IniReader(LogATM_Server.cIniFileName);
            }
            catch (Exception e)
            {
                throw new ServiceExceptions.EIniFileException("Error create IniReader class. \n" + e.Message + "\nSource - " + e.Source, 0x02);
            }
            ArrayList AllSections = new ArrayList();

            AllSections = IniMain.GetSectionNames();
            Boolean IsSectionPresent;

            IsSectionPresent = false;

            if (AllSections.Count > 0)
            {
                foreach (String tmpSectionName in AllSections)
                {
                    fFileLog.WriteLog("IniFileName - " + IniMain.Filename + ". SectionName - " + tmpSectionName);
                    if (tmpSectionName == "Main")
                    {
                        IsSectionPresent = true;
                        break;
                    }
                }
            }
            if (!IsSectionPresent)
            {
                throw new ServiceExceptions.EIniFileException("Section Main does not Exists in IniFile. \n" + LogATM_Server.cIniFileName, 0x03);
            }
            sIniMain.EvtLog = IniMain.ReadString("Main", "IsEvtLog");

            if (sIniMain.EvtLog.Length == 0)
            {
                throw new ServiceExceptions.EIniFileException("Missing or not defined key IsEvtLog.\n" + LogATM_Server.cIniFileName, 0x04);
            }
            if (sIniMain.EvtLog.Remove(1).Contains("Y"))
            {
                sIniMain.isEvtLog = true;
            }
            else
            {
                sIniMain.isEvtLog = false;
            }

            sIniMain.FileLog = IniMain.ReadString("Main", "IsFileLog");
            if (sIniMain.FileLog.Length == 0)
            {
                throw new ServiceExceptions.EIniFileException("Missing or not defined key IsFileLog.\n" + LogATM_Server.cIniFileName, 0x05);
            }
            if (sIniMain.FileLog.Remove(1).Contains("Y"))
            {
                sIniMain.isFileLog = true;
            }
            else
            {
                sIniMain.isFileLog = false;
            }
            sIniMain.sDaysSaveFileLog = IniMain.ReadString("Main", "DaysSaveFileLog");
            if (!Int16.TryParse(sIniMain.sDaysSaveFileLog, out sIniMain.DaysSaveFileLog))
            {
                throw new ServiceExceptions.EIniFileException("Missing or error defined key DaysSaveCopy.\n" + LogATM_Server.cIniFileName, 0x05);
            }
        }