Esempio n. 1
0
        private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;
            FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out  dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir); 
            RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            string zipPath;
            FileInfo info;

            try
            {
                zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);
                info = new FileInfo(zipPath);
            }
            catch
            {
                // give nicer error
                throw new Exception("Could not compress file.  Is the file in use?");
            }
            
            if (info.Length > 15 * 1000000) throw new Exception("The package is too large!  The package must be less than 15 MB!");

            return zipPath;
        }
Esempio n. 2
0
        public PackageVersionUpload NewPackageVersionUpload(Package package, string packagesDirectory, IEnumerable<string> files, PackageUploadHandle handle)
        {
            if (package == null) throw new ArgumentNullException("package");
            if (packagesDirectory == null) throw new ArgumentNullException("packagesDirectory");
            if (files == null) throw new ArgumentNullException("files");
            if (handle == null) throw new ArgumentNullException("handle");

            return new PackageVersionUpload(NewRequestBody(package), BuildAndZip(package, packagesDirectory, files, handle).Name);
        }
Esempio n. 3
0
        private IFileInfo BuildAndZip(Package package, string packagesDirectory, IEnumerable<string> files, PackageUploadHandle handle)
        {
            handle.UploadState = PackageUploadHandle.State.Copying;

            var dir = builder.BuildDirectory(package, packagesDirectory, files);

            handle.UploadState = PackageUploadHandle.State.Compressing;

            return Zip(dir);
        }
Esempio n. 4
0
        private static string DoPackageFileOperationsAndZip(Package pkg, List<string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;
            FormPackageDirectory(dynSettings.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out  dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir); 
            RemapCustomNodeFilePaths(files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            var zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);

            return zipPath;
        }
Esempio n. 5
0
        private PackageUploadHandle PublishPackage(bool isNewVersion,
                                                   Package l,
                                                   List <string> files,
                                                   PackageUploadHandle packageUploadHandle)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    ResponseBody ret = null;
                    if (isNewVersion)
                    {
                        var pkg = PackageUploadBuilder.NewPackageVersion(this.dynamoModel, l, files, packageUploadHandle);
                        ret     = Client.ExecuteAndDeserialize(pkg);
                    }
                    else
                    {
                        var pkg = PackageUploadBuilder.NewPackage(this.dynamoModel, l, files, packageUploadHandle);
                        ret     = Client.ExecuteAndDeserialize(pkg);
                    }
                    if (ret == null)
                    {
                        packageUploadHandle.Error("Failed to submit.  Try again later.");
                        return;
                    }

                    if (ret != null && !ret.success)
                    {
                        packageUploadHandle.Error(ret.message);
                        return;
                    }

                    packageUploadHandle.Done(null);
                }
                catch (Exception e)
                {
                    packageUploadHandle.Error(e.GetType() + ": " + e.Message);
                }
            });

            return(packageUploadHandle);
        }
Esempio n. 6
0
        private PackageUploadHandle PublishPackage( bool isNewVersion, 
                                                    Package l, 
                                                    List<string> files,
                                                    PackageUploadHandle packageUploadHandle )
        {

            Task.Factory.StartNew(() =>
            {
                try
                {
                    ResponseBody ret = null;
                    if (isNewVersion)
                    {
                        var pkg = PackageUploadBuilder.NewPackageVersion(l, files, packageUploadHandle);
                        ret = Client.ExecuteAndDeserialize(pkg);
                    }
                    else
                    {
                        var pkg = PackageUploadBuilder.NewPackage(l, files, packageUploadHandle);
                        ret = Client.ExecuteAndDeserialize(pkg);
                    }
                    if (ret == null)
                    {
                        packageUploadHandle.Error("Failed to submit.  Try again later.");
                        return;
                    }

                    if (ret != null && !ret.success)
                    {
                        packageUploadHandle.Error(ret.message);
                        return;
                    }

                    packageUploadHandle.Done(null);

                }
                catch (Exception e)
                {
                    packageUploadHandle.Error(e.GetType() + ": " + e.Message);
                }
            });

            return packageUploadHandle;

        }
Esempio n. 7
0
        public PackageUploadHandle Publish( Package l, List<string> files, bool isNewVersion )
        {
            dynSettings.Controller.DynamoViewModel.OnRequestAuthentication();

            var nv = new ValidateAuth();
            var pkgResponse = Client.ExecuteAndDeserialize(nv);

            if (pkgResponse == null)
            {
                throw new AuthenticationException(
                    "It looks like you're not logged into Autodesk 360.  Log in to submit a package.");
            }

            var packageUploadHandle = new PackageUploadHandle(l.Header);
            return PublishPackage(isNewVersion, l, files, packageUploadHandle);

        }
