Use the same job to loop through multiple origins: Difference between revisions

From Starfish ETL
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
object ScriptedVariable()
object ScriptedVariable()
{
{
                //Sample UserIDs setting: ADMIN      ;UAAAAA000069;UAAAAA00006B;UAAAAA00006A;UAAAAA000068
                 string mb = Starfish.GetSetting("Mailboxes");
                 string mb = Starfish.GetSetting("Mailboxes");
                 Starfish.LogMessage(runCnt.ToString());
                 Starfish.LogMessage(runCnt.ToString());

Revision as of 21:11, 12 February 2018

This example looks at reading from multiple mailboxes for email. Use a variable in the origin connection string. If the job needs to run for another mailbox, it calls the GotoJob function in the “Once After Conn” and pass in the Job's ID.

Once Before Conn Before Operation that returns the current Mailbox to process.

object ScriptedVariable()
{
                //Sample UserIDs setting: ADMIN       ;UAAAAA000069;UAAAAA00006B;UAAAAA00006A;UAAAAA000068
                string mb = Starfish.GetSetting("Mailboxes");
                Starfish.LogMessage(runCnt.ToString());
                mb = mb.Split(';')[runCnt].Split(',')[0];
                mailBox = mb;
                Starfish.LogMessage("Mailbox: " + mb);
                return mb;
}

Connection String:

@@VAR:vMailbox@@

Once After Conn

void CSharpProcedure()
{              
                if (!Starfish.PreviewMode)
                                Starfish.SaveSetting("Mail-LRD-"+mailBox, DateTime.Now.ToString());
                string mb = Starfish.GetSetting("Mailboxes");
                if (runCnt < mb.Split(';').Length-1)
                {
                                runCnt++;
                                Starfish.GotoJob("f54baebc-d128-4f9d-9d1a-ac7c88e027fe");
                }
}