public override OfficeWorkerDetail CreateDetail(VirtualResource resource)
        {
            AdminWorker worker = resource as AdminWorker;

            AdminWorkerDetail detail = new AdminWorkerDetail
            {
                ResourceId             = worker.VirtualResourceId,
                ResourceType           = EnumUtil.Parse <VirtualResourceType>(worker.ResourceType),
                Name                   = worker.Name,
                Description            = worker.Description,
                InstanceCount          = worker.InstanceCount,
                Platform               = worker.Platform,
                Enabled                = worker.Enabled,
                RandomizeActivities    = false,
                RandomizeStartupDelay  = false,
                MinStartupDelay        = 0,
                MaxStartupDelay        = 0,
                RandomizeActivityDelay = false,
                MinActivityDelay       = 0,
                MaxActivityDelay       = 0,
                RepeatCount            = 1,
                ExecutionMode          = worker.ExecutionMode
            };

            CreateMetadataDetail(worker, detail);
            return(detail);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes this instance with the specified object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <exception cref="ControlTypeMismatchException">
        /// Thrown when an object of incorrect type is passed to this instance.
        ///   </exception>
        public override void Initialize(object entity)
        {
            _adminWorker = entity as AdminWorker;
            if (_adminWorker == null)
            {
                throw new ControlTypeMismatchException(entity, typeof(AdminWorker));
            }

            // Load the configurations into the helper class
            foreach (var item in _adminWorker.VirtualResourceMetadataSet)
            {
                WorkerExecutionPlan plan = null;
                if (item.ExecutionPlan == null)
                {
                    plan = new WorkerExecutionPlan();
                }
                else
                {
                    plan = LegacySerializer.DeserializeDataContract <WorkerExecutionPlan>(item.ExecutionPlan);
                }

                _mainConfigurations.Add(new WorkerActivityConfiguration(item, plan));
            }

            // Load the activities into the binding list
            activity_TabControl.SelectTab(main_TabPage);
            _selectedPhase = ResourceExecutionPhase.Main;
            activity_GridView.BestFitColumns();

            // Set up data bindings
            name_TextBox.DataBindings.Add("Text", _adminWorker, "Name");
            description_TextBox.DataBindings.Add("Text", _adminWorker, "Description");

            platform_ComboBox.SetPlatform(_adminWorker.Platform, VirtualResourceType.AdminWorker);
            testcaseid_numericUpDown.Value = _adminWorker.TestCaseId;
            ConfigureEnableAllButton();
            CreateActivityDropDownMenu();

            RefreshGrid();
        }
Exemplo n.º 3
0
        private void AddToken_Click(object sender, EventArgs e)
        {
            try
            {
                // Sends all the token creation data to admin-auth-worker
                var res = AdminWorker.AddToken((int)yearcount.Value, (int)monthcount.Value, (int)weekcount.Value, (int)daycount.Value, (int)licquantity.Value, (int)level.Value, addSecurity.Text);

                if (res.Success)
                {
                    MessageBox.Show("The following licenses have been copied to the clipboard:\n" + string.Join("\n", res.TokenList));
                    Clipboard.SetText(string.Join("\n", res.TokenList));
                }
                else
                {
                    MessageBox.Show(res.ErrorMessage);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }