protected override bool Initialize()
        {
            if (_theProcessor == null)
            {
                // Force a read context to be opened.  When developing the retry mechanism
                // for startup when the DB was down, there were problems when the type
                // initializer for enumerated values were failng first.  For some reason,
                // when the database went back online, they would still give exceptions.
                // changed to force the processor to open a dummy DB connect and cause an
                // exception here, instead of getting to the enumerated value initializer.
                using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    readContext.Dispose();
                }

                var xp = new WorkQueueManagerExtensionPoint();
                IWorkQueueManagerExtensionPoint[] extensions = CollectionUtils.Cast <IWorkQueueManagerExtensionPoint>(xp.CreateExtensions()).ToArray();
                foreach (IWorkQueueManagerExtensionPoint extension in extensions)
                {
                    try
                    {
                        extension.OnInitializing(this);
                    }
                    catch (Exception)
                    {
                        ThreadRetryDelay = (int)_retryDelay.TotalMilliseconds;
                        return(false);
                    }
                }

                _theProcessor = new WorkQueueProcessor(_threadCount, ThreadStop, Name);
            }

            return(true);
        }
 private void EnsureWebDeleteExtensionsLoaded()
 {
     if (_extensions == null)
     {
         WebDeleteProcessorExtensionPoint xp = new WebDeleteProcessorExtensionPoint();
         _extensions = CollectionUtils.Cast <IWebDeleteProcessorExtension>(xp.CreateExtensions());
     }
 }
        private void UpdateServerGroups()
        {
            if (!_component.ShowCheckBoxes)
            {
                return;
            }

            UpdateServerGroups(CollectionUtils.Cast <TreeNode>(_aeTreeView.Nodes));
        }
Example #4
0
        /// <summary>
        /// Persists an in-memory abstract action model to the XML model.
        /// </summary>
        /// <remarks>
        /// This method functions as a counterpart to <see cref="BuildAbstractActionModel"/>. The specified abstract action model
        /// (created by <see cref="BuildAbstractActionModel"/>, or potentially modified further) is flattened and its nodes
        /// written out to the XML mode, replacing any existing model at the same qualified site. This allows action model
        /// configuration interfaces to make changes to the action model.
        /// </remarks>
        /// <param name="namespace">A namespace to qualify the site.</param>
        /// <param name="site">The site.</param>
        /// <param name="abstractActionModel">The abstract action model to be persisted.</param>
        /// <returns>An <see cref="ActionModelNode"/> representing the root of the action model.</returns>
        public void PersistAbstractActionModel(string @namespace, string site, ActionModelRoot abstractActionModel)
        {
            // do one time initialization
            if (_actionModelXmlDoc == null)
            {
                Initialize();
            }

            XmlElement separatorTemplate = _actionModelXmlDoc.CreateElement("separator");

            string actionModelId = string.Format("{0}:{1}", @namespace, site);

            XmlElement xmlActionModel = FindXmlActionModel(actionModelId);

            if (xmlActionModel != null)
            {
                // clear the action model
                List <XmlNode> childrenToClear = CollectionUtils.Cast <XmlNode>(xmlActionModel.ChildNodes);
                foreach (XmlNode childNode in childrenToClear)
                {
                    xmlActionModel.RemoveChild(childNode);
                }
            }
            else
            {
                // add a new action model
                this.GetActionModelsNode().AppendChild(xmlActionModel = CreateXmlActionModel(actionModelId));
            }

            ActionModelNode[] leafNodes = abstractActionModel.GetLeafNodesInOrder();
            for (int n = 0; n < leafNodes.Length; n++)
            {
                ActionModelNode leafNode = leafNodes[n];
                if (leafNode is ActionNode)
                {
                    xmlActionModel.AppendChild(CreateXmlAction(_actionModelXmlDoc, ((ActionNode)leafNode).Action));
                }
                else if (leafNode is SeparatorNode)
                {
                    xmlActionModel.AppendChild(separatorTemplate.Clone());
                }
            }

            if (!_temporary)
            {
                this.ActionModelsXml = _actionModelXmlDoc;
                this.Save();
            }
        }
        private void UpdateServerGroups(IEnumerable <TreeNode> nodes)
        {
            if (!_component.ShowCheckBoxes)
            {
                return;
            }

            foreach (TreeNode node in nodes)
            {
                if (node.Tag is IServerTreeGroup)
                {
                    UpdateServerGroups(CollectionUtils.Cast <TreeNode>(node.Nodes));
                    UpdateServerGroup(node);
                }
            }
        }
        protected IList <IDeleteStudyProcessorExtension> LoadExtensions()
        {
            if (_extensions == null)
            {
                _extensions = CollectionUtils.Cast <IDeleteStudyProcessorExtension>(
                    new DeleteStudyProcessorExtensionPoint().CreateExtensions());

                DeleteStudyContext context = CreatePluginProcessingContext();
                foreach (IDeleteStudyProcessorExtension ext in _extensions)
                {
                    ext.Initialize(context);
                }
            }

            return(_extensions);
        }
