Exemple #1
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);
        }
        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);

                        packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                        ret = Client.ExecuteAndDeserialize(pkg);
                    }
                    else
                    {
                        var pkg = PackageUploadBuilder.NewPackage(this.dynamoModel, l, files, packageUploadHandle);

                        packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                        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);
        }
        internal void Publish(Package package, IEnumerable <string> files, bool isNewVersion, PackageUploadHandle packageUploadHandle)
        {
            try
            {
                ResponseBody ret = null;
                if (isNewVersion)
                {
                    var pkg = uploadBuilder.NewPackageVersionUpload(package, packageUploadDirectory, files,
                                                                    packageUploadHandle);
                    packageUploadHandle.UploadState = PackageUploadHandle.State.Uploading;
                    ret = this.client.ExecuteAndDeserialize(pkg);
                }
                else
                {
                    var pkg = uploadBuilder.NewPackageUpload(package, packageUploadDirectory, 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);
            }
        }
        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;

        }
        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);
            }
        }
        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;
        }