Пример #1
0
        /// <summary>
        /// Loads the workflow types.
        /// </summary>
        private void LoadWorkflowTypes()
        {
            _ddlWorkflowType.Items.Clear();

            if (!Required)
            {
                _ddlWorkflowType.Items.Add(new ListItem(string.Empty, Rock.Constants.None.IdValue));
            }

            using (var rockContext = new RockContext())
            {
                var workflowTypeService = new Rock.Model.WorkflowTypeService(rockContext);

                var workflowTypes = workflowTypeService.Queryable().AsNoTracking()
                                    .Where(t =>
                                           t.Category != null &&
                                           t.IsActive.HasValue &&
                                           t.IsActive.Value)
                                    .OrderBy(t => t.Category.Name)
                                    .ThenBy(t => t.Name)
                                    .Select(a => new { a.Id, CategoryName = a.Category.Name, a.Name })
                                    .AsNoTracking()
                                    .ToList();
                foreach (var t in workflowTypes)
                {
                    _ddlWorkflowType.Items.Add(new ListItem(string.Format("{0}: {1}", t.CategoryName, t.Name), t.Id.ToString().ToUpper()));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
 /// </summary>
 /// <param name="workflowTypeGuid">The group type GUID.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public WorkflowFieldAttribute(string workflowTypeGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null)
     : base(name, description, required, defaultValue, category, order, key, typeof(Rock.Field.Types.WorkflowFieldType).FullName)
 {
     if (!string.IsNullOrWhiteSpace(workflowTypeGuid))
     {
         Guid guid = Guid.Empty;
         if (Guid.TryParse(workflowTypeGuid, out guid))
         {
             using (var rockContext = new Rock.Data.RockContext())
             {
                 var workflowType = new Rock.Model.WorkflowTypeService(rockContext).Get(guid);
                 if (workflowType != null)
                 {
                     var configValue = new Field.ConfigurationValue(workflowType.Id.ToString());
                     FieldConfigurationValues.Add("workflowtype", configValue);
                 }
             }
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefinedValueFieldAttribute" /> class.
 /// </summary>
 /// <param name="workflowTypeGuid">The group type GUID.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The description.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="defaultValue">The default value.</param>
 /// <param name="category">The category.</param>
 /// <param name="order">The order.</param>
 /// <param name="key">The key.</param>
 public WorkflowFieldAttribute( string workflowTypeGuid = "", string name = "", string description = "", bool required = true, string defaultValue = "", string category = "", int order = 0, string key = null )
     : base(name, description, required, defaultValue, category, order, key, typeof( Rock.Field.Types.WorkflowFieldType ).FullName)
 {
     if ( !string.IsNullOrWhiteSpace( workflowTypeGuid ) )
     {
         Guid guid = Guid.Empty;
         if ( Guid.TryParse( workflowTypeGuid, out guid ) )
         {
             using ( var rockContext = new Rock.Data.RockContext() )
             {
                 var workflowType = new Rock.Model.WorkflowTypeService( rockContext ).Get( guid );
                 if ( workflowType != null )
                 {
                     var configValue = new Field.ConfigurationValue( workflowType.Id.ToString() );
                     FieldConfigurationValues.Add( "workflowtype", configValue );
                 }
             }
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Loads the workflow types.
        /// </summary>
        private void LoadWorkflowTypes()
        {
            _ddlWorkflowType.Items.Clear();

            if ( !Required )
            {
                _ddlWorkflowType.Items.Add( new ListItem( string.Empty, Rock.Constants.None.IdValue ) );
            }

            using ( var rockContext = new RockContext() )
            {
                var workflowTypeService = new Rock.Model.WorkflowTypeService( rockContext );

                var workflowTypes = workflowTypeService.Queryable().AsNoTracking()
                    .Where( t =>
                        t.Category != null &&
                        t.IsActive.HasValue &&
                        t.IsActive.Value )
                    .OrderBy( t => t.Category.Name)
                    .ThenBy( t => t.Name )
                    .ToList();
                foreach ( var t in workflowTypes )
                {
                    _ddlWorkflowType.Items.Add( new ListItem( string.Format( "{0}:{1}", t.Category.Name, t.Name), t.Id.ToString().ToUpper() ) );
                }
            }
        }