public static void send_CommandToEmulator(string message) { long output; message = CustomFunction.convertToSabreChars(message); output = MySabreAPI.sendCommandToEmulator(ref message); }
public void client_Connect() { int connected; int output = 0; string strVendorName = "MySabre API Development Team"; string strVendorPcc = "PE51"; string strApplicationName = "MySabre API Sample"; string strApplicationVersion = "1.0"; string strToken = "VKOG6WSS"; handleMod = 0; try { mySabreAPI = new MySabreAPI(); load_Dll(); connected = MySabreAPI.clientConnect(ref strVendorName, ref strVendorPcc, ref strApplicationName, ref strApplicationVersion, ref strToken, strToken.Length, 0, ref output); if (connected.Equals(0)) { IsConnected = true; } } catch (Exception) { } }
public static void send_MessageToEmulator(string message) { long output; Components.CommandsAPILog.WriteCommandIntoFile(message); message = CustomFunction.convertToSabreChars(message); output = MySabreAPI.sendMessageToEmulator(ref message); }
private void CreateNamedManualResetEvent(string name, ref int handle) { MySabreAPI.SECURITY_ATTRIBUTES sd = new MySabreAPI.SECURITY_ATTRIBUTES(); handle = 0; sd.nLength = Microsoft.VisualBasic.Strings.Len(sd); sd.lpSecurityDescriptor = 0; sd.bInheritHandle = 0; handle = MySabreAPI.CreateEvent(ref sd, 1, 0, ref name); }
private static void unload_DLL() { string emuapi = "emuapi"; int hVal = MySabreAPI.GetModuleHandle(ref emuapi); if (hVal != 0) { while (MySabreAPI.FreeLibrary(hVal)) { } } }
public string SendReceiveEmission(string message, int showCommand, int showResponse, int millisecondsTimeout) { CommandsAPI.ValidateMarkups = false; defaultmillisecondsTimeout = millisecondsTimeout; currentmsg = message; myresult = string.Empty; message = CustomFunction.convertToSabreChars(message); MySabreAPI.sendCommandToHost2(ref message, showCommand, showResponse); cbCustom.Invoke(0, string.Empty); string finalresult = string.Empty; while (!isfinish) { if (frmMain.getApiStateFromEvents().Equals(frmMain.API_UNAVAILABLE)) { isfinish = true; } else { if (counter > timeAPIResponse) { isfinish = true; } else { System.Threading.Thread.Sleep(defaultmillisecondsTimeout); counter++; } } } counter = 1; IsFinish(true); if (myresult.Contains("PREVIOUS ENTRY ACTIVE-PLEASE WAIT FOR RESPONSE")) { IsFinish(true); } Components.CommandsAPILog.WriteCommandIntoFile(string.Concat(sabreCommand, "|", myresult)); CommandsAPI.ValidateMarkups = true; if (string.IsNullOrEmpty(myresult)) { myresult = "NOTHING"; } return(myresult); }
private void client_Disconnect() { int IsDisconnected; mySabreAPI = null; IsDisconnected = MySabreAPI.clientDisconnect(); if (IsDisconnected.Equals(0)) { IsConnected = false; Listenercount = 0; } }
public string SendReceiveProfile(string message, int showCommand, int showResponse, bool showAllContent) { ValidateMarkups = false; currentmsg = message; singleMessage = string.Empty; message = CustomFunction.convertToSabreCharsProfile(message); MySabreAPI.sendCommandToHost2(ref message, showCommand, showResponse); cbCustom.Invoke(0, string.Empty); string finalresult = string.Empty; while (!isfinish) { if (frmMain.getApiStateFromEvents().Equals(frmMain.API_UNAVAILABLE)) { isfinish = true; } else { if (counter > timeAPIResponse) { isfinish = true; } else { System.Threading.Thread.Sleep(500); counter++; } } } counter = 1; IsFinish(true); Components.CommandsAPILog.WriteCommandIntoFile(string.Concat(sabreCommand, " -APP")); ValidateMarkups = true; if (string.IsNullOrEmpty(singleMessage)) { singleMessage = "NOTHING"; } return((showAllContent) ? allMessage : singleMessage); }
private void waitForManualResetEvent() { long WaitRet = API_ERROR; int[] handlesNotify = new int[2]; int count; bool bNotifyAEventSet = false; bool bNotifyBEventSet = false; CreateNamedManualResetEvent(SABRE_API_NOTIFY_A, ref handlesNotify[0]); CreateNamedManualResetEvent(SABRE_API_NOTIFY_B, ref handlesNotify[1]); WaitRet = MySabreAPI.WaitForMultipleObjects(2, ref handlesNotify[0], 0, INFINITE); if (WaitRet == MySabreAPI.WAIT_OBJECT_0) { bNotifyAEventSet = true; } if (MySabreAPI.WAIT_OBJECT_0 + 1 == WaitRet) { bNotifyBEventSet = true; } if (bNotifyAEventSet | bNotifyBEventSet) { checkStateChange(); } do { bool bWaitingOnA = !bNotifyAEventSet; if (bWaitingOnA) { count = 0; } else { count = 1; } WaitRet = MySabreAPI.WaitForSingleObject(handlesNotify[count], -1); if (WaitRet == MySabreAPI.WAIT_OBJECT_0) { bNotifyAEventSet = bWaitingOnA; checkStateChange(); } } while (true); }
private static bool isEventSet(string eventName) { bool bEventSet = false; int hEvent = API_ERROR; long WaitRet; hEvent = MySabreAPI.OpenEvent(MySabreAPI.EVENT_ALL_ACCESS, 0, ref eventName); if (hEvent != 0) { WaitRet = MySabreAPI.WaitForSingleObject(hEvent, 0); MySabreAPI.CloseHandle(hEvent); if (MySabreAPI.WAIT_OBJECT_0 == WaitRet) { bEventSet = true; } } return(bEventSet); }
private void CloseObjects() { if (this.InvokeRequired) { this.Invoke(new SenderInvoker(CloseObjects)); } else { try { int IsDisconnected; mySabreAPI = null; IsDisconnected = MySabreAPI.clientDisconnect(); } catch { } try { string emuapi = "emuapi"; int hVal = MySabreAPI.GetModuleHandle(ref emuapi); if (hVal != 0) { while (MySabreAPI.FreeLibrary(hVal)) { } } } catch {} Application.Exit(); frmLogin frm = (frmLogin)Application.OpenForms["frmLogin"]; if (frm != null) { frm.Dispose(); } } }
private static void client_Disconnect() { int IsDisconnected; IsDisconnected = MySabreAPI.clientDisconnect(); }
private void load_Dll() { string emuapi = "emuapi.dll"; handleMod = MySabreAPI.LoadLibrary(ref emuapi); }