コード例 #1
0
 public Task<bool> Send([FromUri] int configId)
 {
     return Task.Run(() =>
     {
         var scheduler = this._schedulerRepository.GetScheduler(configId);
         var priceSender = new PriceMailSender(scheduler, this._schedulerRepository);
         priceSender.Send();
         return true;
     });
 }
コード例 #2
0
 public Task<bool> SendAll([FromUri]int groupId)
 {
     return Task.Run(() =>
     {
         List<SchedulerItem> schedulers = this._schedulerRepository.GetSchedulersByGroupId(groupId);
         foreach (var scheduler in schedulers)
         {
             var priceSender = new PriceMailSender(scheduler, this._schedulerRepository);
             priceSender.Send();
         }
         return true;
     });
 }
コード例 #3
0
        public HttpResponseMessage Price(int configId)
        {
            var priceSender = new PriceMailSender(configId, this._schedulerRepository);

            var file = priceSender.CreatePrice();

            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(file)
            };

            result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = priceSender.Config.FileType
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            return(result);
        }
コード例 #4
0
        public HttpResponseMessage GetAhiveFile(int configId, string fileName)
        {
            var dir      = PriceMailSender.GetSchedulerConfigDir(configId);
            var fullName = Path.Combine(dir, fileName + ".zip");

            if (!File.Exists(fullName))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "File not found"));
            }

            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(File.ReadAllBytes(fullName))
            };

            result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = "arhive.zip"
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            return(result);
        }
コード例 #5
0
        public void ProcessItem(SchedulerItem item)
        {
            try
            {
                if (string.IsNullOrEmpty(item.Email))
                {
                    this._logger.WriteWarning(string.Format("Price not sent. Not set email. Id:{0}", item.Id));
                    return;
                }

                var priceSender = new PriceMailSender(item, this._schedulerRepository);

                if (priceSender.Send())
                {
                    this._logger.WriteEvent(
                        String.Format("Begin send price.Id:{0}, email:{1},lastSend:{2}, nextTime:{3}", item.Id,
                                      item.Email, item.LastSend, item.NextSend));
                }
            }
            catch (Exception e)
            {
                this._logger.WriteError("Error send price. Id:" + item.Id, e);
            }
        }
コード例 #6
0
        public ArhiveFile[] GetAllAhives()

        {
            return(PriceMailSender.GetAllArhives().OrderByDescending(o => o.Date).ToArray());
        }
コード例 #7
0
 public ArhiveFile[] GetAhive(int configId)
 {
     return(PriceMailSender.GetArhives(configId));
 }