示例#1
0
        public static void VideoCheck(string SearchPath, string ReportFile, Mode Mode)
        {
            DateTime             PStart    = DateTime.Now;
            Output_ProcessReport Report    = new Output_ProcessReport();
            List <string>        videoList = Retriever.GetVideoFiles(SearchPath);

            if (!File.Exists(ReportFile))
            {
                CreateReportFile(ReportFile, Mode, null);
            }
            if (videoList != null)
            {
                if (videoList.Any())
                {
                    for (var i = 0; i < videoList.Count; i++)
                    {
                        if (ExecuteFFMPEG(ReportFile, SearchPath, videoList[i], ProcessType.VideoCheck))
                        {
                            Report.Damaged += 1;
                            string frameTraceReport = Path.Combine(SearchPath, Path.GetFileName(videoList[i]) + OutputExtension.TXT);
                            if (!File.Exists(frameTraceReport))
                            {
                                CreateReportFile(frameTraceReport, Mode, null);
                            }
                            ExecuteFFMPEG(frameTraceReport, SearchPath, videoList[i], ProcessType.FrameTrace);
                            if (File.Exists(frameTraceReport))
                            {
                                if (new FileInfo(frameTraceReport).Length == 0)
                                {
                                    try
                                    {
                                        File.Delete(frameTraceReport);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.ToString());
                                    }
                                }
                            }
                        }
                        else
                        {
                            Report.Healthy += 1;
                        }
                        SetProgressBar(i, videoList.Count);
                        Report.Total += 1;
                    }
                }
            }
            TimeSpan Elapsed = DateTime.Now.Subtract(PStart);

            SummariseReport(ReportFile, Mode, Elapsed, Report);
        }
示例#2
0
        public static void Verify(string SearchPath, string ReportFile, Mode Mode, int StartingPoint = 0, DateTime?FilterDate = null, bool UseDateFilter = false)
        {
            DateTime             PStart  = DateTime.Now;
            List <FileItem>      lists   = new List <FileItem>();
            List <string>        md5List = Retriever.GetFiles(SearchPath, SearchExtension.MD5, FilterDate, UseDateFilter);
            Output_ProcessReport Result  = new Output_ProcessReport();

            Console.WriteLine("No. of md5 : " + md5List.Count);
            if (!File.Exists(ReportFile))
            {
                if (!CreateReportFile(ReportFile, Mode, md5List))
                {
                    throw new Exception("Unable to create report file.");
                }
            }
            for (int i = StartingPoint; i < md5List.Count; i++)
            {
                lists = BuildFileItemList(md5List[i]);
                if (lists.Any())
                {
                    Result.Total += lists.Count;
                    if (Mode != Mode.Combine_All_MD5)
                    {
                        using (StreamWriter file = File.AppendText(ReportFile))
                        {
                            file.WriteLine(Convert.ToString(i + 1) + "/" + md5List.Count + "\t" + md5List[i].Replace(SearchPath, "") + " Proccessing..."); //md5List[i].Split('\'')[md5List[i].Split('\'').Length - 1]
                        }
                    }
                    Output_ProcessReport ItemResult = ProcessMD5File(lists, Mode, ReportFile);
                    Result.Healthy += ItemResult.Healthy;
                    Result.Damaged += ItemResult.Damaged;
                    Result.Missing += ItemResult.Missing;

                    if (Mode != Mode.Combine_All_MD5)
                    {
                        using (StreamWriter file = File.AppendText(ReportFile))
                        {
                            file.WriteLine("Verification Completed");
                            file.WriteLine("----------------------");
                        }
                    }
                    Console.WriteLine(Convert.ToString(i + 1) + "/" + md5List.Count + "\t" + md5List[i].Replace(SearchPath, "") + " Checked.");
                    SetProgressBar(i, md5List.Count);
                    lists.Clear();
                }
            }
            TimeSpan Elapsed = DateTime.Now.Subtract(PStart);

            SummariseReport(ReportFile, Mode, Elapsed, Result);
        }
