コード例 #1
0
        public override void Initialize(SessionMapElement element, SessionInfo sessionInfo)
        {
            _sessionId = sessionInfo.SessionId;
            _hostName  = element.Name;

            base.Initialize(element, sessionInfo);
        }
コード例 #2
0
        private static string GetImageKey(SessionMapElement element)
        {
            switch (element.ElementType)
            {
            case ElementType.Session:
                return("Session");

            case ElementType.Workers:
                return("SessionResources");

            case ElementType.Assets:
                return("SessionAssets");

            case ElementType.Machine:
                return("Computer");

            case ElementType.RemotePrintQueues:
                return("PrintServer");

            case ElementType.RemotePrintQueue:
                return("RemotePrinter");

            case ElementType.Device:
            case ElementType.Worker:
            case ElementType.Activity:
                return(element.ElementSubtype);

            default:
                return(null);
            }
        }
コード例 #3
0
        private void SessionMapElementReceived(object sender, SessionMapElementEventArgs e)
        {
            // We only care about updates that pertain to the current session ID
            SessionMapElement element = e.MapElement;

            if (element.SessionId != _sessionId)
            {
                return;
            }

            if (assetStatus_GridView.InvokeRequired)
            {
                assetStatus_GridView.Invoke(new Action(() => SessionMapElementReceived(sender, e)));
                return;
            }

            switch (element.ElementType)
            {
            case ElementType.Machine:
            case ElementType.Device:
            case ElementType.RemotePrintQueue:
                UpdateRow(element);
                break;

            default:
                if (element.State == RuntimeState.Error || element.State == RuntimeState.Warning)
                {
                    UpdateRow(element);
                }
                break;
            }
        }
コード例 #4
0
            public void Update(SessionMapElement element)
            {
                Name        = element.Name;
                ElementType = element.ElementType.ToString();
                Details     = element.Message;
                State       = element.State;
                switch (element.State)
                {
                case RuntimeState.Validated:
                    Icon = Icons.Images["Available"];
                    break;

                case RuntimeState.Warning:
                    Icon = Icons.Images["Warning"];
                    break;

                case RuntimeState.Error:
                    Icon = Icons.Images["Unavailable"];
                    break;

                case RuntimeState.Validating:
                default:
                    Icon = Icons.Images["Unknown"];
                    break;
                }
            }
コード例 #5
0
        private void SessionExecutionTreeView_ContextMenuOpening(object sender, TreeViewContextMenuOpeningEventArgs e)
        {
            if (e.Node == null || e.Node.Tag == null)
            {
                e.Cancel = true;
                return;
            }

            SessionMapElement element = e.Node.Tag as SessionMapElement;

            switch (element.ElementType)
            {
            // Virtual hosts can show the menu if they are starting up
            case ElementType.Machine:
                e.Cancel = (element.State != RuntimeState.Starting);
                break;

            // Simulators can show the menu if they are starting up
            case ElementType.Device:
                if (element.ElementSubtype == "JediSimulator")
                {
                    e.Cancel = (element.State != RuntimeState.Starting);
                }
                else
                {
                    // Only display if it's Running or Offline
                    e.Cancel = (element.State != RuntimeState.Running && element.State != RuntimeState.Offline);
                }
                break;

            // Worker type virtual resources can show the menu if they are running or paused
            case ElementType.Worker:
                List <string> workerResourceTypes = new List <string>()
                {
                    "OfficeWorker", "AdminWorker", "CitrixWorker"
                };
                if (workerResourceTypes.Contains(element.ElementSubtype))
                {
                    e.Cancel = (element.State != RuntimeState.Running && element.State != RuntimeState.Paused);
                }
                else
                {
                    e.Cancel = true;
                }
                break;

            // No menus for anything else
            default:
                e.Cancel = true;
                break;
            }

            // If we are going to allow the menu to be shown, configure it and save the selected element for later
            if (!e.Cancel)
            {
                ConfigureContextMenu(element);
                _contextMenuElement = element;
            }
        }
コード例 #6
0
 private void SessionMapElementReceived(SessionMapElement element)
 {
     if (element.ElementType == ElementType.Session)
     {
         SessionId            = element.SessionId;
         sessionId_Label.Text = element.SessionId;
     }
 }
