CDYNE Phone Notify! Application

From CDYNE Wiki
Jump to navigation Jump to search

Back to Phone Notify!

This is open source Freeware. Feel free to use it as you wish.

Screen Shot

CDYNENotifyScreenShot.jpg

Download Links

Executable Program. *
C# Source Code

* If the executable does not run, please download the .NET Framework 2.0 from Microsoft MSDN or from Windows Update.

Goal

By writing this tutorial we would like to achive two goals:

  • Provide detailed description about how to use a Web Service in a stand alone application.
  • Build "real world" user application that uses CDYNE's Phone Notify! Web Service.

By following these instructions, the reader should be able to build a completely functional application. CDYNE also provide complete source code as well as fully built application.

Requirements

We are going to use C-Sharp (C#) Programming Language as a language of our choice. We will use Visual Studio .NET 2005 as our development environment.

Upload Routine

This is a code example from this program on how to upload sound files:

 1 void UploadFiles(string[] fileNames)
 2 {
 3  if (fileNames == null)
 4   return;
 5  
 6  splitContainer2.Enabled = false;
 7  
 8  bool bSuccess = false;
 9  PhoneNotify notify = new PhoneNotify();
10  
11  foreach (string fileName in fileNames)
12  {
13   try
14   {
15    lblStatus.Text = "Uploading " + fileName;
16    byte[] ba = System.IO.File.ReadAllBytes(fileName);
17    UploadFileResponse response = notify.UploadSoundFile(ba, fileName.Substring(fileName.LastIndexOf("\\")), txtLicenseKey.Text.Trim());
18    if (response.UploadSuccessful == false)
19    {
20     lblStatus.Text = "Uploading for: " + fileName + " FAILED";
21    }
22    else
23    {
24     lblStatus.Text = "Uploading for: " + fileName + " SUCCEEDED";
25     bSuccess = true;
26    }
27   }
28   catch (Exception)
29   {
30    lblStatus.Text = "One or more file upload FAILED";
31   }
32   Application.DoEvents();
33  }
34  
35  if (bSuccess)
36   FillSoundCmb();
37  
38  splitContainer2.Enabled = true;
39 }

The important part of the code above is:

1 PhoneNotify notify = new PhoneNotify();
2 byte[] ba = System.IO.File.ReadAllBytes(fileName);
3 UploadFileResponse response = notify.UploadSoundFile(ba, fileName.Substring(fileName.LastIndexOf("\\")), txtLicenseKey.Text.Trim());

Those 3 lines will upload a wav file into your account under that license key.