Esempio n. 1
0
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            var cmd  = new NewGroupCommand(Command.MainWindowCommandInterface, Command.GetSelection());
            var item = new CommandToolStripMenuItem(cmd);

            base.DropDownItems.Add(item);

            T[] groups = VMGroup <T> .GroupsInCache(Command.GetSelection()[0].Connection.Cache);

            if (groups.Length > 0)
            {
                base.DropDownItems.Add(new ToolStripSeparator());
            }

            Array.Sort(groups);

            for (int index = 0; index < groups.Length; index++)
            {
                T   group    = groups[index];
                var menuText = index < 9
                    ? String.Format(Messages.DYNAMIC_MENUITEM_WITH_ACCESS_KEY, index + 1, group.Name)
                    : String.Format(Messages.DYNAMIC_MENUITEM_WITHOUT_ACCESS_KEY, group.Name);

                var cmdGroup  = new AssignGroupToVMCommand(Command.MainWindowCommandInterface, Command.GetSelection(), group, menuText);
                var itemGroup = new CommandToolStripMenuItem(cmdGroup);
                if (Command.GetSelection().Count == 1 &&
                    VMGroup <T> .VmToGroup((VM)Command.GetSelection()[0].XenObject).opaque_ref == group.opaque_ref)
                {
                    itemGroup.Checked = true;
                }
                base.DropDownItems.Add(itemGroup);
            }
        }
Esempio n. 2
0
        public NewGroupCommandResult New([FromBody] NewGroupCommand command)
        {
            command.setRequestHost(HttpContext.Request.Host.ToString());

            _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Group = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method });

            NewGroupCommandResult result = (NewGroupCommandResult)_groupHandler.Handle(command);

            _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Group = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode });

            HttpContext.Response.StatusCode = result.Code;

            return(result);
        }
        protected override void OnDropDownOpening(EventArgs e)
        {
            base.DropDownItems.Clear();

            var cmd  = new NewGroupCommand(Command.MainWindowCommandInterface, Command.GetSelection());
            var item = new CommandToolStripMenuItem(cmd);

            base.DropDownItems.Add(item);

            T[] groups = VMGroup <T> .GroupsInCache(Command.GetSelection()[0].Connection.Cache);

            if (groups.Length > 0)
            {
                base.DropDownItems.Add(new ToolStripSeparator());
            }

            Array.Sort(groups);

            for (int index = 0, offset = 0; index < groups.Length; index++)
            {
                T group = groups[index];

                /* do not add unsupported policies to the drop down for VMSS */
                XenAPI.VMSS policy = group as VMSS;
                if (policy != null && policy.policy_type == policy_backup_type.snapshot_with_quiesce)
                {
                    List <VM> vms          = Command.GetSelection().AsXenObjects <VM>();
                    bool      doNotInclude = vms.Any(vm => !vm.allowed_operations.Contains(vm_operations.snapshot_with_quiesce));
                    if (doNotInclude)
                    {
                        offset--;
                        continue;
                    }
                }

                var menuText = (index + offset) < 9
                    ? String.Format(Messages.DYNAMIC_MENUITEM_WITH_ACCESS_KEY, (index + offset) + 1, group.Name)
                    : String.Format(Messages.DYNAMIC_MENUITEM_WITHOUT_ACCESS_KEY, group.Name);

                var cmdGroup  = new AssignGroupToVMCommand(Command.MainWindowCommandInterface, Command.GetSelection(), group, menuText);
                var itemGroup = new CommandToolStripMenuItem(cmdGroup);
                if (Command.GetSelection().Count == 1 &&
                    VMGroup <T> .VmToGroup((VM)Command.GetSelection()[0].XenObject).opaque_ref == group.opaque_ref)
                {
                    itemGroup.Checked = true;
                }
                base.DropDownItems.Add(itemGroup);
            }
        }