Ejemplo n.º 1
0
        private static void Main()
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            Stopwatch sw             = new Stopwatch();
            var       noOfIterations = TotalRecords / noOfRecordsPerFile;

            for (var i = 0; i < noOfIterations; i++)
            {
                var reportService = new ReportPdf();

                sw.Restart();
                var reportData = CreateReportData();
                var path       = GetTempPdfPath();
                reportService.Export(path, reportData);
                sw.Stop();
                Console.WriteLine("Time taken" + sw.Elapsed.TotalSeconds);
                //Process.Start(path);
            }
            sw.Reset();
            sw.Start();
            Console.WriteLine();
            ReportPdf.CombinePDFs(@"D:\APDFData", "ConcatenatedDocument1_tempfile.pdf");
            sw.Stop();
            Console.WriteLine("Time taken to combine the pdf" + sw.Elapsed.TotalSeconds);
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            Stopwatch sw             = new Stopwatch();
            var       noOfIterations = TotalRecords / noOfRecordsPerFile;

            for (var i = 0; i < noOfIterations; i++)
            {
                var reportService = new ReportPdf();

                sw.Restart();
                var reportData = CreateReportData();
                var path       = GetTempPdfPath();
                reportService.Export(path, reportData);
                sw.Stop();
                Console.WriteLine("Time taken" + sw.Elapsed.TotalSeconds);
                Process.Start(path);
            }
            sw.Reset();
            sw.Start();
            Console.WriteLine();
            ReportPdf.CombinePDFs(@"D:\GeneratedPDF", "ConcatenatedDocument1_tempfile.pdf");
            sw.Stop();
            Console.WriteLine("Time taken to combine the pdf" + sw.Elapsed.TotalSeconds);
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private static void Main()
        {
            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            var path = GetTempPdfPath();

            reportService.Export(path, reportData);

            Process.Start(path);
        }
Ejemplo n.º 4
0
        private void PrintButtonClicked(object sender, RoutedEventArgs e)
        {
            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            var path = GetTempPdfPath();

            reportService.Export(path, reportData);

            Process.Start(path);
        }
        public void TestePdfExport()
        {
            string daten = File.ReadAllText($"{System.AppDomain.CurrentDomain.BaseDirectory}\\TestDaten\\2019_Landesliga_RCA-Bayreuth_vs_ASV-Hof.json");
            MannschaftskampfViewModel testMannschaftskampfViewModel = new MannschaftskampfViewModel(JObject.Parse(daten), null);

            var zusatzInfos = GetDemoZusatzInfos();

            //TODO Löschen, sobald wirklich Punkte hinterlegt sind
            Random rnd = new Random();
            int    cnt = 0;

            foreach (Bout bout in testMannschaftskampfViewModel.Children)
            {
                for (int i = 0; i < rnd.Next(1, 10); i++)
                {
                    var ringer = (rnd.Next(1, 3) == 1 ? Core.CS.BoutPoint.Wrestler.Home : Core.CS.BoutPoint.Wrestler.Opponent);

                    var zeit = new DateTime(
                        testMannschaftskampfViewModel.BoutDateDateTime.Year,
                        testMannschaftskampfViewModel.BoutDateDateTime.Month,
                        testMannschaftskampfViewModel.BoutDateDateTime.Day,
                        testMannschaftskampfViewModel.ScaleTime.Hours,
                        testMannschaftskampfViewModel.ScaleTime.Minutes + cnt + i + 4,
                        rnd.Next(1, 59)
                        );

                    bout.Points.Add(new Core.CS.BoutPoint(rnd.Next(1, 5).ToString(), null, ringer, zeit));
                }

                cnt++;
            }

            Random random   = new Random();
            string filename = $"Test_{random.Next()}.pdf";

            IReport bericht = new ReportPdf();

            bericht.Export(filename, testMannschaftskampfViewModel, zusatzInfos);
            Process.Start(filename);//Öffne PDF
        }
