GetSwitchToData2()

If a SwitchTo LDL command has been executed to switch to a new Segment, then this method returns true, and passes information about the new segment via parameters.

Syntax

STDMETHODIMP GenericClass::GetSwitchToData2( BSTR *pbstrGUID, BSTR *pbstrHost,BSTR *pbstrSystemName, BOOL *pbSwitched )

Parameters

pbstrGUID

This is a reference to the GUID pointer and points at the GUID of the system to be switched after returning.

pbstrHost

This is a reference to the string containing the host machine name where the system is deployed after returning.

pbstrSystemName

This is a reference to a string containing the name of the new Segment after returning.

pbSwitched[out]

This Boolean value is set to true if a valid SwitchTo command data is found otherwise it is set to false.

Once this method is executed, an instance of the segment should be created using the GUID value and then can be used communicating with the switched system.

Example

/// <summary>
/// This method checks if there were any SwitchTo Command that was executed in the current Ispec transaction
 /// </summary>
 /// <param name="IspecOutput">Output GenericClass object of the ProcessMsg() method</param>
/// <returns>0 if no SwitchTo happened, 1 if SwitchTo happened</returns>
public int CheckSwitchTo(ref IIspecCycle IspecOutput)
 int ret;
string ispec;
 string guid;
string host;
string segmentname;
ret = IspecOutput.GetSwitchToData2( out guid, out host, out newSegmentName);
// if ret is 0 means where is no switchto happening, return
 if (ret == 0)
return ret;
// Disconnect the old system
 try
{
 mySegmentCycle.Disconnect(sessid);
NGLINC.ISegmentCycle iSegmentCycle = (NGLINC.ISegmentCycle)(mySegmentCycle);
((IDisposable)iSegmentCycle).Dispose();
}
catch (Exception ex)
{
 return 999;
}
// Connect to the new system using the guid value
Guid gd = new Guid(guid);
Type tp = Type.GetTypeFromCLSID(gd, host, false);
 objApp = Activator.CreateInstance(tp);
 // mySegmentCycle is an object of NGLINC.ISegmentCycle
mySegmentCycle = (ISegmentCycle)objApp;
// Once this is done, call Connect() on mySegmentCycle to start using the switched system
 return 1;
}