Esempio n. 8
0
        public PackageVersionUpload NewPackageVersionUpload(Package package, string packagesDirectory, IEnumerable <string> files, PackageUploadHandle handle)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }
            if (packagesDirectory == null)
            {
                throw new ArgumentNullException("packagesDirectory");
            }
            if (files == null)
            {
                throw new ArgumentNullException("files");
            }
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            return(new PackageVersionUpload(NewRequestBody(package), BuildAndZip(package, packagesDirectory, files, handle).Name));
        }
Esempio n. 9
0
        public static PackageVersionUpload NewPackageVersion(DynamoModel dynamoModel, Package pkg, List <string> files, PackageUploadHandle uploadHandle)
        {
            var zipPath = DoPackageFileOperationsAndZip(dynamoModel, pkg, files, uploadHandle);

            return(BuildPackageVersionUpload(pkg.Header, zipPath));
        }
Esempio n. 10
0
        internal void Publish(Package package, IEnumerable<string> files, bool isNewVersion, PackageUploadHandle packageUploadHandle)
        {
            try
            {
                ResponseBody ret = null;
                if (isNewVersion)
                {
                    var pkg = uploadBuilder.NewPackageVersionUpload(package, packagesDirectory, files,
                        packageUploadHandle);
                    packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                    ret = this.client.ExecuteAndDeserialize(pkg);
                }
                else
                {
                    var pkg = uploadBuilder.NewPackageUpload(package, packagesDirectory, files,
                        packageUploadHandle);
                    packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                    ret = this.client.ExecuteAndDeserialize(pkg);
                }
                if (ret == null)
                {
                    packageUploadHandle.Error("Failed to submit.  Try again later.");
                    return;
                }

                if (ret != null && !ret.success)
                {
                    packageUploadHandle.Error(ret.message);
                    return;
                }
               
                packageUploadHandle.Done(null);
            }
            catch (Exception e)
            {
                packageUploadHandle.Error(e.GetType() + ": " + e.Message);
            }
        }
Esempio n. 11
0
        internal PackageUploadHandle PublishAsync(Package package, IEnumerable<string> files, bool isNewVersion)
        {
            var packageUploadHandle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(package));

            Task.Factory.StartNew(() =>
            {
                Publish(package, files, isNewVersion, packageUploadHandle);
            });

            return packageUploadHandle;
        }
Esempio n. 12
0
        private static string DoPackageFileOperationsAndZip(string rootPkgDir, CustomNodeManager customNodeManager, PackageUploadRequestBody header, Package pkg, List <string> files, PackageUploadHandle uploadHandle, bool isTestMode)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;

            FormPackageDirectory(rootPkgDir, pkg.Name, out rootDir, out dyfDir, out binDir, out extraDir);  // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir);
            RemapCustomNodeFilePaths(customNodeManager, files, dyfDir.FullName, isTestMode);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            string   zipPath;
            FileInfo info;

            try
            {
                zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);
                info    = new FileInfo(zipPath);
            }
            catch
            {
                // give nicer error
                throw new Exception(Properties.Resources.CouldNotCompressFile);
            }

            if (info.Length > 100 * 1024 * 1024)
            {
                throw new Exception(Properties.Resources.PackageTooLarge);
            }

            return(zipPath);
        }
Esempio n. 13
0
        public static PackageVersionUpload NewPackageVersion(string rootPkgDir, CustomNodeManager customNodeManager, Package pkg, List <string> files, PackageUploadHandle uploadHandle, bool isTestMode)
        {
            var header  = NewPackageHeader(pkg);
            var zipPath = DoPackageFileOperationsAndZip(rootPkgDir, customNodeManager, header, pkg, files, uploadHandle, isTestMode);

            return(new PackageVersionUpload(header, zipPath));
        }
Esempio n. 14
0
        private PackageUploadHandle PublishPackage( bool isNewVersion, 
                                                    Package l, 
                                                    List<string> files,
                                                    PackageUploadHandle packageUploadHandle )
        {
            ThreadStart start = () =>
                {
                    try
                    {
                        int maxRetries = 5;
                        int count = 0;
                        ResponseBody ret = null;
                        if (isNewVersion)
                        {
                            var pkg = PackageUploadBuilder.NewPackageVersion(l, files, packageUploadHandle);
                            while (ret == null && count < maxRetries)
                            {
                                count++;
                                ret = Client.ExecuteAndDeserialize(pkg);
                            }
                        }
                        else
                        {
                            var pkg = PackageUploadBuilder.NewPackage(l, files, packageUploadHandle);
                            while (ret == null && count < maxRetries)
                            {
                                count++;
                                ret = Client.ExecuteAndDeserialize(pkg);
                            }
                        }
                        if (ret == null)
                        {
                            packageUploadHandle.Error("Failed to submit.  Try again later.");
                            return;
                        }

                        if (ret != null && !ret.success)
                        {
                            packageUploadHandle.Error(ret.message);
                            return;
                        }

                        packageUploadHandle.Done(null);

                    }
                    catch (Exception e)
                    {
                        packageUploadHandle.Error(e.GetType() + ": " + e.Message);
                    }
                };
            new Thread(start).Start();

            return packageUploadHandle;
        }
