Linxter SDK Batch Exception

Namespace:  Linxter.Common.Util.Exceptions
Assembly:  Linxter.Common.Util (in Linxter.Common.Util.dll) Version: 1.5.0.0 (1.5.0.0)

Syntax

C#
public class LinxterSdkBatchException : Exception
Visual Basic (Declaration)
Public Class LinxterSdkBatchException _
	Inherits Exception

Examples

CopyC#
public void ExceptionsExample(string aliasName)
{
    // Simple example showing the use of many of the Linxter Exception classes
    string status = string.Empty;

    try
    {
        // Instantiate Linxter objects
        ILinxterMessaging messaging = new LinxterSDK();
        ILinxterRegistration registration = messaging as ILinxterRegistration;
        ILinxterCommunicationChannel commChannels = messaging as ILinxterCommunicationChannel;

        // Register this program instance with the ISB, if it's not registered yet.
        if (!registration.IsRegistered)
        {
            registration.RegisterProgramInstance();
        }

        // Make sure registration is complete
        if (!registration.IsActivated)
        {
            while (!registration.IsActivated)
            {
                Thread.Sleep(250);
            }
        }

        try
        {
            // Set the scheduled send interval to 1 second
            messaging.SetScheduledSendInterval(1000);
        }
        catch (LinxterPolicyValidationException)
        {
            status += "Unable to set send interval - check this program's settings in Linxter Web Manager.\n";
        }

        // rename this instance
        registration.RenameAlias(aliasName);

        // Set up a communications channel with myself.  Note that this will only work if the 
        // program is configured (in Linxter Web Manager) to automatically accept all connections
        commChannels.CreateRequest(registration.ProgramInstanceId, string.Empty);
        // Wait 30 seconds for the request to complete:
        Thread.Sleep(30000);

        try
        {
            // Send a test message
            LinxterMessage newMessage = new LinxterMessage();
            newMessage.ActivityId = "c856ceb1-6bf6-4cb5-a366-b2b8b0b5933d"; // enter the correct activityID for your program here
            newMessage.Body = "Test Message";
            messaging.CreateMessage(newMessage);
        }
        catch (ProgramInstanceNotActivatedException ex)
        {
            status += "ProgramInstanceNotActivatedException - the instance failed to activate.\n";
        }
        catch (ProgramInstanceNotFoundException ex)
        {
            status += "ProgramInstanceNotFoundException - the instance could not be found.\n";
        }
    }
    catch (LinxterServerNotFoundException ex)
    {
        status += "Linxter server could not be reached.  This may be caused by network connection issues, or incorrect Linkxter SDK configuration.\n";
    }
    catch (MaximumRegistrationException ex)
    {
        status += "Cannot register this instance because the maximum number of registrations for this program has been reached.  Use Linxter Web Manager to change the number of allowed instances.\n";
    }
    catch (LinxterSdkException ex)
    {
        switch (ex.ErrorNumber)
        {
            case LinxterError.RegistrationFailure:
                status += "Registration process failed.\n";
                break;

            case LinxterError.DuplicateRegistrationException:
                status += "A registration for this program instance already exists.\n";
                break;

            case LinxterError.InvalidAliasname:
                status += "Invalid alias name passed.  Alias name must be alphanumeric, 100 characters or less.";
                break;

            default:
                status += string.Format("Linxter SDK Exception thrown: {0} - {1}", ex.ErrorNumber, ExceptionMessageUtil.GetExceptionMessage(ex.ErrorNumber));
                break;
        }
    }
    catch (Exception ex)
    {
        status += string.Format("Unanticipated exception thrown: {0}", ex.Message);
    }
    finally
    {
        if (string.IsNullOrEmpty(status))
        {
            status = "Operation succeeded.";
        }

        MessageBox.Show(status);
    }
}
CopyVB.NET
Public Sub ExceptionsExample(ByVal aliasName As String)
    ' Simple example showing the use of many of the Linxter Exception classes
    Dim status As String = String.Empty

    Try
        ' Instantiate Linxter objects
        Dim messaging As ILinxterMessaging = New LinxterSDK()
        Dim registration As ILinxterRegistration = TryCast(messaging, ILinxterRegistration)
        Dim commChannels As ILinxterCommunicationChannel = TryCast(messaging, ILinxterCommunicationChannel)

        ' Register this program instance with the ISB, if it's not registered yet.
        If Not registration.IsRegistered Then
            registration.RegisterProgramInstance()
        End If

        ' Make sure registration is complete
        If Not registration.IsActivated Then
            Do While Not registration.IsActivated
                Thread.Sleep(250)
            Loop
        End If

        Try
            ' Set the scheduled send interval to 1 second
            messaging.SetScheduledSendInterval(1000)
        Catch e1 As LinxterPolicyValidationException
            status &= "Unable to set send interval - check this program's settings in Linxter Web Manager." & vbLf
        End Try

        ' rename this instance
        registration.RenameAlias(aliasName)

        ' Set up a communications channel with myself.  Note that this will only work if the 
        ' program is configured (in Linxter Web Manager) to automatically accept all connections
        commChannels.CreateRequest(registration.ProgramInstanceId, String.Empty)
        ' Wait 30 seconds for the request to complete:
        Thread.Sleep(30000)

        Try
            ' Send a test message
            Dim newMessage As New LinxterMessage()
            newMessage.ActivityId = "c856ceb1-6bf6-4cb5-a366-b2b8b0b5933d" ' enter the correct activityID for your program here
            newMessage.Body = "Test Message"
            messaging.CreateMessage(newMessage)
        Catch ex As ProgramInstanceNotActivatedException
            status &= "ProgramInstanceNotActivatedException - the instance failed to activate." & vbLf
        Catch ex As ProgramInstanceNotFoundException
            status &= "ProgramInstanceNotFoundException - the instance could not be found." & vbLf
        End Try
    Catch ex As LinxterServerNotFoundException
        status &= "Linxter server could not be reached.  This may be caused by network connection issues, or incorrect Linkxter SDK configuration." & vbLf
    Catch ex As MaximumRegistrationException
        status &= "Cannot register this instance because the maximum number of registrations for this program has been reached.  Use Linxter Web Manager to change the number of allowed instances." & vbLf
    Catch ex As LinxterSdkException
        Select Case ex.ErrorNumber
            Case LinxterError.RegistrationFailure
                status &= "Registration process failed." & vbLf

            Case LinxterError.DuplicateRegistrationException
                status &= "A registration for this program instance already exists." & vbLf

            Case LinxterError.InvalidAliasname
                status &= "Invalid alias name passed.  Alias name must be alphanumeric, 100 characters or less."

            Case Else
                status &= String.Format("Linxter SDK Exception thrown: {0} - {1}", ex.ErrorNumber, ExceptionMessageUtil.GetExceptionMessage(ex.ErrorNumber))
        End Select
    Catch ex As Exception
        status &= String.Format("Unanticipated exception thrown: {0}", ex.Message)
    Finally
        If String.IsNullOrEmpty(status) Then
            status = "Operation succeeded."
        End If

        MessageBox.Show(status)
    End Try
End Sub

Inheritance Hierarchy

System..::.Object
  System..::.Exception
    Linxter.Common.Util.Exceptions..::.LinxterSdkBatchException

See Also