/// <summary>
        /// Shows the medium.
        /// </summary>
        private MediumControl LoadMediumControl(bool setData)
        {
            phContent.Controls.Clear();

            // The component to load control for
            MediumComponent component = null;

            // Get the current medium type
            EntityTypeCache entityType = null;

            if (MediumEntityTypeId.HasValue)
            {
                entityType = EntityTypeCache.Read(MediumEntityTypeId.Value);
            }

            foreach (var serviceEntry in MediumContainer.Instance.Components)
            {
                var mediumComponent = serviceEntry.Value.Value;

                // Default to first component
                if (component == null)
                {
                    component = mediumComponent;
                }

                // If invalid entity type, exit (and use first component found)
                if (entityType == null)
                {
                    break;
                }
                else if (entityType.Id == mediumComponent.EntityType.Id)
                {
                    component = mediumComponent;
                    break;
                }
            }

            if (component != null)
            {
                phContent.Controls.Clear();
                var mediumControl = component.GetControl(false);
                mediumControl.ID              = "commControl";
                mediumControl.IsTemplate      = true;
                mediumControl.ValidationGroup = btnSave.ValidationGroup;
                phContent.Controls.Add(mediumControl);

                if (setData)
                {
                    mediumControl.MediumData = MediumData;
                }

                // Set the medium in case it wasn't already set or the previous component type was not found
                MediumEntityTypeId = component.EntityType.Id;

                return(mediumControl);
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the medium.
        /// </summary>
        private MediumControl LoadMediumControl(bool setData)
        {
            if (setData)
            {
                phContent.Controls.Clear();
            }

            // The component to load control for
            MediumComponent component  = null;
            string          mediumName = string.Empty;

            // Get the current medium type
            EntityTypeCache entityType = null;

            if (MediumEntityTypeId.HasValue)
            {
                entityType = EntityTypeCache.Read(MediumEntityTypeId.Value);
            }

            foreach (var serviceEntry in MediumContainer.Instance.Components)
            {
                var mediumComponent = serviceEntry.Value;

                // Default to first component
                if (component == null)
                {
                    component  = mediumComponent.Value;
                    mediumName = mediumComponent.Metadata.ComponentName + " ";
                }

                // If invalid entity type, exit (and use first component found)
                if (entityType == null)
                {
                    break;
                }
                else if (entityType.Id == mediumComponent.Value.EntityType.Id)
                {
                    component  = mediumComponent.Value;
                    mediumName = mediumComponent.Metadata.ComponentName + " ";
                    break;
                }
            }

            if (component != null)
            {
                var mediumControl = component.GetControl(!_fullMode);
                mediumControl.ID                    = "commControl";
                mediumControl.IsTemplate            = false;
                mediumControl.AdditionalMergeFields = this.AdditionalMergeFields.ToList();
                mediumControl.ValidationGroup       = btnSubmit.ValidationGroup;
                phContent.Controls.Add(mediumControl);

                if (setData)
                {
                    mediumControl.MediumData = MediumData;
                }

                // Set the medium in case it wasn't already set or the previous component type was not found
                MediumEntityTypeId = component.EntityType.Id;

                if (component.Transport == null || !component.Transport.IsActive)
                {
                    nbInvalidTransport.Text    = string.Format("The {0}medium does not have an active transport configured. The communication will not be delivered until the transport is configured correctly.", mediumName);
                    nbInvalidTransport.Visible = true;
                }
                else
                {
                    nbInvalidTransport.Visible = false;
                }

                cbBulk.Visible = _fullMode && component.SupportsBulkCommunication;

                return(mediumControl);
            }

            return(null);
        }