コード例 #7
0
        private void SessionExecutionTreeView_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
        {
            if (e.Node != null)
            {
                // Get the element information for the selected node
                SessionMapElement element = e.Node.Tag as SessionMapElement;

                SessionMapElementSelected?.Invoke(this, new SessionMapElementEventArgs(element));
            }
        }
コード例 #8
0
 private void ProcessOrphans(RadTreeNode node, SessionMapElement element)
 {
     lock (_orphans)
     {
         // Find any nodes that should be connected to the node we just added
         List <SessionMapElement> children = _orphans.Where(n => n.ParentId == element.Id).ToList();
         foreach (SessionMapElement child in children)
         {
             AddChild(node, child);
             _orphans.Remove(child);
         }
     }
 }
コード例 #9
0
        private void UpdateRow(SessionMapElement element)
        {
            AssetStatusRow row = _statusRows.FirstOrDefault(n => n.Id == element.Id);

            if (row != null)
            {
                row.Update(element);
            }
            else
            {
                AssetStatusRow newRow = new AssetStatusRow(element);
                newRow.Update(element);
                _statusRows.Add(newRow);
            }
        }
コード例 #10
0
        /// <summary>
        /// Updates an existing node with new data from a SessionMapElement.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="element">The element.</param>
        private void ConfigureNode(RadTreeNode node, SessionMapElement element)
        {
            node.Tag      = element;
            node.ImageKey = GetImageKey(element);
            SetContextMenu(node, element.ElementType);

            if (!string.IsNullOrWhiteSpace(element.Message))
            {
                node.Text = "{0} ({1})".FormatWith(GetName(element), element.Message);
            }
            else
            {
                node.Text = GetName(element);
            }
        }
コード例 #11
0
        private void restartVM_MenuItem_Click(object sender, EventArgs e)
        {
            switch (_contextMenuElement.ElementType)
            {
            case ElementType.Machine:
                SessionClient.Instance.RestartMachine(_contextMenuElement.SessionId, _contextMenuElement.Name, false);
                break;

            case ElementType.Device:
                SessionClient.Instance.RestartAsset(_contextMenuElement.SessionId, _contextMenuElement.Name);
                break;
            }

            _contextMenuElement = null;
        }
コード例 #12
0
        private void ConfigureContextMenu(SessionMapElement element)
        {
            switch (element.ElementType)
            {
            case ElementType.Device:
                switch (element.State)
                {
                case RuntimeState.Running:
                    suspendAsset_MenuItem.Visibility = ElementVisibility.Visible;
                    resumeAsset_MenuItem.Visibility  = ElementVisibility.Collapsed;
                    break;

                default:
                    suspendAsset_MenuItem.Visibility = ElementVisibility.Collapsed;
                    resumeAsset_MenuItem.Visibility  = ElementVisibility.Visible;
                    break;
                }
                break;

            case ElementType.Machine:
                restartVM_MenuItem.Visibility    = ElementVisibility.Visible;
                pauseWorker_MenuItem.Visibility  = ElementVisibility.Collapsed;
                resumeWorker_MenuItem.Visibility = ElementVisibility.Collapsed;
                haltWorker_MenuItem.Visibility   = ElementVisibility.Collapsed;
                break;

            case ElementType.Worker:
                if (element.State == RuntimeState.Running)
                {
                    pauseWorker_MenuItem.Visibility  = ElementVisibility.Visible;
                    resumeWorker_MenuItem.Visibility = ElementVisibility.Collapsed;
                }
                else
                {
                    resumeWorker_MenuItem.Visibility = ElementVisibility.Visible;
                    pauseWorker_MenuItem.Visibility  = ElementVisibility.Collapsed;
                }

                haltWorker_MenuItem.Visibility = ElementVisibility.Visible;
                restartVM_MenuItem.Visibility  = ElementVisibility.Collapsed;
                break;

            default:
                break;
            }
        }
