Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);

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