コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                string itemId = PageParameter("serviceJobId");
                if (!string.IsNullOrWhiteSpace(itemId))
                {
                    ShowDetail("serviceJobId", int.Parse(itemId));
                }
                else
                {
                    pnlDetails.Visible = false;
                }
            }

            if (pnlDetails.Visible)
            {
                var job = new ServiceJob {
                    Id = int.Parse(hfId.Value), Class = ddlJobTypes.SelectedValue ?? "Rock.Jobs.JobPulse"
                };
                if (job.Id > 0)
                {
                    job.LoadAttributes();
                    phAttributes.Controls.Clear();
                    Rock.Attribute.Helper.AddEditControls(job, phAttributes, true);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Builds a Quartz Job for a specified <see cref="Rock.Model.ServiceJob">Job</see>
        /// </summary>
        /// <param name="job">The <see cref="Rock.Model.ServiceJob"/> to create a Quarts Job for.</param>
        /// <returns>A object that implements the <see cref="Quartz.IJobDetail"/> interface</returns>
        public IJobDetail BuildQuartzJob( ServiceJob job )
        {
            // build the type object, will depend if the class is in an assembly or the App_Code folder
            Type type = null;
            if ( job.Assembly == string.Empty || job.Assembly == null )
            {
                type = BuildManager.GetType( job.Class, false );
            }
            else
            {
                string thetype = string.Format( "{0}, {1}", job.Class, job.Assembly );
                type = Type.GetType( thetype );
            }

            // load up job attributes (parameters) 
            job.LoadAttributes();

            JobDataMap map = new JobDataMap();

            foreach ( KeyValuePair<string, List<Rock.Model.AttributeValue>> attrib in job.AttributeValues )
            {
                map.Add( attrib.Key, attrib.Value[0].Value );
            }

            // create the quartz job object
            IJobDetail jobDetail = JobBuilder.Create( type )
            .WithDescription( job.Id.ToString() )
            .WithIdentity( new Guid().ToString(), job.Name )
            .UsingJobData( map )
            .Build();

            return jobDetail;
        }
コード例 #3
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                string itemId = PageParameter( "serviceJobId" );
                if ( !string.IsNullOrWhiteSpace( itemId ) )
                {
                    ShowDetail( "serviceJobId", int.Parse( itemId ) );
                }
                else
                {
                    pnlDetails.Visible = false;
                }
            }

            if ( pnlDetails.Visible )
            {
                var job = new ServiceJob { Id = int.Parse( hfId.Value ), Class = ddlJobTypes.SelectedValue ?? "Rock.Jobs.JobPulse" };
                if ( job.Id > 0 )
                {
                    job.LoadAttributes();
                    phAttributes.Controls.Clear();
                    Rock.Attribute.Helper.AddEditControls( job, phAttributes, true );
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Builds a Quartz Job for a specified <see cref="Rock.Model.ServiceJob">Job</see>
        /// </summary>
        /// <param name="job">The <see cref="Rock.Model.ServiceJob"/> to create a Quarts Job for.</param>
        /// <returns>A object that implements the <see cref="Quartz.IJobDetail"/> interface</returns>
        public IJobDetail BuildQuartzJob( ServiceJob job )
        {
            // build the type object, will depend if the class is in an assembly or the App_Code folder
            Type type = null;

            if ( string.IsNullOrWhiteSpace(job.Assembly) )
            {
                // first try to load the job type from the App_Code folder
                type = BuildManager.GetType( job.Class, false );

                if (type == null)
                {
                    // if it couldn't be loaded from the app_code folder, look in Rock.dll
                    string thetype = string.Format( "{0}, {1}", job.Class, this.GetType().Assembly.FullName );
                    type = Type.GetType( thetype );
                }
            }
            else
            {
                // if an assembly is specified, load the type from that
                string thetype = string.Format( "{0}, {1}", job.Class, job.Assembly );
                type = Type.GetType( thetype );
            }

            // load up job attributes (parameters)
            job.LoadAttributes();

            JobDataMap map = new JobDataMap();

            foreach ( var attrib in job.AttributeValues )
            {
                map.Add( attrib.Key, attrib.Value.Value );
            }

            // create the quartz job object
            IJobDetail jobDetail = JobBuilder.Create( type )
            .WithDescription( job.Id.ToString() )
            .WithIdentity( job.Guid.ToString(), job.Name )
            .UsingJobData( map )
            .Build();

            return jobDetail;
        }
コード例 #5
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                ShowDetail(PageParameter("serviceJobId").AsInteger());
            }

            if (pnlDetails.Visible)
            {
                var job = new ServiceJob {
                    Id = int.Parse(hfId.Value), Class = ddlJobTypes.SelectedValue ?? "Rock.Jobs.JobPulse"
                };

                job.LoadAttributes();
                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls(job, phAttributes, true, BlockValidationGroup);
            }
        }
コード例 #6
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                ShowDetail( PageParameter( "serviceJobId" ).AsInteger() );
            }

            if ( pnlDetails.Visible )
            {
                var job = new ServiceJob { Id = int.Parse( hfId.Value ), Class = ddlJobTypes.SelectedValue ?? "Rock.Jobs.JobPulse" };

                job.LoadAttributes();
                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls( job, phAttributes, true, BlockValidationGroup );
            }
        }