Beispiel #1
0
        /// <summary>
        /// Job that updates the JobPulse setting with the current date/time.
        /// This will allow us to notify an admin if the jobs stop running.
        ///
        /// Called by the <see cref="IScheduler" /> when a
        /// <see cref="ITrigger" /> fires that is associated with
        /// the <see cref="IJob" />.
        /// </summary>
        public virtual void  Execute(IJobExecutionContext context)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                AttributeService      attribService         = new AttributeService();
                AttributeValueService attributeValueService = new AttributeValueService();

                Rock.Core.Attribute      jobPulseAttrib      = attribService.GetGlobalAttribute("JobPulse");
                Rock.Core.AttributeValue jobPulseAttribValue = jobPulseAttrib.AttributeValues.FirstOrDefault();

                // create attribute value if one does not exist
                if (jobPulseAttribValue == null)
                {
                    jobPulseAttribValue             = new AttributeValue();
                    jobPulseAttribValue.AttributeId = jobPulseAttrib.Id;
                    attributeValueService.Add(jobPulseAttribValue, null);
                }

                // store todays date and time
                jobPulseAttribValue.Value = DateTime.Now.ToString();

                // save attribute
                attributeValueService.Save(jobPulseAttribValue, null);
            }
        }
        void modalDetails_SaveClick(object sender, EventArgs e)
        {
            int attributeId = 0;

            if (hfId.Value != string.Empty && !Int32.TryParse(hfId.Value, out attributeId))
            {
                attributeId = 0;
            }

            if (attributeId != 0 && phEditControl.Controls.Count > 0)
            {
                AttributeService attributeService = new AttributeService();
                var attribute = attributeService.Get(attributeId);

                AttributeValueService attributeValueService = new AttributeValueService();
                var attributeValue = attributeValueService.GetByAttributeIdAndEntityId(attributeId, _entityId).FirstOrDefault();
                if (attributeValue == null)
                {
                    attributeValue             = new Rock.Core.AttributeValue();
                    attributeValue.AttributeId = attributeId;
                    attributeValue.EntityId    = _entityId;
                    attributeValueService.Add(attributeValue, CurrentPersonId);
                }

                var fieldType = Rock.Web.Cache.FieldType.Read(attribute.FieldTypeId);
                attributeValue.Value = fieldType.Field.ReadValue(phEditControl.Controls[0]);

                attributeValueService.Save(attributeValue, CurrentPersonId);

                Rock.Web.Cache.Attribute.Flush(attributeId);
            }

            modalDetails.Hide();

            BindGrid();
        }
        void modalDetails_SaveClick( object sender, EventArgs e )
        {
            int attributeId = 0;
            if ( hfId.Value != string.Empty && !Int32.TryParse( hfId.Value, out attributeId ) )
                attributeId = 0;

            if ( attributeId != 0 && phEditControl.Controls.Count > 0 )
            {
                AttributeService attributeService = new AttributeService();
                var attribute = attributeService.Get( attributeId );

                AttributeValueService attributeValueService = new AttributeValueService();
                var attributeValue = attributeValueService.GetByAttributeIdAndEntityId( attributeId, _entityId ).FirstOrDefault();
                if ( attributeValue == null )
                {
                    attributeValue = new Rock.Core.AttributeValue();
                    attributeValue.AttributeId = attributeId;
                    attributeValue.EntityId = _entityId;
                    attributeValueService.Add( attributeValue, CurrentPersonId );
                }

                var fieldType = Rock.Web.Cache.FieldType.Read( attribute.FieldTypeId );
                attributeValue.Value = fieldType.Field.ReadValue( phEditControl.Controls[0] );

                attributeValueService.Save(attributeValue, CurrentPersonId);

                Rock.Web.Cache.Attribute.Flush( attributeId );

            }

            modalDetails.Hide();

            BindGrid();
        }