コード例 #13
0
        private RadTreeNode AddChild(RadTreeNode node, SessionMapElement childElement)
        {
            // If this is a metadata item, determine whether we should actually show it
            if (childElement.ElementType == ElementType.Activity)
            {
                string subtype = (node.Tag as SessionMapElement).ElementSubtype;
                VirtualResourceType resourceType = EnumUtil.Parse <VirtualResourceType>(subtype);
                if (!resourceType.UsesPlugins())
                {
                    return(null);
                }
            }

            RadTreeNode childNode = CreateElementNode(childElement);

            node.Nodes.Add(childNode);
            return(childNode);
        }
コード例 #14
0
        private RadTreeNode CreateElementNode(SessionMapElement element)
        {
            RadTreeNode node = new RadTreeNode();

            ConfigureNode(node, element);

            switch (element.ElementType)
            {
            case ElementType.Session:
            case ElementType.Workers:
            case ElementType.Assets:
            case ElementType.RemotePrintQueues:
                node.Expanded = true;
                break;
            }

            return(node);
        }
コード例 #15
0
        private void SessionMapElementReceived(SessionMapElement element)
        {
            if (element == null)
            {
                return;
            }

            // If this node already exists, update it
            RadTreeNode existingNode = FindNode(element.Id);

            if (existingNode != null)
            {
                ConfigureNode(existingNode, element);
            }
            else
            {
                // If there is no parent, add it as a root node
                if (element.ParentId == Guid.Empty)
                {
                    RadTreeNode node = CreateElementNode(element);
                    RootNode.Nodes.Add(node);
                    ProcessOrphans(node, element);
                }
                else
                {
                    // Look for the parent
                    RadTreeNode parentNode = FindNode(element.ParentId);
                    if (parentNode != null)
                    {
                        RadTreeNode node = AddChild(parentNode, element);
                        if (node != null)
                        {
                            ProcessOrphans(node, element);
                        }
                    }
                    else
                    {
                        // This is an orphan
                        _orphans.Add(element);
                    }
                }
            }
        }
コード例 #16
0
        private string GetName(SessionMapElement element)
        {
            switch (element.ElementType)
            {
            case ElementType.Session:
                return(element.Name);

            case ElementType.Workers:
                return("Virtual Resources");

            case ElementType.Assets:
                return("Test Assets");

            case ElementType.RemotePrintQueues:
                return("Remote Print Queues");

            default:
                return(element.Name);
            }
        }
コード例 #17
0
        private void ClearSession(string sessionId)
        {
            // LINQ gets messy, so do this the old fashioned way
            RadTreeNode subRootNode = null;

            foreach (RadTreeNode node in RootNode.Nodes.ToList())
            {
                SessionMapElement element = node.Tag as SessionMapElement;
                if (element != null && element.SessionId == sessionId)
                {
                    subRootNode = node;
                    break;
                }
            }

            if (subRootNode != null)
            {
                RootNode.Nodes.Remove(subRootNode);
            }
        }
