Exemple #1
0
        private void reportPrint(List <titletable> title, List <TB_EXPENSE> detail, List <foots> fs)
        {
            try
            {
                ReportTools     myReportTool;
                TfrxReportClass report;
                myReportTool = new ReportTools();
                report       = new TfrxReportClass();
                report.ClearDatasets();
                FrxDataTable titleable = new FrxDataTable("dtWorkTitle");      //概要
                myReportTool.ListToFrxTable(title, titleable);
                FrxDataTable detailtable = new FrxDataTable("dtWorkDetail");   //明细
                myReportTool.ListToFrxTable(detail, detailtable);
                FrxDataTable detailtable2 = new FrxDataTable("dtWorkDetail2"); //明细2
                myReportTool.ListToFrxTable(fs, detailtable2);
                report.LoadReportFromFile("ExpenseReport.fr3");

                detailtable.AssignToReport(true, report);
                titleable.AssignToReport(true, report);
                report.ShowReport();
            }
            catch (System.Exception ex)
            {
                MessageHelper.ShowMessage(ex.Message);
            }
        }
Exemple #2
0
        public void SendEmail(CodeActivityContext context, MemoryStream AttachContent)
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.From = new MailAddress(From.Get(context));
            string STo = To.Get(context);

            STo.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList()
            .ForEach(item => mailMessage.To.Add(item.Trim()));

            mailMessage.Subject = Subject.Get(context);
            mailMessage.Body    = Body.Get(context);

            SmtpClient smtpClient = new SmtpClient();

            smtpClient.Host           = Host.Get(context);
            smtpClient.Port           = Port;
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            if (!String.IsNullOrEmpty(UserName.Get(context)) && !String.IsNullOrEmpty(Password.Get(context)))
            {
                smtpClient.Credentials = new System.Net.NetworkCredential(UserName.Get(context), Password.Get(context));
            }

            if (AttachContent != null)
            {
                string attachName = AttachName.Get(context);
                if (string.IsNullOrEmpty(attachName))
                {
                    attachName = "Отчет";
                }
                else
                {
                    attachName = ReportTools.CorrectFileName(attachName);
                }
                Attachment Attach;

                //if (UseZipArchive)
                //{
                //    MemoryStream compresStream = new MemoryStream();
                //    ComponentAce.Compression.ZipForge.ZipForge zip = new ComponentAce.Compression.ZipForge.ZipForge();
                //    zip.FileName = attachName + ".zip"; ;
                //    AttachContent.Position = 0;
                //    zip.OpenArchive(compresStream, true);
                //    zip.AddFromStream(attachName + GetFileExtByReportFormat(), AttachContent);
                //    zip.CloseArchive();
                //    Attach = new Attachment(AttachContent, zip.FileName);
                //    zip.Dispose();
                //}
                //else
                {
                    Attach = new Attachment(AttachContent, attachName + GetFileExt());
                }
                mailMessage.Attachments.Add(Attach);
            }
            //throw new Exception("Error sending email"); // test exception
            smtpClient.Send(mailMessage);
        }
        public void PutReportToFolder(CodeActivityContext context, MemoryStream Document)
        {
            string folder;
            string fileName;


            folder   = context.GetValue(this.Folder);
            fileName = context.GetValue(this.FileName);
            fileName = ReportTools.CorrectFileName(fileName + GetFileExtByReportFormat());
            fileName = Path.Combine(folder, fileName);
            using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                Document.WriteTo(file);
            }
        }
