Example #1
0
        /// <summary>
        /// Delegate used to publish the element to a local folder</summary>
        private void PublishLocally()
        {
            var publishPath = GetPublishFolder();

            if (string.IsNullOrEmpty(publishPath))
            {
                return;
            }

            var files = BuildPackage();

            try
            {
                UploadState = PackageUploadHandle.State.Copying;
                Uploading   = true;
                // begin publishing to local directory
                var remapper = new CustomNodePathRemapper(DynamoViewModel.Model.CustomNodeManager,
                                                          DynamoModel.IsTestMode);
                var builder = new PackageDirectoryBuilder(new MutatingFileSystem(), remapper);
                builder.BuildDirectory(Package, publishPath, files);
                UploadState = PackageUploadHandle.State.Uploaded;
            }
            catch (Exception e)
            {
                UploadState = PackageUploadHandle.State.Error;
                ErrorString = e.Message;
                dynamoViewModel.Model.Logger.Log(e);
            }
            finally
            {
                Uploading = false;
            }
        }
        /// <summary>
        /// Delegate used to publish the element to a local folder</summary>
        private void PublishLocally()
        {
            var publishPath = GetPublishFolder();

            if (string.IsNullOrEmpty(publishPath))
            {
                return;
            }

            var files = BuildPackage();

            try
            {
                var unqualifiedFiles = GetAllUnqualifiedFiles();

                // if the unqualified files are bigger than 0, error message is triggered.
                // At the same time, as unqualified files existed,
                // files returned from BuildPackage() is 0.
                // This is caused by the package file is not existed or it has already been in a package.
                if (files == null || unqualifiedFiles.Count() > 0)
                {
                    string filesCannotBePublished = null;
                    foreach (var file in unqualifiedFiles)
                    {
                        filesCannotBePublished = filesCannotBePublished + file + "\n";
                    }
                    string FileNotPublishMessage = string.Format(Resources.FileNotPublishMessage, filesCannotBePublished);
                    UploadState = PackageUploadHandle.State.Error;
                    DialogResult response = System.Windows.Forms.MessageBox.Show(FileNotPublishMessage, Resources.FileNotPublishCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (response == DialogResult.OK)
                    {
                        this.ClearPackageContents();
                        UploadState = PackageUploadHandle.State.Ready;
                        Uploading   = false;
                    }
                    return;
                }
                UploadState = PackageUploadHandle.State.Copying;
                Uploading   = true;
                // begin publishing to local directory
                var remapper = new CustomNodePathRemapper(DynamoViewModel.Model.CustomNodeManager,
                                                          DynamoModel.IsTestMode);
                var builder = new PackageDirectoryBuilder(new MutatingFileSystem(), remapper);
                builder.BuildDirectory(Package, publishPath, files);
                UploadState = PackageUploadHandle.State.Uploaded;

                // Once upload is successful, a display message will appear to ask
                // whether user wants to continue uploading another file or not.
                if (UploadState == PackageUploadHandle.State.Uploaded)
                {
                    DialogResult dialogResult = System.Windows.Forms.MessageBox.Show(Resources.PublishPackageMessage, Resources.PublishPackageDialogCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.Yes)
                    {
                        this.ClearAllEntries();
                        Uploading   = false;
                        UploadState = PackageUploadHandle.State.Ready;
                    }
                    else
                    {
                        Uploading = true;
                        System.Threading.Timer timer = null;
                        timer = new System.Threading.Timer((obj) =>
                        {
                            OnPublishSuccess();
                            timer.Dispose();
                        },
                                                           null, 1200, System.Threading.Timeout.Infinite);
                    }
                }
            }
            catch (Exception e)
            {
                UploadState = PackageUploadHandle.State.Error;
                ErrorString = e.Message;
                dynamoViewModel.Model.Logger.Log(e);
            }
        }
Example #3
0
        /// <summary>
        /// Delegate used to publish the element to a local folder</summary>
        private void PublishLocally()
        {
            var publishPath = GetPublishFolder();
            if (string.IsNullOrEmpty(publishPath))
                return;

            var files = BuildPackage();

            try
            {
                //if buildPackage() returns no files then the package
                //is empty so we should return
                if (files == null || files.Count() < 1)
                {
                    return;
                }
                UploadState = PackageUploadHandle.State.Copying;
                Uploading = true;
                // begin publishing to local directory
                var remapper = new CustomNodePathRemapper(DynamoViewModel.Model.CustomNodeManager,
                    DynamoModel.IsTestMode);
                var builder = new PackageDirectoryBuilder(new MutatingFileSystem(), remapper);
                builder.BuildDirectory(Package, publishPath, files);
                UploadState = PackageUploadHandle.State.Uploaded;
            }
            catch (Exception e)
            {
                UploadState = PackageUploadHandle.State.Error;
                ErrorString = e.Message;
                dynamoViewModel.Model.Logger.Log(e);
            }
            finally
            {
                Uploading = false;
            }
        }
        /// <summary>
        /// Delegate used to publish the element to a local folder</summary>
        private void PublishLocally()
        {
            var publishPath = GetPublishFolder();
            if (string.IsNullOrEmpty(publishPath))
                return;

            var files = BuildPackage();

            try
            {
                var unqualifiedFiles = GetAllUnqualifiedFiles();

                // if the unqualified files are bigger than 0, error message is triggered.
                // At the same time, as unqualified files existed, 
                // files returned from BuildPackage() is 0.
                // This is caused by the package file is not existed or it has already been in a package.
                // files.Count() is also checking for the exception that was caught in BuildPackage().
                // The scenario can be user trying to publish unsaved workspace.
                if (files == null || files.Count() < 1 || unqualifiedFiles.Count() > 0) 
                {
                    string filesCannotBePublished = null;
                    foreach (var file in unqualifiedFiles)
                    {
                        filesCannotBePublished = filesCannotBePublished + file + "\n";
                    }
                    string FileNotPublishMessage = string.Format(Resources.FileNotPublishMessage, filesCannotBePublished);
                    UploadState = PackageUploadHandle.State.Error;
                    DialogResult response = DynamoModel.IsTestMode ? DialogResult.OK : System.Windows.Forms.MessageBox.Show(FileNotPublishMessage, Resources.FileNotPublishCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    if (response == DialogResult.OK)
                    {
                        this.ClearPackageContents();
                        UploadState = PackageUploadHandle.State.Ready;
                        Uploading = false;
                    }
                    return;
                }

                UploadState = PackageUploadHandle.State.Copying;
                Uploading = true;
                // begin publishing to local directory
                var remapper = new CustomNodePathRemapper(DynamoViewModel.Model.CustomNodeManager,
                    DynamoModel.IsTestMode);
                var builder = new PackageDirectoryBuilder(new MutatingFileSystem(), remapper);
                builder.BuildDirectory(Package, publishPath, files);
                UploadState = PackageUploadHandle.State.Uploaded;

                // Once upload is successful, a display message will appear to ask
                // whether user wants to continue uploading another file or not.
                if (UploadState == PackageUploadHandle.State.Uploaded)
                {
                    // For test mode, presume the dialog input to be No and proceed.
                    DialogResult dialogResult = DynamoModel.IsTestMode ? DialogResult.No : System.Windows.Forms.MessageBox.Show(Resources.PublishPackageMessage, Resources.PublishPackageDialogCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information); ;

                    if (dialogResult == DialogResult.Yes)
                    { 
                        this.ClearAllEntries();
                        Uploading = false;
                        UploadState = PackageUploadHandle.State.Ready;
                    }
                    else
                    {
                        Uploading = true;
                        System.Threading.Timer timer = null;
                        timer = new System.Threading.Timer((obj) =>
                        {
                            OnPublishSuccess();
                            timer.Dispose();
                        },
                            null, 1200, System.Threading.Timeout.Infinite);
                    }
                }
            }
            catch (Exception e)
            {
                UploadState = PackageUploadHandle.State.Error;
                ErrorString = e.Message;
                dynamoViewModel.Model.Logger.Log(e);
            }
        }