Exemplo n.º 1
0
        protected override bool OnServerSideEvaluate()
        {
            String deviceAE = GetControlValidationValue(ControlToValidate);

            if (String.IsNullOrEmpty(deviceAE))
            {
                ErrorMessage = ValidationErrors.AETitleCannotBeEmpty;
                return(false);
            }

            if (OriginalAeTitle.Equals(deviceAE))
            {
                return(true);
            }

            var controller = new DeviceConfigurationController();
            var criteria   = new DeviceSelectCriteria();

            criteria.AeTitle.EqualTo(deviceAE);
            criteria.ServerPartitionKey.EqualTo(Partition);

            IList <Device> list = controller.GetDevices(criteria);

            foreach (var d in list)
            {
                if (string.Compare(d.AeTitle, deviceAE, false, CultureInfo.InvariantCulture) == 0)
                {
                    ErrorMessage = String.Format(ValidationErrors.AETitleIsInUse, deviceAE);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the devices for the partition based on the filters specified in the filter panel.
        /// </summary>
        /// <remarks>
        /// This method only reloads and binds the list bind to the internal grid. <seealso cref="Refresh"/> should be called
        /// to explicit update the list in the grid.
        /// <para>
        /// This is intentionally so that the list can be reloaded so that it is available to other controls during postback.  In
        /// some cases we may not want to refresh the list if there's no change. Calling <seealso cref="Refresh"/> will
        /// give performance hit as the data will be transfered back to the browser.
        ///
        /// </para>
        /// </remarks>
        public void LoadDevices()
        {
            if (ServerPartition == null)
            {
                return;
            }

            var criteria = new DeviceSelectCriteria();

            // only query for device in this partition
            criteria.ServerPartitionKey.EqualTo(ServerPartition.GetKey());

            if (!String.IsNullOrEmpty(AETitleFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.AeTitle,
                                                  SearchHelper.LeadingAndTrailingWildCard(AETitleFilter.TrimText));
            }

            if (!String.IsNullOrEmpty(DescriptionFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.Description,
                                                  SearchHelper.LeadingAndTrailingWildCard(DescriptionFilter.TrimText));
            }

            if (!String.IsNullOrEmpty(IPAddressFilter.TrimText))
            {
                QueryHelper.SetGuiStringCondition(criteria.IpAddress,
                                                  SearchHelper.TrailingWildCard(IPAddressFilter.TrimText));
            }

            if (StatusFilter.SelectedIndex != 0)
            {
                criteria.Enabled.EqualTo(StatusFilter.SelectedIndex == 1);
            }

            if (DHCPFilter.SelectedIndex != 0)
            {
                criteria.Dhcp.EqualTo(DHCPFilter.SelectedIndex == 1);
            }

            if (DeviceTypeFilter.SelectedIndex > -1)
            {
                var types = new List <DeviceTypeEnum>();
                foreach (ListItem item in DeviceTypeFilter.Items)
                {
                    if (item.Selected)
                    {
                        types.Add(DeviceTypeEnum.GetEnum(item.Value));
                    }
                }
                criteria.DeviceTypeEnum.In(types);
            }

            DeviceGridViewControl1.Devices = _theController.GetDevices(criteria);
            DeviceGridViewControl1.RefreshCurrentPage();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load the devices for the partition based on the filters specified in the filter panel.
        /// </summary>
        /// <remarks>
        /// This method only reloads and binds the list bind to the internal grid. <seealso cref="UpdateUI()"/> should be called
        /// to explicit update the list in the grid.
        /// <para>
        /// This is intentionally so that the list can be reloaded so that it is available to other controls during postback.  In
        /// some cases we may not want to refresh the list if there's no change. Calling <seealso cref="UpdateUI()"/> will
        /// give performance hit as the data will be transfered back to the browser.
        ///
        /// </para>
        /// </remarks>
        public void LoadDevices()
        {
            DeviceSelectCriteria criteria = new DeviceSelectCriteria();

            // only query for device in this partition
            criteria.ServerPartitionKey.EqualTo(Partition.GetKey());

            if (!String.IsNullOrEmpty(AETitleFilter.TrimText))
            {
                string key = AETitleFilter.TrimText + "%";
                key = key.Replace("*", "%");
                key = key.Replace("?", "_");
                criteria.AeTitle.Like(key);
            }

            if (!String.IsNullOrEmpty(DescriptionFilter.TrimText))
            {
                string key = DescriptionFilter.TrimText + "%";
                key = key.Replace("*", "%");
                key = key.Replace("?", "_");
                criteria.Description.Like(key);
            }

            if (!String.IsNullOrEmpty(IPAddressFilter.TrimText))
            {
                string key = IPAddressFilter.TrimText + "%";
                key = key.Replace("*", "%");
                key = key.Replace("?", "_");
                criteria.IpAddress.Like(key);
            }

            if (DHCPFilter.SelectedIndex != 0)
            {
                if (DHCPFilter.SelectedIndex == 1)
                {
                    criteria.Dhcp.EqualTo(true);
                }
                else
                {
                    criteria.Dhcp.EqualTo(false);
                }
            }

            if (DeviceTypeFilter.SelectedIndex > -1)
            {
                List <DeviceTypeEnum> types = new List <DeviceTypeEnum>();
                foreach (ListItem item in DeviceTypeFilter.Items)
                {
                    if (item.Selected)
                    {
                        types.Add(DeviceTypeEnum.GetEnum(item.Value));
                    }
                }
                criteria.DeviceTypeEnum.In(types);
            }

            // only enabled devices and devices that allow retrieves.
            criteria.Enabled.EqualTo(true);
            criteria.AllowRetrieve.EqualTo(true);

            DeviceGridPanel.Devices = _theController.GetDevices(criteria);
            DeviceGridPanel.RefreshCurrentPage();
        }