示例#1
0
        // refresh the wizard UI for the Running page
        public void CheckStatus()
        {
            // retrieve the job that invoked the agent
            Sitecore.Diagnostics.Assert.IsNotNullOrEmpty(this.JobHandle, "JobHandle");
            Sitecore.Handle handle = Sitecore.Handle.Parse(this.JobHandle);
            Sitecore.Diagnostics.Assert.IsNotNull(handle, "handle");
            Sitecore.Jobs.Job job = Sitecore.Jobs.JobManager.GetJob(handle);
            Sitecore.Diagnostics.Assert.IsNotNull(job, "job");

            // if the job agent finished
            if (job.Status.State != Sitecore.Jobs.JobState.Running)
            {
                // if the job or agent failed
                if (job.Status.Failed)
                {
                    this.Result.Text = "Job failed.";
                }
                else
                {
                    // otherwise assume the agent succeeded
                    this.Result.Text = "Job succeeded.";
                }

                // report the most recent message written by the agent
                if (job.Status.Messages.Count > 0)
                {
                    this.Result.Text += " Last status message: " + job.Status.Messages[job.Status.Messages.Count - 1];
                }

                // move the wizard to its final page
                base.Active = "LastPage";
            }
            else
            {
                // the agent is still running (or queueud?)
                // report the most recent message written by the agent
                if (job.Status.Messages.Count > 0)
                {
                    this.Status.Text = "Last status message: " + job.Status.Messages[job.Status.Messages.Count - 1];
                }
                else
                {
                    this.Status.Text = "No status messages available.";
                }

                // refresh the wizard UI for the Running page in 100ms
                Sitecore.Web.UI.Sheer.SheerResponse.Timer("CheckStatus", 100);
            }
        }
        /// <summary>
        /// Publish Item
        /// </summary>
        /// <param name="Id"></param>
        private void PublishItem(Guid Id)
        {
            using (new Sitecore.SecurityModel.SecurityDisabler())
            {
                Database webdb    = Sitecore.Configuration.Factory.GetDatabase("web");
                Database masterdb = Sitecore.Configuration.Factory.GetDatabase("master");

                ClearSitecoreDatabaseCache(masterdb);

                Sitecore.Data.Items.Item masterItem = masterdb.GetItem(new ID(Id));

                // target databases
                Database[] databases = new Database[1] {
                    webdb
                };

                Sitecore.Handle publishHandle = Sitecore.Publishing.PublishManager.PublishItem(masterItem, databases, webdb.Languages, true, false);

                ClearSitecoreDatabaseCache(webdb);
            }
        }