Ejemplo n.º 6
0
        public void SendReport(PartnerModel model)
        {
            var reportService = new ReportPdf();


            string startDate = DateTime.Now.AddDays(-2).ToString("MM/dd/yyyy");
            string endDate   = DateTime.Now.AddDays(-1).ToString("MM/dd/yyyy");
            List <ALMParnterSearchModelsData> listData = new List <ALMParnterSearchModelsData>();

            var yesterDayDate = DateTime.Now.AddDays(-1).ToString("MM-dd-yyyy");

            //  string partnerData = "select PolicyDetail.PolicyNumber as PolicyNumber, PartnerCommissions.CommissionPercentage ,Branch.BranchName as BranchName,  convert(varchar, PolicyDetail.CreatedOn, 106) as CreatedOn , PaymentInformation.PaymentId, VehicleDetail.Premium,cast(VehicleDetail.Premium * PartnerCommissions.CommissionPercentage as decimal(10, 2)) as Comission_Amount, Customer.ALMId from PolicyDetail join Customer on Customer.Id = PolicyDetail.CustomerId join VehicleDetail on VehicleDetail.PolicyId = PolicyDetail.Id join PaymentInformation on PaymentInformation.PolicyId = PolicyDetail.Id join Branch on VehicleDetail.ALMBranchId = Branch.Id join Partners on Partners.Id = Branch.PartnerId join PartnerCommissions on CommissionEffectiveDate <= PolicyDetail.CreatedOn and PartnerCommissions.PartnerId = branch.PartnerId where PolicyDetail.CreatedOn BETWEEN '" + startDate + "' AND '" + endDate + "' and branch.PartnerId=" + model.Id;

            string partnerData = "select PolicyDetail.PolicyNumber as PolicyNumber, Branch.BranchName as BranchName, ";

            partnerData += " convert(varchar, PolicyDetail.CreatedOn, 106) as CreatedOn, PaymentInformation.PaymentId, VehicleDetail.Premium, ";
            partnerData += " cast(VehicleDetail.Premium * ( select top 1  CommissionPercentage  from PartnerCommissions as b  where PartnerId=" + model.Id + " and b.CommissionEffectiveDate<= PolicyDetail.CreatedOn ";
            partnerData += " or b.CommissionEffectiveDate < (select top 1 CommissionEffectiveDate from PartnerCommissions where b.Id = b.Id+1  )) as decimal(10, 2)) as Comission_Amount,  ";
            partnerData += " Customer.ALMId  from PolicyDetail  join Customer on Customer.Id = PolicyDetail.CustomerId join VehicleDetail on VehicleDetail.PolicyId = PolicyDetail.Id  ";
            partnerData += " join PaymentInformation on PaymentInformation.PolicyId = PolicyDetail.Id  join Branch on VehicleDetail.ALMBranchId = Branch.Id  ";
            partnerData += " join Partners on Partners.Id = Branch.PartnerId where convert(varchar,PolicyDetail.CreatedOn,110)=convert(varchar,'" + yesterDayDate + "',110) and branch.PartnerId=" + model.Id;

            // convert(varchar(5),PolicyDetail.CreatedOn,110)=convert(varchar(5),getdate(),110)
            Library.WriteErrorLog("Query: " + partnerData);

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();

                SqlCommand com = new SqlCommand(partnerData);
                com.CommandType = CommandType.Text;
                com.Connection  = con;

                using (SqlDataReader reader = com.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        ALMParnterSearchModelsData data = new ALMParnterSearchModelsData();
                        data.BranchName   = reader["BranchName"] == null ? "" : Convert.ToString(reader["BranchName"]);
                        data.PolicyNumber = reader["PolicyNumber"] == null ? "" : Convert.ToString(reader["PolicyNumber"]);

                        listData.Add(data);
                    }
                }
            }



            StructureSet structureSet = new StructureSet
            {
                Id         = model.PartnerName + " ALM Daily Report ",
                Structures = listData.ToArray()
            };

            var reportData = CreateReportData(model, structureSet);
            var path       = GetTempPdfPath();

            reportService.Export(path, reportData);

            //TODO list of Partners to recive emails
            var FromMailAddress = System.Configuration.ConfigurationManager.AppSettings["SendEmailFrom"].ToString();
            var password        = System.Configuration.ConfigurationManager.AppSettings["SendEmailFromPassword"].ToString();
            var smtpAddress     = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["SendEmailSMTP"]);


            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(FromMailAddress);
            mail.To.Add("*****@*****.**");
            mail.Subject = "ALM Partner Daily Report ";
            mail.Body    = "Please check attached file.";

            System.Net.Mail.Attachment attachment;
            attachment      = new System.Net.Mail.Attachment(path);
            attachment.Name = "ALM Partner Daily Report";
            mail.Attachments.Add(attachment);
            var smtp = new System.Net.Mail.SmtpClient();

            {
                smtp.Host           = smtpAddress;
                smtp.Port           = 587;
                smtp.EnableSsl      = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new System.Net.NetworkCredential(FromMailAddress, password);
            }
            smtp.Send(mail);
        }