public void WhenОтправляем() { SendDocument ITOG = new SendDocument(); ITOG.Senddocument(); Thread.Sleep(6000); }
public void WhenПрикрепляемДокумент() { SendDocument nearli = new SendDocument(); nearli.AffixD(); Thread.Sleep(5000); }
public void WhenНажимаемНаКнопкуДокумент() { SendDocument affix = new SendDocument(); affix.docaffix(); Thread.Sleep(5000); }
public Message SendDocument <R, P>(P parameter) where R : ReplyMarkup where P : SendDocumentParameter <R> { var method = new SendDocument <R, P>(); return(method.Execute(parameter, HttpClient).Result); }
public Response <SendDocumentModel> Create(SendDocumentCreateModel createModel) { try { using (var unitOfwork = new UnitOfWork()) { var user = unitOfwork.GetRepository <User>().GetById(createModel.CreatedByUserId); if (user == null) { return(new Response <SendDocumentModel>(0, "", null)); } SendDocument entity = new SendDocument { SecretLevel = createModel.SecretLevel, ResponsibleUserId = createModel.ResponsibleUserId, ResponseForRDocId = createModel.ResponseForRDocId, SenderId = createModel.SenderId, SignedByUserId = createModel.SignedByUserId, Summary = createModel.Summary, WrittenByUserId = createModel.WrittenByUserId, ResponseDeadline = createModel.ResponseDeadline, ReceiverContactPersonId = createModel.ReceiverContactPersonId, ReceiverId = createModel.ReceiverId, Name = createModel.Name, DocumentStatusId = createModel.DocumentStatusId, CategoryId = createModel.CategoryId, CreatedByUserId = createModel.CreatedByUserId, CreatedOnDate = DateTime.Now, DeliveryMethodId = createModel.DeliveryMethodId, LastModifiedOnDate = DateTime.Now, DepartmentId = user.DepartmentId, IsDelete = false, LastModifiedByUserId = createModel.CreatedByUserId, SendDocumentId = 1, ResignedNumber = createModel.ResignedNumber, ResignedOnDate = createModel.ResignedOnDate, AttachedFileUrl = createModel.AttachedFileUrl }; var last = unitOfwork.GetRepository <SendDocument>().GetAll().OrderByDescending(d => d.SendDocumentId).FirstOrDefault(); if (last != null) { entity.SendDocumentId = last.SendDocumentId + 1; } unitOfwork.GetRepository <SendDocument>().Add(entity); if (unitOfwork.Save() >= 1) { return(GetById(entity.SendDocumentId)); } return(new Response <SendDocumentModel>(0, "Lưu thông tin không thành công", null)); } } catch (Exception ex) { return(new Response <SendDocumentModel>(-1, ex.ToString(), null)); } }
public static void RunBot(string accessToken) { var bot = new TelegramBot(accessToken); var me = bot.MakeRequestAsync(new GetMe()).Result; if (me == null) { Console.WriteLine("GetMe() FAILED. Do you forget to add your AccessToken to App.config?"); Console.WriteLine("(Press ENTER to quit)"); } Console.WriteLine("{0} (@{1}) connected!", me.FirstName, me.Username); Console.WriteLine(); Console.WriteLine("Find @{0} in Telegram and send him a message - it will be displayed here", me.Username); Console.WriteLine("(Press ENTER to stop listening and quit)"); Console.WriteLine(); string uploadedPhotoId = null; string uploadedDocumentId = null; long offset = 0; while (!stopMe) { var updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset }).Result; if (updates != null) { foreach (var update in updates) { offset = update.UpdateId + 1; if (update.Message == null) { continue; } var from = update.Message.From; var text = update.Message.Text; Console.WriteLine( "Msg from {0} {1} ({2}) at {4}: {3}", from.FirstName, from.LastName, from.Username, text, update.Message.Date); if (string.IsNullOrEmpty(text)) { continue; } if (text == "/photo") { if (uploadedPhotoId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_photo"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var photoData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.t_logo.png")) { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(photoData, "Telegram_logo.png")) { Caption = "Telegram_logo.png" }; var msg = bot.MakeRequestAsync(req).Result; uploadedPhotoId = msg.Photo.Last().FileId; } } else { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(uploadedPhotoId)) { Caption = "Resending photo id=" + uploadedPhotoId }; bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/doc") { if (uploadedDocumentId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.Telegram_Bot_API.htm")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Telegram_Bot_API.htm")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } } else { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(uploadedDocumentId)); bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/docutf8") { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.Пример UTF8 filename.txt")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Пример UTF8 filename.txt")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } continue; } if (text == "/help") { var keyb = new ReplyKeyboardMarkup() { Keyboard = new[] { new[] { "/photo", "/doc", "/docutf8" }, new[] { "/help" } }, OneTimeKeyboard = true, ResizeKeyboard = true }; var reqAction = new SendMessage(update.Message.Chat.Id, "Here is all my commands") { ReplyMarkup = keyb }; bot.MakeRequestAsync(reqAction).Wait(); continue; } if (update.Message.Text.Length % 2 == 0) { bot.MakeRequestAsync(new SendMessage(update.Message.Chat.Id, "You wrote " + update.Message.Text.Length + " characters")).Wait(); } else { bot.MakeRequestAsync(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId)).Wait(); } } } } }
public static void RunBot(string accessToken) { var bot = new TelegramBot(accessToken); var me = bot.MakeRequestAsync(new GetMe()).Result; if (me == null) { Console.WriteLine("GetMe() FAILED. Do you forget to add your AccessToken to App.config?"); Console.WriteLine("(Press ENTER to quit)"); Console.ReadLine(); return; } Console.WriteLine("{0} (@{1}) connected!", me.FirstName, me.Username); Console.WriteLine(); Console.WriteLine("Find @{0} in Telegram and send him a message - it will be displayed here", me.Username); Console.WriteLine("(Press ENTER to stop listening and quit)"); Console.WriteLine(); Console.WriteLine("ATENTION! This project uses nuget package, not 'live' project in solution (because 'live' project is vNext now)"); Console.WriteLine(); string uploadedPhotoId = null; string uploadedDocumentId = null; long offset = 0; while (!stopMe) { var updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset }).Result; if (updates != null) { foreach (var update in updates) { offset = update.UpdateId + 1; if (update.Message == null) { continue; } var from = update.Message.From; var text = update.Message.Text; var photos = update.Message.Photo; Console.WriteLine( "Msg from {0} {1} ({2}) at {4}: {3}", from.FirstName, from.LastName, from.Username, text, update.Message.Date); if (photos != null) { var webClient = new WebClient(); foreach (var photo in photos) { Console.WriteLine(" New image arrived: size {1}x{2} px, {3} bytes, id: {0}", photo.FileId, photo.Height, photo.Width, photo.FileSize); var file = bot.MakeRequestAsync(new GetFile(photo.FileId)).Result; var tempFileName = System.IO.Path.GetTempFileName(); webClient.DownloadFile(file.FileDownloadUrl, tempFileName); Console.WriteLine(" Saved to {0}", tempFileName); } } if (string.IsNullOrEmpty(text)) { continue; } if (text == "/photo") { if (uploadedPhotoId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_photo"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var photoData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.t_logo.png")) { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(photoData, "Telegram_logo.png")) { Caption = "Telegram_logo.png" }; var msg = bot.MakeRequestAsync(req).Result; uploadedPhotoId = msg.Photo.Last().FileId; } } else { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(uploadedPhotoId)) { Caption = "Resending photo id=" + uploadedPhotoId }; bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/doc") { if (uploadedDocumentId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.Telegram_Bot_API.htm")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Telegram_Bot_API.htm")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } } else { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(uploadedDocumentId)); bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/docutf8") { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.Пример UTF8 filename.txt")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Пример UTF8 filename.txt")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } continue; } if (text == "/help") { var keyb = new ReplyKeyboardMarkup() { Keyboard = new[] { new[] { new KeyboardButton("/photo"), new KeyboardButton("/doc"), new KeyboardButton("/docutf8") }, new[] { new KeyboardButton("/help") } }, OneTimeKeyboard = true, ResizeKeyboard = true }; var reqAction = new SendMessage(update.Message.Chat.Id, "Here is all my commands") { ReplyMarkup = keyb }; bot.MakeRequestAsync(reqAction).Wait(); continue; } if (update.Message.Text.Length % 2 == 0) { bot.MakeRequestAsync(new SendMessage( update.Message.Chat.Id, "You wrote: \r\n_" + update.Message.Text.MarkdownEncode() + "_") { ParseMode = SendMessage.ParseModeEnum.Markdown }).Wait(); } else { bot.MakeRequestAsync(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId)).Wait(); } } } } }
public static void RunBot(string accessToken) { var bot = new TelegramBot(accessToken); var me = bot.MakeRequestAsync(new GetMe()).Result; if (me == null) { Console.WriteLine("GetMe() FAILED. Do you forget to add your AccessToken to config.json?"); Console.WriteLine("(Press ENTER to quit)"); Console.ReadLine(); return; } Console.WriteLine("{0} (@{1}) connected!", me.FirstName, me.Username); Console.WriteLine(); Console.WriteLine("Find @{0} in Telegram and send him a message - it will be displayed here", me.Username); Console.WriteLine("(Press ENTER to stop listening and quit)"); Console.WriteLine(); string uploadedPhotoId = null; string uploadedDocumentId = null; long offset = 0; while (!stopMe) { var updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset }).Result; if (updates != null) { foreach (var update in updates) { offset = update.UpdateId + 1; if (update.Message == null) { continue; } var from = update.Message.From; var text = update.Message.Text; var photos = update.Message.Photo; Console.WriteLine( "Msg from {0} {1} ({2}) at {4}: {3}", from.FirstName, from.LastName, from.Username, text, update.Message.Date); if (photos != null) { var webClient = new WebClient(); foreach (var photo in photos) { Console.WriteLine(" New image arrived: size {1}x{2} px, {3} bytes, id: {0}", photo.FileId, photo.Height, photo.Width, photo.FileSize); var file = bot.MakeRequestAsync(new GetFile(photo.FileId)).Result; var tempFileName = System.IO.Path.GetTempFileName(); webClient.DownloadFile(file.FileDownloadUrl, tempFileName); Console.WriteLine(" Saved to {0}", tempFileName); } } if (string.IsNullOrEmpty(text)) { continue; } if (text == "/photo") { if (uploadedPhotoId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_photo"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var photoData = typeof(Program).Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.t_logo.png")) { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(photoData, "Telegram_logo.png")) { Caption = "Telegram_logo.png" }; var msg = bot.MakeRequestAsync(req).Result; uploadedPhotoId = msg.Photo.Last().FileId; } } else { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(uploadedPhotoId)) { Caption = "Resending photo id=" + uploadedPhotoId }; bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/doc") { if (uploadedDocumentId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = typeof(Program).Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.Telegram_Bot_API.htm")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Telegram_Bot_API.htm")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } } else { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(uploadedDocumentId)); bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/docutf8") { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using (var docData = typeof(Program).Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.Пример UTF8 filename.txt")) { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Пример UTF8 filename.txt")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } continue; } if (text == "/help") { var keyb = new ReplyKeyboardMarkup() { Keyboard = new[] { new[] { "/photo", "/doc", "/docutf8" }, new[] { "/help" } }, OneTimeKeyboard = true, ResizeKeyboard = true }; var reqAction = new SendMessage(update.Message.Chat.Id, "Here is all my commands") { ReplyMarkup = keyb }; bot.MakeRequestAsync(reqAction).Wait(); continue; } if (update.Message.Text.Length % 2 == 0) { bot.MakeRequestAsync(new SendMessage( update.Message.Chat.Id, "You wrote *" + update.Message.Text.Length + " characters*") { ParseMode = SendMessage.ParseModeEnum.Markdown }).Wait(); } else { bot.MakeRequestAsync(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId)).Wait(); } } } } }
private void buttonConnect_Click(object sender, EventArgs e) { if (this.dataGridViewFileDocTable.SelectedRows.Count < 1) { MessageBox.Show("Please select a row first.", "No row selected", MessageBoxButtons.OK); StatusUpdate("No row selected. Please select a row first."); } else { StatusUpdate("Connecting..."); foreach (DataGridViewRow row in this.dataGridViewFileDocTable.SelectedRows) { string DocFile = row.Cells["FullFilePath"].Value.ToString(); StatusUpdate("Sending: " + DocFile); var docRequest = new SendDocument() { DocumentTemplateId = "GLDT9223370666504283001RA000000006DTP2000001", Subject = "API exchange test", SendViaGroup = Settings.Default.EntityID, Recipient = "XCNL10201", //"XCNL10027", //"*****@*****.**", RecipientEmailId = "*****@*****.**", //"*****@*****.**", Payload = XElement.Parse(System.IO.File.ReadAllText(DocFile)), DocumentAsFile = new DocumentAsFile() { FileContents = "T3JkZXIgRGV0YWlscyBmb3IgUGFydG5lcldvcmxkIExpY2Vuc2U=", FileName = "order.txt" } }; StatusUpdate(String.Format("ExternalID: {0} ConsignmentID: {1}",APIclient.SendDocument(docRequest).ExternalId,APIclient.SendDocument(docRequest).ConsignmentId)); // TODO ARCHIVE! } StatusUpdate("Done sending..."); } }
public static void RunBot(string accessToken) { var bot = new TelegramBot(accessToken, new HttpClient()); var me = bot.MakeRequestAsync(new GetMe()).Result; if (me == null) { Console.WriteLine("GetMe() FAILED. Do you forget to add your AccessToken to config.json?"); Console.WriteLine("(Press ENTER to quit)"); Console.ReadLine(); return; } Console.OutputEncoding = System.Text.Encoding.UTF8; Console.WriteLine("{0} (@{1}) connected!", me.FirstName, me.Username); Console.WriteLine(); Console.WriteLine("Find @{0} in Telegram and send him a message - it will be displayed here", me.Username); Console.WriteLine("(Press ENTER to stop listening and quit)"); Console.WriteLine(); string uploadedPhotoId = null; string uploadedDocumentId = null; long offset = 0; while (!stopMe) { var updates = bot.MakeRequestAsync(new GetUpdates() { Offset = offset }).Result; if (updates != null) { foreach (var update in updates) { offset = update.UpdateId + 1; if (update.Message == null) { continue; } var from = update.Message.From; var text = update.Message.Text; var photos = update.Message.Photo; var contact = update.Message.Contact; var location = update.Message.Location; Console.WriteLine( "Msg from {0} {1} ({2}) at {4}: {3}", from.FirstName, from.LastName, from.Username, text, update.Message.Date); if (photos != null) { var webClient = new HttpClient(); foreach (var photo in photos) { Console.WriteLine(" New image arrived: size {1}x{2} px, {3} bytes, id: {0}", photo.FileId, photo.Height, photo.Width, photo.FileSize); var file = bot.MakeRequestAsync(new GetFile(photo.FileId)).Result; var tempFileName = System.IO.Path.GetTempFileName(); var bytes = webClient.GetByteArrayAsync(file.FileDownloadUrl).Result; System.IO.File.WriteAllBytes(tempFileName, bytes); Console.WriteLine(" Saved to {0}", tempFileName); } } if (contact != null) { var req = new SendContact(update.Message.Chat.Id, contact.PhoneNumber, contact.FirstName) { LastName = contact.LastName }; bot.MakeRequestAsync(req).Wait(); } if (location != null) { var req = new SendLocation(update.Message.Chat.Id, location.Latitude, location.Longitude); bot.MakeRequestAsync(req).Wait(); } if (string.IsNullOrEmpty(text)) { continue; } if (text == "/photo") { if (uploadedPhotoId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_photo"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using var photoData = typeof(Program).GetTypeInfo().Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.t_logo.png"); var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(photoData, "Telegram_logo.png")) { Caption = "Telegram_logo.png" }; var msg = bot.MakeRequestAsync(req).Result; uploadedPhotoId = msg.Photo.Last().FileId; } else { var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(uploadedPhotoId)) { Caption = "Resending photo id=" + uploadedPhotoId }; bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/doc") { if (uploadedDocumentId == null) { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using var docData = typeof(Program).GetTypeInfo().Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.Telegram_Bot_API.htm"); var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Telegram_Bot_API.htm")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; } else { var req = new SendDocument(update.Message.Chat.Id, new FileToSend(uploadedDocumentId)); bot.MakeRequestAsync(req).Wait(); } continue; } if (text == "/docutf8") { var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_document"); bot.MakeRequestAsync(reqAction).Wait(); System.Threading.Thread.Sleep(500); using var docData = typeof(Program).GetTypeInfo().Assembly.GetManifestResourceStream("TelegramBotDemo-vNext.Пример_UTF8_filename.txt"); var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "Пример_UTF8_filename.txt")); var msg = bot.MakeRequestAsync(req).Result; uploadedDocumentId = msg.Document.FileId; continue; } if (text == "/help") { var keyb = new ReplyKeyboardMarkup() { Keyboard = new[] { new[] { new KeyboardButton("/photo"), new KeyboardButton("/doc"), new KeyboardButton("/docutf8") }, new[] { new KeyboardButton("/contact") { RequestContact = true }, new KeyboardButton("/location") { RequestLocation = true } }, new[] { new KeyboardButton("/help") } }, OneTimeKeyboard = true, ResizeKeyboard = true }; var reqAction = new SendMessage(update.Message.Chat.Id, "Here is all my commands") { ReplyMarkup = keyb }; bot.MakeRequestAsync(reqAction).Wait(); continue; } if (text == "/longmsg") { var msg = new string('X', 10240); bot.MakeRequestAsync(new SendMessage(update.Message.Chat.Id, msg)).Wait(); continue; } if (update.Message.Text.Length % 2 == 0) { bot.MakeRequestAsync(new SendMessage( update.Message.Chat.Id, "You wrote: \r\n" + update.Message.Text.MarkdownEncode()) { ParseMode = SendMessage.ParseModeEnum.Markdown }).Wait(); } else { bot.MakeRequestAsync(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId)).Wait(); } } } } }
public static ValidationResult <SendDocument> CreateValidation(this SendDocument value) => new ValidationResult <SendDocument>(value) .ValidateRequired(x => x.ChatId) .ValidateRequired(x => x.Document);
public void WhenНажимаемНаКнопкуПрикрепитьДокумент() { SendDocument Doc = new SendDocument(); Doc.Docum.Click(); }
public string SendAndReport(SendDocument sendingDelegate) { return("Sending " + sendingDelegate()); }