Use the same job to loop through multiple origins

From Starfish ETL
Revision as of 20:17, 6 January 2017 by Jkuehlthau (talk | contribs)
Jump to navigation Jump to search

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

object ScriptedVariable()
{
                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");
                }
}