Listing 6
void UltraMaxWebServiceNETClass::LogOn(String* loginID, String* password)
{
try {
GetSessionStorage()->LogOn(loginID, password);
}
catch(CMyException* e) {
throw new Exception(e->GetError());
}
}
SongInfo UltraMaxWebServiceNETClass::GetSongs()[]
{
// Call unmanaged (MFC)
const CSongInfoArray& Songs = GetSessionStorage()->GetSongs();
// Copy from unmanaged (MFC) to managed (.NET)
SongInfo MyArray[] = new SongInfo[Songs.GetSize()];
for ( int i = 0; i < Songs.GetSize(); i++ )
MyArray[i] = Songs[i];
return MyArray;
}
void UltraMaxWebServiceNETClass::SetSongs(SongInfo songs[])
{
CSongInfoArray MyArray;
// Copy from managed (.NET) to managed (MFC)
for ( int i = 0; i < songs->Count; i++ )
MyArray.Add(ToCSongInfo(songs[i]));
// Call unmanaged (MFC)
GetSessionStorage()->SetSongs(MyArray);
}
void UltraMaxWebServiceNETClass::GetReleaseDate(DateTime& currentDate)
{
// Convert from managed (.NET) to managed (MFC)
COleDateTime MyDate(currentDate.Year, currentDate.Month,
currentDate.Day, currentDate.Hour, currentDate.Minute,
currentDate.Second);
// Call unmanaged (MFC)
GetSessionStorage()->GetReleaseDate(MyDate);
// Convert from unmanaged (MFC) to managed (.NET)
currentDate = DateTime(MyDate.GetYear(), MyDate.GetMonth(),
MyDate.GetDay(), MyDate.GetHour(), MyDate.GetMinute(),
MyDate.GetSecond());
}