'Prepares parameters for the extract using a feed type of the object type, being extracted
Function PrepareExtractParams(feedType As String) As Object
Dim ExtractParams As Object
Dim SecAlias, FromDate, ToDate, FromEffectiveDate, ToEffectiveDate, Ticker, PrimaryAssetId, SourceName, OnlyHeld, HeldPositionSources, EntitySelectionType, EntitySelectionValue, EntityXrefType, MaxRows
Set ExtractParams = CreateObject("scripting.dictionary")
ExtractParams.Add "FeedType", feedType
If StrComp(feedType, "SMFEXTRACT", vbTextCompare) = 0 Then
SecAlias = Range("F15").Text
FromDate = Range("F17").Text
ToDate = Range("F19").Text
OnlyHeld = Range("F21").Text
HeldPositionSources = Range("F23").Text
MaxRows = Range("F25").Text
If SecAlias <> "" Then
ExtractParams.Add "securityalias", SecAlias
End If
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If StrComp(OnlyHeld, "yes", vbTextCompare) = 0 Then
ExtractParams.Add "onlyheld", "Y"
Else
ExtractParams.Add "onlyheld", "N"
End If
If HeldPositionSources <> "" Then
ExtractParams.Add "heldpositionsources", HeldPositionSources
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
If StrComp(feedType, "WRHSPOSITIONEXTRACT", vbTextCompare) = 0 Or StrComp(feedType, "WRHSTRADEEXTRACT", vbTextCompare) = 0 Then
SecAlias = Range("F15").Text
FromDate = Range("F17").Text
ToDate = Range("F19").Text
FromEffectiveDate = Range("F21").Text
ToEffectiveDate = Range("F23").Text
PrimaryAssetId = Range("F25").Text
Ticker = Range("F27").Text
SourceName = Range("F29").Text
EntitySelectionType = Range("F31").Text
EntitySelectionValue = Range("F33").Text
EntityXrefType = Range("F35").Text
MaxRows = Range("F37").Text
If SecAlias <> "" Then
ExtractParams.Add "securityalias", SecAlias
End If
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If FromEffectiveDate <> "" Then
ExtractParams.Add "FromEffectiveDate", Replace(FromEffectiveDate, ":", "-")
End If
If ToEffectiveDate <> "" Then
ExtractParams.Add "ToEffectiveDate", Replace(ToEffectiveDate, ":", "-")
End If
If PrimaryAssetId <> "" Then
ExtractParams.Add "primaryassetid", PrimaryAssetId
End If
If Ticker <> "" Then
ExtractParams.Add "ticker", Ticker
End If
If SourceName <> "" Then
ExtractParams.Add "sourcename", SourceName
End If
If EntitySelectionType <> "" Then
ExtractParams.Add "entityselectiontype", EntitySelectionType
ExtractParams.Add "entityselectionvalue", EntitySelectionValue
End If
If StrComp(EntitySelectionType, "EntityXrefId", vbTextCompare) = 0 And EntityXrefType <> "" Then
ExtractParams.Add "EntityXrefType", EntityXrefType
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
If StrComp(feedType, "ENTITYEXTRACT", vbTextCompare) = 0 Then
FromDate = Range("F15").Text
ToDate = Range("F17").Text
EntitySelectionType = Range("F19").Text
EntitySelectionValue = Range("F21").Text
EntityXrefType = Range("F23").Text
MaxRows = Range("F25").Text
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If EntitySelectionType <> "" Then
ExtractParams.Add "entityselectiontype", EntitySelectionType
ExtractParams.Add "entityselectionvalue", EntitySelectionValue
End If
If StrComp(EntitySelectionType, "EntityXrefId", vbTextCompare) = 0 And EntityXrefType <> "" Then
ExtractParams.Add "EntityXrefType", EntityXrefType
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
If StrComp(feedType, "REFTIMESERIESEXTRACT", vbTextCompare) = 0 Then
FromDate = Range("F15").Text
ToDate = Range("F17").Text
MaxRows = Range("F19").Text
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
If StrComp(feedType, "SCHEDULEEXTRACT", vbTextCompare) = 0 Then
SecAlias = Range("F15").Text
FromDate = Range("F17").Text
ToDate = Range("F19").Text
FromEffectiveDate = Range("F21").Text
ToEffectiveDate = Range("F23").Text
PrimaryAssetId = Range("F25").Text
Ticker = Range("F27").Text
SourceName = Range("F29").Text
OnlyHeld = Range("F31").Text
HeldPositionSources = Range("F33").Text
MaxRows = Range("F35").Text
If SecAlias <> "" Then
ExtractParams.Add "securityalias", SecAlias
End If
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If FromEffectiveDate <> "" Then
ExtractParams.Add "fromeffectivedate", FromEffectiveDate
End If
If ToEffectiveDate <> "" Then
ExtractParams.Add "toeffectivedate", ToEffectiveDate
End If
If PrimaryAssetId <> "" Then
ExtractParams.Add "primaryassetid", PrimaryAssetId
End If
If Ticker <> "" Then
ExtractParams.Add "ticker", Ticker
End If
If SourceName <> "" Then
ExtractParams.Add "sourcename", SourceName
End If
If StrComp(OnlyHeld, "yes", vbTextCompare) = 0 Then
ExtractParams.Add "onlyheld", "Y"
Else
ExtractParams.Add "onlyheld", "N"
End If
If HeldPositionSources <> "" Then
ExtractParams.Add "heldpositionsources", HeldPositionSources
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
If StrComp(feedType, "GENISSUEREXTRACT", vbTextCompare) = 0 Then
FromDate = Range("F15").Text
ToDate = Range("F17").Text
MaxRows = Range("F19").Text
If FromDate <> "" Then
ExtractParams.Add "fromdate", Replace(FromDate, ":", "-")
End If
If ToDate <> "" Then
ExtractParams.Add "todate", Replace(ToDate, ":", "-")
End If
If MaxRows <> "" Then
ExtractParams.Add "maxrows", MaxRows
End If
Set PrepareExtractParams = ExtractParams
End If
End Function
'Launches the extract process for a specified feed type
Sub Extract_Data(feedType As String)
Dim Login As String
Dim Pass As String
Dim ParamString As String
Dim ParamName As String
Dim ParamValue As String
Dim i As Integer
Dim Params As Object
Set Params = PrepareExtractParams(feedType)
Login = Range("F7").Text
Pass = ActiveSheet.TextBox1.Text
ParamString = ""
'Wrap the extract parameters, generated by the PrepareExtractParams method into the <taskParameter> nodes
For i = 0 To UBound(Params.Keys())
ParamName = Params.Keys()(i)
ParamValue = Replace(Params(ParamName), ":", "")
ParamString = ParamString & "<taskParameter><name>" & ParamName & "</name><dataType>S</dataType><value>" & ParamValue & "</value></taskParameter>"
Next
'Start an extract using the wrapped parameters
If Login <> "" And Pass <> "" Then
Extract_TSR "https://eagleeccprod1.eagleaccess.com", Login, Pass, ParamString, feedType
Else
MsgBox "Invalid authorization!"
End If
End Sub