示例#3
0
        private static Output_ProcessReport ProcessMD5File(List <FileItem> list, Mode Mode, string ReportFile)
        {
            try
            {
                Output_ProcessReport Report = new Output_ProcessReport();
                using (StreamWriter file = File.AppendText(ReportFile))
                {
                    foreach (FileItem fItem in list)
                    {
                        if (Mode == Mode.Combine_All_MD5)
                        {
                            file.WriteLine(fItem.Hash + " *" + fItem.Filepath.Substring(fItem.Filepath.IndexOf("\\") + 1));
                            continue;
                        }

                        if (!File.Exists(fItem.Filepath))
                        {
                            file.WriteLine("Missing \t" + Path.GetFileName(fItem.Filepath));
                            Report.Missing++;
                            continue;
                        }

                        if (Mode == Mode.Verify_Checksums)
                        {
                            if (fItem.Hash.ToLowerInvariant() == ComputeMD5(fItem.Filepath).ToLowerInvariant())
                            {
                                file.WriteLine("Healthy \t" + Path.GetFileName(fItem.Filepath));
                                Report.Healthy++;
                            }
                            else
                            {
                                file.WriteLine("Damaged \t" + Path.GetFileName(fItem.Filepath));
                                Report.Damaged++;
                            }
                        }
                        else
                        {
                            file.WriteLine("Exist \t" + Path.GetFileName(fItem.Filepath));
                            Report.Healthy++;
                        }
                    }
                }
                return(Report);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public static void ParalleRefresh(string SearchPath, string ReportFile, Mode Mode, ProcessingPower ProcessingPower, int StartingPoint = 0, DateTime?FilterDate = null, bool UseDateFilter = false)
        {
            DateTime             PStart      = DateTime.Now;
            Output_ProcessReport Report      = new Output_ProcessReport();
            List <FileItem>      FileList    = new List <FileItem>();
            List <FileItem>      HealthyList = new List <FileItem>();
            List <FileItem>      DamagedList = new List <FileItem>();
            List <FileItem>      MissingList = new List <FileItem>();
            List <string>        folderList  = Retriever.Getfolders(SearchPath, FilterDate, UseDateFilter);
            List <string>        md5List     = Retriever.GetFiles(SearchPath, SearchExtension.MD5, FilterDate, UseDateFilter);

            if (!File.Exists(ReportFile))
            {
                CreateReportFile(ReportFile, Mode, null);
            }
            Console.WriteLine("No. of md5 : " + md5List.Count);
            Console.WriteLine("No. of folders : " + folderList.Count);
            for (int i = StartingPoint; i < folderList.Count; i++)
            {
                string md5File = md5List.FirstOrDefault(s => Path.GetFileNameWithoutExtension(s) == Path.GetFileName(folderList[i]));
                if (!string.IsNullOrEmpty(md5File))
                {
                    FileList = BuildFileItemList(md5File);
                }
                FileList = ProcessFilesInFolder(folderList[i], ReportFile, FileList, DamagedList, ProcessingPower);
                if (FileList.Any())
                {
                    FileList    = Sort(FileList, folderList[i]);
                    HealthyList = FileList.Where(s => s.IsChecksummed != ChecksumStat.DuplicateNameOrCorrupted && s.IsChecksummed != ChecksumStat.Init).ToList();
                    if (HealthyList.Any())
                    {
                        if (ProcessGeneratedList(HealthyList, ListType.Healthy, folderList[i]))
                        {
                            Report.Healthy += HealthyList.Count;
                        }
                        HealthyList.Clear();
                    }
                    DamagedList = FileList.Where(s => s.IsChecksummed == ChecksumStat.DuplicateNameOrCorrupted).ToList();
                    if (DamagedList.Any())
                    {
                        DamagedList = Sort(DamagedList, folderList[i]);
                        if (ProcessGeneratedList(DamagedList, ListType.Damaged, folderList[i]))
                        {
                            Report.Damaged += DamagedList.Count;
                        }
                        DamagedList.Clear();
                    }
                    MissingList = FileList.Where(s => s.IsChecksummed == ChecksumStat.Init).ToList();
                    if (MissingList.Any())
                    {
                        MissingList = Sort(MissingList, folderList[i]);
                        if (ProcessGeneratedList(MissingList, ListType.Missing, folderList[i]))
                        {
                            Report.Missing += MissingList.Count;
                        }
                        MissingList.Clear();
                    }
                    FileList.Clear();
                }
                SetProgressBar(i, folderList.Count);
                Console.WriteLine(Convert.ToString((i + 1)) + "/" + folderList.Count + "\t" + Path.GetFileName(folderList[i]) + OutputExtension.MD5 + " Generated.");
                using (StreamWriter file = File.AppendText(ReportFile))
                {
                    file.WriteLine(Convert.ToString((i + 1)) + "/" + folderList.Count + "\t" + Path.GetFileName(folderList[i]) + OutputExtension.MD5 + " Generated.");
                }
                Report.Total += 1;
            }
            TimeSpan Elapsed = DateTime.Now.Subtract(PStart);

            SummariseReport(ReportFile, Mode, Elapsed, Report);
            //DateTime PStart = DateTime.Now;
            //Output_ProcessReport Report = new Output_ProcessReport();
            //List<FileItem> FileList = new List<FileItem>();
            //List<FileItem> HealthyList = new List<FileItem>();
            //List<FileItem> DamagedList = new List<FileItem>();
            //List<FileItem> MissingList = new List<FileItem>();
            //List<string> folderList = Retriever.Getfolders(SearchPath, FilterDate, UseDateFilter);
            //List<string> md5List = Retriever.GetFiles(SearchPath, SearchExtension.MD5, FilterDate, UseDateFilter);
            //if (!File.Exists(ReportFile))
            //{
            //    CreateReportFile(ReportFile, Mode, null);
            //}
            //Console.WriteLine("No. of md5 : " + md5List.Count);
            //Console.WriteLine("No. of folders : " + folderList.Count);
            //int index = 0;
            //StreamWriter file = File.AppendText(ReportFile);
            ////using (StreamWriter file = File.AppendText(ReportFile))
            ////{
            //try
            //{
            //    var result = Parallel.ForEach(folderList, new ParallelOptions { MaxDegreeOfParallelism = 2 },
            //    folder =>
            //    {
            //        string FolderPath = folder;
            //        index += 1;
            //        Task task = Task.Factory.StartNew(() =>    // Begin task
            //        {
            //            return TaskTest(md5List, FileList, HealthyList, DamagedList, MissingList, FolderPath, ReportFile);
            //        })
            //            .ContinueWith(ant =>
            //            {
            //                Report.Healthy += ant.Result.Healthy;
            //                Report.Damaged += ant.Result.Damaged;
            //                Report.Missing += ant.Result.Missing;
            //                Report.Total += ant.Result.Total;
            //                SetProgressBar(index, folderList.Count);
            //                Console.WriteLine(Convert.ToString(index + 1) + "/" + folderList.Count + "\t" + Path.GetFileName(FolderPath) + OutputExtension.MD5 + " Generated.");
            //            //using (StreamWriter file = File.AppendText(ReportFile))
            //            //{
            //            file.WriteLine(Convert.ToString(index + 1) + "/" + folderList.Count + "\t" + Path.GetFileName(FolderPath) + OutputExtension.MD5 + " Generated.");
            //            //}
            //        });
            //    }).IsCompleted;
            //    //if (result)
            //    //    file.Dispose();
            //}
            //finally
            //{
            //    file.Dispose();
            //}
            ////}
            //TimeSpan Elapsed = DateTime.Now.Subtract(PStart);
            //SummariseReport(ReportFile, Mode, Elapsed, Report);
        }
示例#5
0
        private static void SummariseReport(string ReportFile, Mode Mode, TimeSpan Elapsed, Output_ProcessReport Result)
        {
            using (StreamWriter file = File.AppendText(ReportFile))
            {
                string SummaryTotal = null;
                switch (Mode)
                {
                case Mode.Create_Checksum_for_Every_Folder:
                    SummaryTotal = "Total md5s generated : " + Result.Total;
                    break;

                case Mode.Check_Video_Corruption:
                    SummaryTotal = "Total video checked : " + Result.Total;
                    break;

                default:
                    SummaryTotal = "Total files checked : " + Result.Total;
                    break;
                }
                string SummarySubCat    = "Healthy : " + Result.Healthy + ", Damaged : " + Result.Damaged + ", Missing : " + Result.Missing;
                string SummaryTimeStamp = "Completed  @ " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string SummaryElasp     = "Time Elapse : " + Elapsed.ToString();
                Console.WriteLine(SummaryTotal);
                Console.WriteLine(SummarySubCat);
                Console.WriteLine(SummaryTimeStamp);
                Console.WriteLine(SummaryElasp);

                if (Mode != Mode.Combine_All_MD5)
                {
                    file.WriteLine("Version:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    file.WriteLine(SummaryTotal);
                    file.WriteLine(SummarySubCat);
                    file.WriteLine(SummaryTimeStamp);
                    file.WriteLine(SummaryElasp);
                }
            }
        }