/// <summary>
        /// Constructor for ServiceLock processor.
        /// </summary>
        /// <param name="numberThreads">The number of threads allocated to the processor.</param>
        /// <param name="terminationEvent">Stop signal</param>
        public ServiceLockProcessor(int numberThreads, ManualResetEvent terminationEvent)
        {
            _terminationEvent = terminationEvent;
            _threadStop       = new ManualResetEvent(false);

            _threadPool = new ServiceLockThreadPool(numberThreads);
            _threadPool.ThreadPoolName = "ServiceLock Pool";

            ServiceLockFactoryExtensionPoint ep = new ServiceLockFactoryExtensionPoint();

            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the ServiceLock processor.
                Platform.Log(LogLevel.Warn, "No ServiceLockFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IServiceLockProcessorFactory factory = obj as IServiceLockProcessorFactory;
                    if (factory != null)
                    {
                        ServiceLockTypeEnum type = factory.GetServiceLockType();
                        _extensions.Add(type, factory);
                    }
                    else
                    {
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                    }
                }
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            IList <ServiceLockTypeEnum> types = ServiceLockTypeEnum.GetAll();

            TypeDropDownList.Items.Add(new ListItem(SR.All));
            foreach (ServiceLockTypeEnum t in types)
            {
                TypeDropDownList.Items.Add(new ListItem(ServerEnumDescription.GetLocalizedDescription(t), t.Lookup));
            }

            EditServiceLockDialog.ServiceLockUpdated += AddEditServiceLockDialog_ServiceLockUpdated;

            // setup child controls
            GridPagerTop.InitializeGridPager(SR.GridPagerServiceSingleItem, SR.GridPagerServiceMultipleItems, ServiceLockGridViewControl.TheGrid, delegate { return(ServiceLockGridViewControl.ServiceLocks != null ? ServiceLockGridViewControl.ServiceLocks.Count : 0); }, ImageServerConstants.GridViewPagerPosition.Top);
            ServiceLockGridViewControl.Pager = GridPagerTop;

            StatusFilter.Items.Add(new ListItem(SR.All));
            StatusFilter.Items.Add(new ListItem(SR.Enabled));
            StatusFilter.Items.Add(new ListItem(SR.Disabled));

            FileSystemsConfigurationController fileSystemController = new FileSystemsConfigurationController();
            IList <Model.Filesystem>           fileSystems          = fileSystemController.GetAllFileSystems();

            foreach (Model.Filesystem fs in fileSystems)
            {
                FileSystemFilter.Items.Add(new ListItem(fs.Description, fs.Key.ToString()));
            }

            ConfirmEditDialog.Confirmed += ConfirmEditDialog_Confirmed;
        }
        public void Insert(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription)
        {
            var item = new ServiceLockTypeEnum();

            item.Guid = Guid;

            item.EnumX = EnumX;

            item.Lookup = Lookup;

            item.Description = Description;

            item.LongDescription = LongDescription;


            item.Save(UserName);
        }
        public void Update(Guid Guid, short EnumX, string Lookup, string Description, string LongDescription)
        {
            var item = new ServiceLockTypeEnum();
            item.MarkOld();
            item.IsLoaded = true;

            item.Guid = Guid;

            item.EnumX = EnumX;

            item.Lookup = Lookup;

            item.Description = Description;

            item.LongDescription = LongDescription;

            item.Save(UserName);
        }
예제 #5
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.
        /// </remarks>
        public void LoadServiceLocks()
        {
            var criteria = new ServiceLockSelectCriteria();

            var controller = new ServiceLockConfigurationController();

            if (TypeDropDownList.SelectedValue != SR.All)
            {
                criteria.ServiceLockTypeEnum.EqualTo(ServiceLockTypeEnum.GetEnum(TypeDropDownList.SelectedValue));
            }

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

            if (FileSystemFilter.SelectedIndex != -1)
            {
                var fsController   = new FileSystemsConfigurationController();
                var fileSystemKeys = new List <ServerEntityKey>();
                foreach (ListItem fileSystem in FileSystemFilter.Items)
                {
                    if (fileSystem.Selected)
                    {
                        fileSystemKeys.Add(new ServerEntityKey("FileSystem", fileSystem.Value));
                    }
                }

                IList <Filesystem> fs = fsController.GetFileSystems(fileSystemKeys);

                if (fs != null)
                {
                    var entityKeys = new List <ServerEntityKey>();
                    foreach (Filesystem f in fs)
                    {
                        entityKeys.Add(f.Key);
                    }
                    criteria.FilesystemKey.In(entityKeys);
                }
            }

            if (PartitionFilter.SelectedIndex != -1)
            {
                var partitionKeys = new List <ServerEntityKey>();
                foreach (ListItem partition in PartitionFilter.Items)
                {
                    if (partition.Selected)
                    {
                        partitionKeys.Add(new ServerEntityKey("ServerPartition", partition.Value));
                    }
                }

                criteria.ServerPartitionKey.In(partitionKeys);
            }

            IList <ServiceLock> services = controller.GetServiceLocks(criteria);

            List <ServiceLock> sortedServices =
                CollectionUtils.Sort(services, delegate(ServiceLock a, ServiceLock b)
            {
                if (a == null)
                {
                    if (b == null)
                    {
                        // If both null, they're equal.
                        return(0);
                    }
                    // If x is null and y is not null, y
                    // is greater.
                    return(-1);
                }
                // If a is not null...
                if (b == null)
                {
                    // ...and b is null, x is greater.
                    return(1);
                }
                // just compare
                if (a.Filesystem == null || b.Filesystem == null)
                {
                    return(String.Compare(a.ServiceLockTypeEnum.Description, b.ServiceLockTypeEnum.Description, StringComparison.Ordinal));
                }

                int retVal = String.Compare(a.Filesystem.Description, b.Filesystem.Description, StringComparison.Ordinal);
                if (retVal == 0)
                {
                    return(String.Compare(a.ServiceLockTypeEnum.Description, b.ServiceLockTypeEnum.Description, StringComparison.Ordinal));
                }
                return(retVal);
            });


            var items = new ServiceLockCollection
            {
                sortedServices
            };

            ServiceLockGridViewControl.ServiceLocks = items;

            ServiceLockGridViewControl.RefreshCurrentPage();
        }