private void LoadDocument(RouteListPrintableDocuments docType) { int rlNumber = GetRouteListNumber(); if (rlNumber == 0) { return; } ReportInfo document = null; using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot()) { RouteList rl = uow.GetById <RouteList>(rlNumber); if (rl == null) { MessageDialogHelper.RunErrorDialog($"Маршрутный лист с номером {rlNumber} не найден"); return; } document = PrintRouteListHelper.GetRDL(rl, docType, uow); } if (document == null) { MessageDialogHelper.RunErrorDialog("Не возможно получить печатную форму документа"); return; } if (document.Source != null) { reportViewer.LoadReport(document.Source, document.GetParametersString(), document.ConnectionString, true, document.RestrictedOutputPresentationTypes); } else { reportViewer.LoadReport(document.GetReportUri(), document.GetParametersString(), document.ConnectionString, true, document.RestrictedOutputPresentationTypes); } }
void LoadReport(ReportInfo info) { logger.Debug(String.Format("Report Parameters[{0}]", info.GetParametersString())); MultiplePrintOperation multiplePrintOperation = null; if (info.PrintType == ReportInfo.PrintingType.MultiplePrinters) { IUnitOfWorkFactory unitOfWorkFactory = UnitOfWorkFactory.GetDefaultFactory; var commonService = ServicesConfig.CommonServices; var userPrintSettingsRepository = new UserPrintingRepository(); multiplePrintOperation = new MultiplePrintOperation(unitOfWorkFactory, commonService, userPrintSettingsRepository); } if (info.Source != null) { reportviewer1.LoadReport(info.Source, info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes); } else { if (multiplePrintOperation == null) { reportviewer1.LoadReport(info.GetReportUri(), info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes); } else { reportviewer1.LoadReport(info.GetReportUri(), info.GetParametersString(), info.ConnectionString, true, info.RestrictedOutputPresentationTypes, multiplePrintOperation.Run); } } if (!string.IsNullOrWhiteSpace(info.Title)) { reportviewer1.DefaultExportFileName = info.Title; } }
void LoadReport(ReportInfo info) { logger.Debug(String.Format("Report Parameters[{0}]", info.GetParametersString())); if (info.Source != null) { reportviewer1.LoadReport(info.Source, info.GetParametersString(), info.ConnectionString, true); } else { reportviewer1.LoadReport(info.GetReportUri(), info.GetParametersString(), info.ConnectionString, true); } }
public void ResendEmailWithErrorSendingStatus(DateTime date) { IEmailService service = EmailServiceSetting.GetEmailService(); if (service == null) { return; } IList <StoredEmail> errorSendedEmails; using (var uowLocal = UnitOfWorkFactory.CreateWithoutRoot()) { StoredEmail unsendedEmailAlias = null; StoredEmail alreadyResendedEmailAlias = null; var dateCriterion = Projections.SqlFunction( new SQLFunctionTemplate( NHibernateUtil.Date, "Date(?1)" ), NHibernateUtil.Date, Projections.Property <StoredEmail>(x => x.SendDate) ); ICriterion dateResctict = Restrictions.Eq(dateCriterion, date.Date); ICriterion dateResctictGe = Restrictions.Ge(dateCriterion, date.Date); var resendedQuery = QueryOver.Of <StoredEmail>() .Where(Restrictions.EqProperty(Projections.Property <StoredEmail>(x => x.Order.Id), Projections.Property(() => unsendedEmailAlias.Order.Id))) .Where(x => x.State != StoredEmailStates.SendingError) .Where(dateResctictGe) .Select(Projections.Count(Projections.Id())); errorSendedEmails = uowLocal.Session.QueryOver <StoredEmail>(() => unsendedEmailAlias) .Where(x => x.State == StoredEmailStates.SendingError) .Where(dateResctict) .WithSubquery.WhereValue(0).Eq(resendedQuery) .List(); foreach (var sendedEmail in errorSendedEmails) { var billDocument = sendedEmail.Order.OrderDocuments.FirstOrDefault(y => y.Type == OrderDocumentType.Bill) as BillDocument; if (billDocument == null) { continue; } billDocument.HideSignature = false; ReportInfo ri = billDocument.GetReportInfo(); var billTemplate = billDocument.GetEmailTemplate(); Email email = new Email { Title = string.Format("{0} {1}", billTemplate.Title, billDocument.Title), Text = billTemplate.Text, HtmlText = billTemplate.TextHtml, Recipient = new EmailContact("", sendedEmail.RecipientAddress), Sender = new EmailContact("vodovoz-spb.ru", ParametersProvider.Instance.GetParameterValue("email_for_email_delivery")), Order = billDocument.Order.Id, OrderDocumentType = OrderDocumentType.Bill }; foreach (var item in billTemplate.Attachments) { email.AddInlinedAttachment(item.Key, item.Value.MIMEType, item.Value.FileName, item.Value.Base64Content); } using (MemoryStream stream = ReportExporter.ExportToMemoryStream(ri.GetReportUri(), ri.GetParametersString(), ri.ConnectionString, OutputPresentationType.PDF, true)) { string billDate = billDocument.DocumentDate.HasValue ? "_" + billDocument.DocumentDate.Value.ToString("ddMMyyyy") : ""; email.AddAttachment($"Bill_{billDocument.Order.Id}{billDate}.pdf", stream); } email.AuthorId = sendedEmail.Author.Id; email.ManualSending = sendedEmail.ManualSending ?? false; service.SendEmail(email); } } }
private Email CreateDocumentEmail(string clientName, string organizationName, OrderDocument document) { if (document.Type == OrderDocumentType.Bill) { var billDocument = document as BillDocument; var wasHideSignature = billDocument.HideSignature; billDocument.HideSignature = false; ReportInfo ri = billDocument.GetReportInfo(); billDocument.HideSignature = wasHideSignature; EmailTemplate template = billDocument.GetEmailTemplate(); Email email = new Email(); email.Title = string.Format("{0} {1}", template.Title, billDocument.Title); email.Text = template.Text; email.HtmlText = template.TextHtml; foreach (var item in template.Attachments) { email.AddInlinedAttachment(item.Key, item.Value.MIMEType, item.Value.FileName, item.Value.Base64Content); } email.Recipient = new EmailContact(clientName, yvalidatedentryEmail.Text); email.Sender = new EmailContact(organizationName, ParametersProvider.Instance.GetParameterValue("email_for_email_delivery")); email.Order = document.Order.Id; email.OrderDocumentType = document.Type; using (MemoryStream stream = ReportExporter.ExportToMemoryStream(ri.GetReportUri(), ri.GetParametersString(), ri.ConnectionString, OutputPresentationType.PDF, true)) { string billDate = billDocument.DocumentDate.HasValue ? "_" + billDocument.DocumentDate.Value.ToString("ddMMyyyy") : ""; email.AddAttachment($"Bill_{billDocument.Order.Id}{billDate}.pdf", stream); } return(email); } else { //для других документов не реализована отправка почты return(null); } }