DSS - Extracted files - Clean up

Hilarius
Hilarius Explorer

Is there any api or a way to remove 'Extracted files' with additional information(ScheduleId, ReportExtractionId... )? What our team wants to do is remove specific file on 'Extracted files' PROGRMATICALLY.

In document below, I just found about 'Clean up' section, but there is no about 'Extracted files'. (Only about instrument list, a report template and a schedule)

- https://developers.thomsonreuters.com/datascope-select-dss/datascope-select-rest-api/learning?content=5994&type=learning_material_item

Best Answer

  • gteage01
    gteage01 LSEG
    Answer ✓

    Hi,

    I would recommend using the .NET Example Application (C# / Direct HTTP - executable code examples):

    https://hosted.datascopeapi.reuters.com/RestApi.Help/Home/ExampleAppInstructions

    (from landing page: https://hosted.datascopeapi.reuters.com/RestApi.Help/Home/Index - DSS credentials required)

    Once unzipped use ...\RESTAPIExampleApplication\bin\Release\Dss.Api.Examples.exe

    Login into DSS App using DSS credentials

    The "Schedule Extractions" (section) > "Cleanup" example should help here, particularly this part of the code:

    //Delete the extracted files, schedule, instrument list and report template. See the "Cleanup" example for
    //the various steps involved with cleanup. NOTE: It is a good idea to clean up the extracted files (Report Extractions)
    //once you have downloaded the results. If the schedule is not immediate (i.e. recurring), you want to keep the
    //instrument list, report template and schedule around.
    if (schedule.ScheduleId != null)
    {
    //Get the extractions so that we can delete the extraction files
    var scheduleExtractions = ExtractionsContext.ReportExtractionOperations.GetByScheduleId(schedule.ScheduleId);

    foreach (var reportExtraction in scheduleExtractions)
    {
    //Get all the files for this extraction
    ExtractionsContext.LoadProperty(reportExtraction, "Files");

    //Use the DeleteMultiple method to delete all the files associated with the schedule
    var fileIds = reportExtraction.Files
    .Where(f => f.ContentsExists).Select(f => f.ExtractedFileId).ToList();
    if (fileIds.Count > 0)
    ExtractionsContext.ExtractedFileOperations.DeleteMultiple(fileIds);
    }

    This landing page can also be found via the DSS GUI: https://hosted.datascope.reuters.com/DataScope/ > "Help" (dropdown) > "REST API Help"

    Best regards,

    Gareth