How to insert and retrive data from Discussion forum in Oracle Server 10g

Hi,
I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
Please help me to to understand the work flow, as well to know, the place where queries are written.
Thanks in advance,
Dhananjay

Hi,
I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
Please help me to to understand the work flow, as well to know, the place where queries are written.
Thanks in advance,
Dhananjay

Similar Messages

  • How to connect Openoffice Base with java and retrive data from it?

    I need to retrive data from Openoffice-Base in windows through java. Is there any driver which helps to retrive data from Openoffice-Base.

    [http://tinyurl.com/nfvbbg]

  • How to insert and view images from oracle using jsf

    Can anyone please give me some code example or link of article explaining that how can i insert and view images to/from oracle using jsf?
    Thanks in advance.

    You mean you want to view image data stored in the database, right?
    Create a servlet that streams the image data to the response (setting the appropriate content-type), then reference this servlet in your img tag. Here is an example:
    http://balusc.blogspot.com/2007/04/imageservlet.html
    Storage is something different. What exactly don't you understand there? Perhaps you want a file upload component?

  • Inserting and retrieving data from a BLOB

    Hi All,
    I have a table where in i will be storing .CSV and .XLS files as BLOBS. I have no clue as to how to read from this column and translate the data into a meaningful form!.
    Can anyone help me with this?

    Don't store the results as BLOBS/CLOBS and unstructured solutions.
    If you do, then your requirement to "read from this column and translate data into a meaningful form" will fail.
    You should convert the logical representation of data in the CSV (field,row) or XLS representation into a database design following the principles of the relational model.
    You will then need to write a loading mechanism, which would probably leverage external tables as an access method; or possibly heterogeneous services for binary XLS if conversion isn't an option.

  • Inserting and retrieving data from a al32UTF8 database USING SQL Developer

    hi guys,
    Before i post my questions , i think its better for me to provide you guys with my understandings first so that it easier to understand where/if i have gone wrong..
    I am using Window XP and Oracle 10g
    Non-unicode client - a client program that need to use the OS code page for mapping of the retrieved unicode data from the database as well as the support of displaying/inserting the characters from that code page to the database.
    E.G sqlplusw.exe
    Therefore, when using a non-unicode client
    1) we have to set the OS code page (Control panel - regional and language setting - advance - language for non unicode program ) to the code page that contain the characters we are going to display/insert.
    2) we will also have to set the NLS_LANG characterset to the character set of the code page we are going to insert so that when we do a insert (for e.g in thai ) , oracle will know, and auto conversion to UNICODE can take place. This is also true when we retrieve unicode data from the database so that conversion to the correct character set can take place.
    INSERTING
    THAI ---> conversion ----> UNICODE
    RETRIEVING
    THAI <---- conversion <---- UNICODE
    I hope my basic understanding is correct up till this point.
    Unicode client - a client program that supports the displaying/inserting of unicode characters without the need of setting the OS code page (Control panel - regional and language setting - advance - language for non unicode program )
    E.G isqlplus http or SQL developer
    However,
    1) There is still a need to set the NLS_LANG so that correct conversion can take place between the client and the database.
    For e.g, when retrieving if we set the NLS_LANG character set to ZHS16GBK (chinese) and the data store in unicode in database is E.G (THAI) , then the conversion would be wrong .
    Since it is a unicode supported client, then the NLS_LANG character set should be set to UNICODE as well.
    Here come my questions
    *Important - please help if you are busy and have no other time to answer the rest of the questions
    *Q1) If i were to use a unicode client, what should i set my NLS_LANG character set to ?
    AMERICAN_AMERICA.UTF8 ?
    *Q2) Where do i set the NLS_LANG character set information in SQL Developer, i know there is a metalink for setting NLS_LANG using isqlplus but i cant seems to google any result for SQL developer.
    Q3) Is my basic understanding right until this point ? If not, please explain in a more generalised term as i am really not familiar with character sets, code page, unicode , glyphs and fonts..
    Q4) If a unicode client does not need to refer to the OS code page (set in regional and language) , is there a UNICODE code page for the client to refer to , or is there any Window API available ?
    Q5)
    There is still a need to set the NLS_LANG so that correct conversion can take place between the client and the >>database.
    For e.g, when retrieving if we set the NLS_LANG character set to ZHS16GBK (chinese) and the data store in >>unicode in database is E.G (THAI) , then the conversion would be wrong .am i right on this point for UNICODE supported client ?
    Thanks for spending time to read my questions and i hope to hear advices from you guys soon.
    Million thanks again for sharing.
    Best Regards,
    Noob but willing to learn

    The requirement to always set NLS_LANG is not true for JDBC, which ignores NLS_LANG altogether. Java programs fetch text data into String variables, which use Unicode UTF-16 by design. JDBC sets character set conversion so that data is converted between UTF-16 and the database or national character set.
    The requirement to set NLS_LANG is not generally true for OCI, either. The first call in an OCI problem can be OCIEnvNlsCreate(). This call has two parameters that allow the caller to define the character set to use for VARCHAR2/CHAR/LONG/CLOB/statement text and the character set to use for NVARCHAR2/NCHAR/NCLOB. Only if these character sets are specified as 0, NLS_LANG character set is used. Also, OCI programs can specify different character sets for each bind or define variable (i.e. input/output buffer). Note: OCI programs always use NLS_LANG to initialize the language and territory settings for the client program and the database session. Only the character set can be specified is OCIEnvNlsCreate().
    OCIEnvNlsCreate() can specify the client character set as UTF-16 (in platform endianess). This is not possible with NLS_LANG.
    Various interfaces building on OCI, such as Oracle ODBC and ODP .NET, explicitly initialize OCI with Unicode character set, and thus ignore the NLS_LANG character set as well.
    Thnx,
    Sergiusz

  • How to read and write data from json file from windows phone7 app

    Hi
    I am developing wp7 app for the use of students my questions are
    How can i write a code to read and write the json/text file for the wp7.
    I am using windows 7 OS, VS 2010 Edition.
    This is my code below:
    xaml:
    <Grid>
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="7,18,0,550" Name="textBlock1" Text="Full
    Name: " />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,1,0,0" Name="txtName"
    Text="Enter your full name" VerticalAlignment="Top" />
                        <TextBlock Height="45" HorizontalAlignment="Left" Margin="6,75,0,0" Name="textBlock2" Text="Contact
    No: " VerticalAlignment="Top" />
                        <TextBox Width="350" Height="70" HorizontalAlignment="Left" Margin="108,61,0,480" Name="txtContact"
    Text="Enter your contact number" MaxLength="10" />
                        <Button Content="Register" Height="72" HorizontalAlignment="Left" Margin="10,330,0,0" Name="btnRegister"
    VerticalAlignment="Top" Width="190" Click="btnRegister_Click" />
                    </Grid>
    xaml.cs:
    private void btnRegister_Click(object sender, RoutedEventArgs e)
                string name, contact;
                name = txtName.Text;
                contact = txtContact.Text;
                try
                    if (name != "" && contact != "")
                        string msg = name + " " + contact;
                        MessageBox.Show(msg);
                        Student stud = new Student
                            Name= name,
                            Contact = contact,
                        string jsonString = JsonConvert.SerializeObject(stud);
                        MessageBox.Show(jsonString);
                    else
                        MessageBox.Show("Input Proper Information", MessageBoxButton.OK);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
    I have download NewtonSoft.json version 5.0.8.
    So, I am able to convert input data into json format, but how can I able to write and read this data from a json/text file.
    How can I do?
    Thank you in adv and please, reply soon.

    We don't have many samples left for Windows Phone 7 + Azure, the closest one to what you want to do is probably:
    Using Local Storage with OData on Windows Phone To Reduce Network Bandwidth
    this sample uses the local database feature: 'LINQ to SQL', available to Windows Phone 7.1 and 8.0 Silverlight applications, instead of simple file storage but even if you choose to stick with simple file storage I believe you should be able to adapt the
    networking related portions of the sample to your particular application.
    Eric Fleck, Windows Store and Windows Phone Developer Support. If you would like to provide feedback or suggestions for future improvements to the Windows Phone SDK please go to http://wpdev.uservoice.com/ where you can post your suggestions and/or cast
    your votes for existing suggestions.

  • How to read and write data from Excel to TestStand without using LabVIEW VIs

    Hi,
    How can I read in columns of data from Excel into a TestStand array and write columns of data to Excel from TestStand without using LabVIEW VIs?
    I don't think the Property Loader custom step type in TestStand will work because the data I would like to read in from Excel is in a column that is thousands of rows long and the data has to be in the proper format to use the Property Loader to load in an array from Excel.
    Thanks for your help.

    That example does not use LabVIEW and it does about 40% of what you need to do by calling Excel through ActiveX. If you don't know how to use Excel through ActiveX then you'll need to brush up on that.
    http://www.microsoft.com/en-us/download/details.aspx?id=16250
    http://support.microsoft.com/kb/141759
    http://support.microsoft.com/kb/302084
    CTA, CLA, MTFBWY

  • How to read and store data from an SQL resultset

    I'm writing a program to create testing scripts. I have a working version of the program that takes data from a specific input file, processes it and then outputs it as a test file that is readable by this other system. That's all fine and dandy, but now I wish to extend my program so that it doesn't need the input file, it shoud run an SQL query on the database itself and output this, with some other data to the output file, I have been experimenting with some code below:
              ResultSet rset;
              rset = sql.sqlweight();
              while (rset.next()!= false)
                   System.out.println("I'm getting to this loop");
                   scanCode = rset.getString(1);
                   System.out.println(scanCode);
                   rset.next();
              }And method sqlweight looks like this:
         public static ResultSet sqlweight() throws SQLException
              Connection connectiona = DriverManager.getConnection(//hiding connection details);
              Statement stmtW = connectiona.createStatement();
              String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
              ResultSet rset = stmtW.executeQuery(sqlW);
              while (rset.next())
                   //System.out.println(rset.getString(1));
              //rset.close();
              //stmtW.close();
              //connectiona.close();
              return rset;
         }Code is a bit messy at the moment as I am constantly changing and adding things so excuse the formatting. I can't get it to enter the loop (hence the testing line I put in it). I am wondering what the best way would be to get the data held in the results set into my String variable scanCode. Thanks for any help or advice.

    I haven't thrown it away, it just looks like this now:
         public static ResultSet sqlweight() throws SQLException
              Connection connectiona = DriverManager.getConnection(//hiding connection details);
              Statement stmtW = connectiona.createStatement();
              String sqlW = "Select distinct (selc_code) from selling_code, prod_orgu_link where selling_code.prod_id = prod_orgu_link.prod_id and prod_orgu_link.prou_prod_handling = 20";
              ResultSet rset = stmtW.executeQuery(sqlW);
              return rset;     
         }

  • How to insert a JPG file from file system to Oracle 10g?

    I have developed a schema to store photos as BLOB which store the text description as CLOB original filename, file size.
    I also use ctxsys.context to index TEXT_DESCRIPTION in order to perform Oracle Text Search and it works.
    I would like to insert some JPG file from say C:\MYPHOTO\Photo1.jpg as a new record. How can I do this in SQL PLus and/or Loader?
    How can I retrieve the PHOTO_IMAGE back to the file system using SQL Plus and/or command line in DOS?
    See the following script:
    create user myphoto identified by myphoto;
    grant connect, resource, ctxapp to myphoto;
    connect myphoto/myphoto@orcl;
    PROMPT Creating Table PHOTOS
    CREATE TABLE PHOTOS
    (PHOTO_ID VARCHAR2(15) NOT NULL,
    PHOTO_IMAGE BLOB,
    TEXT_DESCRIPTION CLOB,
    FILENAME VARCHAR2(50),
    FILE_SIZE NUMBER NOT NULL,
    CONSTRAINT PK_PHOTOS PRIMARY KEY (PHOTO_ID)
    create index idx_photos_text_desc on
    PHOTOS(TEXT_DESCRIPTION) indextype is ctxsys.context;
    INSERT INTO PHOTOS VALUES
    ('P00000000000001', empty_blob(), empty_clob(),
    'SCGP1.JPG',100);
    INSERT INTO PHOTOS VALUES
    ('P00000000000002', empty_blob(), 'Cold Play with me at the concert in Melbourne 2005',
    'COLDPLAY1.JPG',200);
    INSERT INTO PHOTOS VALUES
    ('P00000000000003', empty_blob(), 'My parents in Melbourne 2001',
    'COLDPLAY1.JPG',200);
    EXEC CTX_DDL.SYNC_INDEX('idx_photos_text_desc');
    SELECT PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'parents',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'cold play',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),score(2), PHOTO_ID ,TEXT_DESCRIPTION
    FROM photos
    WHERE CONTAINS(TEXT_DESCRIPTION,'Melbourne',1)> 0
    AND CONTAINS(TEXT_DESCRIPTION,'2005',2)> 0
    ORDER BY score(1) DESC;

    Hi
    You can use the following to insert an image:
    create table imagetab(id number primary key,imagfile blob, fcol varchar2(10));
    create or replace directory imagefiles as 'c:\'
    declare
        v_bfile BFILE;
        v_blob  BLOB;
      begin
        insert into imagetab (id,imagfile,fcol)
        values (3,empty_blob(),'BINARY')
        return imagfile into v_blob;
        v_bfile := BFILENAME ('IMAGEFILES', 'MyImage.JPG');
        Dbms_Lob.fileopen (v_bfile, Dbms_Lob.File_Readonly);
        Dbms_Lob.Loadfromfile (v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
        Dbms_Lob.Fileclose(v_bfile);
        commit;
      end;
    /

  • How can i view the data from Access DB in oracle

    pls tell me that how can i view the data of MS ACCESS DATABASE in ORACLE.i was use ODBC of ACCESS DATABASE AND THEN CREATE DATABASE LINK IN ORACLE BUT NOT YET SUCCEEDED.PLS TELL ME THE PROCEDURE.
    regard's

    hi,
    u nedd to use Oracle Hetrogeneous Services,,
    full details of the procedure u may fing on metalink
    Regards

  • How to open and read data from text file in PL/SQL

    We have a project ,need to open a file containing entries of data
    ,then process those data records one by one to update the
    database.This operation shoulbe be done in the database
    enviroment. Is there any hint about the file operation in
    PL/SQL? How to open the file and get one record ,maybe one line,
    and parse and get the data field ?
    thanks
    defang

    There was also a question on this over at AskTom
    (asktom.oracle.com) about a week ago complete with sample code.
    The pointer to the sample code is here:
    <A HREF="http://asktom.oracle.com/pls/ask/f?
    p=4950:8:::::F4950_P8_DISPLAYID:464420312302
    TARGET=_blank>http://asktom.oracle.com/pls/ask/f?
    p=4950:8:::::F4950_P8_DISPLAYID:464420312302</A>
    Admittedly it's about Win95, but the principles should apply.
    Yours faithfully, Graham Reeds.
    [email protected] | http://omnieng.co.uk/

  • How to acquire and display data from labview to excel simultaneo​usly

    hello,
    I am using the NI-DAQ to measure the falling edges of a clock and display them into a table. What I need is to display these data in a table in excel while the program is running. In addition, when I receive a pulse from an external clock, for which I have created a digital channell, the data must be logged in a different column. In other words, every time I receive a pulse the data must be stored in the adjacent column in excel.

    Hello Evangelos,
    As far as I know and have experienced, it is not possible to access a spreadsheet file (or any file, for that matter) by two programs at the same time, you will get an error.
    Also, a couple of observations on your code:
    A constant wired to a case selector of a case structure makes no sense as the false case will never be executed.
    Move the DAQmx Read from your Digital Input task into the while loop, as the DAQmx Read will only read once and the wire won’t get information in or out of a while loop as long as the while loop is iterating.
    Regards,
    Daniel REDS
    RF Systems Engineer
    Help us grow.
    If a post solves your question, mark it as The Solution.
    If a post helps, give Kudos to it.

  • How to post and get data from server using Get Webrequest

    Hi:-)
    I'm trying to send a username and password argument my server and the server is suppose to send some string back. The following code, that I got of the web, just dies. I think this line:
    HttpWebRequestpreq = result.AsyncState
    asHttpWebRequest;
    is null. Can you kindly fix this for me? Thank you in advance:-)
    notes: I have a few textboxes with the values for the request params
    I'm targeting Windows Phone 8.0 and Windows Phone 8.1 devices
    privatevoidBtnSignUpSubmit_Tab(objectsender,
    RoutedEventArgse)
    //show error if Username == Username
    if(TbUN.Text.ToString() ==
    "Username")
    MessageBox.Show("You
    must fill in your Username in the Username textbox.\nThank you.");
    return;
    //make sure all fields are filled in
    if(TbUN.Text.ToString() ==
    ""|| TbPW.Text.ToString()
    == ""|| TbCPW.Text.ToString()
    == "")
    MessageBox.Show("All
    fields must be filled in.\nThank you.");
    return;
    //make sure Password is the same as Confirm Password
    if(TbPW.Text.CompareTo(TbCPW.Text) !=
    0)
    MessageBox.Show("Your
    Password should be the same as Confirm Password.\nThank you.");
    return;
    //make sure Username contains valid characters
    boolbValid = IsUsernameValid(TbUN.Text);
    if(bValid)
                    bSignUp =
    true;
    //disable textboxes
                    TbUN.IsEnabled =
    false;
                    TbPW.IsEnabled =
    false;
                    TbCPW.IsEnabled =
    false;
                    TbEmail.IsEnabled =
    false;
                    BtnSignUpSubmit.IsEnabled =
    false;
                    title.Text =
    "requesting...";
    //make Post request top-server
    //add parameters
    stringdata =
    "username="+TbUN.Text+"&Password="+TbPW.Text;
    if(TbEmail.Text.Contains("@")
    && TbEmail.Text.Contains("."))
                        data +=
    "&email="+ TbEmail.Text;
                    System.
    UriURL =
    newUri("http://www.iclips.co.za/RegisterUsernameAndPassword.php");
    WebRequestwebRequest =
    WebRequest.Create(URL);
                    webRequest.Method =
    "POST";
                    webRequest.ContentType =
    "application/x-www-form-urlencoded";
                    webRequest.ContentLength = data.Length;
    //we first obtain an input stream to which to write the body of the HTTP POST
                    webRequest.BeginGetRequestStream((
    IAsyncResultresult) =>
    HttpWebRequestpreq = result.AsyncState
    asHttpWebRequest;
    if(preq !=
    null)
    StreampostStream = preq.EndGetRequestStream(result);
    //guess one could just accept a byte[] [via function argument] for arbitrary data types - images, audio,...
    byte[] dataStream =
    Encoding.UTF8.GetBytes(data);
                            postStream.Write(dataStream, 0, dataStream.Length);
                            postStream.Close();
    //we can then finalize the request...
                            preq.BeginGetResponse((
    IAsyncResultfinal_result) =>
    HttpWebRequestreq = final_result.AsyncState
    asHttpWebRequest;
    if(req !=
    null)
    try
    //we call the success callback as long as we get a response stream
    WebResponseresponse = req.EndGetResponse(final_result);
                                        success_callback(response.GetResponseStream());
    catch(WebExceptionwe)
    //otherwise call the error/failure callback
                                        error_callback(we.Message);
    return;
                            }, preq);
                    }, URL);
    privatevoiderror_callback(stringp)
    if(bSignUp)
                    bSignUp =
    false;
    // Show error message
    MessageBox.Show("Connection
    Error!\n\n"+ p);
    //enable input
    //disable textboxes
                    TbUN.IsEnabled =
    true;
                    TbPW.IsEnabled =
    true;
                    TbCPW.IsEnabled =
    true;
                    TbEmail.IsEnabled =
    true;
                    BtnSignUpSubmit.IsEnabled =
    false;
                    title.Text =
    "try again";
    privatevoidsuccess_callback(Streamstream)
    if(bSignUp)
                    bSignUp =
    false;
    // Open the stream using a StreamReader for easy access.
    StreamReaderreader =
    newStreamReader(stream);
    // Read the content.
    stringresponse = reader.ReadToEnd();
    // Display the content.
    MessageBox.Show(response);
    // Clean up the streams.
                    reader.Close();

    // Directives
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Microsoft.Phone.Controls;
    using Microsoft.Phone.Shell;
    using iClips.Resources;
    using System.ComponentModel;
    using System.Threading;
    using System.IO;
    using System.IO.IsolatedStorage;
    using Microsoft.Devices;
    using System.Windows.Media;
    using Microsoft.Xna.Framework.Media;
    using System.Windows.Media.Imaging;
    using System.Threading.Tasks;
    using System.Text;
    using Windows.Storage;
    using System.Windows.Threading;
    using System.Diagnostics;
    using System.Globalization;
    namespace iClips
    public partial class MainPage : PhoneApplicationPage
    Boolean bSignUp;
    HyperlinkButton BtnSignIn, BtnSignUp, BtnSignUpSubmit;
    TextBox TbUN, TbPW, TbCPW, TbEmail;
    TextBlock un, title;
    System.DateTime startTime;
    // Viewfinder for capturing video.
    private VideoBrush videoRecorderBrush;
    // Source and device for capturing video.
    private CaptureSource captureSource;
    private CaptureDevice vcDevice;
    double w, h;
    // File details for storing the recording.
    private IsolatedStorageFileStream isoVideoFile;
    private FileSink fileSink;
    private string isoVideoFileName = "CameraMovie.mp4";
    // For managing button and application state.
    private enum ButtonState { Initialized, Stopped, Ready, Recording, Playback, Paused, NoChange, CameraNotSupported };
    private ButtonState currentAppState;
    //create reference to SocketClient
    SocketClient sock = new SocketClient();
    // Constructor
    public MainPage()
    InitializeComponent();
    //setup recording
    // Prepare ApplicationBar and buttons.
    PhoneAppBar = (ApplicationBar)ApplicationBar;
    PhoneAppBar.IsVisible = true;
    StartRecording = ((ApplicationBarIconButton)ApplicationBar.Buttons[0]);
    StopPlaybackRecording = ((ApplicationBarIconButton)ApplicationBar.Buttons[1]);
    StartPlayback = ((ApplicationBarIconButton)ApplicationBar.Buttons[2]);
    PausePlayback = ((ApplicationBarIconButton)ApplicationBar.Buttons[3]);
    //display a welcome message
    txtDebug.Text = "Welcome to iClips.";
    string result = sock.Connect("197.189.214.116", 5000);
    txtOutput.Text = result;
    if(result.Contains("success")){
    sock.Send("#testing_");
    SetScreenResolution();
    //set image on load friends
    /*Uri uri = new Uri("/Assets/home_icons/myFriends.png", UriKind.Relative);
    BitmapImage imgSource = new BitmapImage(uri);
    Image image = new Image();
    image.Source = imgSource;
    load_friends.Content = image;*/
    SignIn();
    private void SignIn()
    // remove all elements inside sign grid
    for (int index = MyGrid.Children.Count - 1; index >= 0; index--)
    MyGrid.Children.RemoveAt(index);
    BtnSignIn = new HyperlinkButton();
    BtnSignIn.Content = "<< Sign In >>";
    BtnSignIn.Click += new RoutedEventHandler(SignIn_Tab);
    BtnSignIn.VerticalAlignment = VerticalAlignment.Bottom;
    BtnSignUp = new HyperlinkButton();
    BtnSignUp.Content = "<< I'm new here. Sign Up. >>";
    BtnSignUp.Click += new RoutedEventHandler(SignUp_Tab);
    BtnSignUp.VerticalAlignment = VerticalAlignment.Bottom;
    un = new TextBlock();
    un.Text = "Enter your Username:";
    un.VerticalAlignment = VerticalAlignment.Bottom;
    un.HorizontalAlignment = HorizontalAlignment.Center;
    TextBlock pw = new TextBlock();
    pw.Text = "Enter your Password:";
    pw.VerticalAlignment = VerticalAlignment.Bottom;
    pw.HorizontalAlignment = HorizontalAlignment.Center;
    //setup username textbox
    TbUN = new TextBox();
    TbUN.Opacity = 0.5;
    TbUN.Text = "";
    TbUN.FontSize = 16;
    TbUN.FontWeight = FontWeights.ExtraBold;
    TbUN.Foreground = new SolidColorBrush(Colors.Black);
    TbUN.Background = new SolidColorBrush(Colors.Transparent);
    TbUN.VerticalAlignment = VerticalAlignment.Top;
    TbUN.Height = 70;
    TbUN.Tap += TbUN_Tap;
    //setup password textbox
    TbPW = new TextBox();
    TbPW.Opacity = 0.5;
    TbPW.Text = "";
    TbPW.FontSize = 16;
    TbPW.FontWeight = FontWeights.ExtraBold;
    TbPW.Foreground = new SolidColorBrush(Colors.Black);
    TbPW.Background = new SolidColorBrush(Colors.Transparent);
    TbPW.VerticalAlignment = VerticalAlignment.Top;
    TbPW.Height = 70;
    TbPW.Tap += TbPW_Tap;
    //Show the background color of MyGrid
    MyGrid.Background = new SolidColorBrush(Colors.Blue);
    // Create Row for Username Textblock
    RowDefinition gridRow0 = new RowDefinition();
    gridRow0.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow0);
    // Create Row for Username
    RowDefinition gridRow1 = new RowDefinition();
    gridRow1.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow1);
    //create row for password Textblock
    RowDefinition gridRow2a = new RowDefinition();
    gridRow2a.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow2a);
    //create row for password
    RowDefinition gridRow2 = new RowDefinition();
    gridRow2.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow2);
    //create row for << Sign In >>
    RowDefinition gridRow3 = new RowDefinition();
    gridRow3.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow3);
    //create row for << Sign Up >>
    RowDefinition gridRow4 = new RowDefinition();
    gridRow4.Height = new GridLength(120);
    MyGrid.RowDefinitions.Add(gridRow4);
    Grid.SetRow(un, 0);
    Grid.SetColumn(un, 0);
    Grid.SetRow(TbUN, 1);
    Grid.SetColumn(TbUN, 0);
    Grid.SetRow(pw, 2);
    Grid.SetColumn(pw, 0);
    Grid.SetRow(TbPW, 3);
    Grid.SetColumn(TbPW, 0);
    Grid.SetRow(BtnSignIn, 4);
    Grid.SetColumn(BtnSignIn, 0);
    Grid.SetRow(BtnSignUp, 5);
    Grid.SetColumn(BtnSignUp, 0);
    MyGrid.Children.Add(un);
    MyGrid.Children.Add(TbUN);
    MyGrid.Children.Add(pw);
    MyGrid.Children.Add(TbPW);
    MyGrid.Children.Add(BtnSignIn);
    MyGrid.Children.Add(BtnSignUp);
    private void SignUp_Tab(object sender, RoutedEventArgs e)
    MessageBox.Show("Welcome to Sign up.\n\nYou need 3 things to create an account:\n1. A unique Case-Sensitive Username. ex 'iClips' is not the same as 'Iclips'\n2. A password to secure you account. \n3. A profile photo for easy recognition.\nThank you.");
    // remove all elements inside sign grid
    for (int index = MyGrid.Children.Count - 1; index >= 0; index--)
    MyGrid.Children.RemoveAt(index);
    //repopulate grid with Sign Up elements
    //create title
    title = new TextBlock();
    title.Text = "--- Sign Up 1/2 ---";
    title.VerticalAlignment = VerticalAlignment.Top;
    title.HorizontalAlignment = HorizontalAlignment.Center;
    //field for Username
    TbUN = new TextBox();
    TbUN.Opacity = 0.5;
    TbUN.Text = "Username";
    TbUN.FontSize = 16;
    TbUN.FontWeight = FontWeights.ExtraBold;
    TbUN.Foreground = new SolidColorBrush(Colors.Black);
    TbUN.Background = new SolidColorBrush(Colors.Transparent);
    TbUN.VerticalAlignment = VerticalAlignment.Top;
    TbUN.Height = 70;
    TbUN.Tap += TbUN_Tap;
    //field for Password
    TbPW = new TextBox();
    TbPW.Opacity = 0.5;
    TbPW.Text = "Password";
    TbPW.FontSize = 16;
    TbPW.FontWeight = FontWeights.ExtraBold;
    TbPW.Foreground = new SolidColorBrush(Colors.Black);
    TbPW.Background = new SolidColorBrush(Colors.Transparent);
    TbPW.VerticalAlignment = VerticalAlignment.Top;
    TbPW.Height = 70;
    TbPW.Tap += TbPW_Tap;
    //field Confirm for Password
    TbCPW = new TextBox();
    TbCPW.Opacity = 0.5;
    TbCPW.Text = "Confirm Password";
    TbCPW.FontSize = 16;
    TbCPW.FontWeight = FontWeights.ExtraBold;
    TbCPW.Foreground = new SolidColorBrush(Colors.Black);
    TbCPW.Background = new SolidColorBrush(Colors.Transparent);
    TbCPW.VerticalAlignment = VerticalAlignment.Top;
    TbCPW.Height = 70;
    TbCPW.Tap += TbCPW_Tap;
    //field for Optional Email
    TbEmail = new TextBox();
    TbEmail.Opacity = 0.5;
    TbEmail.Text = "Email (Optional)";
    TbEmail.FontSize = 16;
    TbEmail.FontWeight = FontWeights.ExtraBold;
    TbEmail.Foreground = new SolidColorBrush(Colors.Black);
    TbEmail.Background = new SolidColorBrush(Colors.Transparent);
    TbEmail.VerticalAlignment = VerticalAlignment.Top;
    TbEmail.Height = 70;
    TbEmail.Tap += TbEmail_Tap;
    HyperlinkButton BtnGoBack = new HyperlinkButton();
    BtnGoBack.Content = "<< Go Back ";
    BtnGoBack.Click += new RoutedEventHandler(BtnGoBack_Tab);
    BtnGoBack.VerticalAlignment = VerticalAlignment.Bottom;
    BtnSignUpSubmit = new HyperlinkButton();
    BtnSignUpSubmit.Content = "<< Sign Up >>";
    BtnSignUpSubmit.Click += new RoutedEventHandler(BtnSignUpSubmit_Tab);
    BtnSignUpSubmit.VerticalAlignment = VerticalAlignment.Bottom;
    // Create Row for title
    RowDefinition gridRow0 = new RowDefinition();
    gridRow0.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow0);
    // Create Row for Username
    RowDefinition gridRow1 = new RowDefinition();
    gridRow1.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow1);
    //create row for password Textblock
    RowDefinition gridRow2a = new RowDefinition();
    gridRow2a.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow2a);
    //create row for Confirm password
    RowDefinition gridRow2 = new RowDefinition();
    gridRow2.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow2);
    //create row for email
    RowDefinition gridRow3 = new RowDefinition();
    gridRow3.Height = new GridLength(60);
    MyGrid.RowDefinitions.Add(gridRow3);
    //create row for << Sign Up >>
    RowDefinition gridRow4 = new RowDefinition();
    gridRow4.Height = new GridLength(120);
    MyGrid.RowDefinitions.Add(gridRow4);
    //create row for << Go Back >>
    RowDefinition gridRow5 = new RowDefinition();
    gridRow5.Height = new GridLength(120);
    MyGrid.RowDefinitions.Add(gridRow5);
    Grid.SetRow(title, 0);
    Grid.SetColumn(title, 0);
    Grid.SetRow(TbUN, 1);
    Grid.SetColumn(TbUN, 0);
    Grid.SetRow(TbPW, 2);
    Grid.SetColumn(TbPW, 0);
    Grid.SetRow(TbCPW, 3);
    Grid.SetColumn(TbCPW, 0);
    Grid.SetRow(TbEmail, 4);
    Grid.SetColumn(TbEmail, 0);
    Grid.SetRow(BtnSignUpSubmit, 5);
    Grid.SetColumn(BtnSignUpSubmit, 0);
    Grid.SetRow(BtnGoBack, 6);
    Grid.SetColumn(BtnGoBack, 0);
    MyGrid.Children.Add(title);
    MyGrid.Children.Add(TbUN);
    MyGrid.Children.Add(TbPW);
    MyGrid.Children.Add(TbCPW);
    MyGrid.Children.Add(TbEmail);
    MyGrid.Children.Add(BtnSignUpSubmit);
    MyGrid.Children.Add(BtnGoBack);
    BtnSignUp.Content = "<< Sign Up >>";
    private bool IsUsernameValid(string str)
    int d;
    if (str.Length > 30)
    MessageBox.Show("You may only use a maximum of 30 characters for your Username.\nThank you.");
    return false;
    for (d = 0; d < str.Length; d++)
    if (str.Contains("~") || str.Contains("!") || str.Contains("@") || str.Contains("$")
    || str.Contains("#") || str.Contains("%") || str.Contains("|") || str.Contains("_"))
    MessageBox.Show("Your Username may not contain any of the follwing characters: \n~ ! @ # $ % | _\nThank you.");
    return false;
    return true;
    private void BtnSignUpSubmit_Tab(object sender, RoutedEventArgs e)
    //show error if Username == Username
    if (TbUN.Text.ToString() == "Username")
    MessageBox.Show("You must fill in your Username in the Username textbox.\nThank you.");
    return;
    //make sure all fields are filled in
    if (TbUN.Text.ToString() == "" || TbPW.Text.ToString() == "" || TbCPW.Text.ToString() == "")
    MessageBox.Show("All fields must be filled in.\nThank you.");
    return;
    //make sure Password is the same as Confirm Password
    if (TbPW.Text.CompareTo(TbCPW.Text) != 0)
    MessageBox.Show("Your Password should be the same as Confirm Password.\nThank you.");
    return;
    //make sure Username contains valid characters
    bool bValid = IsUsernameValid(TbUN.Text);
    if (bValid)
    bSignUp = true;
    //disable textboxes
    TbUN.IsEnabled = false;
    TbPW.IsEnabled = false;
    TbCPW.IsEnabled = false;
    TbEmail.IsEnabled = false;
    BtnSignUpSubmit.IsEnabled = false;
    title.Text = "requesting...";
    //make Post request top-server
    //add parameters
    string data = "username="+TbUN.Text+"&Password="+TbPW.Text;
    if(TbEmail.Text.Contains("@") && TbEmail.Text.Contains("."))
    data += "&email=" + TbEmail.Text;
    System.Uri URL = new Uri("http://www.iclips.co.za/RegisterUsernameAndPassword.php");
    WebRequest webRequest = WebRequest.Create(URL);
    webRequest.Method = "POST";
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.ContentLength = data.Length;
    //we first obtain an input stream to which to write the body of the HTTP POST
    webRequest.BeginGetRequestStream((IAsyncResult result) =>
    HttpWebRequest preq = result.AsyncState as HttpWebRequest;
    if (preq != null)
    Stream postStream = preq.EndGetRequestStream(result);
    //guess one could just accept a byte[] [via function argument] for arbitrary data types - images, audio,...
    byte[] dataStream = Encoding.UTF8.GetBytes(data);
    postStream.Write(dataStream, 0, dataStream.Length);
    postStream.Close();
    //we can then finalize the request...
    preq.BeginGetResponse((IAsyncResult final_result) =>
    HttpWebRequest req = final_result.AsyncState as HttpWebRequest;
    if (req != null)
    try
    //we call the success callback as long as we get a response stream
    WebResponse response = req.EndGetResponse(final_result);
    success_callback(response.GetResponseStream());
    catch (WebException we)
    //otherwise call the error/failure callback
    error_callback(we.Message);
    return;
    }, preq);
    }, URL);
    private void error_callback(string p)
    if (bSignUp)
    bSignUp = false;
    // Show error message
    MessageBox.Show("Connection Error!\n\n" + p);
    //enable input
    //disable textboxes
    TbUN.IsEnabled = true;
    TbPW.IsEnabled = true;
    TbCPW.IsEnabled = true;
    TbEmail.IsEnabled = true;
    BtnSignUpSubmit.IsEnabled = false;
    title.Text = "try again";
    private void success_callback(Stream stream)
    if (bSignUp)
    bSignUp = false;
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(stream);
    // Read the content.
    string response = reader.ReadToEnd();
    // Display the content.
    MessageBox.Show(response);
    // Clean up the streams.
    reader.Close();
    private void BtnGoBack_Tab(object sender, RoutedEventArgs e)
    SignIn();
    private void TbEmail_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    TbEmail.SelectAll();
    private void TbCPW_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    TbCPW.SelectAll();
    private void SignIn_Tab(object sender, RoutedEventArgs e)
    if (TbUN.Text.ToString() == "" || TbPW.Text.ToString() == "")
    MessageBox.Show("Your Username or Password cannot be empty.\nThank you.");
    return;
    private void TbUN_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    TbUN.SelectAll();
    un.Text = "Usernames are Case-Sensitive.\n'Iclips' is not the same as 'iClips'.";
    private void TbPW_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    TbPW.SelectAll();
    protected override void OnNavigatedTo(NavigationEventArgs e)
    base.OnNavigatedTo(e);
    // Initialize the video recorder.
    InitializeVideoRecorder();
    CameraButtons.ShutterKeyHalfPressed += OnButtonHalfPress;
    // The event is fired when the shutter button receives a full press.
    CameraButtons.ShutterKeyPressed += OnButtonFullPress;
    // The event is fired when the shutter button is released.
    CameraButtons.ShutterKeyReleased += OnButtonRelease;
    protected override void OnNavigatedFrom(NavigationEventArgs e)
    // Dispose of camera and media objects.
    DisposeVideoPlayer();
    DisposeVideoRecorder();
    base.OnNavigatedFrom(e);
    CameraButtons.ShutterKeyHalfPressed -= OnButtonHalfPress;
    CameraButtons.ShutterKeyPressed -= OnButtonFullPress;
    CameraButtons.ShutterKeyReleased -= OnButtonRelease;
    // Ensure that the viewfinder is upright in LandscapeRight.
    protected override void OnOrientationChanged(OrientationChangedEventArgs e)
    if (vcDevice != null)
    if (e.Orientation == PageOrientation.LandscapeLeft)
    txtDebug.Text = "LandscapeLeft";
    videoRecorderBrush.RelativeTransform =
    new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 90 };
    //rotate logo
    if (logo != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = 90;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    logo.RenderTransformOrigin = new Point(0.5, 0.5);
    logo.RenderTransform = rt;
    //rotate sign in link
    if (MyGrid != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = 90;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    MyGrid.RenderTransformOrigin = new Point(0.5, 0.5);
    MyGrid.RenderTransform = rt;
    if (e.Orientation == PageOrientation.PortraitUp)
    txtDebug.Text = "PortraitUp";
    videoRecorderBrush.RelativeTransform =
    new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 };
    //rotate logo
    if (logo != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = 0;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    logo.RenderTransformOrigin = new Point(0.5, 0.5);
    logo.RenderTransform = rt;
    //rotate sign in link
    if (MyGrid != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = 0;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    MyGrid.RenderTransformOrigin = new Point(0.5, 0.5);
    MyGrid.RenderTransform = rt;
    if (e.Orientation == PageOrientation.LandscapeRight)
    txtDebug.Text = "LandscapeRight";
    // Rotate for LandscapeRight orientation.
    //videoRecorderBrush.RelativeTransform =
    //new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 180 };
    //rotate logo
    if (logo != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = -90;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    logo.RenderTransformOrigin = new Point(0.5, 0.5);
    logo.RenderTransform = rt;
    //rotate sign in link
    if (MyGrid != null)
    RotateTransform rt = new RotateTransform();
    rt.Angle = -90;
    //default rotation is around top left corner of the control,
    //but you sometimes want to rotate around the center of the control
    //to do that, you need to set the RenderTransFormOrigin
    //of the item you're going to rotate
    //I did not test this approach, maybe You're going to need to use actual coordinates
    //so this bit is for information purposes only
    MyGrid.RenderTransformOrigin = new Point(0.5, 0.5);
    MyGrid.RenderTransform = rt;
    if (e.Orientation == PageOrientation.PortraitDown)
    txtDebug.Text = "PortraitDown";
    videoRecorderBrush.RelativeTransform =
    new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 270 };
    // Provide auto-focus with a half button press using the hardware shutter button.
    private void OnButtonHalfPress(object sender, EventArgs e)
    // Focus when a capture is not in progress.
    try
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "Half Button Press: Auto Focus";
    catch (Exception focusError)
    // Cannot focus when a capture is in progress.
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = focusError.Message;
    // Capture the image with a full button press using the hardware shutter button.
    private void OnButtonFullPress(object sender, EventArgs e)
    // Focus when a capture is not in progress.
    try
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "Full Button Press: Auto Focus";
    catch (Exception focusError)
    // Cannot focus when a capture is in progress.
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = focusError.Message;
    // Cancel the focus if the half button press is released using the hardware shutter button.
    private void OnButtonRelease(object sender, EventArgs e)
    try
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "Shutter is released: Auto Focus";
    catch (Exception focusError)
    // Cannot focus when a capture is in progress.
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = focusError.Message;
    // Update the buttons and text on the UI thread based on app state.
    private void UpdateUI(ButtonState currentButtonState, string statusMessage)
    // Run code on the UI thread.
    Dispatcher.BeginInvoke(delegate
    switch (currentButtonState)
    // When the camera is not supported by the phone.
    case ButtonState.CameraNotSupported:
    StartRecording.IsEnabled = false;
    StopPlaybackRecording.IsEnabled = false;
    StartPlayback.IsEnabled = false;
    PausePlayback.IsEnabled = false;
    break;
    // First launch of the application, so no video is available.
    case ButtonState.Initialized:
    StartRecording.IsEnabled = true;
    StopPlaybackRecording.IsEnabled = false;
    StartPlayback.IsEnabled = false;
    PausePlayback.IsEnabled = false;
    break;
    // Ready to record, so video is available for viewing.
    case ButtonState.Ready:
    StartRecording.IsEnabled = true;
    StopPlaybackRecording.IsEnabled = false;
    StartPlayback.IsEnabled = true;
    PausePlayback.IsEnabled = false;
    break;
    // Video recording is in progress.
    case ButtonState.Recording:
    StartRecording.IsEnabled = false;
    StopPlaybackRecording.IsEnabled = true;
    StartPlayback.IsEnabled = false;
    PausePlayback.IsEnabled = false;
    break;
    // Video playback is in progress.
    case ButtonState.Playback:
    StartRecording.IsEnabled = false;
    StopPlaybackRecording.IsEnabled = true;
    StartPlayback.IsEnabled = false;
    PausePlayback.IsEnabled = true;
    break;
    // Video playback has been paused.
    case ButtonState.Paused:
    StartRecording.IsEnabled = false;
    StopPlaybackRecording.IsEnabled = true;
    StartPlayback.IsEnabled = true;
    PausePlayback.IsEnabled = false;
    break;
    default:
    break;
    // Display a message.
    txtDebug.Text = statusMessage;
    // Note the current application state.
    currentAppState = currentButtonState;
    public void InitializeVideoRecorder()
    if (captureSource == null)
    // Create the VideoRecorder objects.
    captureSource = new CaptureSource();
    fileSink = new FileSink();
    vcDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
    // Add eventhandlers for captureSource.
    captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
    // Initialize the camera if it exists on the phone.
    if (vcDevice != null)
    // Create the VideoBrush for the viewfinder.
    videoRecorderBrush = new VideoBrush();
    videoRecorderBrush.SetSource(captureSource);
    // Display the viewfinder image on the rectangle.
    viewfinderRectangle.Fill = videoRecorderBrush;
    // Start video capture and display it on the viewfinder.
    captureSource.Start();
    // Set the button state and the message.
    UpdateUI(ButtonState.Initialized, "Tap record to start recording...");
    else
    // Disable buttons when the camera is not supported by the phone.
    UpdateUI(ButtonState.CameraNotSupported, "A camera is not supported on this phone.");
    // Set recording state: start recording.
    private void StartVideoRecording()
    try
    // Connect fileSink to captureSource.
    if (captureSource.VideoCaptureDevice != null
    && captureSource.State == CaptureState.Started)
    captureSource.Stop();
    // Connect the input and output of fileSink.
    fileSink.CaptureSource = captureSource;
    fileSink.IsolatedStorageFileName = isoVideoFileName;
    // Begin recording.
    if (captureSource.VideoCaptureDevice != null
    && captureSource.State == CaptureState.Stopped)
    captureSource.Start();
    // Set the button states and the message.
    UpdateUI(ButtonState.Recording, "Recording...");
    StartTimer();
    // If recording fails, display an error.
    catch (Exception e)
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "ERROR: " + e.Message.ToString();
    //start the timer
    private void StartTimer()
    dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
    dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
    dispatcherTimer.Start();
    startTime = System.DateTime.Now;
    private void StopTimer()
    dispatcherTimer.Stop();
    private void dispatcherTimer_Tick(object sender, EventArgs e)
    System.DateTime now = System.DateTime.Now;
    txtRecTime.Text = now.Subtract(startTime).ToString();
    // Set the recording state: stop recording.
    private void StopVideoRecording()
    try
    // Stop recording.
    if (captureSource.VideoCaptureDevice != null
    && captureSource.State == CaptureState.Started)
    captureSource.Stop();
    // Disconnect fileSink.
    fileSink.CaptureSource = null;
    fileSink.IsolatedStorageFileName = null;
    // Set the button states and the message.
    UpdateUI(ButtonState.Stopped, "Preparing viewfinder...");
    StopTimer();
    StartVideoPreview();
    // If stop fails, display an error.
    catch (Exception e)
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "ERROR: " + e.Message.ToString();
    // Set the recording state: display the video on the viewfinder.
    private void StartVideoPreview()
    try
    // Display the video on the viewfinder.
    if (captureSource.VideoCaptureDevice != null
    && captureSource.State == CaptureState.Stopped)
    // Add captureSource to videoBrush.
    videoRecorderBrush.SetSource(captureSource);
    // Add videoBrush to the visual tree.
    viewfinderRectangle.Fill = videoRecorderBrush;
    captureSource.Start();
    // Set the button states and the message.
    UpdateUI(ButtonState.Ready, "Ready to record.");
    // If preview fails, display an error.
    catch (Exception e)
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "ERROR: " + e.Message.ToString();
    // Start the video recording.
    private void StartRecording_Click(object sender, EventArgs e)
    // Avoid duplicate taps.
    StartRecording.IsEnabled = false;
    StartVideoRecording();
    // Handle stop requests.
    private void StopPlaybackRecording_Click(object sender, EventArgs e)
    // Avoid duplicate taps.
    StopPlaybackRecording.IsEnabled = false;
    // Stop during video recording.
    if (currentAppState == ButtonState.Recording)
    StopVideoRecording();
    // Set the button state and the message.
    UpdateUI(ButtonState.NoChange, "Recording stopped.");
    // Stop during video playback.
    else
    // Remove playback objects.
    DisposeVideoPlayer();
    StartVideoPreview();
    // Set the button state and the message.
    UpdateUI(ButtonState.NoChange, "Playback stopped.");
    // Start video playback.
    private void StartPlayback_Click(object sender, EventArgs e)
    // Avoid duplicate taps.
    StartPlayback.IsEnabled = false;
    // Start video playback when the file stream exists.
    if (isoVideoFile != null)
    VideoPlayer.Play();
    // Start the video for the first time.
    else
    // Stop the capture source.
    captureSource.Stop();
    // Remove VideoBrush from the tree.
    viewfinderRectangle.Fill = null;
    // Create the file stream and attach it to the MediaElement.
    isoVideoFile = new IsolatedStorageFileStream(isoVideoFileName,
    FileMode.Open, FileAccess.Read,
    IsolatedStorageFile.GetUserStoreForApplication());
    VideoPlayer.SetSource(isoVideoFile);
    // Add an event handler for the end of playback.
    VideoPlayer.MediaEnded += new RoutedEventHandler(VideoPlayerMediaEnded);
    // Start video playback.
    VideoPlayer.Play();
    // Set the button state and the message.
    UpdateUI(ButtonState.Playback, "Playback started.");
    // Pause video playback.
    private void PausePlayback_Click(object sender, EventArgs e)
    // Avoid duplicate taps.
    PausePlayback.IsEnabled = false;
    // If mediaElement exists, pause playback.
    if (VideoPlayer != null)
    VideoPlayer.Pause();
    // Set the button state and the message.
    UpdateUI(ButtonState.Paused, "Playback paused.");
    private void DisposeVideoPlayer()
    if (VideoPlayer != null)
    // Stop the VideoPlayer MediaElement.
    VideoPlayer.Stop();
    // Remove playback objects.
    VideoPlayer.Source = null;
    isoVideoFile = null;
    // Remove the event handler.
    VideoPlayer.MediaEnded -= VideoPlayerMediaEnded;
    private void DisposeVideoRecorder()
    if (captureSource != null)
    // Stop captureSource if it is running.
    if (captureSource.VideoCaptureDevice != null
    && captureSource.State == CaptureState.Started)
    captureSource.Stop();
    // Remove the event handler for captureSource.
    captureSource.CaptureFailed -= OnCaptureFailed;
    // Remove the video recording objects.
    captureSource = null;
    vcDevice = null;
    fileSink = null;
    videoRecorderBrush = null;
    // If recording fails, display an error message.
    private void OnCaptureFailed(object sender, ExceptionRoutedEventArgs e)
    this.Dispatcher.BeginInvoke(delegate()
    txtDebug.Text = "ERROR: " + e.ErrorException.Message.ToString();
    // Display the viewfinder when playback ends.
    public void VideoPlayerMediaEnded(object sender, RoutedEventArgs e)
    // Remove the playback objects.
    DisposeVideoPlayer();
    StartVideoPreview();
    public void SetScreenResolution()
    w = Application.Current.Host.Content.ActualWidth;
    h = Application.Current.Host.Content.ActualHeight;
    setResViewF(w, h);
    public void setResViewF(double width, double height)
    viewfinderRectangle.Width = width;
    viewfinderRectangle.Height = height;
    resMI.Content = "resolution: " + width + "*" + height;
    private void resMI_Click(object sender, RoutedEventArgs e)
    switch (resMI.Content.ToString())
    case "resolution: 176*220":
    setResViewF(240, 320);
    break;
    case "resolution: 240*320":
    setResViewF(360, 480);
    break;
    case "resolution: 360*480":
    setResViewF(480, 800);
    break;
    case "resolution: 480*800":
    setResViewF(1440, 720);
    break;
    case "resolution: 1440*720":
    setResViewF(1920, 1080);
    break;
    case "resolution: 1920*1080":
    setResViewF(176, 220);
    break;
    default:
    setResViewF(176, 220);
    break;
    public void WriteToFile(string key, string value)
    var Iso_settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
    if (!Iso_settings.Contains(key))
    Iso_settings.Add(key, value);
    Iso_settings.Save();//This will save your data in isolated storage.
    public string ReadFromFile(string key)
    var Iso_settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
    if (Iso_settings.Contains(key))
    return (string)Iso_settings[key];
    else
    return null;
    public DispatcherTimer dispatcherTimer { get; set; }
    private void ToggleZoom(MediaElement media)
    if (media.Stretch != Stretch.UniformToFill)
    // zoom
    media.Stretch = Stretch.UniformToFill;
    else
    // unzoom
    media.Stretch = Stretch.Uniform;
    BtnSignUpSubmit_Tab is the HyperLinkButton that would trigger the web request process. I need this code to work perfectly because a lot of people will use this. If you can simplify the http web request that already feels so good. Thank you. 

  • Process Class:How to give and get data from an exe file continuously???

    hi,,,
    I am trying to run an executable file from my program to give it input and read its output....
    And i am having problems...
    The exe file takes one input and appends to it "1235" (ITS A TEST CASE).
    When it is only for a single input , the program rums perfectly.. but when it is within a loop it does not
    Pls help
    Here is the code for that EXE file. (its in C)
    #include<stdio.h>
    int main()
    char a[10];
    int i;
    int k=1235;
    while(1){
    scanf("%s",a);
    if(a[0]=='s')
    break;
    printf("%s%d\n",a,k);
    }Note that when i remove the loop here, my code is able to get and give it data.
    My JAVA program::
    import java.io.*;
    public class Main {
      public static void main(String[] args) throws IOException {
            try {
          String line;
          Process p = Runtime.getRuntime().exec
            ("C:\\users\\Untitled3.exe");
           BufferedWriter   out=new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
              out.write("dfgsfs\n");
              time= java.lang.System.nanoTime();
              out.flush();
          BufferedReader input =new BufferedReader(new InputStreamReader(p.getInputStream()));
         while ((line = input.readLine()) != null) {
            System.out.println(input.readLine());
          input.close();
        catch (Exception err) {
          err.printStackTrace();
    }PLS HELP

    I see a problem in your C code. You're not flushing stdout after you printf and that usually means java is not seeing whats your C program is printing.
    removing the loop probably works because stdout is being flushed right before exit.
    I used a perl script to test your stuff and found that flushing made the trick
    #!/usr/bin/perl
    open(OUTFILE,">>./output.txt");
    $| = 1;
    while (<STDIN>) {
        if (m/.*error.*/) {
            print STDERR  $_;
        } else {
            print STDOUT  $_;
        print OUTFILE $_;
        if (m/exit/) {
            last;
    close(OUTFILE);
    exit;notice "$| =1;" that autoflushes in perl (just in case you were wondering where my flush call went)
    Enjoy!

  • How to insert and  view data in a structure???

    Hi to everyone!
    I'm trying to append my user define table to a standard table. First i tried like this.
    1. I went to the append structure in a transparent table, created one and then included my table in it. It says table cannot be appended in the database table.
    2. I went to the append structure in a structure in a standard structure, created one and then included my table. Its not geeting activated.
    Please help me out with the answer.
    Thanks and Regards in advance.
    Abdur Rafique.

    Hi
    You cannot append a table to Standard table.
    You have to create a structure with the same structure of your table and append it to the standarda table using append structure
    Then populate your table's data into the standard table data using any report (create a report to do that...)
    Reward if helpful...

Maybe you are looking for