Example #7
0
        private IList <TokenRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array tokenRowData      = null;
            Array tokenRowDataRange = Array.CreateInstance(typeof(TokenRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <TokenRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityTokenSummary> tokens    = service.ListAuthorityTokens();
                List <TokenRowData>           tokenRows = CollectionUtils.Map <AuthorityTokenSummary, TokenRowData>(
                    tokens, delegate(AuthorityTokenSummary token)
                {
                    TokenRowData row = new TokenRowData(token);
                    return(row);
                });

                tokenRowData = CollectionUtils.ToArray(tokenRows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, tokenRowData.Length);

                Array.Copy(tokenRowData, startRowIndex, tokenRowDataRange, 0, copyLength);

                if (copyLength < tokenRowDataRange.Length)
                {
                    tokenRowDataRange = resizeArray(tokenRowDataRange, copyLength);
                }
            };

            if (tokenRowData != null)
            {
                resultCount = tokenRowData.Length;
            }

            return(CollectionUtils.Cast <TokenRowData>(tokenRowDataRange));
        }
        private void LoadFolderSystems()
        {
            var folderSystems = FolderExplorerComponentSettings.Default.ApplyFolderSystemsOrder(
                CollectionUtils.Cast <IFolderSystem>(new FolderSystemExtensionPoint().CreateExtensions()));

            var fsNodes = CollectionUtils.Map <IFolderSystem, FolderSystemConfigurationNode>(
                folderSystems,
                fs => new FolderSystemConfigurationNode(fs, FolderExplorerComponentSettings.Default.IsFolderSystemReadOnly(fs)));

            CollectionUtils.ForEach(
                fsNodes,
                node => node.ModifiedChanged += ((sender, args) => this.Modified = true));

            _folderSystems = new BindingList <FolderSystemConfigurationNode>(fsNodes);

            // Set the initial selected folder system
            if (_folderSystems.Count > 0)
            {
                this.SelectedFolderSystemIndex = 0;
            }
        }
Example #9
0
 protected SerializerBase(OptionsBase options)
 {
     _hooks  = CollectionUtils.Cast <IJsmlSerializerHook>(new JsmlSerializerHookExtensionPoint().CreateExtensions());
     Options = options;
 }
