public void TestMethod1()
        {
            ITelegramPostSaver aTools = new TelegFtpTools();
            IChannelTools      cTools = new WebChannelTools();
            var manager = new JobAttachmentManager(cTools, aTools);
            var job     = manager.CreateJobAsync("telegram", 2, 77).Result;

            manager.ExecuteJobAsync(job.Id).Wait();
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> SaveAttachments(string channelName, [FromBody] AttachmentRequest req)
        {
            if (req == null || !ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ITelegramPostSaver attachment = new TelegFtpTools(req.FtpUrl, req.FtpUser, req.FtpPassword);
            var manager = new JobAttachmentManager(_cTools, attachment);
            var job     = await manager.CreateJobAsync(channelName, req.FromId, req.ToId);

            HostingEnvironment.QueueBackgroundWorkItem(ct => manager.ExecuteJobAsync(job.Id));

            return(Request.CreateResponse(HttpStatusCode.Accepted, job));
        }