• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1084
  • Last Modified:

(COM and PHP Array incomapatiblity)Login to IOS(IRESS Order System) using COM interface with PHP

Hi Experts,
We are trying to login to IOS system by looking at given macro sample(on IRESS programmer reference help) using COM objects.
We managed to develop most of the features(IRESS and IOS) available on given DLL files with IRESS application.
I've managed to develop IOS Login status function which shows in below, which is working correctly.
But I can't get work with IOS Login function(even the simplest macro example) . It gives following error on IRESS logs.
--------------------------------------------------------------------
[110216 14:27:55] Caught exception: Source: IRESS
Description: Internal application error.
--------------------------------------------------------------------
or
----------------------------------------------------------------------------------------------------------------------------------------
[110216 12:14:41] Caught exception: Variant type conversion failed: Type mismatch.
----------------------------------------------------------------------------------------------------------------------------------------
We are using IRESS Data object not Command Objects.
I would greatly appreciate that if some one could share experience who had similar situation.
(We tried with COM, VARIANTS and related classes available on PHP5. But still we can't get it work.
Looked at following links also.
http://www.php.net/manual/en/class.com.php
http://www.php.net/manual/en/class.variant.php
http://theserverpages.com/php/manual/en/class.variant.php
http://theserverpages.com/php/manual/en/ref.com.php#com.constants
http://dewa03.unep.org/manuals/php_manual/function.variant-cast.html
http://dewa03.unep.org/manuals/php_manual/class.variant.html

BR Dushan.
----------------------------------------PHP: Login Fucntion (not working)----------------------------------------------------
	private function cmd_login()
	{
		$Logins = $this->app->DataManager->CreateOb("iosmisc");			 
		$Logins->IOSName		= "IOSTEST";
		$Logins->AccCode		= "ACCOUNT1"; 

		$Logins->GetID;
		$Logins->GetCode;
		
		$Logins->Request();
		$this->WaitCmdRequest($Logins);		

			$vars	= 	array(	"AccNo"			=>	$Logins->AccNo,
						"AccCode"		=>	$Logins->AccCode
					//	"ErrorDescription"	=>	$ILog->ErrorDescription
								
								);		
		$Logins->clear();
                 unset($Logins);				
		return 	$this->packArray($vars); 

	}
-----------------------------------------------------------------------------------------------------------------------------

----------------Macro Login Function (working on IRESS Macro Editor)---------------------------------------------------------
Sub GetAnID()
    Dim datamgr As New DfsCmd.DataManager
    Dim misc As DfsIos.DataIosMisc
    Set misc = datamgr.CreateOb("iosmisc")
    
    misc.IOSName(0) = "IOSTEST"
    misc.AccCode(0) = "ACCOUNT1"
    
    misc.GetID
    
    If Not DoRequest(misc) Then End
    
    Debug.Print vbNewLine
    Debug.Print misc.AccNo(0); misc.AccCode(0)
 
End Sub

-------------------------------------------------------------------------------------------------------------------------

-------------------PHP: Login status(working correctly)------------------------------------------------------------------
	private function login_sts()
	{		
		$Sts = $this->app->DataManager->CreateOb("iosstatus");
		
		$vars = array();
		
		for($i = 0; $i < $Sts->RowCount; $i++)
                  {			
			$vars[$Sts ->IOSName($i)] 	= array(
								"LoggedIn" 		=> 	$Sts ->LoggedIn($i),
								"IosOnline"		=>	$Sts ->IosOnline($i),
								);						
		}
		return 	$this->packArray($vars);
	}
-----------------------------------------------------------------------------------------------------------------------------

---------------------Macro : Login Status Function (working on IRESS Macro Editor)-------------------------------------------
Sub iosStatusExample()

Dim dataMgr As New DfsCmd.DataManager
	Dim iosstatus As DfsIos.DataIosStatus
	Dim i As Integer
	
    Set iosstatus = dataMgr.CreateOb("iosstatus")
    
    ' Note: Don't need to call request method on this object - The data is filled in the
    '		object when the object is created
    
    ' Print to debug window IOS Status information    
    With iosStatus
	For i = 0 To .RowCount - 1
	        Debug.Print "LoggedIn: " & .LoggedIn(i)
                Debug.Print "IosOnline: " & .IosOnline(i)
	    Next i
    End With
End Sub
-----------------------------------------------------------------------------------------------------------------------------

Open in new window

0
Dushan De Silva
Asked:
Dushan De Silva
  • 5
  • 3
1 Solution
 
Ray PaseurCommented:
It might be worthwhile to post the complete PHP and ASP scripts.  These fragments leave us guessing about the rest of the class.
0
 
Dushan De SilvaAuthor Commented:
Hi Ray_Paseur,
Thanks a lot for attending to this question.

Please find attached example VB: DoRequest Function which is on the IRESS programmer reference help and it's working correctly with IRESS macro editor.

And please find attached PHP: WaitCmdRequest() Function which is working with other IRESS and IOS data object functions we converted to PHP.

All other functions are stays on the DLL files which got from IRESS.

BR Dushan.

-----------------------------------------------------VB: DoRequest Function ---------------------------------------------------------------
'The following lines must be included in your project in order to
'use every data object example 

'Make sure that the following line appears at the TOP of the module
'you are working on!
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function DoRequest(obj As Object, Optional lTimeOutMilliseconds As Long = 20000, Optional bRequestNext as Boolean = False) As Boolean
    DoRequest = False

    
    Const SLEEP_VALUE As Long = 200
    Dim bTimeoutCheck As Boolean
    Dim lTimeCount As Long
    Dim state As Integer
    Dim lErrorNumber As Long
    Dim strErrorDescription As String

    ' Handle any automation exception errors generated when calling Request method
    On Error Resume Next

    If (bRequestNext) then
        obj.RequestNext
    Else
        obj.Request
    End if

    lErrorNumber = Err.Number

    strErrorDescription = Err.Description

    On Error Goto 0

    If lErrorNumber <> 0 Then
        MsgBox "An automation exception error occurred with the request: " & strErrorDescription
        Exit Function
    End If

    bTimeoutCheck = (lTimeOutMilliseconds > 0)
    lTimeCount = 0
    state = obj.state

    Do Until state <> DfsCmd.DataPending
        ' Check if timeout occurred
        If bTimeoutCheck And lTimeCount >= lTimeOutMilliseconds Then Exit Do

        DoEvents ' Allow system events to be processed while looping
        Sleep SLEEP_VALUE
        state = obj.state
        ' Increment time counter if checking for timeouts
        If bTimeoutCheck Then lTimeCount = lTimeCount + SLEEP_VALUE
    Loop

    Select Case state
        Case DfsCmd.Error
            MsgBox "An error occurred with the request: " & obj.Error
        Case DfsCmd.DataReady
            DoRequest = True

        Case DfsCmd.DataIncomplete
            MsgBox "The data was incomplete at the time of the request. Please try again later!"
        Case DfsCmd.DataMorePending
            DoRequest obj, lTimeOutMilliseconds, True
        Case Else
            ' Determine if timeout occurred
            If (lTimeOutMilliseconds > 0) And (lTimeCount >= lTimeOutMilliseconds) Then
                MsgBox "Request timeout occurred!"
            Else

                MsgBox "Unexpected Error in Request"
            End If
    End Select
End Function

---------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------PHP: WaitCmdRequest() Function -----------------------------------------------
    function WaitCmdRequest($obj, $timelimit=4)
    {
        $WaitCmdRequest = false;

        $state = $obj->State;
        $wait_times = 0;
        while ($state === 2 || $state === 1|| 4===$state || 5===$state)
        {
            //sleep(1);
            usleep(200000);
            if (1!==$state)
            {
                $wait_times++;
                if ($wait_times >= $timelimit) break;
            }
            $state = $obj->State;
            //echo "sleep\n";
        }

        if ($state == 2)
        {
            $WaitCmdRequest = true;
        }
        elseif ($state == 3)
        {
            msg("An error occurred with the request: " . $obj->Error . LF);
        }
        elseif ($state== 4)
        {
            $WaitCmdRequest = true;
        }
        elseif ($state == 0)
        {
            $WaitCmdRequest = true;
        }
		elseif ($state == 5)
        {
            $WaitCmdRequest = true;
        }
        else
        {
            msg("Unexpected Error in Request: State = ".$state.LF);
        }
 //       msg("state=".$state.LF);
        return $WaitCmdRequest;
    }
---------------------------------------------------------------------------------------------------------------------------------

Open in new window

0
 
Dushan De SilvaAuthor Commented:
This WaitCmdRequest() Function is working correctly for the other IRESS functions which we've developed. On the given VB example for the IOS they used same DoRequest function.
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
Dushan De SilvaAuthor Commented:
Seems due to incompatibility between VB 6.0 and PHP5 this can't achieve
0
 
Ray PaseurCommented:
Why did you give me a bad grade for asking you to post a more complete code example?  Nobody offered any help - just delete the question or accept your own answer that you cannot do this.
0
 
Dushan De SilvaAuthor Commented:
Hi Ray_Paseur,
I'm sorry about Bad Grade.
But you never post a comment after that. I posted code examples to identify, if someone faced similar situation.
I thought to keep this question for knowledge base to get an idea if some one face similar situation during future.
We are trying different approach now.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26846864.html

To EE Admin - Please accept my own answer or Delete this question.

BR Dushan.
0
 
Ray PaseurCommented:
It's OK - no hard feelings at all.  I was just hoping that when I or someone else saw the code there would be an obvious solution.
0
 
Dushan De SilvaAuthor Commented:
Due to incompatibility between the objects of PHP and VB, seems we can't achieve this.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now