Exemple #1
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Called when the form is loaded to initialize various UI components.
        /// </summary>
        /// <param name="sender">
        /// The form being loaded.
        /// </param>
        /// <param name="e">
        /// The event arguments describing the event.
        /// </param>
        private void SubmitterWizard_Load(object sender, EventArgs e)
        {
            // Add submission targets to the tree view.

            foreach (ITarget target in engine.Root.Children)
            {
                TargetTreeNode node = new TargetTreeNode(target);
                submissionTargetsTree.Nodes.Add(node);
                ExpandLocalGroups(node);
            }

            UpdateSubmittablesField();
            UpdateNextEnablement();
        }
Exemple #2
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Expands all of the local (non-imported) assignment groups in the
        /// tree view. Delay-loaded groups are not automatically expanded since
        /// they potentially require slower network access.
        /// </summary>
        /// <param name="parent">
        /// The node that should be expanded.
        /// </param>
        private void ExpandLocalGroups(TargetTreeNode parent)
        {
            if (parent.Target.IsLoaded)
            {
                parent.PopulateChildren(false);
                parent.Expand();

                foreach (TreeNode child in parent.Nodes)
                {
                    TargetTreeNode targetChild = child as TargetTreeNode;

                    if (targetChild != null)
                    {
                        ExpandLocalGroups(targetChild);
                    }
                }
            }
        }
Exemple #3
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Used to update the availability of the Next button based on whether
        /// the current selections and field values are valid.
        /// </summary>
        private void UpdateNextEnablement()
        {
            bool enabled = true;

            TargetTreeNode selNode = submissionTargetsTree.SelectedNode
                                     as TargetTreeNode;

            if (selNode == null || !selNode.Target.IsActionable)
            {
                enabled = false;
            }
            else if (usernameField.Text.Length == 0)
            {
                enabled = false;
            }
            else if (submittables.Length == 0)
            {
                enabled = false;
            }

            nextButton.Enabled = enabled;
        }
Exemple #4
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Performs the actual submission of the projects.
        /// </summary>
        private void DoSubmission()
        {
            TargetTreeNode node =
                (TargetTreeNode)submissionTargetsTree.SelectedNode;

            SubmissionManifest parameters = new SubmissionManifest();

            parameters.Assignment       = (ITargetAssignment)node.Target;
            parameters.Username         = usernameField.Text;
            parameters.Password         = passwordField.Text;
            parameters.SubmittableItems = submittables;

            Exception exception = null;

            BackgroundWorkerDialog dialog = new BackgroundWorkerDialog(
                Messages.SendingSubmission, true,
                delegate(object sender, DoWorkEventArgs e)
            {
                try
                {
                    engine.SubmitProject(parameters);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            });

            dialog.ShowDialog(this);

            if (exception == null)
            {
                string message = engine.HasResponse ?
                                 Messages.ResponseClose : Messages.NoResponseClose;

                SetSubmissionResults(SubmissionResultCode.Success, message);
            }
            else if (exception is RequiredFilesMissingException)
            {
                RequiredFilesMissingException e =
                    (RequiredFilesMissingException)exception;

                StringBuilder builder = new StringBuilder();
                builder.Append(Messages.WizardMissingFilesPreamble);

                foreach (string file in e.MissingFiles)
                {
                    builder.Append(String.Format(
                                       Messages.WizardMissingFilesListItem, file));
                }

                SetSubmissionResults(SubmissionResultCode.Incomplete,
                                     builder.ToString());
            }
            else if (exception is ProtocolNotRegisteredException)
            {
                ProtocolNotRegisteredException e =
                    (ProtocolNotRegisteredException)exception;

                SetSubmissionResults(SubmissionResultCode.Error,
                                     String.Format(Messages.ProtocolNotFound, e.Scheme));
            }
            else
            {
                SetSubmissionResults(SubmissionResultCode.Error,
                                     exception.Message);
            }
        }