Monday, May 9, 2011

TIFFtoPDF conversion - Image Bitmap File Lock Problem - Resolved



   string[] files = Directory.GetFiles(faxpath, "*.tif");
            foreach (string infilename in files)
            {
                PdfDocument document = new PdfDocument();                
                StreamReader imgstreamer = new StreamReader(infilename);                
                Bitmap bm = new Bitmap(imgstreamer.BaseStream);
                int total = bm.GetFrameCount(FrameDimension.Page);                
                _logger.Log("TIFtoPDFConversion", LogEntryType.Debug, "Converting TIF File: " + infilename);
                for (Int32 k = 0; k < total; k++)
                {
                    Bitmap bm2 = new Bitmap(infilename);
                    bm2.SelectActiveFrame(FrameDimension.Page, k);
                    XImage image = XImage.FromGdiPlusImage(bm2);
                    PdfPage page1 = document.AddPage();

                    // Get Image width, Height and Resolution and Set output document Width and Height in Inches
                    page1.Width = XUnit.FromInch(image.PixelWidth / image.HorizontalResolution);
                    page1.Height = XUnit.FromInch(image.PixelHeight / image.VerticalResolution);
                    XGraphics gfx = XGraphics.FromPdfPage(page1, XGraphicsPdfPageOptions.Append);
                    gfx.DrawImage(image, 0, 0);
                    gfx.Dispose();
                    image.Dispose();
                    page1.Close();
                    bm2.Dispose();
                }
                string pdffilename = infilename.Substring(0, infilename.ToLower().LastIndexOf(".tif") - 1) + ".pdf";
                _logger.Log("TIFtoPDFConversion", LogEntryType.Debug, "Completed Converting TIF File: " + infilename);
                // Save the PDF
                document.Save(pdffilename);
                imgstreamer.Close();
            }       


So Simple as that. Add pdfsharp in the reference nothing else to install.
Pdfsharp can be obtained from PDFSharp.

Friday, May 6, 2011

Call a WCF Service from Linux Nusoap



include('lib/nusoap.php');

$client = new nusoap_client('http://url.svc?wsdl', 'wsdl',
                $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo "Constructor error";
exit;
}
$client->soap_defencoding = 'UTF-8';
$result = $client->call('DoWork');
echo $result['DoWorkResult'];
//echo $client->debug_str;
echo "\n";

Wednesday, April 20, 2011

TIFF to PDF Conversion using .Net - Free



            string infilename = "c:\\temp\\faxsample.tif";
            PdfDocument document = new PdfDocument();
            Bitmap bm = new Bitmap(infilename);
            int total = bm.GetFrameCount(FrameDimension.Page);
            for (Int32 k = 0; k < total; k++)
            {
                Bitmap bm2 = new Bitmap(infilename);
                bm2.SelectActiveFrame(FrameDimension.Page, k);
                XImage image = XImage.FromGdiPlusImage(bm2);
                PdfPage page1 = document.AddPage();
                
                // Get Image width, Height and Resolution and Set output document Width and Height in Inches
                page1.Width = XUnit.FromInch(image.Width / image.HorizontalResolution);
                page1.Height = XUnit.FromInch(image.Height / image.VerticalResolution);
                XGraphics gfx = XGraphics.FromPdfPage(page1, XGraphicsPdfPageOptions.Append);
                gfx.DrawImage(image, 0, 0);
                gfx.Dispose();
                image.Dispose();
                page1.Close();
                bm2.Dispose();
            } 
            document.Save("c:\\temp\\faxsample.pdf");
            Console.WriteLine("Total Pages: " + total);


So Simple as that. Add pdfsharp in the reference nothing else to install.
Pdfsharp can be obtained from PDFSharp.

Monday, April 18, 2011

Tropo ClicktoCall with Conference in PHP - Cloud Telephony



$calloptions['onAnswer'] = 'secondCallInitiator';
$calloptions['callerID'] = 'Calleridhere';
call('+1'.$numbertodial, $calloptions);

function secondCallInitiator($event)
{
$confid = $conferenceid;
$confoptions['mute'] = false;
$confoptions['playTones'] = true;
$confoptions['leaveprompt'] = 'beep';
$sleep(2);
Say('Please hold');
Conference($confid,$confoptions);
}


Pass two variables, numbertodail & conferenceid as POST parameters.
ClicktCall with Conference, That is so Simple to a Complex Infrastructure.

Tropo ClicktoCall PHP Script - Cloud Internet Telephony Made Easy !



$aftercalloptions['onAnswer'] = 'onAnswerCB';
call('+1'. agentnumber, $aftercalloptions);

function onAnswerCB($event)
{
    global $customernumber;
    Sleep(3);
    transfer('+1' . $customernumber);
}



Cool and Pretty for a Complex Need !

Initiate a call with the following URL
https://api.tropo.com/1.0/sessions?action=create&token=yourtoken&agentnumber=agentnum&customernumber=custnum

Ensoy !

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