Exemple #4
0
 private void reportPrint(List <projProfileClass> summery, List <TB_EXPENSE> detail)
 {
     try
     {
         ReportTools     myReportTool;
         TfrxReportClass report;
         myReportTool = new ReportTools();
         report       = new TfrxReportClass();
         report.ClearDatasets();
         FrxDataTable summeryTable = new FrxDataTable("dtWorkTitle");  //概要
         myReportTool.ListToFrxTable(summery, summeryTable);
         FrxDataTable detailtable = new FrxDataTable("dtWorkDetail");  //明细
         myReportTool.ListToFrxTable(detail, detailtable);
         report.LoadReportFromFile("profileReport.fr3");
         summeryTable.AssignToReport(true, report);
         detailtable.AssignToReport(true, report);
         report.ShowReport();
     }
     catch (System.Exception ex)
     {
         MessageHelper.ShowMessage(ex.Message);
     }
 }
        private void GenerateReport(Connections connections, VariableDispenser variableDispenser,
                                    IDTSComponentEvents componentEvents, bool refire)
        {
            componentEvents.FireInformation(0, "SSISReportGeneratorTask", "Get Needed Variables", string.Empty, 0, ref refire);

            GetNeededVariables(variableDispenser, componentEvents);

            try
            {
                string reportName = ReportName;

                if (!string.IsNullOrEmpty(ReportNameFromExpression))
                {
                    reportName = Tools.EvaluateExpression(ReportNameFromExpression, variableDispenser).ToString();
                }


                var reportTools = new ReportTools();

                componentEvents.FireInformation(0, "SSISReportGeneratorTask", "Get Report's parameters", string.Empty, 0,
                                                ref refire);
                var reportParameters = new ReportParameter[((MappingParams)MappingParams).Count];

                int paramCounter = 0;

                foreach (var mappingParams in (MappingParams)MappingParams)
                {
                    reportParameters[paramCounter++] = new ReportParameter
                    {
                        Name  = mappingParams.Name,
                        Value =
                            Tools.EvaluateExpression(mappingParams.Value,
                                                     variableDispenser).ToString()
                    };

                    componentEvents.FireInformation(0, "SSISReportGeneratorTask",
                                                    string.Format("Param. {0} - {1} with value: {2}",
                                                                  mappingParams.Name,
                                                                  mappingParams.Value,
                                                                  Tools.EvaluateExpression(mappingParams.Value,
                                                                                           variableDispenser)),
                                                    string.Empty, 0, ref refire);
                }

                componentEvents.FireInformation(0, "SSISReportGeneratorTask",
                                                string.Format("Start to render the report for {0}{1} OutPutType is {2}",
                                                              Tools.EvaluateExpression(ReportServer, variableDispenser),
                                                              ReportPath + "/" + reportName,
                                                              OutPutType),
                                                string.Empty, 0, ref refire);

                byte[] reportSource =
                    reportTools.RenderReport(Tools.EvaluateExpression(ReportServer, variableDispenser).ToString(),
                                             ReportPath + "/" + reportName,
                                             reportParameters,
                                             OutPutType,
                                             componentEvents);

                var targetFile = GetTargetFile(variableDispenser, connections);

                componentEvents.FireInformation(0, "SSISReportGeneratorTask",
                                                string.Format("Copy the result to {0}", targetFile),
                                                string.Empty, 0, ref refire);

                if (File.Exists(targetFile))
                {
                    File.Delete(targetFile);
                }

                File.WriteAllBytes(targetFile, reportSource);

                componentEvents.FireInformation(0, "SSISReportGeneratorTask",
                                                string.Format("The file was generated successfully to {0}",
                                                              targetFile),
                                                string.Empty, 0, ref refire);

                if (SendFileByEmail == Keys.TRUE)
                {
                    componentEvents.FireInformation(0, "SSISReportGeneratorTask",
                                                    string.Format("Prepare to send the file by email from -{0}- to -{1}-",
                                                                  Tools.EvaluateExpression(SmtpFrom, variableDispenser),
                                                                  Tools.EvaluateExpression(SmtpRecipients, variableDispenser)),
                                                    string.Empty, 0, ref refire);

                    Tools.SendEmail(variableDispenser,
                                    connections,
                                    componentEvents,
                                    targetFile,
                                    SmtpFrom,
                                    SmtpRecipients,
                                    EmailSubject,
                                    EmailBody,
                                    SmtpServer);
                }
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "SSISReportGeneratorTask",
                                          string.Format("Problem: {0} {1}", ex.Message, ex.StackTrace), "", 0);
            }
            finally
            {
                if (_vars.Locked)
                {
                    _vars.Unlock();
                }
            }
        }