コード例 #18
0
        /// <summary>
        /// Creates a session status control for the specified <see cref="SessionMapElement"/>.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public static SessionStatusControlBase Create(SessionMapElement element)
        {
            if (element == null)
            {
                // No element provided.  Return null.
                return(null);
            }

            switch (element.ElementType)
            {
            default:
                if (GlobalSettings.IsDistributedSystem)
                {
                    return(new GenericMapElementControl());
                }
                else
                {
                    return(new GenericMapElementControlLite());
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// Initializes this instance with the specified <see cref="SessionMapElement" />.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="sessionControl">The session execution control used to start/stop etc.</param>
        /// <exception cref="ControlTypeMismatchException">
        /// Thrown when an object of incorrect type is passed to this instance.
        /// </exception>
        public override void Initialize(SessionMapElement element, ControlSessionExecution sessionControl)
        {
            try
            {
                if (element == null || sessionControl == null)
                {
                    throw new ArgumentNullException("Element and SessionControl arguments must not be null");
                }

                _element   = element;
                _sessionId = element.SessionId;

                elementInfoCompositeControl.Initialize(element, sessionControl);

                _sessionExecutionControl = sessionControl;
                _sessionExecutionControl.RefreshRequested += _sessionExecutionControl_RefreshRequested;
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Initialize", ex);
            }
        }
コード例 #20
0
        /// <summary>
        /// Initializes this instance with the specified <see cref="SessionMapElement" />.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="sessionControl">The session execution control used to start/stop etc.</param>
        /// <exception cref="ControlTypeMismatchException">
        /// Thrown when an object of incorrect type is passed to this instance.
        /// </exception>
        public void Initialize(SessionMapElement element, ControlSessionExecution sessionControl)
        {
            try
            {
                if (element == null || sessionControl == null)
                {
                    throw new ArgumentNullException("Element and SessionControl arguments must not be null");
                }

                _element   = element;
                _sessionId = element.SessionId;
                RefreshSessionInfo();

                _sessionExecutionControl = sessionControl;
                _sessionExecutionControl.RefreshRequested += _sessionExecutionControl_RefreshRequested;

                Task.Factory.StartNew(() => LoadElementInfoControl(element, _sessionInfo));
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Initialize", ex);
            }
        }
コード例 #21
0
        /// <summary>
        /// Loads the element information control into the display
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="sessionInfo">The session information.</param>
        private void LoadElementInfoControl(SessionMapElement element, SessionInfo sessionInfo)
        {
            _elementInfoControl = null;
            var title = "{0} {1}".FormatWith(element.ElementSubtype, element.Name);

            groupBox_ElementInfo.InvokeIfRequired(c =>
            {
                radPanel_ElementInfoHolder.Text = string.Empty;
                groupBox_ElementInfo.Text       = "Loading {0}...".FormatWith(title);
            });

            var elementInfoControl = ObjectFactory.Create <ElementInfoControlBase>(element.ElementType);

            elementInfoControl.Initialize(element, sessionInfo);

            var revisedTitle = elementInfoControl.GetTitle();

            radPanel_ElementInfoHolder.InvokeIfRequired(c =>
            {
                this.SuspendLayout();
                elementInfoControl.Dock = DockStyle.Fill;
                radPanel_ElementInfoHolder.Controls.Add(elementInfoControl);

                if (!string.IsNullOrEmpty(revisedTitle) && revisedTitle != title)
                {
                    groupBox_ElementInfo.Text = revisedTitle;
                }
                else
                {
                    groupBox_ElementInfo.Text = title;
                }
                this.ResumeLayout();
            }
                                                        );
            _elementInfoControl = elementInfoControl;
        }
コード例 #22
0
 private void haltWorker_MenuItem_Click(object sender, EventArgs e)
 {
     SessionClient.Instance.HaltWorker(_contextMenuElement.SessionId, _contextMenuElement.Name);
     _contextMenuElement = null;
 }
コード例 #23
0
 public AssetStatusRow(SessionMapElement element)
 {
     Id = element.Id;
 }
コード例 #24
0
 public override void Initialize(SessionMapElement element, SessionInfo sessionInfo)
 {
     RefreshData();
 }
コード例 #25
0
 /// <summary>
 /// Initializes this instance with the specified <see cref="SessionMapElement"/>.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <exception cref="ControlTypeMismatchException">
 /// Thrown when an object of incorrect type is passed to this instance.
 /// </exception>
 public virtual void Initialize(SessionMapElement element, ControlSessionExecution control)
 {
     throw new NotImplementedException();
 }
コード例 #26
0
 public virtual void Initialize(SessionMapElement element, SessionInfo sessionInfo)
 {
     // Do nothing by default
 }
コード例 #27
0
 public override void Initialize(SessionMapElement element, SessionInfo sessionInfo)
 {
     _sessionId = sessionInfo.SessionId;
     _deviceId  = element.Name;
     RefreshData();
 }
コード例 #28
0
 private void suspendAsset_MenuItem_Click(object sender, EventArgs e)
 {
     SessionClient.Instance.TakeAssetOffline(_contextMenuElement.SessionId, _contextMenuElement.Name);
     _contextMenuElement = null;
 }
コード例 #29
0
 private void resumeAsset_MenuItem_Click(object sender, EventArgs e)
 {
     SessionClient.Instance.BringAssetOnline(_contextMenuElement.SessionId, _contextMenuElement.Name);
     _contextMenuElement = null;
 }
コード例 #30
0
 /// <summary>
 /// Handles the Click event of the disableCRC_MenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void disablePaperless_MenuItem_Click(object sender, EventArgs e)
 {
     SetDeviceCRC(false);
     _contextMenuElement = null;
 }