private static void GetGuidsFromReport(MailTrigger Trigger)
        {
            string          folder          = "\\AutoMailer\\";
            FileSystemEntry fileSystemEntry = new FileSystemEntry(folder, FileSystemEntry.Types.Folder, (string)null);

            Sessions.Session  defaultInstance = Session.DefaultInstance;
            FSExplorer        rptExplorer     = new FSExplorer(defaultInstance);
            ReportMainControl r           = new ReportMainControl(defaultInstance, false);
            ReportIFSExplorer ifsExplorer = new ReportIFSExplorer(r, defaultInstance);


            FileSystemEntry report         = ifsExplorer.GetFileSystemEntries(fileSystemEntry).Where(x => x.Name.Equals(Trigger.ReportFilter)).FirstOrDefault();
            ReportSettings  reportSettings = Session.DefaultInstance.ReportManager.GetReportSettings(report);

            LoanReportParameters reportParams1 = new LoanReportParameters();

            reportParams1.Fields.AddRange((IEnumerable <ColumnInfo>)reportSettings.Columns);
            reportParams1.FieldFilters.AddRange((IEnumerable <FieldFilter>)reportSettings.Filters);
            reportParams1.UseDBField              = reportSettings.UseFieldInDB;
            reportParams1.UseDBFilter             = reportSettings.UseFilterFieldInDB;
            reportParams1.UseExternalOrganization = reportSettings.ForTPO;
            reportParams1.CustomFilter            = CreateLoanCustomFilter(reportSettings);
            ReportResults results = Session.DefaultInstance.ReportManager.QueryLoansForReport(reportParams1, null);


            List <string[]> reportResults = ReportResults.Download(results);
            List <string>   guids         = results.GetAllResults().Select(x => x.FirstOrDefault()).ToList();

            bool fieldsAreGuids = Guid.TryParse(guids.FirstOrDefault(), out Guid _);

            if (fieldsAreGuids)
            {
                SendEmails(Trigger, guids);
            }
        }
Exemple #2
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            ResetGrid();
            gpReportControls.Visible = true;
            ReportMainControl r = (ReportMainControl)FormWrapper.Find("ReportMainControl");

            if (r == null)
            {
                MessageBox.Show("Please Open the Report tab and select a report.");
                return;
            }

            FileSystemEntry f = (FileSystemEntry)r.GetType().GetField("currentFile", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(r);

            if (f == null)
            {
                MessageBox.Show("Issue finding selected Report.");
                return;
            }

            Sessions.Session sesh        = Session.DefaultInstance;
            FSExplorer       rptExplorer = new FSExplorer(sesh);

            r = new ReportMainControl(sesh, false);
            ReportIFSExplorer ifs      = new ReportIFSExplorer(r, sesh);
            ReportSettings    settings = sesh.ReportManager.GetReportSettings(f);

            if (settings.Columns.Count() < 2)
            {
                MessageBox.Show("Please enter two fields and save your report.");
                return;
            }

            string firstColID = settings.Columns.FirstOrDefault().FieldID;

            if (!firstColID.Equals("GUID") && !firstColID.Equals("364"))
            {
                MessageBox.Show("The first field of your report must be Loan Number or GUID");
                return;
            }

            LoanReportParameters parameters = new LoanReportParameters();

            parameters.Fields.AddRange(settings.Columns);
            parameters.FieldFilters.AddRange(settings.Filters);
            parameters.UseDBField  = settings.UseFieldInDB;
            parameters.UseDBFilter = settings.UseFilterFieldInDB;

            parameters.UseExternalOrganization = settings.forTPO;
            parameters.CustomFilter            = CreateLoanCustomFilter(settings);
            ReportResults results = sesh.ReportManager.QueryLoansForReport(parameters, null);

            List <string[]> data = results.GetAllResults();

            dgvData.Columns.AddRange(parameters.Fields.Select(x => new DataGridViewTextBoxColumn()
            {
                HeaderText = x.FieldID
            }).ToArray());
            dgvData.Rows.Add(data.Count);
            for (int i = 0; i < data.Count; i++)
            {
                for (int ii = 0; ii < data[i].Count(); ii++)
                {
                    dgvData.Rows[i].Cells[ii].Value = data[i][ii];
                }
            }
            dgvData.CellValueChanged -= dgvData_CellValueChanged;
            dgvData.CellValueChanged += dgvData_CellValueChanged;
        }