/// <summary>
        /// Returns
        /// </summary>
        public static void BuildDocument(DocumentModel model)
        {
            var stopwatch = new Stopwatch("BuildDocument");

            try
            {
                FileService.Build(model.File, true);
            }
            finally
            {
                stopwatch.Stop();
            }
        }
        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();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Used to quickly rebuild the active documents cache.  Used to speed up development and exercise code
        /// </summary>
        public static void RebuildActiveDocument()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                OutputService.ClearOutputWindow?.Invoke();
                PerformanceService.StartEvent($"Rebuild Active Document for {Current.Model.File.Path}");
                Thread.CurrentThread.Name = "Rebuild.Active.Document";

                var file = Current.Model.File;
                file.Clear();
                FileService.Build(file, true);
                file.IsCached_Lazy_NetworkMessages = false;
                NetworkService.CheckNetworkMessages(file, View.StatusUpdate, "Source");

                // Invalidate will force dependent Components to Render
                file.DataController.Invalidate();
            });
        }