Exemplo n.º 1
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            if (m_bConnected)
            {
                // disconnect
                listView1.Clear();
                m_jglue = null;
                btnConnect.Text = "Connect";
                btnUpload.Enabled = false;
                btnImportFile.Enabled = false;
                statusBar1.Panels[0].Text = "Ready...";
            }
            else
            {
                if (m_jglue != null)
                    m_jglue = null;
                if (txtServerName.Text != "")
                {
                    btnConnect.Text = "Disconnect";
                    m_jglue = new JglueService(txtServerName.Text);
                    NameValue[] credentials = new NameValue[0];
                    m_sSessionId = m_jglue.login(credentials);
                    if (m_sSessionId == "")
                    {
                        System.Windows.Forms.MessageBox.Show(this,"Could not get session id from server. Login command failed.");
                        statusBar1.Panels[0].Text = "Error connecting...";
                    }
                    else
                    {
                        m_bConnected = true;
                        statusBar1.Panels[0].Text = "Connected, listing assets...";
                        Application.DoEvents();
                        RefreshAssetList();
                        statusBar1.Panels[0].Text = "List assets complete.";

                        statusBar1.Panels[0].Text = "Making ftp connection...";

                        FtpSession = null;
                        FtpSession = new KCommon.Net.FTP.Session();
                        FtpSession.Port = 2121;
                        FtpSession.Server = txtServerName.Text;
                        FtpSession.Connect("oyster","oyster");

                        FtpSession.CommandSent += new KCommon.Net.FTP.FtpCommandEventHandler(FtpSession_CommandSent);
                        FtpSession.BeginPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginPutFile);
                        FtpSession.EndPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndPutFile);
                        FtpSession.FileTransferProgress += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_FileTransferProgress);
                        FtpSession.ResponseReceived += new KCommon.Net.FTP.FtpResponseEventHandler(FtpSession_ResponseReceived);
                        FtpSession.BeginGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginGetFile);
                        FtpSession.EndGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndGetFile);

            //						foreach (KCommon.Net.FTP.FtpDirectory dir in FtpSession.CurrentDirectory.SubDirectories)
            //						{
            //							if (dir.Name == "Oyster")
            //							{
            //								goto Oyster_Found;
            //							}
            //						}
            //					Oyster_Found:

                        statusBar1.Panels[0].Text = "Online. Ready.";
                        btnUpload.Enabled = true;
                        btnImportFile.Enabled = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void DisconnectFTP()
 {
     m_ftp = null;
 }
Exemplo n.º 3
0
        public bool ConnectFTP(string sServerAddress, int iFTPPort, string sLoginName, string sPassword)
        {
            m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_NONE;
            if (m_ftp != null)
            {
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_ALREADYCONNECTED;
                return false;
            }

            if (sLoginName == "")
                sLoginName = "Anonymous";
            if (sPassword == "")
                sPassword = "******";

            m_ftp = new KCommon.Net.FTP.Session();
            m_ftp.CommandSent += new KCommon.Net.FTP.FtpCommandEventHandler(FtpSession_CommandSent);
            m_ftp.BeginPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginPutFile);
            m_ftp.EndPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndPutFile);
            m_ftp.FileTransferProgress += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_FileTransferProgress);
            m_ftp.ResponseReceived += new KCommon.Net.FTP.FtpResponseEventHandler(FtpSession_ResponseReceived);
            m_ftp.BeginGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginGetFile);
            m_ftp.EndGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndGetFile);

            m_ftp.Port = iFTPPort;
            m_ftp.Server = sServerAddress;
            try
            {
                m_ftp.Connect(sLoginName,sPassword);
            }
            catch
            {
                m_ecLastError = WM9_ERROR_CODE.WM9_ERROR_COULD_NOT_CONNECT_TO_SERVER;
            }
            if (m_ftp.IsConnected)
            {
                return true;
            }
            return false;
        }
Exemplo n.º 4
0
 public WM9()
 {
     m_bConnected = false;
     m_ftp = null;
 }
