<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for Camilo Lozano III</title>
	<atom:link href="http://camilord.kagayan.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://camilord.kagayan.com</link>
	<description>Linux for Servers, Macintosh for Graphics and Windows for Solitair...</description>
	<lastBuildDate>Wed, 21 Jul 2010 17:04:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>Comment on CEntOS: Securing FTP (vsftpd) and SSH by faiz</title>
		<link>http://camilord.kagayan.com/2010/05/08/centossecuring-ftp-vsftpd-and-ssh/comment-page-1/#comment-1464</link>
		<dc:creator>faiz</dc:creator>
		<pubDate>Wed, 21 Jul 2010 17:04:02 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=388#comment-1464</guid>
		<description>hi i am computer engineer i wnat  linux group pls.</description>
		<content:encoded><![CDATA[<p>hi i am computer engineer i wnat  linux group pls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Freelance Freedom by NC Winters by wella</title>
		<link>http://camilord.kagayan.com/2009/05/20/freelance-freedom-by-nc-winters/comment-page-1/#comment-1136</link>
		<dc:creator>wella</dc:creator>
		<pubDate>Sun, 30 May 2010 08:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=238#comment-1136</guid>
		<description>this is so true and funny pomelo, thanks for sharing :)</description>
		<content:encoded><![CDATA[<p>this is so true and funny pomelo, thanks for sharing <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Visual C#: Detect Conflict Schedule by Steve</title>
		<link>http://camilord.kagayan.com/2010/01/18/visual-csharp-detect-conflict-schedule/comment-page-1/#comment-1130</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 28 May 2010 14:23:14 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=325#comment-1130</guid>
		<description>how about in vb.net?...   :D</description>
		<content:encoded><![CDATA[<p>how about in vb.net?&#8230;   <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on [Software Integration] MS Visual C# + Nokia PC Connectivity API 3.2 by Camilo III</title>
		<link>http://camilord.kagayan.com/2009/04/02/ms-visual-c-sharp-nokia-pc-connectivity-api-32-software-integration/comment-page-1/#comment-1001</link>
		<dc:creator>Camilo III</dc:creator>
		<pubDate>Wed, 21 Apr 2010 14:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=146#comment-1001</guid>
		<description>greetings Jayanta..

try to delay the retrieving of data from you phone and from the network...

try using System.Threading ...

System.Threading.Sleep(3);  

so that your phone can buffer the last retrieve...</description>
		<content:encoded><![CDATA[<p>greetings Jayanta..</p>
<p>try to delay the retrieving of data from you phone and from the network&#8230;</p>
<p>try using System.Threading &#8230;</p>
<p>System.Threading.Sleep(3);  </p>
<p>so that your phone can buffer the last retrieve&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on [Software Integration] MS Visual C# + Nokia PC Connectivity API 3.2 by Jayanta</title>
		<link>http://camilord.kagayan.com/2009/04/02/ms-visual-c-sharp-nokia-pc-connectivity-api-32-software-integration/comment-page-1/#comment-999</link>
		<dc:creator>Jayanta</dc:creator>
		<pubDate>Sun, 18 Apr 2010 17:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=146#comment-999</guid>
		<description>Spent a lot of effort developing a C# program based
on forum &amp; sample PIMNavigator

Works fine for SEND

Works fine for FIRST RECEIVE Message
Subsequent INPUT Messages fail at
DAContentAccess.CAReadItem with code -2146435035

If I restart program works fine again for 1 RECEIVE Message.
A huge amount of effort spent but at end stuck i RECEIVE.


using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

using System.Data;
using Oracle.DataAccess.Client;

using CAContentAccess;

using Errors = PCCSErrors.PCCSErrors;
using TypeDefinitions = PCCSTypeDefinitions.PCCSTypeDefinitions;

namespace MyWindowsService{

  public class SMS 
  {
  
    private int intSMSHandle;
    
    private int intStatusCode;
    
    private OracleConnection con;
    
    private CAContentAccess.DAContentAccessDefinitions.CANotifyCallbackDelegate pCANotifyCallBack;

//  private CAContentAccess.DAContentAccessDefinitions.CAOperationCallbackDelegate pCAOperationCallback;

    private long msgid;
    private string mobileno;
    private string sendtext;
    private string recvtext;
    private string strSerialNumber; // 353080029098956
    
    private int hOperHandle;
              
    static void Main(string[] args)
    {
      SMS mySMS=new SMS();
      
      mySMS.LoopForEver();

    }

    private void LoopForEver()
    {
      
      intSMSHandle= 0;

      //Initializing API
      intStatusCode = DAContentAccess.CAAPI_Initialize(30, 0);

      strSerialNumber= &quot;353080029098956&quot;;
      
      try{
        //Opening connection to send messages
        intSMSHandle = OpenSMSConnection(strSerialNumber);   
        
      }catch(Exception ex){
      
        // throw ex;
        Console.WriteLine(&quot;Opening SMS connection Exception ex = &quot; + ex.Message); // jnc
        Console.WriteLine(ex.StackTrace);
        
        Environment.Exit(-1);
      }
      
      pCANotifyCallBack = CANotifyCallBack;
      
//    pCAOperationCallback = CAOperationCallback;
      
      int iResult = DAContentAccess.CARegisterNotifyCallback(
                      intSMSHandle, 
                      TypeDefinitions.API_REGISTER, 
                      pCANotifyCallBack);

      if (iResult != Errors.CONA_OK) {
        Console.WriteLine(&quot;DAContentAccess.CARegisterNotifyCallback Failed = &quot; + iResult); // jnc
        Environment.Exit(-1); 
      }
      
//    int iResult = DAContentAccess.CARegisterOperationCallBack(
//                    intSMSHandle, 
//                    TypeDefinitions.API_REGISTER, 
//                    pCAOperationCallback);                      
//                    
//    if (iResult != Errors.CONA_OK)    
//      Environment.Exit(-1); 
        
      // create connection string using EZCONNECT format
      // this format specifies the server and the Oracle
      // service name as the datasource
      // using the format: server/oracle service name
      // no tnsnames.ora or sqlnet.ora file is needed

      string constr = &quot;User Id=hr; &quot; +
                           &quot;Password=hr; &quot; +
                           &quot;Data Source=localhost/xe&quot;;

      // create connection object
      con = new OracleConnection(constr);
      
      // use &quot;try&quot; block to open connection
      // if an error occurs, simply display the message
      // since there is a &quot;catch&quot; block a &quot;using&quot; statement is not used
      try {
        // attempt to open the connection
        con.Open();

     }
      catch (OracleException ex) {
      
        // an OracleException was thrown
        Console.WriteLine(&quot;OracleException ex = &quot; + ex.Message); // jnc
        Console.WriteLine(ex.StackTrace);
        
        Environment.Exit(-1);
      }
      
      string strQuery = @&quot;SELECT msgid, mobileno, smstext 
                            FROM zsmstraffic 
                           WHERE status = &#039;I&#039; 
                             AND direction = &#039;S&#039;&quot;;

      // Create the OracleCommand object
      OracleCommand cmdQuery = new OracleCommand(strQuery);
      cmdQuery.Connection = con;
      cmdQuery.CommandType = CommandType.Text;
      
      OracleDataReader reader;
      
      for(;;) {
      
        try
        {
          // Execute command, create OracleDataReader object
          reader = cmdQuery.ExecuteReader();
          
          if(reader.HasRows)
          {
            while (reader.Read())
            {
              msgid=reader.GetInt64(0);
              mobileno=reader.GetString(1);
              sendtext=reader.GetString(2);
              sendtext=sendtext.Replace(&quot;\\n&quot;, &quot;\n&quot;);
              break;
            }
            
            SendSMS(&quot;353080029098956&quot;, mobileno, sendtext, true);
            
            OracleCommand cmdUpdate = con.CreateCommand();
            cmdUpdate.CommandText = @&quot;UPDATE zsmstraffic 
                                         SET status = &#039;X&#039;
                                       WHERE msgid = &quot; + msgid;
            cmdUpdate.ExecuteNonQuery();
            cmdUpdate.Dispose();

          }
          else
          {
            System.Threading.Thread.Sleep(60000); // 1 minute
            Console.WriteLine(&quot;Sleeping for 1 minute&quot;); // jnc
          }
        }
        catch (Exception ex) 
        {
          Console.WriteLine(&quot;FOREVER LOOP Exception ex = &quot; + ex.Message); // jnc
          Console.WriteLine(ex.StackTrace);
          Environment.Exit(-1);
        } 

      } // for(;;) 

      // Closing the SMS connection
      CloseSMSConnection(intSMSHandle);
            
      // Terminating api
      DAContentAccess.CAAPI_Terminate(0);
      
      // clean up the connection object
      con.Dispose();
      
    }


    public void SendSMS(string strSerialNumber, string strPhoneNo, string strMessage, bool DontDelete){

      try{
        // Not sure why this is needed, but didnt work without it
        DAContentAccessDefinitions.CA_FOLDER_INFO folderInfo=
            new DAContentAccessDefinitions.CA_FOLDER_INFO();

        folderInfo.iSize = Marshal.SizeOf(folderInfo);
        IntPtr bufItem = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_FOLDER_INFO)));
        Marshal.StructureToPtr(folderInfo, bufItem, true);
        intStatusCode = DAContentAccess.CAGetFolderInfo(intSMSHandle, bufItem);

        int intOperationHandle = 0;
        // Starting SMS-sending operation
        intStatusCode = DAContentAccess.CABeginOperation(intSMSHandle, 0, ref intOperationHandle);
        
        if(intStatusCode != Errors.CONA_OK){
          Console.WriteLine(&quot;DAContentAccess.CABeginOperation Failed = &quot; + intStatusCode); // jnc
          Environment.Exit(-1); 
        }
        
        // Putting the message straight to SENT-folder so it will be sent.
        // You could also put it to outbox, but then the code below that
        // deletes the message after sending doesnt work like this.                
        DAContentAccessDefinitions.CA_ITEM_ID itemUid = new DAContentAccessDefinitions.CA_ITEM_ID();
        itemUid.iSize = Marshal.SizeOf(itemUid);
        itemUid.iFolderId = CADataDefinitions.CA_MESSAGE_FOLDER_OUTBOX;
        itemUid.iStatus = 0;
        itemUid.iTemporaryID = 0;
        itemUid.iUidLen = 0;
        itemUid.pbUid = IntPtr.Zero;
        IntPtr buf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ITEM_ID)));
        Marshal.StructureToPtr(itemUid, buf, true);

        // Creating the SMS-message object
        CADataDefinitions.CA_DATA_MSG objSMSMessage = new CADataDefinitions.CA_DATA_MSG();
        objSMSMessage.iSize = Marshal.SizeOf(objSMSMessage);
        CADataDefinitions.CA_SET_DATA_FORMAT(ref objSMSMessage.iInfoField, CADataDefinitions.CA_DATA_FORMAT_UNICODE);
        CADataDefinitions.CA_SET_DATA_CODING(ref objSMSMessage.iInfoField, CADataDefinitions.CA_DATA_CODING_UNICODE);
        CADataDefinitions.CA_SET_MESSAGE_STATUS(ref objSMSMessage.iInfoField, CADataDefinitions.CA_MESSAGE_STATUS_DRAFT);
        CADataDefinitions.CA_SET_MESSAGE_TYPE(ref objSMSMessage.iInfoField, CADataDefinitions.CA_SMS_SUBMIT);

        objSMSMessage.bAddressCount = 1;
        // Setting the phone number
        objSMSMessage.pAddress = CreateSMSPhoneNoReference(strPhoneNo);

        objSMSMessage.iDataLength = strMessage.Length * 2;
        // Setting the message
        objSMSMessage.pbData = Marshal.StringToCoTaskMemUni(strMessage);

        // Setting the timestamp
        CreateTimestamp(ref objSMSMessage.messageDate);

        IntPtr buf2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CADataDefinitions.CA_DATA_MSG)));
        Marshal.StructureToPtr(objSMSMessage, buf2, true);

        // creating the SMS to the phone
        intStatusCode =DAContentAccess.CAWriteItem(intOperationHandle, buf, 0, 
            CADataDefinitions.CA_DATA_FORMAT_STRUCT, buf2);

        if(intStatusCode != Errors.CONA_OK){
          Console.WriteLine(&quot;DAContentAccess.CAWriteItem Failed = &quot; + intStatusCode); // jnc
          Environment.Exit(-1); 
        }

        Marshal.FreeHGlobal(buf2);
        Marshal.FreeHGlobal(buf);
        Marshal.FreeCoTaskMem(objSMSMessage.pbData);
        Marshal.FreeCoTaskMem(objSMSMessage.pAddress);

        // Creating a list object so that we can get info of the SMS that was created to the phone (for deleting purposes)
        DAContentAccessDefinitions.CA_ID_LIST lstIDs = new DAContentAccessDefinitions.CA_ID_LIST();
        lstIDs.iSize = Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ID_LIST));
        IntPtr lstbuf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ID_LIST)));
        Marshal.StructureToPtr(lstIDs, lstbuf, true);

        // Committing creation of the SMS, at this time the SMS is created to the phone
        // Returns the ID of the SMS to the list
        intStatusCode = DAContentAccess.CACommitOperations(intOperationHandle, lstbuf);

        if(intStatusCode != Errors.CONA_OK){
          Console.WriteLine(&quot;DAContentAccess.CACommitOperations Failed = &quot; + intStatusCode); // jnc
          Environment.Exit(-1); 
        }

        // Deleting the message after send if that was wanted
        if(!DontDelete){
            // Picking the first (and only) message from list and deleting it
            lstIDs = (DAContentAccessDefinitions.CA_ID_LIST)
                Marshal.PtrToStructure(lstbuf, typeof(DAContentAccessDefinitions.CA_ID_LIST));
            DAContentAccessDefinitions.CA_ITEM_ID objViestiUID= 
                GetUidFromBuffer(0, lstIDs.pUIDs);

            DeleteMessage(intOperationHandle, objViestiUID);

            intStatusCode = DAContentAccess.CACommitOperations(intOperationHandle, IntPtr.Zero);

            if(intStatusCode != Errors.CONA_OK){
              Console.WriteLine(&quot;DAContentAccess.CACommitOperations Failed = &quot; + intStatusCode); // jnc
              Environment.Exit(-1); 
            }
        }

        // Ending the transaction
        intStatusCode = DAContentAccess.CAEndOperation(intOperationHandle);

        if(intStatusCode != Errors.CONA_OK){
          Console.WriteLine(&quot;DAContentAccess.CAEndOperation Failed = &quot; + intStatusCode); // jnc
          Environment.Exit(-1); 
        }
        
      }catch(Exception ex2){
          Console.WriteLine(&quot;TRY SendSMS Exception ex2 = &quot; + ex2.Message); // jnc
          Console.WriteLine(ex2.StackTrace);
          Environment.Exit(-1); 
      }

    }

    private void DeleteMessage(int intOperationHandle, DAContentAccessDefinitions.CA_ITEM_ID objItem){
      IntPtr bufViesti = Marshal.AllocHGlobal(Marshal.SizeOf(objItem));
      Marshal.StructureToPtr(objItem, bufViesti, true);
      int intStatusCode = DAContentAccess.CADeleteItem(intOperationHandle, bufViesti, 0);

      if (intStatusCode != Errors.CONA_OK){
        Console.WriteLine(&quot;DAContentAccess.CADeleteItem Failed = &quot; + intStatusCode); // jnc
        Environment.Exit(-1); 
      }
    }

    private DAContentAccessDefinitions.CA_ITEM_ID GetUidFromBuffer(int iIndex, IntPtr pUIds){
      // Calculate beginning of item &#039;iIndex&#039;
      Int64 iPtr = pUIds.ToInt64() + (iIndex * Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ITEM_ID)));
      // Convert integer to pointer
      IntPtr ptr = new IntPtr(iPtr);
      // Copy data from buffer
      return (DAContentAccessDefinitions.CA_ITEM_ID)
        Marshal.PtrToStructure(ptr, typeof(DAContentAccessDefinitions.CA_ITEM_ID));
    }

    private int OpenSMSConnection(string strSerialNumber){
      IntPtr pstrSerialNumber = Marshal.StringToCoTaskMemUni(strSerialNumber);
      int iMedia = TypeDefinitions.API_MEDIA_ALL;
      int iTarget = CADataDefinitions.CA_TARGET_SMS_MESSAGES;
      int intSMSHandle = 0;
      int intStatusCode = DAContentAccess.DAOpenCA(pstrSerialNumber, ref iMedia, iTarget, ref intSMSHandle);

      if (intStatusCode != Errors.CONA_OK) {
        Console.WriteLine(&quot;DAContentAccess.DAOpenCA Failed = &quot; + intStatusCode); // jnc
        Environment.Exit(-1); 
      }

      Marshal.FreeCoTaskMem(pstrSerialNumber);

      return intSMSHandle;
    }

    private void CloseSMSConnection(int intSMSHandle){
    
      // Close PIM connection
      int intStatusCode = DAContentAccess.DACloseCA(intSMSHandle);
      
      if (intStatusCode != Errors.CONA_OK) {
        Console.WriteLine(&quot;DAContentAccess.DACloseCA Failed = &quot; + intStatusCode); // jnc
        Environment.Exit(-1); 
      }
    }

    private IntPtr CreateSMSPhoneNoReference(string strNumber){
      CADataDefinitions.CA_DATA_ADDRESS dataAddress = new CADataDefinitions.CA_DATA_ADDRESS();
      dataAddress.iSize = Marshal.SizeOf(dataAddress);
      dataAddress.iAddressInfo = CADataDefinitions.CA_MSG_ADDRESS_TYPE_NUMBER;
      dataAddress.pstrAddress = strNumber;
      // Allocate memory for buffer
      IntPtr bufDataAddress = Marshal.AllocHGlobal(Marshal.SizeOf(dataAddress));
      Marshal.StructureToPtr(dataAddress, bufDataAddress, true);
      return bufDataAddress;
    }

    private void CreateTimestamp(ref CADataDefinitions.CA_DATA_DATE pimDate){
      DateTime dateCurrent = DateTime.Now;
      pimDate.iSize = Marshal.SizeOf(pimDate);
      pimDate.wYear = System.Convert.ToUInt16(dateCurrent.Year);
      pimDate.bMonth = (byte)dateCurrent.Month;
      pimDate.bDay = (byte)dateCurrent.Day;
      pimDate.bHour = (byte)dateCurrent.Hour;
      pimDate.bMinute = (byte)dateCurrent.Minute;
      pimDate.bSecond = (byte)dateCurrent.Second;
    }
    
    public int CANotifyCallBack(int hCAHandle, int iReason, int iParam, IntPtr pItemID)
    {
      Console.WriteLine(&quot;Start of CANotifyCallBack&quot;); // jnc
      
      Console.WriteLine(&quot;iReason = &quot; + iReason); // jnc
      
      if (iReason == CAContentAccess.DAContentAccessDefinitions.CA_REASON_ITEM_ADDED) 
      {
        
        Console.WriteLine(&quot;SMS Detected CA_REASON_ITEM_ADDED&quot;); // jnc
        
        intStatusCode = GetSMSDetails(pItemID);
        
        if(intStatusCode==0) {
        
          mobileno = &quot;+91&quot; + mobileno.Substring(mobileno.Length - 10, 10);

          Console.WriteLine(&quot;India MobileNo = &quot; + mobileno); // jnc

          recvtext = recvtext.Replace(&quot;\n&quot;, &quot;\\n&quot;);

          recvtext = Regex.Replace(recvtext, @&quot;[^\u0020-\u007F]&quot;, &quot; &quot;);

          Console.WriteLine(&quot;CLEAN Text = &quot; + recvtext); // jnc

          OracleCommand cmdInsert = con.CreateCommand();
          cmdInsert.CommandText = &quot; INSERT INTO zsmstraffic &quot; + 
                                  &quot; (msgid,status,direction,msgdate,mobileno,smstext) &quot; +
                                  &quot; VALUES (msgid_seq.nextval,&#039;I&#039;,&#039;R&#039;,sysdate,&#039;&quot; + mobileno + &quot;&#039;, &#039;&quot; + recvtext + &quot;&#039;) &quot;;

          Console.WriteLine(&quot;SQL INSERT = &quot; + cmdInsert.CommandText); // jnc

          cmdInsert.ExecuteNonQuery();
          cmdInsert.Dispose();
          
        }
        
       }
     
     return 0;
    }

    //===================================================================
    // GetSMSDetails
    //
    // Read selected SMS from phone and show details in list view.
    //
    //===================================================================
    private int GetSMSDetails(IntPtr pItemID)
    {
      // Read SMS item data from device
      Console.WriteLine(&quot;Start of GetSMSDetails&quot;); // jnc
      
      hOperHandle=0;

      int iRet = DAContentAccess.CABeginOperation(intSMSHandle, 0,ref hOperHandle);

      if (iRet != Errors.CONA_OK) {
        Console.WriteLine(&quot;DAContentAccess.CABeginOperation Failed = &quot; + iRet); // jnc
        return 1; 
      }

      // Creating the SMS-message object
      CADataDefinitions.CA_DATA_MSG dataSMS = new CADataDefinitions.CA_DATA_MSG();

      dataSMS.iSize = Marshal.SizeOf(dataSMS);
      dataSMS.bAddressCount = 0;
      dataSMS.iInfoField = 0;
      dataSMS.iDataLength = 0;
      dataSMS.pAddress = IntPtr.Zero;
      dataSMS.pbData = IntPtr.Zero;
      
      GetEmptyPIMDate(ref dataSMS.messageDate);

      IntPtr pDataSMS = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CADataDefinitions.CA_DATA_MSG)));
      Marshal.StructureToPtr(dataSMS, pDataSMS, true);
      
      iRet = DAContentAccess.CAReadItem(hOperHandle, 
                                        pItemID, 
                                        0, 
                                        CADataDefinitions.CA_DATA_FORMAT_STRUCT, 
                                        pDataSMS);

      if (iRet == Errors.CONA_OK)
      {
          // Copy data from buffer
          dataSMS = (CADataDefinitions.CA_DATA_MSG)
                      Marshal.PtrToStructure(pDataSMS, 
                      typeof(CADataDefinitions.CA_DATA_MSG)); 
      }
      else
      {
        Console.WriteLine(&quot;pItemID = &quot; + pItemID); // jnc
        Console.WriteLine(&quot;pDataSMS = &quot; + pDataSMS); // jnc
        Console.WriteLine(&quot;DAContentAccess.CAReadItem Failed = &quot; + iRet); // jnc
        int intStatusCode = DAContentAccess.CAEndOperation(hOperHandle);
        return 1;
      }

      // Marshal.FreeHGlobal(buffer);

      int iResult = DAContentAccess.CAEndOperation(hOperHandle);
      
      if (iResult != Errors.CONA_OK) {
        Console.WriteLine(&quot;DAContentAccess.CAEndOperation Failed = &quot; + iResult); // jnc
        return 1; 
      }

      
      int i;
      // Addresses
      for (i = 0; i  0)
      {
        if ((CADataDefinitions.CA_GET_DATA_FORMAT(dataSMS.iInfoField)) == CADataDefinitions.CA_DATA_FORMAT_UNICODE)
        {
          if (!IntPtr.Zero.Equals(dataSMS.pbData))
          {

            recvtext = Marshal.PtrToStringUni(dataSMS.pbData, dataSMS.iDataLength / 2);

            Console.WriteLine(&quot;Received SMS Text = &quot; + recvtext); // jnc

          }
        }
      }

