Beispiel #1
0
 public void StrAdd(CmdLogType type, string msg, CommLogType CommType)
 {
     messageQueue.Enqueue(new QueueMsg()
     {
         type = type, msg = msg, CommType = CommType
     });
 }
Beispiel #2
0
        public void Write(CmdLogType type, string LogMsg, CommLogType CommType)
        {
            MakeDir(type, CommType);
            string   sFullPath = GetFullPath(type, CommType);
            string   log       = $"{LogMsg}";
            FileInfo file      = new FileInfo(sFullPath);

            try
            {
                if (!file.Exists)
                {
                    using (StreamWriter sw = new StreamWriter(sFullPath))
                    {
                        sw.WriteLine(log);
                        sw.Close();
                    }
                }
                else
                {
                    using (StreamWriter sw = File.AppendText(sFullPath))
                    {
                        sw.WriteLine(log);
                        sw.Close();
                    }
                }
            }
            catch (Exception e)
            {
                StrAdd(CmdLogType.prdt, $"Event Log file write Error.[{log}]\r\n{e.ToString()}", CommLogType.MPlus);
            }
        }
Beispiel #3
0
        private string GetFullPath(CmdLogType type, CommLogType CommType)
        {
            string   rtn = string.Empty;
            DateTime Date = DateTime.Now;
            string   strY, strM, strD, strFileName, strFullPath = "";

            strY = string.Format("{0:yyyy}", Date);
            strM = string.Format("{0:MM}", Date);
            strD = string.Format("{0:dd}", Date);
            switch (_Ver)
            {
            case eLOGVER.Old:
                strFileName = string.Format("{0}_{1:dd}.txt", type.ToString(), Date);
                strFullPath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}", _PathFodler, type.ToString(), strY, strM, strFileName);
                switch (CommType)
                {
                case CommLogType.MPlus:
                case CommLogType.VEHICLE:
                case CommLogType.LDS:
                case CommLogType.QR:
                case CommLogType.UR:
                case CommLogType.TactTime:
                    rtn = string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\{5}", _PathFodler, type.ToString(), CommType.ToString(), strY, strM, strFileName);
                    break;

                default:
                case CommLogType.None:
                    rtn = string.Format("{0}\\{1}\\{2}\\{3}\\{4}", _PathFodler, type.ToString(), strY, strM, strFileName);
                    break;
                }
                break;

            case eLOGVER.New:
                switch (type)
                {
                case CmdLogType.Comm:
                    switch (CommType)
                    {
                    case CommLogType.MPlus:
                    case CommLogType.VEHICLE:
                    case CommLogType.UR:
                    case CommLogType.QR:
                    case CommLogType.LDS:
                    case CommLogType.Conv:
                    case CommLogType.IO:
                    case CommLogType.TactTime:
                        rtn = $"{_PathFodler}\\{strY}\\{strM}\\{strD}\\{type.ToString()}\\{CommType.ToString()}.txt";
                        break;

                    default: rtn = $"{_PathFodler}\\{strY}\\{strM}\\{strD}\\{type.ToString()}.txt"; break;
                    }
                    break;

                default: rtn = $"{_PathFodler}\\{strY}\\{strM}\\{strD}\\{type.ToString()}.txt"; break;
                }
                break;
            }
            return(rtn);
        }
Beispiel #4
0
        public void Write(CmdLogType type, string msg, CommLogType CommType = CommLogType.None)
        {
            if (null == PrdtLog)
            {
                return;
            }
            string logmsg = string.Empty;

            logmsg = $"{DateTime.Now.ToString("HH:mm:ss.fff")} : {msg}";
            PrdtLog.StrAdd(type, logmsg, CommType);
            Debug.WriteLine($"{type.ToString()} : {msg}");
            OnWriteLog?.Invoke(this, new WriteLogArgs()
            {
                name = "", type = type, msg = logmsg, CommType = CommType
            });
        }
Beispiel #5
0
        private void MakeDir(CmdLogType type, CommLogType CommType)
        {
            DateTime      Date = DateTime.Now;
            string        strY, strM, strD;
            DirectoryInfo dtif = new DirectoryInfo(_PathFodler);

            strY = string.Format("{0:yyyy}", Date);
            strM = string.Format("{0:MM}", Date);
            strD = string.Format("{0:dd}", Date);
            switch (_Ver)
            {
            case eLOGVER.Old:
                dtif = new DirectoryInfo(string.Format("{0}\\{1}\\{2}", _PathFodler, type.ToString(), strY));
                if (!dtif.Exists)
                {
                    dtif.Create();
                }
                switch (CommType)
                {
                case CommLogType.MPlus:
                case CommLogType.VEHICLE:
                case CommLogType.LDS:
                case CommLogType.QR:
                case CommLogType.UR:
                case CommLogType.TactTime:
                    dtif = new DirectoryInfo(string.Format("{0}\\{1}\\{2}\\{3}", _PathFodler, type.ToString(), strY, strM));
                    if (!dtif.Exists)
                    {
                        dtif.Create();
                    }

                    dtif = new DirectoryInfo(string.Format("{0}\\{1}\\{2}\\{3}\\{4}", _PathFodler, type.ToString(), CommType.ToString(), strY, strM));
                    if (!dtif.Exists)
                    {
                        dtif.Create();
                    }
                    break;

                case CommLogType.None:
                default:
                    dtif = new DirectoryInfo(string.Format("{0}\\{1}\\{2}\\{3}", _PathFodler, type.ToString(), strY, strM));
                    if (!dtif.Exists)
                    {
                        dtif.Create();
                    }
                    break;
                }
                break;

            case eLOGVER.New:
                dtif = new DirectoryInfo($"{_PathFodler}\\{strY}");
                if (!dtif.Exists)
                {
                    dtif.Create();
                }
                dtif = new DirectoryInfo($"{_PathFodler}\\{strY}\\{strM}");
                if (!dtif.Exists)
                {
                    dtif.Create();
                }
                dtif = new DirectoryInfo($"{_PathFodler}\\{strY}\\{strM}\\{strD}");
                if (!dtif.Exists)
                {
                    dtif.Create();
                }
                switch (type)
                {
                case CmdLogType.Comm:
                    dtif = new DirectoryInfo($"{_PathFodler}\\{strY}\\{strM}\\{strD}\\{type.ToString()}");
                    if (!dtif.Exists)
                    {
                        dtif.Create();
                    }
                    break;

                default: break;
                }
                break;
            }
        }