Esempio n. 1
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Submits a project.
        /// </summary>
        /// <param name="manifest">
        /// A SubmissionManifest that describes the items to be submitted and
        /// where they should be sent.
        /// </param>
        public void SubmitProject(SubmissionManifest manifest)
        {
            hasResponse        = false;
            submissionResponse = null;

            string[] missingFiles = VerifyRequiredFiles(
                manifest.Assignment, manifest.SubmittableItems);

            if (missingFiles != null)
            {
                throw new RequiredFilesMissingException(missingFiles);
            }

            Uri transport = manifest.ResolvedTransport;

            IProtocol protocol =
                ProtocolRegistry.CreateProtocolInstance(transport.Scheme);

            if (protocol != null)
            {
                protocol.Submit(manifest);

                if (protocol.HasResponse)
                {
                    hasResponse        = true;
                    submissionResponse = protocol.SubmissionResponse;
                }
            }
            else
            {
                throw new ProtocolNotRegisteredException(transport.Scheme);
            }
        }
        //  -------------------------------------------------------------------
        /// <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);
            }
        }
        //  -------------------------------------------------------------------
        /// <summary>
        /// Submits a project.
        /// </summary>
        /// <param name="manifest">
        /// A SubmissionManifest that describes the items to be submitted and
        /// where they should be sent.
        /// </param>
        public void SubmitProject(SubmissionManifest manifest)
        {
            hasResponse = false;
            submissionResponse = null;

            string[] missingFiles = VerifyRequiredFiles(
                manifest.Assignment, manifest.SubmittableItems);

            if(missingFiles != null)
            {
                throw new RequiredFilesMissingException(missingFiles);
            }

            Uri transport = manifest.ResolvedTransport;

            IProtocol protocol =
                ProtocolRegistry.CreateProtocolInstance(transport.Scheme);

            if (protocol != null)
            {
                protocol.Submit(manifest);

                if (protocol.HasResponse)
                {
                    hasResponse = true;
                    submissionResponse = protocol.SubmissionResponse;
                }
            }
            else
            {
                throw new ProtocolNotRegisteredException(transport.Scheme);
            }
        }