Exemplo n.º 1
0
        private void tmrGeneral_Tick(object sender, System.EventArgs e)
        {
            tmrGeneral.Enabled = false;
            frmRecordOptions frm = new frmRecordOptions();

            if (!frm.CurrentRecordOptions.HasBeenSaved)
            {
                if (frm.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
                {
                    DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    //this.Close();
                    return;
                }
            }
            TryOysterAgain:{}
            this.Update();
            Application.DoEvents();
            try
            {
                this.Text = "Connecting to Oyster...";
                m_oyster = new OCL.Oyster(frm.CurrentRecordOptions.DefaultOysterAddress,OCL.Oyster.DefaultOysterNetworkPort);
            }
            catch(Exception Err)
            {
                this.Text = "Unable to connect to Oyster";
                if(Err.Message == "Unable to connect to Oyster Server")
                {
                    if(System.Windows.Forms.MessageBox.Show("Try Again?","Could not connect to Oyster Server",MessageBoxButtons.RetryCancel)== DialogResult.Retry)
                    {
                        goto TryOysterAgain;
                    }
                    this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                    //this.Close();
                    return;
                }
            }
            if (m_oyster == null)
            {
                this.Text = "Unable to connect to Oyster";

                if(System.Windows.Forms.MessageBox.Show("Try Again?","Could not connect to Oyster Server",MessageBoxButtons.RetryCancel)== DialogResult.Retry)
                {
                    goto TryOysterAgain;
                }
                DialogResult = System.Windows.Forms.DialogResult.Abort;
                //this.Close();
                return;
            }
            this.Text = "Login to Oyster System";
            this.Enabled = true;
            this.txtUserName.Focus();
        }
Exemplo n.º 2
0
        void StartRecording()
        {
            frmRecordOptions frm = new frmRecordOptions();

            if(!System.IO.Directory.Exists(frm.CurrentRecordOptions.WMVDirectory))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(frm.CurrentRecordOptions.WMVDirectory);
                }
                catch(Exception Err)
                {
                    MessageBox.Show("Error details:" + Err.Message,"Temporary storage directory does not exist. Creation attempt failed.",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
            }
            frmStatusWindow StatusWindow = new frmStatusWindow("Desktop Recorder: Preparing Session Capture","Please wait...");

            bDontClick = true;
            StatusWindow.Owner = this;
            StatusWindow.Show();
            bool bRecordCamera = true, bRecordScreen = true; // bError = false;
            int NumCams = 0;
            string sErrorBody = "";
            string sErrorCaption = "";

            //btnStartStop.Text = "Preparing...";

            //btnStartStop.Update();
            Application.DoEvents();

            //			clock.DigitalDisplayColor = SriClocks.DigitalColor.GreenColor;
            //			clock.ClockDisplayType = SriClocks.ClockType.StopWatch;
            //			clock.Reset();
            //			btnStartStop.Text = "STOP";

            // startup the oyster encoder

            RecordOptions ro = frm.CurrentRecordOptions;
            bool bIsSession = false;

            System.Diagnostics.Debug.Assert(m_oec == null,"OEC should be null when starting a recording.");
            #region SCREEN SELECTION

            object oparams = null;
            ScreenEncoder.CapturePerformance cp = ScreenEncoder.CapturePerformance.VeryLow;
            ScreenEncoder.CaptureType ct = ScreenEncoder.CaptureType.FullScreen;
            switch (frm.CurrentRecordOptions.RecordType)
            {
                case RecordOptions.ScreenRecordType.ScreenRecordNone:
                    bRecordScreen = false;
                    break;
                case RecordOptions.ScreenRecordType.ScreenRecordFullScreen:

                    //					oparams = "N/A";
                    /*Changed By Kevin Gray 5-6-05 due to errors in typecasting "N/A" to an object[]*/
                    oparams = new object[1];
                    cp = frm.CurrentRecordOptions.ScreenCapturePerformance;
                    ct = ScreenEncoder.CaptureType.FullScreen;
                    bRecordScreen = true;
                    break;
                case RecordOptions.ScreenRecordType.ScreenRecordWindow:
                    CarverLab.Utility.Win32Wrapper w32 = new CarverLab.Utility.Win32Wrapper();
                    CarverLab.Utility.Window CapWin = w32[frm.CurrentRecordOptions.WindowTitleToRecord];

                    cp = frm.CurrentRecordOptions.ScreenCapturePerformance;
                    if (frm.CurrentRecordOptions.WindowTitleToRecord == string.Empty ||
                        CapWin == null)
                    {
                        if (System.Windows.Forms.MessageBox.Show(this,"Could not find the specified window entitled: " + frm.CurrentRecordOptions.WindowTitleToRecord + ". Continue and record the full screen instead?",
                            "Record the Entire Screen?",System.Windows.Forms.MessageBoxButtons.YesNo,
                            System.Windows.Forms.MessageBoxIcon.Question,System.Windows.Forms.MessageBoxDefaultButton.Button1)
                            == System.Windows.Forms.DialogResult.Yes)
                        {
                            ct = ScreenEncoder.CaptureType.FullScreen;
                            oparams = "N/A";
                        }
                        else
                        {
                            if(bRecordCamera)
                            {

                                if (System.Windows.Forms.MessageBox.Show(this,"Would you like to continue recording camera(s)?",
                                    "Record Cameras without Screen Capture?",System.Windows.Forms.MessageBoxButtons.YesNo,
                                    System.Windows.Forms.MessageBoxIcon.Question,System.Windows.Forms.MessageBoxDefaultButton.Button1)
                                    != System.Windows.Forms.DialogResult.Yes)
                                {
                                    bRecordScreen = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.Assert(CapWin != null,"CapWin should not be null!");
                        ct = ScreenEncoder.CaptureType.WindowByHandle;
                        oparams = CapWin;
                    }
                    break;
                default:
                    System.Diagnostics.Debug.Assert(false,"Invalid recording type selected for screen recording.");
                    break;
            }

            #endregion

            #region SET UP FOR SCREEN RECORD

            if (bRecordScreen)
            {
                if (!m_encoder.Execute(ScreenEncoder.Command.SetupEncoder,cp,ct,oparams))
                {
                    sErrorBody = "Could not start the screen recording process. This is a serious error. Contact your system administrator.";
                    sErrorCaption = "Screen Recording Failure...";
                    goto Label_Screen_Error;
                }
                Application.DoEvents();
                System.Threading.Thread.Sleep(1500);
                Application.DoEvents();
            }
            #endregion

            #region CAMERA SELECTION

            switch (ro.SelectedCamera)
            {
                case RecordOptions.CameraSelection.CameraNone:
                    bRecordCamera = false;
                    NumCams = 0;
                    break;
                case RecordOptions.CameraSelection.CameraOne:
                    NumCams = 1;

                    m_sCameraRecordingName = new string[1];
                    m_oec = new OysterEncoderController.Control[1];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(1),ref mLogger);

                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera one recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        //bRecordCamera = false;
                        //bError = true;
                        //Reset();
                        goto Label_Camera_Error;
                    }
                    break;
                case RecordOptions.CameraSelection.CameraTwo:
                    NumCams = 1;
                    m_sCameraRecordingName = new string[1];
                    m_oec = new OysterEncoderController.Control[1];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(2),ref mLogger);
                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera two recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    break;
                case RecordOptions.CameraSelection.CameraOneAndTwo:
                    NumCams = 2;
                    bIsSession = true;
                    m_sCameraRecordingName = new string[2];
                    m_oec = new OysterEncoderController.Control[2];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(1),ref mLogger);
                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera one recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    m_oec[1] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(2),ref mLogger);
                    if (!m_oec[1].Open())
                    {
                        sErrorBody = "Could not start the camera two recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    break;
                default:
                    System.Diagnostics.Debug.Assert(false,"Invalid SelectedCamera enum");

                    sErrorBody = "A programmer error detected.  Please try reselected the desired camera in the options menu. If problem persist please contact your Administrator.";
                    sErrorCaption = "Programmer Error: Invalid SelectedCamera enum";
                    //bRecordCamera = false;
                    //bError = true;
                    goto Label_Camera_Error;
            }

            #endregion

            #region Require Oyster Objects
            //OCL.Oyster oyster = new OCL.Oyster();
            OCL.Oyster oyster = new OCL.Oyster(frm.CurrentRecordOptions.DefaultOysterAddress,frm.CurrentRecordOptions.DefaultOysterConnectionPort);
            OCL.User me = oyster.GetUserById(m_me.ID);
            OCL.VideoStorageServer vss;// = (OCL.VideoStorageServer)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.VideoStorageServer);

            OCL.Scene sce;// = (OCL.Scene)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Scene);
            OCL.Source src = null;// = (OCL.Source)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Source);
            foreach (OCL.Source srcx in oyster.AllVisibleSources(me))
            {
                string shostname = System.Net.Dns.GetHostByAddress(System.Net.IPAddress.Parse(frm.CurrentRecordOptions.DefaultOysterDeviceAddress)).HostName;
                //strip off domain info
                if (shostname.IndexOf(".") != -1)
                {
                    shostname = shostname.Substring(0,shostname.IndexOf("."));
                }
                if (srcx.ControlAddress.ToLower() == shostname.ToLower() ||
                    srcx.ControlAddress.ToLower() == frm.CurrentRecordOptions.DefaultOysterDeviceAddress.ToLower())
                {
                    src = srcx;
                    break;
                }
            }
            if (src == null)
            {

                sErrorBody = "The data for the Oyster Device that was selected for this recording is not configured correctly. Contact the system administrator.";
                sErrorCaption = "Camera Recording Failure";
                //bRecordCamera = false;
                //bError = true;
                goto Label_Camera_Error;
            }
            sce = src.CurrentScene;
            vss = sce.AssignedVideoStorageServer;
            #endregion

            #region START RECORDING

            if (bRecordScreen)
            {
                if (bRecordCamera)
                {
                    bIsSession = true;
                }
                m_sScreenRecordingName = System.Guid.NewGuid().ToString();
                Application.DoEvents();
                System.Threading.Thread T = new System.Threading.Thread(new System.Threading.ThreadStart(StartScreenCapture));
                T.Start();
                //m_encoder.Execute(ScreenEncoder.Command.StartRecording,m_sScreenRecordingName);

            }

            if (bRecordCamera)
            {
                for (int i = 0; i < m_oec.GetLength(0); i++)
                {
                    m_sCameraRecordingName[i] = System.Guid.NewGuid().ToString();
                    m_oec[i].FilePath = vss.OysterRootDirectory;
                    if (m_oec[i].LastError.Length > 0)
                    {
                        sErrorBody = m_oec[i].LastError;
                        sErrorCaption = "Recording Startup Error...";
                        goto Label_Camera_Error;
                    }
                    m_oec[i].StartRecording(m_sCameraRecordingName[i]);
                    m_oec[i].OnConnectionError +=new OysterEncoderController.Control.OnConnectionErrorHandler(frmDisplay_OnConnectionError);

                }
            }
            #endregion

            if (bIsSession)
            {
                m_sRecordingSessionId = System.Guid.NewGuid().ToString();
            }
            else
                m_sRecordingSessionId = null;

            #region Create Database Entries

            bool bIsPresentation = false;
            if(bRecordScreen && bRecordCamera)
            {
                bIsPresentation = true;
            }
            int NumRecordings = NumCams;
            if(bRecordScreen)
                NumRecordings++;

            CurrentRecordingSession = me.CreateASession(DateTime.Now.ToString(),bIsPresentation);
            CurrentRecordings = new OCL.Recording[NumRecordings];
            int iRecIndex = 0;

            /// Create Camera Recording Entries
            if(bRecordCamera)
            {
                for (int i = 0; i < NumCams; i++)
                {
                    bool bIsPrimaryCamera;

                    if (i == System.Convert.ToInt32(frm.CurrentRecordOptions.CameraPrimary))
                        bIsPrimaryCamera = true;
                    else
                        bIsPrimaryCamera = false;

                    CurrentRecordings[iRecIndex] = CurrentRecordingSession.CreateRecording(m_sCameraRecordingName[i] + ".wmv",
                        "Camera " + (i+1),me,sce,src,false,bIsPrimaryCamera);
                    //CurrentRecordings[iRecIndex].UpdateFileSizeOnDisk();
                    //CurrentRecordings[iRecIndex].Update(TotalTime.ToString());
                    iRecIndex++;
                }
            }
            /// Create Desktop Recording Entry
            if(bRecordScreen)
            {

                string sRawFileName = m_sScreenRecordingName;
                string sRName = sRawFileName + ".wmv";

                string sFileLocation = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;

                System.IO.FileInfo FID = new System.IO.FileInfo(sFileLocation);
                m_DesktopRecordingSize = FID.Length;
                CurrentRecordings[iRecIndex] = CurrentRecordingSession.CreateRecording(sRName,"Presentation",
                    me,sce,src,true,false);
                //CurrentRecordings[iRecIndex].Update(m_DesktopRecordingSize);
                //CurrentRecordings[iRecIndex].Update(TotalTime.ToString());
                DataRow R = null;
                string SourceFile = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
                try
                {
                    R = dsFileTransfer.Tables["File"].NewRow();
                    R["ObjectID"] = CurrentRecordings[iRecIndex].ID;
                    R["OysterObjectTypeID"]= 2; //Recording Type
                    R["RecordingSessionID"] = CurrentRecordings[iRecIndex].SessionID;
                    R["UserID"] = m_me.ID;
                    R["UserDescription"]= m_me.Description;
                    R["VideoStorageServerID"]= vss.ID;
                    R["OysterServerAddress"] = frm.CurrentRecordOptions.DefaultOysterAddress;
                    R["SourceFile"] = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
                    R["DestinationFileName"] = sRName;
                    R["DeleteAfterTransfer"] = true;
                    dsFileTransfer.Tables["File"].Rows.Add(R);
                    dsFileTransfer.Tables["File"].AcceptChanges();
                    dsFileTransfer.WriteXml(frm.CurrentRecordOptions.WMVDirectory + @"\" + sRawFileName + ".xml");
                }
                catch(Exception Err)
                {
                    MessageBox.Show(Err.Message,"Programmer Error during writing xml");
                }
            }
            #endregion

            clock.DigitalDisplayColor = SriClocks.DigitalColor.GreenColor;
            clock.ClockDisplayType = SriClocks.ClockType.StopWatch;
            clock.Reset();
            btnStartStop.Text = "STOP";
            btnStartStop.Enabled = true;
            clock.StartTimer();
            StartRecordingTime = DateTime.Now;
            m_bRecording = true;
            m_ScreenIsCaptured = bRecordScreen;
            m_CameraIsCaptured = bRecordCamera;
            this.TopMost = false;
            bDontClick = false;
            StatusWindow.Hide();
            StatusWindow.Dispose();
            return;

            Label_Camera_Error:
            {
                bDontClick = false;
                StatusWindow.Hide();
                StatusWindow.Dispose();
                System.Windows.Forms.MessageBox.Show(this,sErrorBody,
                    sErrorCaption,System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Error);
                if(m_oec != null)
                {
                    for(int i=0; i< m_oec.Length;i++)
                    {
                        m_oec[i] = null;
                    }
                    m_oec = null;
                }
                Reset();
                m_CameraIsCaptured = false;
                m_ScreenIsCaptured = false;
                this.TopMost = true;
                return;
            }
            Label_Screen_Error:
            {
                bDontClick = false;
                StatusWindow.Hide();
                StatusWindow.Dispose();
                System.Windows.Forms.MessageBox.Show(this,sErrorBody,
                    sErrorCaption,System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Error);
                if(m_oec != null)
                {
                    for(int i=0; i< m_oec.Length;i++)
                    {
                        m_oec[i].StopRecording();
                        m_oec[i].Close();
                        m_oec[i] = null;
                    }
                    m_oec = null;
                }
                m_CameraIsCaptured = false;
                m_ScreenIsCaptured = false;
                Reset();
                this.TopMost = true;
                return;
            }
        }
Exemplo n.º 3
0
        private void mitmOptions_Click(object sender, System.EventArgs e)
        {
            frmRecordOptions frm = new frmRecordOptions();

            if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {	// TODO: Save the options in CURRENT_USER
            }
        }
Exemplo n.º 4
0
        private void btnStartStop_Click(object sender, System.EventArgs e)
        {
            if(bDontClick)
                return;

            if (m_bRecording)
            {
                System.Diagnostics.Debug.Assert(m_encoder != null,"m_encoder is null when stopping a recording.");
                StopRecording(true);
                m_encoder.Execute(ScreenEncoder.Command.ExitEncoder,null);
                m_encoder = null;
            }
            else
            {
                bool bRecord = true;
                frmRecordOptions frm = new frmRecordOptions();

                if (!frm.CurrentRecordOptions.HasBeenSaved)
                {
                    if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        bRecord = false;
                    }
                }

                if (bRecord)
                {

                    System.Diagnostics.Debug.Assert(m_encoder == null,"m_encoder is not null when starting a recording.");
                    m_encoder = new ScreenEncoder(frm.CurrentRecordOptions.ProfileDirectory,frm.CurrentRecordOptions.WMVDirectory);
                    //						if (frm.CurrentRecordOptions.SecondsToCountdown != 0)
                    //						{
                    //							clock.CountDownTime = frm.CurrentRecordOptions.SecondsToCountdown * 1000;
                    //							clock.ClockDisplayType = SriClocks.ClockType.CountDown;
                    //							clock.DigitalDisplayColor = SriClocks.DigitalColor.WhiteColor;
                    //							if (frm.CurrentRecordOptions.MinutesToRecord != 0)
                    //							{
                    //								m_iCountdownMinutes = frm.CurrentRecordOptions.MinutesToRecord;
                    //							}
                    //							btnStartStop.Text = "STOP";
                    //							clock.StartTimer();
                    //							m_bWaitingForCountdown = true;
                    //						}
                    //						else
                    //{
                    if (m_me.CanRecord)
                    {
                        StartRecording();
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show(this,
                            "The currently logged in user is not authorized to create recordings.",
                            "Unauthorized User",
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Exclamation);
                    }
                    //}
                    //}
                }
            }
        }
