Solved

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

Posted on 2011-02-15
11
1,041 Views
Last Modified: 2013-12-04
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
Comment
Question by:Dushan De Silva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34921025
It might be worthwhile to post the complete PHP and ASP scripts.  These fragments leave us guessing about the rest of the class.
0
 
LVL 17

Author Comment

by:Dushan De Silva
ID: 34921180
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
 
LVL 17

Author Comment

by:Dushan De Silva
ID: 34922095
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 17

Accepted Solution

by:
Dushan De Silva earned 0 total points
ID: 34994356
Seems due to incompatibility between VB 6.0 and PHP5 this can't achieve
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34998140
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
 
LVL 17

Author Comment

by:Dushan De Silva
ID: 34999834
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 35001040
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
 
LVL 17

Author Closing Comment

by:Dushan De Silva
ID: 35042784
Due to incompatibility between the objects of PHP and VB, seems we can't achieve this.
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question