Monday, September 27, 2010

Adding a New Call to the SugarCRM through Code

Ass a new Call to the SugarCRM through Code.



                    $call = new Call();

                    $call->direction = 'Outbound';

                    $call->status = 'Planned';

                    $call->contact_id = $contactid;

                    $call->duration_hours = '0';

                    $call->duration_minutes = '15';

                    $call->date_start = $date; // (mm/dd/yyyy hh:mmTT) format

                    $call->name = $subjectstring;

                    $call->assigned_user_id = $current_user->id;

                    $call->team_id = '1';

                    $call->team_set_id = '1';

                    $call->save();

                // Create the relationship to Contact to appear in the Contact Subpanel

                    $contact = new Contact();

                    $contact->retrieve($call->contact_id);

                    $contact->load_relationship('calls');

                    $contact->calls->add($call->id);



Enjoy.

Wednesday, June 2, 2010

Asterisk Events with Timestamp 1.4

The below events is the incoming call to asterisk and Plays a prompt and does a Echo after that.

Event: Newchannel
Privilege: call,all
Timestamp: 1261277764.070399
Channel: SIP/broadvox-0a7bde90
State: Down
CallerIDNum:
CallerIDName:
Uniqueid: 1261277764.44

Event: Newcallerid
Privilege: call,all
Timestamp: 1261277764.070456
Channel: SIP/broadvox-0a7bde90
CallerID:
CallerIDName:
Uniqueid: 1261277764.44
CID-CallingPres: 0 (Presentation Allowed, Not Screened)

Event: Newstate
Privilege: call,all
Timestamp: 1261277765.729062
Channel: SIP/broadvox-0a7bde90
State: Up
CallerID:
CallerIDName:
Uniqueid: 1261277764.44

Event: OriginateResponse
Privilege: call,all
Timestamp: 1261277765.729085
Response: Success
Channel: SIP/broadvox-0a7bde90
Context: broadvoxcontext
Exten: 13038598130
Reason: 4
Uniqueid: 1261277764.44
CallerID:
CallerIDNum:
CallerIDName:

Event: Newexten
Privilege: call,all
Timestamp: 1261277765.729144
Channel: SIP/broadvox-0a7bde90
Context: broadvoxcontext
Extension: 13038598130
Priority: 1
Application: Answer
AppData: 4
Uniqueid: 1261277764.44

Event: Newexten
Privilege: call,all
Timestamp: 1261277765.729187
Channel: SIP/broadvox-0a7bde90
Context: broadvoxcontext
Extension: 13038598130
Priority: 2
Application: Read
AppData: DESTNO|vm-enter-num-to-call
Uniqueid: 1261277764.44

Event: Newexten
Privilege: call,all
Timestamp: 1261277778.705334
Channel: SIP/broadvox-0a7bde90
Context: broadvoxcontext
Extension: 13038598130
Priority: 3
Application: SayDigits
AppData: 12345
Uniqueid: 1261277764.44

Event: Newexten
Privilege: call,all
Timestamp: 1261277781.847347
Channel: SIP/broadvox-0a7bde90
Context: broadvoxcontext
Extension: 13038598130
Priority: 4
Application: Echo
AppData:
Uniqueid: 1261277764.44

Event: Hangup
Privilege: call,all
Timestamp: 1261277785.813339
Channel: SIP/broadvox-0a7bde90
Uniqueid: 1261277764.44
Cause: 16
Cause-txt: Normal Clearing

Saturday, May 1, 2010

Unusable Google App Engine - Time wasting efforts with Google App Engine

ok. I tried to inserted the data somehow each record with a new request and that worked fine. Now I tried to delete the data.

Tried to delete all at once. Did not work. Tried 100 at a time, Did not work.
Tried even 10 at a time, did not work. Deleting one by one that worked. Stupid Stuff !



 javax.jdo.Query q = pm.newQuery(Agent.class);

        Collection results = (Collection) q.execute();

        int deletecount =0;

        Iterator iter = results.iterator();

           while (iter.hasNext()) {

               if( deletecount > 1 )

                   break;

               pm.deletePersistent(iter.next());             

               deletecount++;

           }


If I try to delete one by one, then my quota got over. :)  I used to delete millions of records at a time with the existing Databases. Google Datastore or Big Table (I would say funny table) it is a total crap here and totally unusable for enterprise.

I use Microsoft Windows just for browsing and playing games. (Sometimes it is not even worth to play games). Same here too. So far felt comfortable with Google technologies, the app engine is a total crap and the datastore is too crappy. So if you want to use cloud computing and don't deal with huge data at the same time, just like writing personal home based applications, then I would say, opt for Google Appengine. Otherwise keey away and don't waste your time.


More over from the above graph I have still lot of CPU hours left in Datastore CPU Time, I don't know what is the fun of limitation out there. So Daily quota is not Daily Quote, it is per second Quota. Just for marketing purposes they come with the big numbers above.

With the above facts, it becomes unusable for me to work with except to host static files and funny websites. Not yet ready for enterprise and not so reliable though.

Experience with Google App Engine Data Store

Tried the Google's cloud platform with a simple example to store data.



package com.musugundan;

import java.io.IOException;
import java.util.Date;

import javax.jdo.PersistenceManager;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class MusugundanServlet extends HttpServlet {
 public void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws IOException {
  resp.setContentType("text/plain");
  resp.addHeader("Refresh", "0; URL=/musugundan");
  resp.getWriter().println("Adding 100 records, Starting time " + new Date());
  PersistenceManager pm = PMF.get().getPersistenceManager();
  resp.flushBuffer();
        // 
                int maxrecords = 1000;
  for(long i=1;i<1000; i++)
  {
   Agent ag = new Agent("firstname" + i ,"lastname" + i,new Date());
   resp.getWriter().println("Writing Record :" + i );
   resp.flushBuffer();
            pm.makePersistent(ag);
  }    
        resp.getWriter().println("Added 100  records, Ending time " + new Date());
        resp.flushBuffer();
 }
}



When I set the maxrecords to 1000. It is error always. Means I cannot create 1000 records at a stretch.

I changed to 100. The timing went to 12 seconds to 25 seconds.

Change it to 1 and open multiple browsers with the instance of 100. It went on smoothly. Creating single record in a single request is pretty fast.

In Cloud computing make big things in a simpler way. That way it can work fast for its distributed nature of resources.