NET Link Tracker
GetTrackedLinksByAlternateLinkId Method (LinkLogic)
Example 



KellermanSoftware.NetLinkTracker Namespace > LinkLogic Class : GetTrackedLinksByAlternateLinkId Method
Get a link by the AlternateLinkId.
Syntax
'Declaration
 
Public Function GetTrackedLinksByAlternateLinkId( _
   ByVal alternateLinkId As Long _
) As List(Of TrackedLink)
'Usage
 
Dim instance As LinkLogic
Dim alternateLinkId As Long
Dim value As List(Of TrackedLink)
 
value = instance.GetTrackedLinksByAlternateLinkId(alternateLinkId)
public List<TrackedLink> GetTrackedLinksByAlternateLinkId( 
   long alternateLinkId
)
public:
List<TrackedLink^>^ GetTrackedLinksByAlternateLinkId( 
   int64 alternateLinkId
) 

Parameters

alternateLinkId
Example
LinkLogic linkLogic = new LinkLogic(); //Trial Mode
LinkLogic linkLogicLicensed = new LinkLogic("place user name here", "place license key here");  //License Mode
 
//Use a in memory mock database for testing
ILinkTrackerDatabaseLogic databaseLogic = new LinkTrackerMockDatabase();
 
linkLogic.DatabaseLogic = databaseLogic;
 
//Create a dummy file for testing
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt");
File.WriteAllText(filePath, "This is a test");
 
//Create a link that expires 1 year from now, with a maximum of 10 IP Addresss, and a maximum of 2 requests per day
//We are setting the Alternate Link Id to 4242 which is the primary key for an OrderId
LinkParms parms = new LinkParms();
parms.IsUrl = false;
parms.AlternateLinkId = 4242;
parms.AlternateLinkText = "OrderId";
parms.ExpirationDate = DateTime.Now.AddYears(1);
parms.MaxIpAddresses = 10;
parms.MaxRequestsPerDay = 2;
parms.FilePathOrUrl = filePath;
 
TrackedLink createdLink = linkLogic.CreateLink(parms);
 
List<TrackedLink> trackedLinksForOrder = linkLogic.GetTrackedLinksByAlternateLinkId(4242);
 
//Loop through each link found
foreach (var trackedLink in trackedLinksForOrder)
{
    //Get the associated File Path
    Console.WriteLine("File Path:  " + trackedLink.FilePathOrUrl);
}
Dim linkLogic As New LinkLogic() 'Trial Mode
Dim linkLogicLicensed As New LinkLogic("place user name here", "place license key here") 'License Mode
 
'Use a in memory mock database for testing
Dim databaseLogic As ILinkTrackerDatabaseLogic = New LinkTrackerMockDatabase()
 
linkLogic.DatabaseLogic = databaseLogic
 
'Create a dummy file for testing
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt")
File.WriteAllText(filePath, "This is a test")
 
'Create a link that expires 1 year from now, with a maximum of 10 IP Addresss, and a maximum of 2 requests per day
'We are setting the Alternate Link Id to 4242 which is the primary key for an OrderId
Dim parms As New LinkParms()
parms.IsUrl = False
parms.AlternateLinkId = 4242
parms.AlternateLinkText = "OrderId"
parms.ExpirationDate = Date.Now.AddYears(1)
parms.MaxIpAddresses = 10
parms.MaxRequestsPerDay = 2
parms.FilePathOrUrl = filePath
 
Dim createdLink As TrackedLink = linkLogic.CreateLink(parms)
 
Dim trackedLinksForOrder As List(Of TrackedLink) = linkLogic.GetTrackedLinksByAlternateLinkId(4242)
 
'Loop through each link found
For Each trackedLink In trackedLinksForOrder
    'Get the associated File Path
    Console.WriteLine("File Path:  " & trackedLink.FilePathOrUrl)
Next trackedLink
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

LinkLogic Class
LinkLogic Members