Exemplo n.º 1
0
        private void ScanService_EmailNotaDebitoEvent(object sender, ValueEventArgs <EmailInfo> e)
        {
            var t = Task.Factory.StartNew((o) =>
            {
                try
                {
                    EmailInfo val        = (EmailInfo)o;
                    int countryId        = val.IsoId;
                    int officeId         = val.HoId;
                    int invoiceNumber    = val.InNumber;
                    DateTime invoiceDate = val.InDate;

                    string serverUrl = string.Format("http://192.168.53.144/Reportserver/Pages/ReportViewer.aspx?%2fNota+Debito%2fNota+Debito+0032&rs:Command=Render&rs:format=PDF&iso_id={0}&Office={1}&in_date={2:dd/MM/yyyy}&invoicenumber={3}",
                                                     countryId, officeId, invoiceDate, invoiceNumber);

                    WebDataAccess access = new WebDataAccess();
                    var buffer           = access.DownloadReport(serverUrl, ScanService.ReportServerCredentials);
#warning TEST_ONLY
                    string email   = "*****@*****.**";// new PTFDataAccess().FindHeadOfficeEmail(countryId, officeId);//"*****@*****.**";//
                    string ccEmail = val.CC;
                    string subject = val.Subject;
                    string message = val.Body;

                    var att = new Attachment(new MemoryStream(buffer), new ContentType("application/pdf"));
                    EmailSender.SendSafe(email, ccEmail, subject, message, false, att);
                }
                catch (Exception ex)
                {
                    OnError(this, new ThreadExceptionEventArgs(ex));
                }
            }, e.Value, TaskCreationOptions.LongRunning);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="serverUrl"></param>
        /// <returns></returns>
        /// <example>
        /// http://192.168.53.144/Reportserver/Pages/ReportViewer.aspx?%2fNota+Debito%2fNota+Debito+0032&rs:Command=Render&rs:format=PDF&iso_id=724&Office=167150&in_date=02/12/2013&invoicenumber=42538
        /// </example>
        public byte[] DownloadReport(string serverUrl, string s1, string s2)
        {
            try
            {
                SecurityCheckThrow(s1, s2);
                RecordCallHistory("DownloadReport");

                if (ReportServerCredentials == null)
                {
                    throw new Exception("ReportServerCredentials may not be null");
                }

                WebDataAccess access = new WebDataAccess();
                return(access.DownloadReport(serverUrl, ReportServerCredentials));
            }
            catch (Exception ex)
            {
                throw new FaultException <MyApplicationFault>(new MyApplicationFault(), ex.Message);
            }
        }