예제 #1
0
 private byte[] FetchDocumentBytes(TelegramClient client, Document document, uint offset, uint limit)
 {
     var response = (UploadFile)TelegramUtils.RunSynchronously(client.Methods.UploadGetFileAsync(
         new UploadGetFileArgs
         {
             Location = new InputDocumentFileLocation
             {
                 AccessHash = document.AccessHash,
                 Id = document.Id
             },
             Offset = offset,
             Limit = limit,
         }));
     return response.Bytes;
 }
예제 #2
0
 private uint GetAudioTime(Document document)
 {
     foreach (var attribute in document.Attributes)
     {
         var attributeAudio = attribute as DocumentAttributeAudio;
         if (attributeAudio != null)
         {
             return attributeAudio.Duration;
         }
     }
     return 0;
 }
예제 #3
0
 private byte[] FetchDocumentBytes(Document document, uint offset, uint limit)
 {
     if (document.DcId == _settings.NearestDcId)
     {
         using (var clientDisposable = new FullClientDisposable(this))
         {
             return FetchDocumentBytes(clientDisposable.Client, document, offset, limit);
         }
     }
     else
     {
         try
         {
             if (cachedClient == null)
             {
                 cachedClient = GetClient((int) document.DcId);
             }
             return FetchDocumentBytes(cachedClient, document, offset, limit);
         }
         catch (Exception ex)
         {
             DebugPrint("Failed to obtain client from DC manager: " + ex);
             return null;
         }
     }
 }
예제 #4
0
 private string GetDocumentFileName(Document document)
 {
     foreach (var attribute in document.Attributes)
     {
         var attributeFilename = attribute as DocumentAttributeFilename;
         if (attributeFilename != null)
         {
             return attributeFilename.FileName;
         }
     }
     return null;
 }