//    // Free memory allocated by DA API
//    iRet = DAContentAccess.CAFreeItemData(intSMSHandle, CADataDefinitions.CA_DATA_FORMAT_STRUCT, pDataSMS);
//    if (iRet != Errors.CONA_OK) { 
//      Console.WriteLine(&quot;DAContentAccess.CAFreeItemData Failed = &quot; + iRet); // jnc
//      return 1;
//    }

//    Marshal.FreeHGlobal(pDataSMS);
//    pDataSMS = IntPtr.Zero;
      
      return 0;

    }
        
    //===================================================================
    //
    // Structure to map CA_ITEM_ID &quot;permanently&quot; into managed memory 
    // 
    //===================================================================
    private struct CAItemID
    {
        public int iFolderId;
        public int iTemporaryID;
        public byte[] abUID;
        public int iStatus;
    }

    //===================================================================
    // MapUIDToCAItemID
    // 
    // Maps CA_ITEM_ID structure to CaItemID structure
    // 
    //===================================================================
    private CAItemID MapUIDToCAItemID(CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID UID)
    {
        CAItemID functionReturnValue = new CAItemID();
        functionReturnValue.iFolderId = UID.iFolderId;
        functionReturnValue.iTemporaryID = UID.iTemporaryID;
        functionReturnValue.iStatus = UID.iStatus;
        if (UID.iUidLen &gt; 0)
        {
            functionReturnValue.abUID = new byte[UID.iUidLen];
            Marshal.Copy(UID.pbUid, functionReturnValue.abUID, 0, UID.iUidLen);
        }
        else
        {
            functionReturnValue.abUID = null;
        }
        return functionReturnValue;
    }

    //===================================================================
    // MapCAItemIDToUID
    // 
    // Maps CaItemID structure to CA_ITEM_ID structure
    // Remember to free allocated memory after use (FreeUIDMappingMemory).
    // 
    //===================================================================
    private CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID MapCAItemIDToUID(CAItemID caID)
    {
        CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID functionReturnValue = new CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID();
        functionReturnValue.iSize = Marshal.SizeOf(typeof(CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID));
        functionReturnValue.iFolderId = caID.iFolderId;
        functionReturnValue.iTemporaryID = caID.iTemporaryID;
        functionReturnValue.iStatus = caID.iStatus;
        if (caID.abUID == null)
        {
            functionReturnValue.iUidLen = 0;
            functionReturnValue.pbUid = IntPtr.Zero;
        }
        else
        {
            int iSize = caID.abUID.GetUpperBound(0) - caID.abUID.GetLowerBound(0)+1;
            functionReturnValue.iUidLen = iSize;
            functionReturnValue.pbUid = Marshal.AllocHGlobal(iSize);
            Marshal.Copy(caID.abUID, 0, functionReturnValue.pbUid, iSize);
        }
        return functionReturnValue;
    }
    
    //===================================================================
    // GetEmptyPIMDate
    // 
    // Gets empty CA_DATA_DATE
    // 
    //===================================================================
    private void GetEmptyPIMDate(ref CAContentAccess.CADataDefinitions.CA_DATA_DATE pimDate)
    {
        pimDate.iSize = Marshal.SizeOf(pimDate);
        pimDate.bDay = 0;
        pimDate.lBias = 0;
        pimDate.bHour = 0;
        pimDate.bMinute = 0;
        pimDate.bMonth = 0;
        pimDate.bSecond = 0;
        pimDate.lTimeZoneBias = 0;
        pimDate.wYear = 0;
    }
  }
}</description>
		<content:encoded><![CDATA[<p>Spent a lot of effort developing a C# program based<br />
on forum &amp; sample PIMNavigator</p>
<p>Works fine for SEND</p>
<p>Works fine for FIRST RECEIVE Message<br />
Subsequent INPUT Messages fail at<br />
DAContentAccess.CAReadItem with code -2146435035</p>
<p>If I restart program works fine again for 1 RECEIVE Message.<br />
A huge amount of effort spent but at end stuck i RECEIVE.</p>
<p>using System;<br />
using System.Runtime.InteropServices;<br />
using System.Text.RegularExpressions;</p>
<p>using System.Data;<br />
using Oracle.DataAccess.Client;</p>
<p>using CAContentAccess;</p>
<p>using Errors = PCCSErrors.PCCSErrors;<br />
using TypeDefinitions = PCCSTypeDefinitions.PCCSTypeDefinitions;</p>
<p>namespace MyWindowsService{</p>
<p>  public class SMS<br />
  {</p>
<p>    private int intSMSHandle;</p>
<p>    private int intStatusCode;</p>
<p>    private OracleConnection con;</p>
<p>    private CAContentAccess.DAContentAccessDefinitions.CANotifyCallbackDelegate pCANotifyCallBack;</p>
<p>//  private CAContentAccess.DAContentAccessDefinitions.CAOperationCallbackDelegate pCAOperationCallback;</p>
<p>    private long msgid;<br />
    private string mobileno;<br />
    private string sendtext;<br />
    private string recvtext;<br />
    private string strSerialNumber; // 353080029098956</p>
<p>    private int hOperHandle;</p>
<p>    static void Main(string[] args)<br />
    {<br />
      SMS mySMS=new SMS();</p>
<p>      mySMS.LoopForEver();</p>
<p>    }</p>
<p>    private void LoopForEver()<br />
    {</p>
<p>      intSMSHandle= 0;</p>
<p>      //Initializing API<br />
      intStatusCode = DAContentAccess.CAAPI_Initialize(30, 0);</p>
<p>      strSerialNumber= &#8220;353080029098956&#8243;;</p>
<p>      try{<br />
        //Opening connection to send messages<br />
        intSMSHandle = OpenSMSConnection(strSerialNumber);   </p>
<p>      }catch(Exception ex){</p>
<p>        // throw ex;<br />
        Console.WriteLine(&#8220;Opening SMS connection Exception ex = &#8221; + ex.Message); // jnc<br />
        Console.WriteLine(ex.StackTrace);</p>
<p>        Environment.Exit(-1);<br />
      }</p>
<p>      pCANotifyCallBack = CANotifyCallBack;</p>
<p>//    pCAOperationCallback = CAOperationCallback;</p>
<p>      int iResult = DAContentAccess.CARegisterNotifyCallback(<br />
                      intSMSHandle,<br />
                      TypeDefinitions.API_REGISTER,<br />
                      pCANotifyCallBack);</p>
<p>      if (iResult != Errors.CONA_OK) {<br />
        Console.WriteLine(&#8220;DAContentAccess.CARegisterNotifyCallback Failed = &#8221; + iResult); // jnc<br />
        Environment.Exit(-1);<br />
      }</p>
<p>//    int iResult = DAContentAccess.CARegisterOperationCallBack(<br />
//                    intSMSHandle,<br />
//                    TypeDefinitions.API_REGISTER,<br />
//                    pCAOperationCallback);<br />
//<br />
//    if (iResult != Errors.CONA_OK)<br />
//      Environment.Exit(-1); </p>
<p>      // create connection string using EZCONNECT format<br />
      // this format specifies the server and the Oracle<br />
      // service name as the datasource<br />
      // using the format: server/oracle service name<br />
      // no tnsnames.ora or sqlnet.ora file is needed</p>
<p>      string constr = &#8220;User Id=hr; &#8221; +<br />
                           &#8220;Password=hr; &#8221; +<br />
                           &#8220;Data Source=localhost/xe&#8221;;</p>
<p>      // create connection object<br />
      con = new OracleConnection(constr);</p>
<p>      // use &#8220;try&#8221; block to open connection<br />
      // if an error occurs, simply display the message<br />
      // since there is a &#8220;catch&#8221; block a &#8220;using&#8221; statement is not used<br />
      try {<br />
        // attempt to open the connection<br />
        con.Open();</p>
<p>     }<br />
      catch (OracleException ex) {</p>
<p>        // an OracleException was thrown<br />
        Console.WriteLine(&#8220;OracleException ex = &#8221; + ex.Message); // jnc<br />
        Console.WriteLine(ex.StackTrace);</p>
<p>        Environment.Exit(-1);<br />
      }</p>
<p>      string strQuery = @&#8221;SELECT msgid, mobileno, smstext<br />
                            FROM zsmstraffic<br />
                           WHERE status = &#8216;I&#8217;<br />
                             AND direction = &#8216;S&#8217;&#8221;;</p>
<p>      // Create the OracleCommand object<br />
      OracleCommand cmdQuery = new OracleCommand(strQuery);<br />
      cmdQuery.Connection = con;<br />
      cmdQuery.CommandType = CommandType.Text;</p>
<p>      OracleDataReader reader;</p>
<p>      for(;;) {</p>
<p>        try<br />
        {<br />
          // Execute command, create OracleDataReader object<br />
          reader = cmdQuery.ExecuteReader();</p>
<p>          if(reader.HasRows)<br />
          {<br />
            while (reader.Read())<br />
            {<br />
              msgid=reader.GetInt64(0);<br />
              mobileno=reader.GetString(1);<br />
              sendtext=reader.GetString(2);<br />
              sendtext=sendtext.Replace(&#8220;\\n&#8221;, &#8220;\n&#8221;);<br />
              break;<br />
            }</p>
<p>            SendSMS(&#8220;353080029098956&#8243;, mobileno, sendtext, true);</p>
<p>            OracleCommand cmdUpdate = con.CreateCommand();<br />
            cmdUpdate.CommandText = @&#8221;UPDATE zsmstraffic<br />
                                         SET status = &#8216;X&#8217;<br />
                                       WHERE msgid = &#8221; + msgid;<br />
            cmdUpdate.ExecuteNonQuery();<br />
            cmdUpdate.Dispose();</p>
<p>          }<br />
          else<br />
          {<br />
            System.Threading.Thread.Sleep(60000); // 1 minute<br />
            Console.WriteLine(&#8220;Sleeping for 1 minute&#8221;); // jnc<br />
          }<br />
        }<br />
        catch (Exception ex)<br />
        {<br />
          Console.WriteLine(&#8220;FOREVER LOOP Exception ex = &#8221; + ex.Message); // jnc<br />
          Console.WriteLine(ex.StackTrace);<br />
          Environment.Exit(-1);<br />
        } </p>
<p>      } // for(;;) </p>
<p>      // Closing the SMS connection<br />
      CloseSMSConnection(intSMSHandle);</p>
<p>      // Terminating api<br />
      DAContentAccess.CAAPI_Terminate(0);</p>
<p>      // clean up the connection object<br />
      con.Dispose();</p>
<p>    }</p>
<p>    public void SendSMS(string strSerialNumber, string strPhoneNo, string strMessage, bool DontDelete){</p>
<p>      try{<br />
        // Not sure why this is needed, but didnt work without it<br />
        DAContentAccessDefinitions.CA_FOLDER_INFO folderInfo=<br />
            new DAContentAccessDefinitions.CA_FOLDER_INFO();</p>
<p>        folderInfo.iSize = Marshal.SizeOf(folderInfo);<br />
        IntPtr bufItem = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_FOLDER_INFO)));<br />
        Marshal.StructureToPtr(folderInfo, bufItem, true);<br />
        intStatusCode = DAContentAccess.CAGetFolderInfo(intSMSHandle, bufItem);</p>
<p>        int intOperationHandle = 0;<br />
        // Starting SMS-sending operation<br />
        intStatusCode = DAContentAccess.CABeginOperation(intSMSHandle, 0, ref intOperationHandle);</p>
<p>        if(intStatusCode != Errors.CONA_OK){<br />
          Console.WriteLine(&#8220;DAContentAccess.CABeginOperation Failed = &#8221; + intStatusCode); // jnc<br />
          Environment.Exit(-1);<br />
        }</p>
<p>        // Putting the message straight to SENT-folder so it will be sent.<br />
        // You could also put it to outbox, but then the code below that<br />
        // deletes the message after sending doesnt work like this.<br />
        DAContentAccessDefinitions.CA_ITEM_ID itemUid = new DAContentAccessDefinitions.CA_ITEM_ID();<br />
        itemUid.iSize = Marshal.SizeOf(itemUid);<br />
        itemUid.iFolderId = CADataDefinitions.CA_MESSAGE_FOLDER_OUTBOX;<br />
        itemUid.iStatus = 0;<br />
        itemUid.iTemporaryID = 0;<br />
        itemUid.iUidLen = 0;<br />
        itemUid.pbUid = IntPtr.Zero;<br />
        IntPtr buf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ITEM_ID)));<br />
        Marshal.StructureToPtr(itemUid, buf, true);</p>
<p>        // Creating the SMS-message object<br />
        CADataDefinitions.CA_DATA_MSG objSMSMessage = new CADataDefinitions.CA_DATA_MSG();<br />
        objSMSMessage.iSize = Marshal.SizeOf(objSMSMessage);<br />
        CADataDefinitions.CA_SET_DATA_FORMAT(ref objSMSMessage.iInfoField, CADataDefinitions.CA_DATA_FORMAT_UNICODE);<br />
        CADataDefinitions.CA_SET_DATA_CODING(ref objSMSMessage.iInfoField, CADataDefinitions.CA_DATA_CODING_UNICODE);<br />
        CADataDefinitions.CA_SET_MESSAGE_STATUS(ref objSMSMessage.iInfoField, CADataDefinitions.CA_MESSAGE_STATUS_DRAFT);<br />
        CADataDefinitions.CA_SET_MESSAGE_TYPE(ref objSMSMessage.iInfoField, CADataDefinitions.CA_SMS_SUBMIT);</p>
<p>        objSMSMessage.bAddressCount = 1;<br />
        // Setting the phone number<br />
        objSMSMessage.pAddress = CreateSMSPhoneNoReference(strPhoneNo);</p>
<p>        objSMSMessage.iDataLength = strMessage.Length * 2;<br />
        // Setting the message<br />
        objSMSMessage.pbData = Marshal.StringToCoTaskMemUni(strMessage);</p>
<p>        // Setting the timestamp<br />
        CreateTimestamp(ref objSMSMessage.messageDate);</p>
<p>        IntPtr buf2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CADataDefinitions.CA_DATA_MSG)));<br />
        Marshal.StructureToPtr(objSMSMessage, buf2, true);</p>
<p>        // creating the SMS to the phone<br />
        intStatusCode =DAContentAccess.CAWriteItem(intOperationHandle, buf, 0,<br />
            CADataDefinitions.CA_DATA_FORMAT_STRUCT, buf2);</p>
<p>        if(intStatusCode != Errors.CONA_OK){<br />
          Console.WriteLine(&#8220;DAContentAccess.CAWriteItem Failed = &#8221; + intStatusCode); // jnc<br />
          Environment.Exit(-1);<br />
        }</p>
<p>        Marshal.FreeHGlobal(buf2);<br />
        Marshal.FreeHGlobal(buf);<br />
        Marshal.FreeCoTaskMem(objSMSMessage.pbData);<br />
        Marshal.FreeCoTaskMem(objSMSMessage.pAddress);</p>
<p>        // Creating a list object so that we can get info of the SMS that was created to the phone (for deleting purposes)<br />
        DAContentAccessDefinitions.CA_ID_LIST lstIDs = new DAContentAccessDefinitions.CA_ID_LIST();<br />
        lstIDs.iSize = Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ID_LIST));<br />
        IntPtr lstbuf = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ID_LIST)));<br />
        Marshal.StructureToPtr(lstIDs, lstbuf, true);</p>
<p>        // Committing creation of the SMS, at this time the SMS is created to the phone<br />
        // Returns the ID of the SMS to the list<br />
        intStatusCode = DAContentAccess.CACommitOperations(intOperationHandle, lstbuf);</p>
<p>        if(intStatusCode != Errors.CONA_OK){<br />
          Console.WriteLine(&#8220;DAContentAccess.CACommitOperations Failed = &#8221; + intStatusCode); // jnc<br />
          Environment.Exit(-1);<br />
        }</p>
<p>        // Deleting the message after send if that was wanted<br />
        if(!DontDelete){<br />
            // Picking the first (and only) message from list and deleting it<br />
            lstIDs = (DAContentAccessDefinitions.CA_ID_LIST)<br />
                Marshal.PtrToStructure(lstbuf, typeof(DAContentAccessDefinitions.CA_ID_LIST));<br />
            DAContentAccessDefinitions.CA_ITEM_ID objViestiUID=<br />
                GetUidFromBuffer(0, lstIDs.pUIDs);</p>
<p>            DeleteMessage(intOperationHandle, objViestiUID);</p>
<p>            intStatusCode = DAContentAccess.CACommitOperations(intOperationHandle, IntPtr.Zero);</p>
<p>            if(intStatusCode != Errors.CONA_OK){<br />
              Console.WriteLine(&#8220;DAContentAccess.CACommitOperations Failed = &#8221; + intStatusCode); // jnc<br />
              Environment.Exit(-1);<br />
            }<br />
        }</p>
<p>        // Ending the transaction<br />
        intStatusCode = DAContentAccess.CAEndOperation(intOperationHandle);</p>
<p>        if(intStatusCode != Errors.CONA_OK){<br />
          Console.WriteLine(&#8220;DAContentAccess.CAEndOperation Failed = &#8221; + intStatusCode); // jnc<br />
          Environment.Exit(-1);<br />
        }</p>
<p>      }catch(Exception ex2){<br />
          Console.WriteLine(&#8220;TRY SendSMS Exception ex2 = &#8221; + ex2.Message); // jnc<br />
          Console.WriteLine(ex2.StackTrace);<br />
          Environment.Exit(-1);<br />
      }</p>
<p>    }</p>
<p>    private void DeleteMessage(int intOperationHandle, DAContentAccessDefinitions.CA_ITEM_ID objItem){<br />
      IntPtr bufViesti = Marshal.AllocHGlobal(Marshal.SizeOf(objItem));<br />
      Marshal.StructureToPtr(objItem, bufViesti, true);<br />
      int intStatusCode = DAContentAccess.CADeleteItem(intOperationHandle, bufViesti, 0);</p>
<p>      if (intStatusCode != Errors.CONA_OK){<br />
        Console.WriteLine(&#8220;DAContentAccess.CADeleteItem Failed = &#8221; + intStatusCode); // jnc<br />
        Environment.Exit(-1);<br />
      }<br />
    }</p>
<p>    private DAContentAccessDefinitions.CA_ITEM_ID GetUidFromBuffer(int iIndex, IntPtr pUIds){<br />
      // Calculate beginning of item &#8216;iIndex&#8217;<br />
      Int64 iPtr = pUIds.ToInt64() + (iIndex * Marshal.SizeOf(typeof(DAContentAccessDefinitions.CA_ITEM_ID)));<br />
      // Convert integer to pointer<br />
      IntPtr ptr = new IntPtr(iPtr);<br />
      // Copy data from buffer<br />
      return (DAContentAccessDefinitions.CA_ITEM_ID)<br />
        Marshal.PtrToStructure(ptr, typeof(DAContentAccessDefinitions.CA_ITEM_ID));<br />
    }</p>
<p>    private int OpenSMSConnection(string strSerialNumber){<br />
      IntPtr pstrSerialNumber = Marshal.StringToCoTaskMemUni(strSerialNumber);<br />
      int iMedia = TypeDefinitions.API_MEDIA_ALL;<br />
      int iTarget = CADataDefinitions.CA_TARGET_SMS_MESSAGES;<br />
      int intSMSHandle = 0;<br />
      int intStatusCode = DAContentAccess.DAOpenCA(pstrSerialNumber, ref iMedia, iTarget, ref intSMSHandle);</p>
<p>      if (intStatusCode != Errors.CONA_OK) {<br />
        Console.WriteLine(&#8220;DAContentAccess.DAOpenCA Failed = &#8221; + intStatusCode); // jnc<br />
        Environment.Exit(-1);<br />
      }</p>
<p>      Marshal.FreeCoTaskMem(pstrSerialNumber);</p>
<p>      return intSMSHandle;<br />
    }</p>
<p>    private void CloseSMSConnection(int intSMSHandle){</p>
<p>      // Close PIM connection<br />
      int intStatusCode = DAContentAccess.DACloseCA(intSMSHandle);</p>
<p>      if (intStatusCode != Errors.CONA_OK) {<br />
        Console.WriteLine(&#8220;DAContentAccess.DACloseCA Failed = &#8221; + intStatusCode); // jnc<br />
        Environment.Exit(-1);<br />
      }<br />
    }</p>
<p>    private IntPtr CreateSMSPhoneNoReference(string strNumber){<br />
      CADataDefinitions.CA_DATA_ADDRESS dataAddress = new CADataDefinitions.CA_DATA_ADDRESS();<br />
      dataAddress.iSize = Marshal.SizeOf(dataAddress);<br />
      dataAddress.iAddressInfo = CADataDefinitions.CA_MSG_ADDRESS_TYPE_NUMBER;<br />
      dataAddress.pstrAddress = strNumber;<br />
      // Allocate memory for buffer<br />
      IntPtr bufDataAddress = Marshal.AllocHGlobal(Marshal.SizeOf(dataAddress));<br />
      Marshal.StructureToPtr(dataAddress, bufDataAddress, true);<br />
      return bufDataAddress;<br />
    }</p>
<p>    private void CreateTimestamp(ref CADataDefinitions.CA_DATA_DATE pimDate){<br />
      DateTime dateCurrent = DateTime.Now;<br />
      pimDate.iSize = Marshal.SizeOf(pimDate);<br />
      pimDate.wYear = System.Convert.ToUInt16(dateCurrent.Year);<br />
      pimDate.bMonth = (byte)dateCurrent.Month;<br />
      pimDate.bDay = (byte)dateCurrent.Day;<br />
      pimDate.bHour = (byte)dateCurrent.Hour;<br />
      pimDate.bMinute = (byte)dateCurrent.Minute;<br />
      pimDate.bSecond = (byte)dateCurrent.Second;<br />
    }</p>
<p>    public int CANotifyCallBack(int hCAHandle, int iReason, int iParam, IntPtr pItemID)<br />
    {<br />
      Console.WriteLine(&#8220;Start of CANotifyCallBack&#8221;); // jnc</p>
<p>      Console.WriteLine(&#8220;iReason = &#8221; + iReason); // jnc</p>
<p>      if (iReason == CAContentAccess.DAContentAccessDefinitions.CA_REASON_ITEM_ADDED)<br />
      {</p>
<p>        Console.WriteLine(&#8220;SMS Detected CA_REASON_ITEM_ADDED&#8221;); // jnc</p>
<p>        intStatusCode = GetSMSDetails(pItemID);</p>
<p>        if(intStatusCode==0) {</p>
<p>          mobileno = &#8220;+91&#8243; + mobileno.Substring(mobileno.Length &#8211; 10, 10);</p>
<p>          Console.WriteLine(&#8220;India MobileNo = &#8221; + mobileno); // jnc</p>
<p>          recvtext = recvtext.Replace(&#8220;\n&#8221;, &#8220;\\n&#8221;);</p>
<p>          recvtext = Regex.Replace(recvtext, @&#8221;[^\u0020-\u007F]&#8220;, &#8221; &#8220;);</p>
<p>          Console.WriteLine(&#8220;CLEAN Text = &#8221; + recvtext); // jnc</p>
<p>          OracleCommand cmdInsert = con.CreateCommand();<br />
          cmdInsert.CommandText = &#8221; INSERT INTO zsmstraffic &#8221; +<br />
                                  &#8221; (msgid,status,direction,msgdate,mobileno,smstext) &#8221; +<br />
                                  &#8221; VALUES (msgid_seq.nextval,&#8217;I',&#8217;R',sysdate,&#8217;&#8221; + mobileno + &#8220;&#8216;, &#8216;&#8221; + recvtext + &#8220;&#8216;) &#8220;;</p>
<p>          Console.WriteLine(&#8220;SQL INSERT = &#8221; + cmdInsert.CommandText); // jnc</p>
<p>          cmdInsert.ExecuteNonQuery();<br />
          cmdInsert.Dispose();</p>
<p>        }</p>
<p>       }</p>
<p>     return 0;<br />
    }</p>
<p>    //===================================================================<br />
    // GetSMSDetails<br />
    //<br />
    // Read selected SMS from phone and show details in list view.<br />
    //<br />
    //===================================================================<br />
    private int GetSMSDetails(IntPtr pItemID)<br />
    {<br />
      // Read SMS item data from device<br />
      Console.WriteLine(&#8220;Start of GetSMSDetails&#8221;); // jnc</p>
<p>      hOperHandle=0;</p>
<p>      int iRet = DAContentAccess.CABeginOperation(intSMSHandle, 0,ref hOperHandle);</p>
<p>      if (iRet != Errors.CONA_OK) {<br />
        Console.WriteLine(&#8220;DAContentAccess.CABeginOperation Failed = &#8221; + iRet); // jnc<br />
        return 1;<br />
      }</p>
<p>      // Creating the SMS-message object<br />
      CADataDefinitions.CA_DATA_MSG dataSMS = new CADataDefinitions.CA_DATA_MSG();</p>
<p>      dataSMS.iSize = Marshal.SizeOf(dataSMS);<br />
      dataSMS.bAddressCount = 0;<br />
      dataSMS.iInfoField = 0;<br />
      dataSMS.iDataLength = 0;<br />
      dataSMS.pAddress = IntPtr.Zero;<br />
      dataSMS.pbData = IntPtr.Zero;</p>
<p>      GetEmptyPIMDate(ref dataSMS.messageDate);</p>
<p>      IntPtr pDataSMS = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CADataDefinitions.CA_DATA_MSG)));<br />
      Marshal.StructureToPtr(dataSMS, pDataSMS, true);</p>
<p>      iRet = DAContentAccess.CAReadItem(hOperHandle,<br />
                                        pItemID,<br />
                                        0,<br />
                                        CADataDefinitions.CA_DATA_FORMAT_STRUCT,<br />
                                        pDataSMS);</p>
<p>      if (iRet == Errors.CONA_OK)<br />
      {<br />
          // Copy data from buffer<br />
          dataSMS = (CADataDefinitions.CA_DATA_MSG)<br />
                      Marshal.PtrToStructure(pDataSMS,<br />
                      typeof(CADataDefinitions.CA_DATA_MSG));<br />
      }<br />
      else<br />
      {<br />
        Console.WriteLine(&#8220;pItemID = &#8221; + pItemID); // jnc<br />
        Console.WriteLine(&#8220;pDataSMS = &#8221; + pDataSMS); // jnc<br />
        Console.WriteLine(&#8220;DAContentAccess.CAReadItem Failed = &#8221; + iRet); // jnc<br />
        int intStatusCode = DAContentAccess.CAEndOperation(hOperHandle);<br />
        return 1;<br />
      }</p>
<p>      // Marshal.FreeHGlobal(buffer);</p>
<p>      int iResult = DAContentAccess.CAEndOperation(hOperHandle);</p>
<p>      if (iResult != Errors.CONA_OK) {<br />
        Console.WriteLine(&#8220;DAContentAccess.CAEndOperation Failed = &#8221; + iResult); // jnc<br />
        return 1;<br />
      }</p>
<p>      int i;<br />
      // Addresses<br />
      for (i = 0; i  0)<br />
      {<br />
        if ((CADataDefinitions.CA_GET_DATA_FORMAT(dataSMS.iInfoField)) == CADataDefinitions.CA_DATA_FORMAT_UNICODE)<br />
        {<br />
          if (!IntPtr.Zero.Equals(dataSMS.pbData))<br />
          {</p>
<p>            recvtext = Marshal.PtrToStringUni(dataSMS.pbData, dataSMS.iDataLength / 2);</p>
<p>            Console.WriteLine(&#8220;Received SMS Text = &#8221; + recvtext); // jnc</p>
<p>          }<br />
        }<br />
      }</p>
<p>//    // Free memory allocated by DA API<br />
//    iRet = DAContentAccess.CAFreeItemData(intSMSHandle, CADataDefinitions.CA_DATA_FORMAT_STRUCT, pDataSMS);<br />
//    if (iRet != Errors.CONA_OK) {<br />
//      Console.WriteLine(&#8220;DAContentAccess.CAFreeItemData Failed = &#8221; + iRet); // jnc<br />
//      return 1;<br />
//    }</p>
<p>//    Marshal.FreeHGlobal(pDataSMS);<br />
//    pDataSMS = IntPtr.Zero;</p>
<p>      return 0;</p>
<p>    }</p>
<p>    //===================================================================<br />
    //<br />
    // Structure to map CA_ITEM_ID &#8220;permanently&#8221; into managed memory<br />
    //<br />
    //===================================================================<br />
    private struct CAItemID<br />
    {<br />
        public int iFolderId;<br />
        public int iTemporaryID;<br />
        public byte[] abUID;<br />
        public int iStatus;<br />
    }</p>
<p>    //===================================================================<br />
    // MapUIDToCAItemID<br />
    //<br />
    // Maps CA_ITEM_ID structure to CaItemID structure<br />
    //<br />
    //===================================================================<br />
    private CAItemID MapUIDToCAItemID(CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID UID)<br />
    {<br />
        CAItemID functionReturnValue = new CAItemID();<br />
        functionReturnValue.iFolderId = UID.iFolderId;<br />
        functionReturnValue.iTemporaryID = UID.iTemporaryID;<br />
        functionReturnValue.iStatus = UID.iStatus;<br />
        if (UID.iUidLen &gt; 0)<br />
        {<br />
            functionReturnValue.abUID = new byte[UID.iUidLen];<br />
            Marshal.Copy(UID.pbUid, functionReturnValue.abUID, 0, UID.iUidLen);<br />
        }<br />
        else<br />
        {<br />
            functionReturnValue.abUID = null;<br />
        }<br />
        return functionReturnValue;<br />
    }</p>
<p>    //===================================================================<br />
    // MapCAItemIDToUID<br />
    //<br />
    // Maps CaItemID structure to CA_ITEM_ID structure<br />
    // Remember to free allocated memory after use (FreeUIDMappingMemory).<br />
    //<br />
    //===================================================================<br />
    private CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID MapCAItemIDToUID(CAItemID caID)<br />
    {<br />
        CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID functionReturnValue = new CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID();<br />
        functionReturnValue.iSize = Marshal.SizeOf(typeof(CAContentAccess.DAContentAccessDefinitions.CA_ITEM_ID));<br />
        functionReturnValue.iFolderId = caID.iFolderId;<br />
        functionReturnValue.iTemporaryID = caID.iTemporaryID;<br />
        functionReturnValue.iStatus = caID.iStatus;<br />
        if (caID.abUID == null)<br />
        {<br />
            functionReturnValue.iUidLen = 0;<br />
            functionReturnValue.pbUid = IntPtr.Zero;<br />
        }<br />
        else<br />
        {<br />
            int iSize = caID.abUID.GetUpperBound(0) &#8211; caID.abUID.GetLowerBound(0)+1;<br />
            functionReturnValue.iUidLen = iSize;<br />
            functionReturnValue.pbUid = Marshal.AllocHGlobal(iSize);<br />
            Marshal.Copy(caID.abUID, 0, functionReturnValue.pbUid, iSize);<br />
        }<br />
        return functionReturnValue;<br />
    }</p>
<p>    //===================================================================<br />
    // GetEmptyPIMDate<br />
    //<br />
    // Gets empty CA_DATA_DATE<br />
    //<br />
    //===================================================================<br />
    private void GetEmptyPIMDate(ref CAContentAccess.CADataDefinitions.CA_DATA_DATE pimDate)<br />
    {<br />
        pimDate.iSize = Marshal.SizeOf(pimDate);<br />
        pimDate.bDay = 0;<br />
        pimDate.lBias = 0;<br />
        pimDate.bHour = 0;<br />
        pimDate.bMinute = 0;<br />
        pimDate.bMonth = 0;<br />
        pimDate.bSecond = 0;<br />
        pimDate.lTimeZoneBias = 0;<br />
        pimDate.wYear = 0;<br />
    }<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on About Me by Camilo III</title>
		<link>http://camilord.kagayan.com/about-me/comment-page-1/#comment-973</link>
		<dc:creator>Camilo III</dc:creator>
		<pubDate>Thu, 08 Apr 2010 11:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?page_id=2#comment-973</guid>
		<description>asa na kauban? kauban sa barko hoegh?</description>
		<content:encoded><![CDATA[<p>asa na kauban? kauban sa barko hoegh?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on About Me by Kim Gil</title>
		<link>http://camilord.kagayan.com/about-me/comment-page-1/#comment-944</link>
		<dc:creator>Kim Gil</dc:creator>
		<pubDate>Fri, 19 Mar 2010 11:50:04 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?page_id=2#comment-944</guid>
		<description>hello bai.

ig unsa nimo c cheng LOZANo?????

nag kaoban mi nya b4... ikumusta nlang nya ko nya.</description>
		<content:encoded><![CDATA[<p>hello bai.</p>
<p>ig unsa nimo c cheng LOZANo?????</p>
<p>nag kaoban mi nya b4&#8230; ikumusta nlang nya ko nya.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to resize a partition in Windows Vista by kartenlegen per e-mail</title>
		<link>http://camilord.kagayan.com/2009/03/08/how-to-resize-a-partition-in-windows-vista/comment-page-1/#comment-925</link>
		<dc:creator>kartenlegen per e-mail</dc:creator>
		<pubDate>Fri, 05 Mar 2010 12:13:31 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=117#comment-925</guid>
		<description>Great info. Tweeted about it. I&#039;ll bookmark this post too later.</description>
		<content:encoded><![CDATA[<p>Great info. Tweeted about it. I&#8217;ll bookmark this post too later.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Visual C#: Connecting to MySQL remotely by Camilo III</title>
		<link>http://camilord.kagayan.com/2009/04/13/visual-c-connecting-to-mysql-remotely/comment-page-1/#comment-795</link>
		<dc:creator>Camilo III</dc:creator>
		<pubDate>Fri, 29 Jan 2010 16:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=190#comment-795</guid>
		<description>thanks man.. :)</description>
		<content:encoded><![CDATA[<p>thanks man.. <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Visual C#: Connecting to MySQL remotely by puerto_princesa_kid</title>
		<link>http://camilord.kagayan.com/2009/04/13/visual-c-connecting-to-mysql-remotely/comment-page-1/#comment-794</link>
		<dc:creator>puerto_princesa_kid</dc:creator>
		<pubDate>Fri, 29 Jan 2010 14:09:40 +0000</pubDate>
		<guid isPermaLink="false">http://camilord.kagayan.com/?p=190#comment-794</guid>
		<description>bossing maraming salamat for this sample c# program, ang husay!</description>
		<content:encoded><![CDATA[<p>bossing maraming salamat for this sample c# program, ang husay!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