Exemplo n.º 5
0
        private void tmrGeneral_Tick(object sender, System.EventArgs e)
        {
            tmrGeneral.Enabled = false;
            ShowHide();
            frmRecordOptions frmOps = new frmRecordOptions();

            if (!frmOps.CurrentRecordOptions.HasBeenSaved)
            {
                if (frmOps.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    Application.Exit();
                    return;
                }
            }
            mLogger.WriteLog("Displaying Login screen...");
            OCL.Oyster oyster = new OCL.Oyster(frmOps.CurrentRecordOptions.DefaultOysterAddress,frmOps.CurrentRecordOptions.DefaultOysterConnectionPort);
            frmLogin frm = new frmLogin(ref oyster);

            if (frm.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
            {
                //m_bExitWithoutAsking = true;
                Application.Exit(); //this.Close();
                return;
            }
            m_me = frm.LoginUser;
            this.TopMost = true;
            frmIV = new frmInvisible(this);
            frmIV.Show();
            frmIV.Hide();
        }
Exemplo n.º 6
0
        private void StopRecording(bool StopEncoder)
        {
            int iCodeSection = 0;

            if(StopEncoder)
            {

                mLogger.WriteLog("Stopping encode...");

                frmRecordOptions frm = new frmRecordOptions();
                frmStatusWindow StatusWindow = null;
                if(!bConnectionError)
                {
                    StatusWindow = new frmStatusWindow("Desktop Recorder: Stopping session","Please wait...");
                }
                else
                {
                    StatusWindow = new frmStatusWindow("Connection with server has been lost.","Stopping session please wait...");
                }
                string sRawFileName = "";
                string sRName = "";

                bDontClick = true;
                if(!StatusWindow.IsDisposed)
                {
                    StatusWindow.Owner = this;
                    StatusWindow.Show();
                }
                clock.StopTimer();
                clock.DigitalDisplayColor = SriClocks.DigitalColor.RedColor;
                try
                {
                    Application.DoEvents();
                    string[] sCamFiles = new string[1];
                    int NumCams = 0;

            //					bool bScreenRecorded = false;
            //					bool bCamerasRecorded = false;
                    //Stop Presentation Capture
                    System.Threading.Thread T = new System.Threading.Thread(new System.Threading.ThreadStart(StopScreenCapture));
                    iCodeSection = 1; //Stopping Screen Capture
                    if (m_ScreenIsCaptured)
                    {
                        mLogger.WriteLog("... Sending Screen Capture Stop Command");

                        sRawFileName = m_sScreenRecordingName;
                        sRName = sRawFileName + ".wmv";
                        //bScreenRecorded = true;
                        //System.Diagnostics.Debug.Assert(m_encoder != null,"m_encoder is null when stopping a recording.");
                        T.Start();
                        //m_encoder.Execute(ScreenEncoder.Command.StopRecording,null);
                    }

                    // Stop All Cameras
                    //Stopping Cameras: Code = 2 for camera1 and Code = 3 for camera2;
                    if(m_oec != null)
                    {

                        mLogger.WriteLog("Stopping Camera(s)...");
                        iCodeSection++; //Incrents to 2 for camera1 and 3 for camera2
                        sCamFiles = new string[m_oec.GetLength(0)];
                        NumCams = m_oec.GetLength(0);
                        for (int i = 0; i < NumCams; i++)
                        {
                            if(m_oec[i].IsConnected)
                            {
                                mLogger.WriteLog("... Sending stop command to ''Camera'' m_oec[ " + i + "]");
                                m_oec[i].FilePath = "*";	// set back to default
                                m_oec[i].StopRecording();
                            }
                            m_oec[i].Close();
                            m_oec[i] = null;
                        }
                        m_oec = null;
                        mLogger.WriteLog("... done stopping cameras");
                        //bCamerasRecorded = true;
                    }

                    //OCL.Oyster oyster = new OCL.Oyster();
                    OCL.Oyster oyster = new OCL.Oyster(frm.CurrentRecordOptions.DefaultOysterAddress,frm.CurrentRecordOptions.DefaultOysterConnectionPort);
                    #region Moved Code To StartRecording()
            //					iCodeSection = 10; // Section 10 means creating recording entrees in database.

            //					OCL.User me = oyster.GetUserById(m_me.ID);
            //
            //					int iVSS = 0, iSE = 0;
            //					bool bIsPresentation = false;
            //					System.DateTime dtmRecording = System.DateTime.Now;
            //
            //					OCL.VideoStorageServer vss = (OCL.VideoStorageServer)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.VideoStorageServer);
            //					OCL.Scene sce = (OCL.Scene)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Scene);
            //					OCL.Source src = (OCL.Source)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Source);
            //					iVSS = vss.ID;
            //					TimeSpan tsTotalTime = dtmRecording - StartRecordingTime;
            //					double TotalTime = tsTotalTime.TotalSeconds;
            //
            //					//				foreach (OCL.VideoStorageServer vss in oyster.VIDEOSTORAGESERVERS)
            //					//				{
            //					//					if (vss.ControlAddress != "Not Assigned")
            //					//					{
            //					//						iVSS = vss.ID;
            //					//						break;
            //					//					}
            //					//				}
            //
            //					iSE = src.ID;
            //					// get the StreamingEncoder for Not Assigned
            //					//				foreach (OCL.Source se in oyster.SOURCES)
            //					//				{
            //					//					if (se.ControlAddress == "Not Assigned")
            //					//					{
            //					//						iSE = se.ID;
            //					//					}
            //					//				}
            //
            //					if (m_sRecordingSessionId != null)
            //					{
            //						m_sRecordingSessionName = dtmRecording.ToString("MM/dd/yyyy hh:mm tt");
            //					}
            //					else
            //					{
            //						m_sRecordingSessionName = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt");
            //					}
            //
            //					if ((m_sScreenRecordingName != null)&&(bCamerasRecorded))
            //					{
            //						bIsPresentation = true;
            //					}
            //
            //					OCL.RecordingSession RS = me.CreateASession(m_sRecordingSessionName,bIsPresentation);
            //
            //					/* Added a check to see if m_oec is not null.
            //					 * m_oec will be null if only capturing the desktop */
            //
            //					if(NumCams > 0)
            //					{
            //						for (int i = 0; i < NumCams; i++)
            //						{
            //							bool bIsPrimaryCamera;
            //
            //							if (i == System.Convert.ToInt32(frm.CurrentRecordOptions.CameraPrimary))
            //								bIsPrimaryCamera = true;
            //							else
            //								bIsPrimaryCamera = false;
            //							if (m_sScreenRecordingName != null)
            //								bIsPresentation = true;
            //							else
            //								bIsPresentation = false;
            //							sCamFiles[i] = m_sCameraRecordingName[i] + ".wmv";
            //							OCL.Recording CR = RS.CreateRecording(m_sCameraRecordingName[i] + ".wmv",
            //								"Camera " + (i+1),me,sce,src,false,bIsPrimaryCamera);
            //							CR.UpdateFileSizeOnDisk();
            //							CR.Update(TotalTime.ToString());
            //						}
            //					}
            //					if (m_sScreenRecordingName != null)
            //					{
            //						frmRecordOptions RO = new frmRecordOptions();
            //						string sFileLocation = RO.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
            //						RO.Dispose();
            //						System.IO.FileInfo FID = new System.IO.FileInfo(sFileLocation);
            //						m_DesktopRecordingSize = FID.Length;
            //						OCL.Recording DR = RS.CreateRecording(sRName,"Presentation",
            //							me,sce,src,true,false);
            //						DR.Update(m_DesktopRecordingSize);
            //						DR.Update(TotalTime.ToString());
            //						Reset();
            //						DataRow R = null;
            //						string SourceFile = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
            //						try
            //						{
            //							R = dsFileTransfer.Tables["File"].NewRow();
            //							R["ObjectID"] = DR.ID;
            //							R["OysterObjectTypeID"]= 2; //Recording Type
            //							R["RecordingSessionID"] = DR.SessionID;
            //							R["UserID"] = m_me.ID;
            //							R["UserDescription"]= m_me.Description;
            //							R["VideoStorageServerID"]= vss.ID;
            //							R["OysterServerAddress"] = RO.CurrentRecordOptions.DefaultOysterAddress;
            //							R["SourceFile"] = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
            //							R["DestinationFileName"] = sRName;
            //							R["DeleteAfterTransfer"] = true;
            //							dsFileTransfer.Tables["File"].Rows.Add(R);
            //							dsFileTransfer.Tables["File"].AcceptChanges();
            //							dsFileTransfer.WriteXml(frm.CurrentRecordOptions.WMVDirectory + @"\" + sRawFileName + ".xml");
            //						}
            //						catch(Exception Err)
            //						{
            //							MessageBox.Show(Err.Message,"Programmer Error during writing xml");
            //						}
                    #endregion
                    if(m_ScreenIsCaptured)
                    {
                        mLogger.WriteLog("... Preparing to upload screen capture to Server");

                        iCodeSection = 20; //Uploading DesktopRecording
                        if(!StatusWindow.IsDisposed)
                        {
                            StatusWindow.MsgTitle = "Desktop Recording: Uploading desktop capture to Oyster System";
                            StatusWindow.MsgBody = "Please wait...";
                            StatusWindow.Refresh();
                            Application.DoEvents();
                        }

                        DateTime dtStartingUploadTime = DateTime.Now;
                        int iUploadRetryCount = 0;
                        int iUploadRetryMax = 20;
                        int iUploadRetryInterval = 1; // seconds
                        T.Join();

                        if(bConnectionError)
                        {
                            if(!StatusWindow.IsDisposed)
                            {
                                StatusWindow.Hide();
                            }
                            if(MessageBox.Show("Do you wish to try and upload the presentation to server the at this time?","A connection error was detected!",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)== DialogResult.No)
                            {
                                mLogger.WriteLog("User chose not to upload presentation due to detected connection error.");
                                if(!StatusWindow.IsDisposed)
                                {
                                    StatusWindow.Show();
                                }
                                goto SkippedUpload;
                            }
                        }
                        mLogger.WriteLog("... uploading to server");
                        clock.StopTimer();
                    TryUploadAgain:{};
                        TimeSpan tsElapsedUploadTime = DateTime.Now.Subtract(dtStartingUploadTime);

                        if(!StatusWindow.IsDisposed)
                        {
                            StatusWindow.Show();
                            StatusWindow.MsgBody = "Please wait... Elapsed Time (" + System.Convert.ToInt32(tsElapsedUploadTime.TotalSeconds) + " secs)";
                            StatusWindow.Refresh();
                        }
                        Application.DoEvents();
                        try
                        {
                            Application.DoEvents();
                            string[] supload = new string[1];
                            supload[0] = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;

                            if(!oyster.UploadFileToOysterServer(supload[0]))
                            {
                                mLogger.WriteLog("... Upload returned false... forcing exception err for retry attempt.");
                                throw new Exception("Upload returned false... forcing exception err for retry attempt.");
                            }
                            mLogger.WriteLog("... updating xml file with status of Uploaded");
                            dsFileTransfer.Tables["File"].Rows[0]["StatusMessage"]= "Uploaded";
                            dsFileTransfer.Tables["File"].AcceptChanges();
                            dsFileTransfer.WriteXml(frm.CurrentRecordOptions.WMVDirectory + @"\" + sRawFileName + ".xml");
                        }
                        catch(Exception Err)
                        {
                            string PeekErr = Err.Message;
                            mLogger.WriteLog("... upload failed.. Retry count is " + iUploadRetryCount + " of " + iUploadRetryMax);
                            mLogger.WriteLog("... failed Error Message was " + Err.Message);
                            if (++iUploadRetryCount < iUploadRetryMax)
                            {

                                System.Threading.Thread.Sleep(iUploadRetryInterval * 1000);
                                goto TryUploadAgain;
                            }
                            if(!StatusWindow.IsDisposed)
                            {
                                StatusWindow.Hide();
                            }
                            if(MessageBox.Show("Do you wish to try again?","Presentation upload failed",MessageBoxButtons.RetryCancel)== DialogResult.Retry)
                            {
                                iUploadRetryCount = 0;
                                goto TryUploadAgain;
                            }
                            MessageBox.Show("Error detected during file upload. Please contact your Administrator for assistance.","Serious error detected.");
                            dsFileTransfer.Tables["File"].Rows[0]["StatusMessage"]= "Upload Failed with Error Message: " + Err.Message;
                            dsFileTransfer.Tables["File"].AcceptChanges();
                            dsFileTransfer.WriteXml(frm.CurrentRecordOptions.WMVDirectory + @"\" + sRawFileName + ".xml");
                            goto SkippedUpload;
                        }
                        SkippedUpload:{}
                    }
                    else
                    {
                        if(bConnectionError)
                        {
                            if(!StatusWindow.IsDisposed)
                            {
                                StatusWindow.Hide();
                            }
                            MessageBox.Show("Please check connection status and press OK to update Server with final session metadata.","A connection error was detected!");
                            if(!StatusWindow.IsDisposed)
                            {
                                StatusWindow.Show();
                            }
                        }
                    }

            //					bDontClick = false;
            //					StatusWindow.Hide();
            //					StatusWindow.Dispose();
                }
                catch(Exception BigBadError)
                {
                    mLogger.WriteLog("... Oyster Fault Code: " + iCodeSection);
                    mLogger.WriteLog("... Error Message was " + BigBadError.Message);

                    MessageBox.Show(BigBadError.Message,"Oyster Fault Code: " + iCodeSection);
                }
                finally
                {

                    /// Update All Database Entries
                    if(!StatusWindow.IsDisposed)
                    {
                        StatusWindow.MsgBody = "Making final changes in database...";
                        StatusWindow.Refresh();
                    }
                    mLogger.WriteLog("... Updating database with IsReady status entries and file size info");
                    for(int a=0; a < CurrentRecordings.GetLength(0);a++)
                    {

                        int RetryAttempts = 3;
                        int WaitInterval = 1;
                    RetryUpdate:{}
                        try
                        {
                            //CurrentRecordings[a].UpdateFileSizeOnDisk();
                            CurrentRecordings[a].Update(true);
                            System.Threading.Thread.Sleep(1000);
                        }
                        catch(Exception Err)
                        {
                            mLogger.WriteLog("... update entry failed with Error Message: " + Err.Message);

                            System.Threading.Thread.Sleep(WaitInterval * 250);
                            RetryAttempts--;

                            if(RetryAttempts > 0)
                            {
                                goto RetryUpdate;
                            }
                            else
                            {
                                mLogger.WriteLog("... retry attempts timed out...[" + a.ToString() + "] writing failure to xml file");
                            }
                        }
                    }
                    mLogger.WriteLog("... Resetting all variables");
                    bDontClick = false;
                    if(!StatusWindow.IsDisposed)
                    {
                        StatusWindow.Hide();
                        StatusWindow.Dispose();
                    }
                    Reset();
                    bDontClick = false;
                    this.TopMost = true;
                    m_ScreenIsCaptured = false;
                    m_CameraIsCaptured = false;
                    dsFileTransfer.Tables["File"].Rows.Clear();
                    //To do create a SQL Active X that will update PlayLength on Recording update.
                }
            }

            bDontClick = false;
            Reset();
            this.TopMost = true;
        }