Exemplo n.º 1
0
        private async void DoWork()
        {
            double lastProgress = -1.0;

            ReCapPhotosceneResponse progressResult;

            while (true)
            {
                progressResult = await _client.GetPhotosceneProgressAsync(
                    _photosceneId);

                if (!progressResult.IsOk())
                {
                    if (OnSceneProgressError != null)
                    {
                        _syncCtrl.Invoke(OnSceneProgressError, new object[]
                        {
                            progressResult.Error
                        });
                    }

                    return;
                }

                if (OnSceneProgressChanged != null)
                {
                    if (lastProgress != progressResult.Photoscene.Progress)
                    {
                        _syncCtrl.Invoke(OnSceneProgressChanged, new object[]
                        {
                            progressResult
                        });
                    }
                }

                if (progressResult.Photoscene.ProgressMsg == "DONE")
                {
                    if (OnSceneProgressCompleted != null)
                    {
                        _syncCtrl.Invoke(OnSceneProgressCompleted, new object[]
                        {
                            progressResult
                        });
                    }

                    return;
                }
                else if (progressResult.Photoscene.ProgressMsg == "ERROR")
                {
                    return;
                }

                lastProgress = progressResult.Photoscene.Progress;

                Thread.Sleep(_pollingPeriod);
            }
        }
        private async Task <ReCapPhotoscene> RetrieveSceneInfo(string photosceneId)
        {
            try
            {
                var scenePropsResponse = await _reCapClient.GetPhotoscenePropertiesAsync(
                    photosceneId);

                if (!scenePropsResponse.IsOk())
                {
                    OnLogReCapError(scenePropsResponse.Error);
                    return(null);
                }

                ReCapPhotoscene scene = scenePropsResponse.Photoscene;

                var sceneProgResponse = await _reCapClient.GetPhotosceneProgressAsync(
                    photosceneId);

                if (!sceneProgResponse.IsOk())
                {
                    OnLogReCapError(sceneProgResponse.Error);
                    return(null);
                }

                double progress    = sceneProgResponse.Photoscene.Progress;
                string progressMsg = sceneProgResponse.Photoscene.ProgressMsg;

                Uri link = null;

                if (progress == 100.0)
                {
                    var sceneLinkResponse = await _reCapClient.GetPhotosceneLinkAsync(
                        scene.PhotosceneId,
                        MeshFormatEnumExtensions.FromString(
                            scene.ConvertFormat));

                    if (!sceneLinkResponse.IsOk())
                    {
                        OnLogReCapError(sceneLinkResponse.Error);
                    }
                    else
                    {
                        link = sceneLinkResponse.Photoscene.SceneLink;
                    }
                }

                return(new ReCapPhotoscene(
                           scene.SceneName,
                           scene.PhotosceneId,
                           progressMsg,
                           progress,
                           link,
                           scene.FileSize,
                           scene.UserId,
                           scene.MeshQuality,
                           scene.ConvertFormat,
                           scene.ConvertStatus,
                           scene.ProcessingTime,
                           scene.Deleted,
                           scene.Files,
                           scene.Nb3dPoints,
                           scene.NbFaces,
                           scene.NbShots,
                           scene.NbStitchedShots,
                           scene.NbVertices));
            }
            catch
            {
                return(null);
            }
        }