<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom Task: add file as reference in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243463#M17348</link>
    <description>Dang, you're right!  Rookie mistake!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 14 Jan 2016 13:22:41 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-01-14T13:22:41Z</dc:date>
    <item>
      <title>Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239139#M17201</link>
      <description>&lt;P&gt;I am aware that this is a question only &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger﻿&lt;/a&gt; may be able to answer, but i dare to ask anyway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am developing a custom task which creates a new file in the Windows file system (e.g. Excel). What i want to achieve is that after the custom task is executed a reference to this newly created file is added to the process flow.&lt;/P&gt;&lt;P&gt;I read the book "Custom Tasks for SAS Enterprise Guide Using Microsoft .NET" and tried the code from chapter 12 which seems to be close to the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However this (simplified) code:&lt;/P&gt;&lt;PRE&gt; public ISASTaskStream OpenResultStream(int Index)
  {
    var memoryStream = new MemoryStream(File.ReadAllBytes(Settings.ExcelOutputPath));

    var fileInfo = new FileInfo(Settings.ExcelOutputPath);

    return new StreamAdapter(memoryStream
                            , "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"// "application/vnd.ms-excel"
                            , fileInfo.Name);
  }&lt;/PRE&gt;&lt;P&gt;writes a full copy of the file to the process flow and embeds the file into the workflow:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1164i77CE0702A897BC97/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="2015-12-14 13_57_24-SAS Enterprise Guide - SampleProject.egp.png" title="2015-12-14 13_57_24-SAS Enterprise Guide - SampleProject.egp.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that there are plenty of ways to generate an Excel file, but what i would like to achieve is a linked reference in the process flow like the "export as step in process" task does:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1165iB2007832FE55B47F/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="2015-12-14 13_59_38-SAS Enterprise Guide.png" title="2015-12-14 13_59_38-SAS Enterprise Guide.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So can anybody provide me a C# code snippet for adding a file reference or tell me which classes are involved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 13:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239139#M17201</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2015-12-14T13:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239323#M17206</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16887"&gt;@AndreasMenrath﻿&lt;/a&gt;&amp;nbsp;- it sounds like you want to add a reference to an external file as a linked item in the flow, correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure it's possible with the Custom Task APIs, but I will dig in and see if I can find something creative.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 12:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239323#M17206</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2015-12-15T12:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239328#M17207</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger﻿&lt;/a&gt;: exactly.&lt;/P&gt;&lt;P&gt;What i want is just a reference like when an external file is drag&amp;amp;dropped into the process flow from the Windows explorer or like the file reference in the "export as step in process" task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for looking into the solution of this issue &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 13:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239328#M17207</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2015-12-15T13:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239344#M17208</link>
      <description>&lt;P&gt;I've looked into this a bit, and don't yet have a solution. &amp;nbsp;But I'll share some things I've tried in case you want to hammer at them further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I tried adding just a "file" as an output data item in the Task class. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public override System.Collections.Generic.List&amp;lt;ISASTaskDataDescriptor&amp;gt; OutputDataDescriptorList
{
    get
    {
        ISASTaskDataDescriptor d = 
     SAS.Shared.AddIns.SASTaskDataDescriptor.CreateLocalDataDescriptor
      ("c:\temp\sample.xlsx", "Sample.xlsx");
        System.Collections.Generic.List&amp;lt;ISASTaskDataDescriptor&amp;gt; outList =
           new System.Collections.Generic.List&amp;lt;ISASTaskDataDescriptor&amp;gt;();
        outList.Add(d);
        return outList;
    }
}
&lt;/PRE&gt;
&lt;P&gt;Also added this an an attribute on the Task class:&lt;/P&gt;
&lt;PRE&gt;[SAS.Shared.AddIns.CreatesDataDirectly(true)]&lt;/PRE&gt;
&lt;P&gt;But no success. &amp;nbsp;I think that EG doesn't add the result because it's not a true data reference...but I haven't debugged enough to verify.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach to add a file to a project. &amp;nbsp;With EG open, you can launch the SEGuide command with the &lt;STRONG&gt;/openfile&lt;/STRONG&gt; command-line switch and add a file reference to the existing instance of EG. &amp;nbsp;You could tell .NET to take the existing Process command and form your own variation with the command-line option. &amp;nbsp;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;"C:\Program Files (x86)\SASHome\x86\SASEnterpriseGuide\7.1\SEGuide.exe" 
     /openfile:c:\temp\sample.xlsx&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;But&lt;/STRONG&gt;, EG automatically launches the Import Data task for most files that you try to add in this way...because of course that's what EG does with files like Excel spreadsheets. &amp;nbsp;And even if you do get the file added to the project, it won't be linked from your task as output.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2015 14:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/239344#M17208</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2015-12-15T14:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243422#M17345</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your suggestion. It is funny, but your suggested code works on my machine.&lt;/P&gt;&lt;P&gt;It successfully adds a referenced file to the process flow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think EG is case sensitive on the file name. Maybe that's the reason why your code did not run on your machine.&lt;/P&gt;&lt;P&gt;Using this just works fine:&lt;/P&gt;&lt;PRE&gt;var fileInfo = new FileInfo(@"C:\temp\Sample.xlsx");
ISASTaskDataDescriptor d = SASTaskDataDescriptor.CreateLocalDataDescriptor(fileInfo.FullName, fileInfo.Name);&lt;/PRE&gt;&lt;P&gt;Thank you and best regards,&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 09:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243422#M17345</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2016-01-14T09:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243460#M17346</link>
      <description>Well, I'm not going to question it.  If it works for you, that's great!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jan 2016 13:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243460#M17346</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-01-14T13:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243461#M17347</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also noticed a common C# error in your code:&lt;BR /&gt;you used the string "c:\temp\sample.xlsx" inside your code.&lt;BR /&gt;&lt;BR /&gt;The backslash in a string is used for masking, so \t is translated to a tabulator character.&lt;/P&gt;&lt;P&gt;So using double backslashes "c:\\temp\\sample.xlsx" oder using a verbatim string with @"c:\temp\sample.xlsx" should also fix your code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 13:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243461#M17347</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2016-01-14T13:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Task: add file as reference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243463#M17348</link>
      <description>Dang, you're right!  Rookie mistake!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jan 2016 13:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Custom-Task-add-file-as-reference/m-p/243463#M17348</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-01-14T13:22:41Z</dc:date>
    </item>
  </channel>
</rss>

