Пример #1
0
 public TransmittMedia(FileInfo info)
 {
     FileInfo = info;
     try
     {
         _imageStream = FFTools.CreateThumbnail(FileInfo.FullName, out hasInvalidInputData);
         if (!hasInvalidInputData)
         {
             _thumbnail = System.Drawing.Image.FromStream(_imageStream);
         }
     }
     catch
     {
     }
 }
Пример #2
0
 public bool RegenerateThumbnail()
 {
     if (hasInvalidInputData)
     {
         return(false);
     }
     try
     {
         _imageStream = FFTools.CreateThumbnail(FileInfo.FullName, out hasInvalidInputData);
         _thumbnail   = System.Drawing.Image.FromStream(_imageStream);
         return(true);
     }
     catch (System.Exception ex)
     {
         return(false);
     }
 }
Пример #3
0
        public async void SendNotifyFileLoadSuccess(StorageItemInfo item)
        {
            TelegramContext.WithFileHash(item.Hash);
            if (!Subscribers.ContainsKey(item.Owner))
            {
                return;
            }
            var ChatId = Subscribers[item.Owner];

            try
            {
                try
                {
                    using (MemoryStream imageStream = FFTools.CreateThumbnail(item.FullPath))
                    {
                        Message result = await Bot.SendPhotoAsync(
                            ChatId,
                            imageStream,
                            string.Format("{0} ({1}) done", item.Name, item.GetFormatSize()), replyMarkup : Keyboards.CommonFileActions());

                        MessagesHystory.Push(result);
                    }
                }
                catch (Exception)
                {
                    await Bot.SendTextMessageAsync(ChatId, string.Format("{0} ({1}) done", item.Name, item.GetFormatSize()));
                }
            }
            catch (Exception)
            {
                await Task.Delay(3000).ContinueWith(async(a) =>
                {
                    await Bot.SendTextMessageAsync(ChatId, string.Format("{0} ({1}) done", item.Name, item.GetFormatSize()));
                });
            }
        }