Example #1
0
        private Boolean DownloadFileDescriptor(String fileDescriptorId)
        {
            Boolean          downloadResult = false;
            ManualResetEvent manualEvent    = new ManualResetEvent(false);

            fileStorage.GetFileDescriptor(fileDescriptorId, callback =>
            {
                //Do we have a correct answer
                if (callback.Result.Success)
                {
                    downloadResult = true;
                    FileDescriptor fileDescriptor = callback.Data;

                    log.Debug("[DownloadFileDescriptor] fileDescriptor:[{0}]", fileDescriptor.ToString());

                    if (filesDescriptorById.ContainsKey(fileDescriptorId))
                    {
                        filesDescriptorById.Remove(fileDescriptorId);
                    }
                    filesDescriptorById.Add(fileDescriptorId, fileDescriptor);

                    if (filesDescriptorNameById.ContainsKey(fileDescriptorId))
                    {
                        filesDescriptorNameById.Remove(fileDescriptorId);
                    }
                    filesDescriptorNameById.Add(fileDescriptorId, fileDescriptorId + Path.GetExtension(fileDescriptor.Name));

                    AskThumbnailDownload(fileDescriptorId);
                }
                else
                {
                    log.Warn("[DownloadFileDescriptor] Not possible to get file descriptor:[{0}]", Util.SerializeSdkError(callback.Result));
                }

                manualEvent.Set();
            });

            manualEvent.WaitOne();
            manualEvent.Dispose();

            return(downloadResult);
        }