Example #10
0
        private IList <UserGroupRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array authorityRowData;
            Array authorityRowDataRange = Array.CreateInstance(typeof(UserGroupRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <UserGroupRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityGroupSummary> list         = service.ListAllAuthorityGroups();
                IList <AuthorityGroupSummary> filteredList = new List <AuthorityGroupSummary>();

                if (!string.IsNullOrEmpty(GroupName))
                {
                    string matchString = GroupName;

                    while (matchString.StartsWith("*") || matchString.StartsWith("?"))
                    {
                        matchString = matchString.Substring(1);
                    }
                    while (matchString.EndsWith("*") || matchString.EndsWith("?"))
                    {
                        matchString = matchString.Substring(0, matchString.Length - 1);
                    }

                    matchString = matchString.Replace("*", "[A-Za-z0-9]*");
                    matchString = matchString.Replace("?", ".");

                    foreach (AuthorityGroupSummary group in list)
                    {
                        if (Regex.IsMatch(group.Name, matchString, RegexOptions.IgnoreCase))
                        {
                            filteredList.Add(group);
                        }
                    }
                }
                else
                {
                    filteredList = list;
                }

                List <UserGroupRowData> rows = CollectionUtils.Map <AuthorityGroupSummary, UserGroupRowData>(
                    filteredList, delegate(AuthorityGroupSummary group)
                {
                    UserGroupRowData row =
                        new UserGroupRowData(service.LoadAuthorityGroupDetail(group.AuthorityGroupRef));
                    return(row);
                });

                authorityRowData = CollectionUtils.ToArray(rows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, authorityRowData.Length);

                Array.Copy(authorityRowData, startRowIndex, authorityRowDataRange, 0, copyLength);

                if (copyLength < authorityRowDataRange.Length)
                {
                    authorityRowDataRange = resizeArray(authorityRowDataRange, copyLength);
                }
            };

            resultCount = authorityRowData.Length;

            return(CollectionUtils.Cast <UserGroupRowData>(authorityRowDataRange));
        }
 private void OnFolderViewSelectionUpdatePublished(object sender, EventArgs e)
 {
     _component.Selection = new PathSelection(CollectionUtils.Cast <FolderObject>(_folderView.SelectedItems));
 }
            public override void OnDrawing()
            {
                base.OnDrawing();

                if (!_isDirty)
                {
                    return;
                }

                IOverlayGraphicsProvider overlayGraphicsProvider = this.ParentPresentationImage as IOverlayGraphicsProvider;

                if (overlayGraphicsProvider == null)
                {
                    return;
                }

                IList <ShowAnglesToolGraphic> freeAngleGraphics = CollectionUtils.Cast <ShowAnglesToolGraphic>(this.Graphics);

                if (this.Visible && _selectedLine != null && _selectedLine.Points.Count == 2)
                {
                    _selectedLine.CoordinateSystem = CoordinateSystem.Source;
                    try
                    {
                        foreach (IGraphic otherLineGraphic in overlayGraphicsProvider.OverlayGraphics)
                        {
                            IPointsGraphic otherLine = GetLine(otherLineGraphic);
                            if (otherLine != null && !ReferenceEquals(otherLine, _selectedLine) && otherLine.Points.Count == 2)
                            {
                                ShowAnglesToolGraphic showAnglesToolGraphic;
                                if (freeAngleGraphics.Count > 0)
                                {
                                    freeAngleGraphics.Remove(showAnglesToolGraphic = freeAngleGraphics[0]);
                                }
                                else
                                {
                                    this.Graphics.Add(showAnglesToolGraphic = new ShowAnglesToolGraphic());
                                }

                                showAnglesToolGraphic.CoordinateSystem = otherLine.CoordinateSystem = CoordinateSystem.Source;
                                try
                                {
                                    showAnglesToolGraphic.SetEndpoints(_selectedLine.Points[0], _selectedLine.Points[1], otherLine.Points[0], otherLine.Points[1]);
                                }
                                finally
                                {
                                    showAnglesToolGraphic.ResetCoordinateSystem();
                                    otherLine.ResetCoordinateSystem();
                                }
                            }
                        }
                    }
                    finally
                    {
                        _selectedLine.ResetCoordinateSystem();
                    }
                }

                foreach (IGraphic freeAngleGraphic in freeAngleGraphics)
                {
                    this.Graphics.Remove(freeAngleGraphic);
                    freeAngleGraphic.Dispose();
                }
            }
Example #13
0
 private List <IFolderSystem> GetFolderSystems()
 {
     return(CollectionUtils.Cast <IFolderSystem>(new TFolderSystemExtensionPoint().CreateExtensions()));
 }