예제 #1
0
 public static Exception2StringConverter GetInstance()
 {
     if (exceptionLog == null)
     {
         exceptionLog = new Exception2StringConverter();
     }
     return(exceptionLog);
 }
        /// <summary>
        /// It will write the exception to the log and close the application
        /// </summary>
        /// <param name="exceptionMessage"></param>
        public static void WriteLog(Exception exceptionMessage, Logger logger)
        {
            LogClass.GetInstance().WriteLogs2File();
            Exception2StringConverter ex = Exception2StringConverter.GetInstance();
            string exceptionStr          = ex.ConvertException2String(exceptionMessage);

            logger.Info(exceptionStr);
            CustomMessageBox.Show(exceptionStr, "Exception");
            Environment.Exit(0);
        }
예제 #3
0
        public void WriteCaptureLog2File(List <INTUSOFT.EventHandler.Args> capLog)
        {
            try
            {
                write2Log(capLog, captureLog);

                //for (int i = 0; i < CaptureLogList.Count; i++)
                //{
                //    captureLog.Info(CaptureLogList[i] + Environment.NewLine);
                //}
                //CaptureLogList.Clear();
            }
            catch (Exception ex)
            {
                ExceptionLog.Info(Exception2StringConverter.GetInstance().ConvertException2String(ex));
            }
        }
예제 #4
0
        public void WriteLogs2File()
        {
            try
            {
                List <INTUSOFT.EventHandler.Args>[] LogListArr = new List <INTUSOFT.EventHandler.Args>[] { FrameLogList, BulkTransferLogList, CameraLogList, InterruptTransferLogList };
                LogTypeEnum[] logType = new LogTypeEnum[] { LogTypeEnum.FrameLog, LogTypeEnum.BulkLog, LogTypeEnum.Log, LogTypeEnum.InterruptLog };
                int           count   = 0;
                foreach (List <INTUSOFT.EventHandler.Args> item in LogListArr)
                {
                    if (item != null)
                    {
                        LogTypeEnum logT = logType[count];
                        Logger      L    = null;
                        switch (logT)
                        {
                        case LogTypeEnum.BulkLog:
                        {
                            L = BulkTransferLog;
                            break;
                        }

                        case LogTypeEnum.captureLog:
                        {
                            L = captureLog;
                            break;
                        }

                        case LogTypeEnum.Log:
                        {
                            L = log;
                            break;
                        }

                        case LogTypeEnum.FrameLog:
                        {
                            L = FrameLog;
                            break;
                        }

                        case LogTypeEnum.InterruptLog:
                        {
                            L = InterruptLog;
                            break;
                        }
                        }
                        write2Log(item, L);
                    }
                    count++;
                }
                isLogWritingCompleted = true;
                //if (CameraLogList != null)
                //{
                //    for (int i = 0; i < CameraLogList.Count; i++)
                //    {
                //        log.Info(CameraLogList[i] + Environment.NewLine);
                //    }
                //    CameraLogList.Clear();
                //}
                //if (FrameLogList != null)
                //{
                //    for (int i = 0; i < FrameLogList.Count; i++)
                //    {
                //        FrameLog.Info(FrameLogList[i] + Environment.NewLine);
                //    }
                //    FrameLogList.Clear();
                //}
                //if (CaptureLogList != null)
                //{
                //    for (int i = 0; i < CaptureLogList.Count; i++)
                //    {
                //        captureLog.Info(CaptureLogList[i] + Environment.NewLine);
                //    }
                //    CaptureLogList.Clear();
                //}
                //if (BulkTransferLogList != null)
                //{
                //    for (int i = 0; i < BulkTransferLogList.Count; i++)
                //    {
                //        BulkTransferLog.Info(BulkTransferLogList[i] + Environment.NewLine);
                //    }
                //    BulkTransferLogList.Clear();
                //}
            }
            catch (Exception ex)
            {
                ExceptionLog.Info(Exception2StringConverter.GetInstance().ConvertException2String(ex));
            }
        }