コード例 #1
0
        private void WorkerMethod()
        {
            Thread.CurrentThread.Name = "ContentManager.WorkerMethod";
            using (TraceSources.ContentManagerSource.TraceActivity("Worker starting"))
            {
                foreach (Trigger trigger in this._workQueue.GetConsumingEnumerable())
                {
                    Trigger discardedTrigger;

                    while (this._workQueue.TryTake(out discardedTrigger))
                    {
                        TraceSources.ContentManagerSource.TraceInformation(
                            "Skipping redundant rebuild trigger: {0}",
                            discardedTrigger.Reason);
                    }

                    TraceSources.ContentManagerSource.TraceInformation("Rebuilding content: {0}", trigger.Reason);

                    try
                    {
                        ContentBuilder builder = new ContentBuilder();
                        builder.StateChanged          += (o, s) => this._state = s;
                        builder.Template               = this._template;
                        builder.IgnoreVersionComponent = this._ignoreVersionComponent;
                        string folder = Guid.NewGuid().ToBase36String();
                        string tmpDir = Path.Combine(this._contentPath, folder);

                        // TODO maybe pass in a ScopedFileProvider wrapping a DirectoryFileProvider here (instead of tmpdir)
                        builder.Build(this._repositoryPath, tmpDir);

                        // this acts as the "commit"
                        try
                        {
                            this.SetCurrentContentFolder(folder);
                        }
                        catch (Exception ex)
                        {
                            TraceSources.ContentManagerSource.TraceCritical(
                                "An unhandled exception of type {0} occured while setting current content folder: {1}",
                                ex.GetType().Name,
                                ex.ToString());
                            throw;
                        }
                    }
                    catch (Exception ex)
                    {
                        TraceSources.ContentManagerSource.TraceError(
                            "An unhandled exception of type {0} occured while rebuilding content: {1}",
                            ex.GetType().Name,
                            ex.ToString());
                    }
                }
            }
        }
コード例 #2
0
        private void WorkerMethod()
        {
            Thread.CurrentThread.Name = "ContentManager.WorkerMethod";
            using (TraceSources.ContentManagerSource.TraceActivity("Worker starting"))
            {

                foreach (Trigger trigger in this._workQueue.GetConsumingEnumerable())
                {
                    Trigger discardedTrigger;

                    while (this._workQueue.TryTake(out discardedTrigger))
                        TraceSources.ContentManagerSource.TraceInformation("Skipping redundant rebuild trigger: {0}",
                                                                           discardedTrigger.Reason);

                    TraceSources.ContentManagerSource.TraceInformation("Rebuilding content: {0}", trigger.Reason);

                    try
                    {
                        ContentBuilder builder = new ContentBuilder();
                        builder.StateChanged += (o, s) => this._state = s;
                        builder.Template = this._template;
                        builder.IgnoreVersionComponent = this._ignoreVersionComponent;
                        string folder = Guid.NewGuid().ToBase36String();
                        string tmpDir = Path.Combine(this._contentPath, folder);
                        builder.Build(this._repositoryPath, tmpDir);

                        // this acts as the "commit"
                        try
                        {
                            this.SetCurrentContentFolder(folder);
                        }
                        catch (Exception ex)
                        {
                            TraceSources.ContentManagerSource.TraceCritical(
                                                                            "An unhandled exception of type {0} occured while setting current content folder: {1}",
                                                                            ex.GetType().Name,
                                                                            ex.ToString());
                            throw;

                        }
                    }
                    catch (Exception ex)
                    {
                        TraceSources.ContentManagerSource.TraceError(
                                                                     "An unhandled exception of type {0} occured while rebuilding content: {1}",
                                                                     ex.GetType().Name,
                                                                     ex.ToString());
                    }
                }
            }
        }