Attachments from SharePoint on SSRS report

Two weeks have passed and I have learned a lot and I am making slow but steady progress…

First goal was to get the job number from the UserCriteria in ds.DynamicCriteriaParam.UserCriteria. The data had many rows and at first, I could not parse out just the Job Number. The data is XML and I needed LINQ to XML. In the Using Directives, add usingSystem.Xml.Linq; and usingSystem.Linq;

The code to isolate only the JobNumber

string xml = ds.DynamicCriteriaParam[0].UserCriteria;

        XDocument xdoc = XDocument.Parse(xml);
        getJobNum = xdoc.Descendants("RptCriteriaPrompt")
            .Where(p => (string)p.Element("PromptName") == "JobNumber")
            .Select(p => (string)p.Element("PromptValue"))
            .FirstOrDefault();

This provided the JobNumber.

The second goal was to use the JobNumber to retrieve the file attachment names and file paths in SharePoint. The attachments are stored in the JobHead table. By joining the JobHead to the XFileAttch and XFileRef, I could grab the file path. The file path is stored in XFileRef.XFileName. Here is the code to grab the file path.

List<string> outputFileNameList = (
    from JobHead in Db.JobHead
    join xFileAttch in Db.XFileAttch
        on new { JobHead.Company, Key1 = JobHead.JobNum }
        equals new { xFileAttch.Company, Key1 = xFileAttch.Key1 }
    where xFileAttch.RelatedToFile == "JobHead"
    join xFileRef in Db.XFileRef
        on new { xFileAttch.Company, xFileAttch.XFileRefNum }
        equals new { xFileRef.Company, xFileRef.XFileRefNum }
    where JobHead.JobNum == getJobNum
    select xFileRef.XFileName
).ToList();

if (outputFileNameList.Count == 0)
{
    throw new Ice.BLException($"No file attachments found for Job Number '{getJobNum}'.");
}

Slowly and steadily, I learn and make progress toward the end goal of getting the engineering drawings on the Job Traveler.

Goal 3 - next step…