示例#1
0
        void PerformUpload()
        {
            Running = true;
            UpdateButtons();

            while (FileNames.Count > 0)
            {
                Msg(string.Empty);

                string filename;
                lock (FileNames)
                {
                    filename = FileNames.Dequeue();
                }
                Msg(string.Format("Processing: {0}", filename));

                var parser = new OpenMetaverse.ImportExport.ColladaLoader();
                var prims  = parser.Load(filename, UploadImages);
                if (prims == null || prims.Count == 0)
                {
                    Msg("Error: Failed to parse collada file");
                    continue;
                }

                Msg(string.Format("Parse collada file success, found {0} objects", prims.Count));
                Msg("Uploading...");

                var uploader   = new OpenMetaverse.ImportExport.ModelUploader(client, prims, Path.GetFileNameWithoutExtension(filename), "METAbolt " + DateTime.Now.ToString());
                var uploadDone = new AutoResetEvent(false);

                uploader.IncludePhysicsStub = true;
                uploader.UseModelAsPhysics  = false;

                uploader.Upload((res =>
                {
                    if (res == null)
                    {
                        Msg("Upload failed.");
                    }
                    else
                    {
                        Msg("Upload success.");
                    }

                    uploadDone.Set();
                }));

                if (!uploadDone.WaitOne(4 * 60 * 1000))
                {
                    Msg("Message upload timeout");
                }
            }

            Running = false;
            UpdateButtons();
            Msg("Done.");
        }
        void PerformUpload()
        {
            try
            {
                Running = true;
                UpdateButtons();

                while (FileNames.Count > 0)
                {
                    Msg(string.Empty);

                    string filename;
                    lock (FileNames)
                    {
                        filename = FileNames.Dequeue();
                    }
                    Msg($"Processing: {filename}");

                    var parser = new OpenMetaverse.ImportExport.ColladaLoader();
                    var prims  = parser.Load(filename, UploadImages);
                    if (prims == null || prims.Count == 0)
                    {
                        Msg("Error: Failed to parse collada file");
                        continue;
                    }

                    Msg($"Parse collada file success, found {prims.Count} objects");
                    Msg("Uploading...");

                    uploadCancelToken.Token.ThrowIfCancellationRequested();

                    var uploader   = new OpenMetaverse.ImportExport.ModelUploader(client, prims, Path.GetFileNameWithoutExtension(filename), "Radegast " + DateTime.Now.ToString(CultureInfo.InvariantCulture));
                    var uploadDone = new AutoResetEvent(false);

                    uploader.IncludePhysicsStub = true;
                    uploader.UseModelAsPhysics  = false;

                    uploader.Upload((res =>
                    {
                        if (res == null)
                        {
                            Msg("Upload failed.");
                        }
                        else
                        {
                            Msg("Upload success.");
                        }

                        uploadDone.Set();
                    }));

                    if (!uploadDone.WaitOne(4 * 60 * 1000))
                    {
                        Msg("Message upload timeout");
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Msg("Operation cancelled");
            }

            Running = false;
            UpdateButtons();
            Msg("Done.");
        }
示例#3
0
        void PerformUpload()
        {
            Running = true;
            UpdateButtons();

            while (FileNames.Count > 0)
            {
                Msg(string.Empty);

                string filename;
                lock (FileNames)
                {
                    filename = FileNames.Dequeue();
                }
                Msg(string.Format("Processing: {0}", filename));

                var parser = new OpenMetaverse.ImportExport.ColladaLoader();
                var prims = parser.Load(filename, UploadImages);
                if (prims == null || prims.Count == 0)
                {
                    Msg("Error: Failed to parse collada file");
                    continue;
                }

                Msg(string.Format("Parse collada file success, found {0} objects", prims.Count));
                Msg("Uploading...");

                var uploader = new OpenMetaverse.ImportExport.ModelUploader(client, prims, Path.GetFileNameWithoutExtension(filename), "Radegast " + DateTime.Now.ToString());
                var uploadDone = new AutoResetEvent(false);

                uploader.IncludePhysicsStub = true;
                uploader.UseModelAsPhysics = false;

                uploader.Upload((res =>
                {
                    if (res == null)
                    {
                        Msg("Upload failed.");
                    }
                    else
                    {
                        Msg("Upload success.");
                    }

                    uploadDone.Set();
                }));

                if (!uploadDone.WaitOne(4 * 60 * 1000))
                {
                    Msg("Message upload timeout");
                }
            }

            Running = false;
            UpdateButtons();
            Msg("Done.");
        }