Beispiel #1
0
        private void SendInternall()
        {
            try
            {
                this._sendEvent = new SendPriceEvent(_config.Id, _config.GetNextTime(_config.NextSend + _offsetLastSend), _config.Email, _config.ClientId, _config.GroupId);

                this._sendEvent["fileName"] = _config.FileName;

                //создание прайса в виде массива байт
                var pr = CreatePrice();

                if (string.IsNullOrWhiteSpace(this.Config.Email) || this.Config.Email.Trim().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray().Length == 0)
                {
                    SenderSrv.Logger.WriteEvent(string.Format("SendInternall not sended. To is empty. Id:{0}, FileName:{1}", this.Config.Id, this.Config.FileName));
                    return;
                }

                var mailSetting =
                    this._schedulerRepository
                    .GetEmailSettingsForMailingPricesService()
                    .FirstOrDefault(x => x.Id == this.Config.ProfileId);

                this._sendEvent["emailFrom"] = mailSetting.Email;

                //new MailSender().SendEmail(
                //    this.Config.Email,
                //    this.Config.Subject ?? "price",
                //    this.Config.Body ?? "", false, pr, this.Config.FileName, mailSetting);

                ServiceFactory.GetPriceSchedulerRepository().UpdateLastSend(this.Config.ClientId);
                SaveFile(pr);

                this._logger.WriteEvent(
                    string.Format("End task SendPrice. key:{0}, total:{1} wait:{2} active:{3}",
                                  this.Key, _queue.TotalTaskCount, _queue.WaitTasksCount, _queue.ActiveTaskCount));


                this._schedulerRepository.SaveSendEvent(this._sendEvent);
            }
            catch (Exception er)
            {
                this._logger.WriteError("Error send price. Id:" + this.Config.Id, er);
                var evn = new PriceSendErrorEvent(_config.Id, er.Message, er, _config.Email, _config.ClientId, _config.GroupId);

                this._schedulerRepository.SaveSendError(evn);
            }
        }
Beispiel #2
0
 public void SaveSendError(PriceSendErrorEvent sendEvent)
 {
     new EventDbLogger(this._connectionString).SaveLog(sendEvent);
 }