/// <summary>
        /// Remove any files that are not found in the SockDrawer
        /// </summary>
        /// <param name="files"></param>
        private void CheckedForDeletedFiles(string[] files)
        {
            var stopWatch = new Stopwatch(MethodBase.GetCurrentMethod().Name);

            try
            {
                StatusUpdate(StatusModel.Update(null, "Checking for Deleted Files..."));
                DateTime _lastUpdate = DateTime.Now;

                // Using r.DefaultIfEmtpy will set the right values to null where there is no match - Sara
                var query = from f in XmlDal.CacheModel.Files
                            join p in files on f.Path equals p into r
                            from p in r.DefaultIfEmpty()
                            where p == null
                            select f.Path;

                var test    = query.ToList();
                var count   = test.Count;
                int current = 0;

                Parallel.ForEach(test, (path) => {
                    Interlocked.Increment(ref current);
                    if (DateTimeExt.EverySecond(ref _lastUpdate))
                    {
                        StatusUpdate(StatusModel.Update(null, $"Removing Deleted Files {current} of {count}"));
                    }
                    XmlDal.CacheModel.RemoveFile(path);
                });
            }
            finally
            {
                stopWatch.Stop();
            }
            StatusUpdate(StatusModel.AddPersistentDetail("Checking for Deleted Files, Complete... {0}", stopWatch.Duration.Value.ToShortReadableString()));
        }
        public void Execute(List <string> files)
        {
            var stopwatch = new Stopwatch(MethodBase.GetCurrentMethod().Name, true);

            try
            {
                Callback.StatusCallback(StatusModel.StartStopWatch);

                var count   = files.Count;
                var current = 0;

                var start = DateTime.Now;
                Parallel.ForEach(files, (filePath) =>
                {
                    Interlocked.Increment(ref current);

                    var fileStart = DateTime.Now;

                    var detail = new BuildInitializeFileDetail();
                    var file   = XmlDal.CacheModel.GetFile(filePath, ref detail);
                    if (file == null)
                    {
                        Log.WriteError("ProcessSockDrawer.RunItem FilePath returned a null file!", typeof(ProcessSockDrawerLoop).FullName, MethodBase.GetCurrentMethod().Name);
                        return;
                    }

                    var result = new ProcessFileDetail();
                    result.InitializeFileDetail = detail;

                    var buildStart           = DateTime.Now;
                    result.Detail            = FileService.Build(file, false);
                    result.TotalDuration     = DateTime.Now - fileStart;
                    result.TotalTimeDuration = DateTime.Now - start;
                    result.AverageTimeMS     = result.TotalTimeDuration.TotalMilliseconds / current;
                    if (DateTimeExt.EverySecond(ref _lastUpdate))
                    {
                        var totalTimeMS = (DateTime.Now - start).TotalMilliseconds;
                        Callback.StatusCallback(StatusModel.Update($@"Processing FileData {current} of {count}",
                                                                   result.ToString()
                                                                   ));
                    }
                });

                Callback.StatusCallback(StatusModel.StopStopWatch);
            }
            finally
            {
                stopwatch.Stop();
            }
        }
        private static void ClearCache(CallbackModel model)
        {
            var stopWatch = new Stopwatch(MethodBase.GetCurrentMethod().Name);

            try
            {
                if (model.ForceClear)
                {
                    var count       = 0;
                    var _lastUpdate = DateTime.Now;
                    var total       = model.Files.Count();

                    var query = from f in XmlDal.CacheModel.Files
                                join p in model.Files on f.Path equals p
                                select f;

                    foreach (var file in query)
                    {
                        Interlocked.Increment(ref count);
                        if (DateTimeExt.EverySecond(ref _lastUpdate))
                        {
                            model.StatusCallback(StatusModel.Update(null, $"Clearing FileData Cache {count} of {total}"));
                        }

                        if (file != null)
                        {
                            file.Clear();
                        }
                    }
                }
            }
            finally
            {
                stopWatch.Stop();
            }
            model.StatusCallback(StatusModel.AddPersistentDetail("Clearing FileData Cache, Complete... {0}", stopWatch.Duration.Value.ToShortReadableString()));
        }