Example #1
0
        public bool moveFile(CrashLogsInfo logInfo)
        {
            string oldPath = configData.PCCPath + @"\" + configData.LogName + @"\" + configData.currentDate;

            newPath = configData.NEW_TARGET_PATH + @"\" + configData.LogName + @"\" + configData.currentDate;
            string newNoDatePath = configData.NEW_TARGET_PATH;
            bool   flag          = false;
            EFrom  from          = logInfo.From;

            switch (from)
            {
            case EFrom.CMM:
                if (logInfo.IsSuccess)
                {
                    newPath = oldPath + @"\" + logInfo.FileName;
                }
                else
                {
                    newPath = oldPath + "NoMatch" + @"\" + logInfo.FileName;
                }
                flag = doMove(logInfo, newPath);
                break;

            case EFrom.LUT:
                //LUT will be not create date path and match the MTBF
                newPath = newNoDatePath + @"\" + logInfo.FileName;
                flag    = doMove(logInfo, newPath);
                break;

            case EFrom.EXT1:
                newPath = newNoDatePath + @"\" + logInfo.FileName;
                flag    = doMove(logInfo, newPath);
                break;

            case EFrom.EXT2:
                newPath = newNoDatePath + @"\" + logInfo.FileName;
                flag    = doMove(logInfo, newPath);
                break;

            default:
                break;
            }
            return(flag);
        }
Example #2
0
        public static void getCrashFile(string filePath, ref List <CrashFileTypeInfo> fileList, EFrom from)
        {
            bool isLut = false;
            CrashFileTypeInfo    fileTypeInfo = null;
            List <FileInfo>      tempFileList = new List <FileInfo>();
            List <DirectoryInfo> tempDirList  = new List <DirectoryInfo>();

            DirectoryInfo dirInfo = new DirectoryInfo(filePath);

            if (!dirInfo.Exists)
            {
                Trace.WriteLine("The directory path: " + filePath + " doesn't exist");
                return;
            }

            if (from == EFrom.LUT)
            {
                isLut = true;
            }

            FileInfo[]      crashFiles = dirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly);
            DirectoryInfo[] crashDirs  = dirInfo.GetDirectories("*-*", SearchOption.TopDirectoryOnly);

            tempFileList = deleteInvalidFile(crashFiles);

            foreach (DirectoryInfo dir in crashDirs)
            {
                DateTime createTime = dir.CreationTime;
                TimeSpan diff       = DateTime.Now.Subtract(createTime);
                if (diff.TotalHours >= 2)
                {
                    tempDirList.Add(dir);
                }
            }

            foreach (FileInfo file in tempFileList)
            {
                fileTypeInfo          = new CrashFileTypeInfo();
                fileTypeInfo.FileName = file.Name;
                fileTypeInfo.FullName = file.FullName;
                fileTypeInfo.IsFile   = true;
                fileTypeInfo.IsLut    = isLut;
                fileTypeInfo.IsOlder  = (DateTime.Now.Subtract(file.CreationTime).TotalHours >= 8);
                fileTypeInfo.From     = from;

                fileList.Add(fileTypeInfo);
            }

            foreach (DirectoryInfo dir in tempDirList)
            {
                fileTypeInfo          = new CrashFileTypeInfo();
                fileTypeInfo.FileName = dir.Name;
                fileTypeInfo.FullName = dir.FullName;
                fileTypeInfo.IsFile   = false;
                fileTypeInfo.IsLut    = isLut;
                fileTypeInfo.IsOlder  = (DateTime.Now.Subtract(dir.CreationTime).TotalHours >= 8);
                fileTypeInfo.From     = from;

                fileList.Add(fileTypeInfo);
            }
        }