Esempio n. 15
0
        public PackageUploadHandle Publish( Package l, List<string> files, bool isNewVersion )
        {
            OnAuthenticationRequested();

            int maxRetries = 5;
            int count = 0;
            var nv = new ValidateAuth();
            ResponseBody pkgResponse = null;

            while (pkgResponse == null && count < maxRetries)
            {
                count++;
                pkgResponse = Client.ExecuteAndDeserialize(nv);
            }

            if (pkgResponse == null)
            {
                throw new AuthenticationException(
                    "It looks like you're not logged into Autodesk 360.  Log in to submit a package.");
            }

            var packageUploadHandle = new PackageUploadHandle(l.Header);
            return PublishPackage(isNewVersion, l, files, packageUploadHandle);
        }
Esempio n. 16
0
 public static PackageVersionUpload NewPackageVersion(Package pkg, List<string> files, PackageUploadHandle uploadHandle)
 {
     var zipPath = DoPackageFileOperationsAndZip(pkg, files, uploadHandle);
     return BuildPackageVersionUpload(pkg.Header, zipPath);
 }
Esempio n. 17
0
        internal void Publish(Package package, IEnumerable <string> files, bool isNewVersion, PackageUploadHandle packageUploadHandle)
        {
            try
            {
                ResponseBody ret = null;
                if (isNewVersion)
                {
                    var pkg = uploadBuilder.NewPackageVersionUpload(package, packagesDirectory, files,
                                                                    packageUploadHandle);
                    packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                    ret = this.client.ExecuteAndDeserialize(pkg);
                }
                else
                {
                    var pkg = uploadBuilder.NewPackageUpload(package, packagesDirectory, files,
                                                             packageUploadHandle);
                    packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                    ret = this.client.ExecuteAndDeserialize(pkg);
                }
                if (ret == null)
                {
                    packageUploadHandle.Error("Failed to submit.  Try again later.");
                }

                if (ret != null && !ret.success)
                {
                    packageUploadHandle.Error(ret.message);
                }

                packageUploadHandle.Done(null);
            }
            catch (Exception e)
            {
                packageUploadHandle.Error(e.GetType() + ": " + e.Message);
            }
        }
Esempio n. 18
0
        private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List <string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;

            FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out dyfDir, out binDir, out extraDir);  // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir);
            RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            var zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);

            return(zipPath);
        }
Esempio n. 19
0
        private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List <string> files, PackageUploadHandle uploadHandle)
        {
            uploadHandle.UploadState = PackageUploadHandle.State.Copying;

            DirectoryInfo rootDir, dyfDir, binDir, extraDir;

            FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out dyfDir, out binDir, out extraDir);  // shouldn't do anything for pkg versions
            pkg.RootDirectory = rootDir.FullName;
            WritePackageHeader(pkg.Header, rootDir);
            CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir);
            RemoveDyfFiles(files, dyfDir);
            RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName);

            uploadHandle.UploadState = PackageUploadHandle.State.Compressing;

            string   zipPath;
            FileInfo info;

            try
            {
                zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName);
                info    = new FileInfo(zipPath);
            }
            catch
            {
                // give nicer error
                throw new Exception("Could not compress file.  Is the file in use?");
            }

            if (info.Length > 15 * 1000000)
            {
                throw new Exception("The package is too large!  The package must be less than 15 MB!");
            }

            return(zipPath);
        }
Esempio n. 20
0
 public static PackageUpload NewPackage(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle)
 {
     var zipPath = DoPackageFileOperationsAndZip(dynamoModel, pkg, files, uploadHandle);
     return BuildPackageUpload(pkg.Header, zipPath);
 }
Esempio n. 21
0
        private IFileInfo BuildAndZip(Package package, string packagesDirectory, IEnumerable <string> files, PackageUploadHandle handle)
        {
            handle.UploadState = PackageUploadHandle.State.Copying;

            var dir = builder.BuildDirectory(package, packagesDirectory, files);

            handle.UploadState = PackageUploadHandle.State.Compressing;

            return(Zip(dir));
        }
Esempio n. 22
0
        internal PackageUploadHandle Publish(Package package, List <string> files, bool isNewVersion, bool isTestMode)
        {
            var packageUploadHandle = new PackageUploadHandle(PackageUploadBuilder.NewPackageHeader(package));

            return(PublishPackage(isNewVersion, package, files, packageUploadHandle, isTestMode));
        }