Exemplo n.º 5
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            DialogResult DR = MessageBox.Show("Do you wish to permanently remove all selected recordings from the video server?","Delete recordings?",MessageBoxButtons.YesNo);

            if(DR != DialogResult.Yes)
                return;
            int WhereFailed = 0;

            try
            {

                ////////////////////////////////////////////////////////////
                ArrayList RemovedRecordings = new ArrayList();
                string sRestoreText = label1.Text;
                label1.Text = "Recording deletion in progress. Please wait...";
                label1.Refresh();
                this.Update();
                this.Refresh();
                timer1.Enabled = false;
                btnDelete.Enabled = false;
                btnCancel.Enabled = false;
                btnRestoreRecordings.Enabled = false;

                System.Windows.Forms.Cursor OriginalCursor = this.Cursor;
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                this.SuspendLayout();
                try
                {

                    KCommon.Net.FTP.Session ftpSession = null;
                    System.Collections.ArrayList VODServers = new ArrayList();
                    string VSSAddress = "";
                    WhereFailed = -3;
                    foreach(ListViewItem LVI in listView1.CheckedItems)
                    {

                        OysterClassLibrary.Recording R = (OysterClassLibrary.Recording)LVI.Tag;
                        string VAddress = R.VideoStorageServerControlAddress;
                        bool AddItem = true;
                        foreach(Object Nobj in VODServers)
                        {
                            if(((string)Nobj).ToLower() == VAddress.ToLower())
                            {
                                AddItem = false;
                                continue;
                            }
                        }
                        if(AddItem == true)
                        {
                            VODServers.Add(VAddress);
                        }
                    }
                    WhereFailed = -2;
                    foreach(Object VObj in VODServers)
                    {
                        VSSAddress = ((string)VObj).ToUpper();
                        try
                        {
                            if(ftpSession.IsConnected)
                            {
                                ftpSession.Close();
                            }
                        }
                        catch(Exception Err)
                        {
                            string pError = Err.Message;
                        }
                        try
                        {
                            ftpSession = new KCommon.Net.FTP.Session();

                            ftpSession.Server = VSSAddress;
                            ftpSession.Port = 10904;
                            ftpSession.Connect("ftp", "*****@*****.**");
                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message,"Error occurred attempting to connect to " + VSSAddress);
                            MessageBox.Show("All Recordings currently residing on " + VSSAddress + " will are currently inaccessible","Unable to access recordings from " + VSSAddress);
                            continue;
                        }
                        if(ftpSession.IsConnected)
                        {
                            WhereFailed = -1;
                            ////////////////////////////////////////////////////////////
                            foreach(ListViewItem LVI in listView1.CheckedItems)
                            {
                                OysterClassLibrary.Recording Rec = (OysterClassLibrary.Recording)LVI.Tag;
                                if(Rec.VideoStorageServerControlAddress.ToUpper() == VSSAddress)
                                {

                                    try
                                    {

                                        ftpSession.RootDirectory.RemoveFile(Rec.Description);
                                        //ftpSession.RootDirectory.RemoveOysterFile(Rec.Description);
                                        WhereFailed = 1;
                                        OysterClassLibrary.User Owner = FrmParent.OSystem.GetUserById(Rec.OwnerID);
                                        WhereFailed = 2;
                                        Trace.WriteLine("Permanently Deleted from VSS Server Recording: " + Rec.Description + " DisplayName: " + Rec.DisplayName +
                                            "Owner: " + Owner.Description + "(" + Owner.ID  + ")",System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
                                        WhereFailed = 3;
                                        RemovedRecordings.Add(LVI);
                                        WhereFailed = 4;
                                    }
                                    catch(Exception Err)
                                    {
                                        if(Err.Message == "Failed to delete file " + Rec.Description)
                                            goto Continue_With_Process;

                                        MessageBox.Show(this,Err.Message,"Error At location:" + WhereFailed.ToString());
                                        goto JumpToEnd;
                                    }
                                Continue_With_Process:{}
                                    try
                                    {

                                        ftpSession.CurrentDirectory.Refresh();

                                        //								if(CurrentFile == null)
                                        //								{
                                        //									System.Windows.Forms.DialogResult DR2 = MessageBox.Show(Rec.DisplayName + " was not located on video server. Would you like to delete the system reference to this recording?","File not found on server.",System.Windows.Forms.MessageBoxButtons.YesNo);
                                        //									if(DR2 != System.Windows.Forms.DialogResult.Yes)
                                        //										continue;
                                        //									else
                                        //									{
                                        //										try
                                        //										{
                                        //											FrmParent.OSystem.DeleteRecordingById(Rec.ID);
                                        //										}
                                        //										catch(Exception Err)
                                        //										{
                                        //											MessageBox.Show(this,Err.Message);
                                        //										}
                                        //									}
                                        //								}
                                        //CurrentFile = null;
                                        //								Application.DoEvents();
                                        //								ftpSession.CurrentDirectory.RemoveFile(Rec.Description);

                                    }
                                    catch(Exception Err)
                                    {
                                        string pError = Err.Message;
                                    }

                                    try
                                    {
                                        WhereFailed = 10;
                                        string sDescription = Rec.Description;
                                        string sDisplayName = Rec.DisplayName;

                                        FrmParent.OSystem.DeleteRecordingById(Rec.ID);
                                        WhereFailed = 11;
                                        Trace.WriteLine("Removed Permanently Deleted Recording from Database: " + sDescription + " DisplayName: " + sDisplayName,
                                            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
                                        WhereFailed = 12;
                                    }
                                    catch(Exception Err)
                                    {
                                        MessageBox.Show(this,Err.Message,"Failed at: " + WhereFailed.ToString());
                                    }
                                }
                            }
                        }
                    }
                    try
                    {
                        WhereFailed = 13;
                        ftpSession.Close();
                    }
                    catch(Exception Err)
                    {
                        string pError = Err.Message;
                    }
                    WhereFailed = 14;
                JumpToEnd:{}
                    WhereFailed = 15;
                }
                catch(Exception Err)
                {
                    MessageBox.Show(this,Err.Message,"Failed at:" + WhereFailed.ToString());
                }
                finally
                {
                    WhereFailed = 18;
                    foreach(object obj in RemovedRecordings)
                    {
                        listView1.Items.Remove((ListViewItem)obj);
                    }
                    label1.Text = sRestoreText;
                    this.ResumeLayout();
                    this.Cursor = OriginalCursor;
                    timer1.Enabled = true;
                    btnCancel.Enabled = true;
                }

                this.ResumeLayout();
                this.Cursor = OriginalCursor;
            }
            catch(Exception Err)
            {
                MessageBox.Show(this,Err.Message,"Failed at:" + WhereFailed.ToString());
            }
        }
Exemplo n.º 6
0
        internal void ConnectToOysterServer(string ServerAddress)
        {
            ftpSession = new KCommon.Net.FTP.Session();
            ftpSession.BeginPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginPutFile);
            ftpSession.EndPutFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndPutFile);
            ftpSession.BeginGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_BeginGetFile);
            ftpSession.EndGetFile += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_EndGetFile);

            ftpSession.FileTransferProgress += new KCommon.Net.FTP.FtpFileEventHandler(FtpSession_FileTransferProgress);

            ftpSession.Server = ServerAddress;
            m_ThreadTransferCompleteEvent = new System.Threading.AutoResetEvent(false);
            m_ThreadTransferCompleteEvent.Reset();
            //ftpSession.Port = CarverLab.Oyster.SystemDefaults.DefaultOysterFileTransferPort;
            ftpSession.Port = 10904;
            try
            {
                ftpSession.Connect("ftp","*****@*****.**");
            }
            catch(Exception Err)
            {
                throw new Exception("Error connecting to server: " + Err.Message);
            }
        }