示例#1
0
 //-----------------------------------------------------------------------------//
 /// <summary>
 /// Constructor with a node that is a folder.
 /// </summary>
 /// <param name="newFolderNode"></param>
 /// <param name="newForm"></param>
 public FtpFolderWorkUnit(KexplorerFtpNode newFolderNode, ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger)
 {
     this.folderNode = newFolderNode;
     this.site       = newFolderNode.Site;
     this.form       = newForm;
     this.guiFlagger = flagger;
 }
示例#2
0
        public void Initialize(ISimpleKexplorerGUI newForm, FtpSite ftpSite)
        {
            this.isFtpSite = true;
            this.form      = newForm;

            this.pipeline = new Pipeline(this.form);
            this.pipeline.StartWork();

            this.drivePipelines = new Hashtable();

            Pipeline drivePipeline = new Pipeline(this.form);

            this.drivePipelines[ftpSite.host] = drivePipeline;
            drivePipeline.StartWork();

            KexplorerFtpNode createdNode = new KexplorerFtpNode(ftpSite);

            this.form.TreeView1.Nodes.Add(createdNode);

            drivePipeline.AddJob(new FtpLoaderWorkUnit(createdNode, ftpSite, this.form, this));

            this.form.TreeView1.ContextMenu.Popup += new EventHandler(this.ContextMenu_Popup);

            this.form.TreeView1.AfterExpand += new TreeViewEventHandler(TreeView1_AfterExpand);


            this.form.TreeView1.KeyDown += new KeyEventHandler(TreeView1_KeyDown);


            this.form.TreeView1.AfterSelect += new TreeViewEventHandler(TreeView1_AfterFtpSelect);


            this.InitializeScriptManager();
        }
示例#3
0
 /// <summary>
 /// Construct with the drive letter and a pointer to the main form
 /// </summary>
 /// <param name="newDriveLetter"></param>
 /// <param name="form1"></param>
 public FtpLoaderWorkUnit( KexplorerFtpNode newCreatedDriveNode, FtpSite site, ISimpleKexplorerGUI form1, IWorkGUIFlagger flagger )
 {
     this.createdNode = newCreatedDriveNode;
     this.site = site;
     this.form = form1;
     this.guiFlagger = flagger;
 }
示例#4
0
 /// <summary>
 /// Construct with the drive letter and a pointer to the main form
 /// </summary>
 /// <param name="newDriveLetter"></param>
 /// <param name="form1"></param>
 public FtpLoaderWorkUnit(KexplorerFtpNode newCreatedDriveNode, FtpSite site, ISimpleKexplorerGUI form1, IWorkGUIFlagger flagger)
 {
     this.createdNode = newCreatedDriveNode;
     this.site        = site;
     this.form        = form1;
     this.guiFlagger  = flagger;
 }
示例#5
0
 //-----------------------------------------------------------------------------//
 /// <summary>
 /// Constructor with a node that is a folder.
 /// </summary>
 /// <param name="newFolderNode"></param>
 /// <param name="newForm"></param>
 public FtpFolderWorkUnit( KexplorerFtpNode newFolderNode, ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger )
 {
     this.folderNode = newFolderNode;
     this.site = newFolderNode.Site;
     this.form = newForm;
     this.guiFlagger = flagger;
 }
示例#6
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Called from form's invoke, actual treeview operations.
        /// </summary>
        private void AddSubSubNodes()
        {
            lock (this.form.TreeView1)
            {
                KexplorerFtpNode[] nodes = new KexplorerFtpNode[this.subDirs.Length];

                for (int i = 0; i < nodes.Length; i++)
                {
                    nodes[i] = new KexplorerFtpNode(this.site, this.currentSubFolderNode.Path + "/" + this.subDirs[i], this.subDirs[i]);
                }
                this.currentSubFolderNode.Nodes.AddRange(nodes);
            }
        }
示例#7
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Add the found sub-directories to the current sub dir.
        /// </summary>
        private void AddSubDirsToSubDir()
        {
            lock (this.form.TreeView1)
            {
                KexplorerFtpNode[] nodes = new KexplorerFtpNode[this.subDirs.Length];

                for (int i = 0; i < nodes.Length; i++)
                {
                    nodes[i] = new KexplorerFtpNode(site, this.currentWorkingSubDir.Path + "/" + this.subDirs[i], this.subDirs[i]);
                    nodes[i].Collapse();
                }


                this.currentWorkingSubDir.Nodes.AddRange(nodes);
            }
        }
示例#8
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Job three is to load all directories beneath the first level of directories.
        /// After this, there is no more work created from this.
        /// </summary>
        /// <returns></returns>
        private IWorkUnit DoJobThree()
        {
            try
            {
                foreach (KexplorerFtpNode dirNode in this.createdNode.Nodes)
                {
                    if (this.stop)
                    {
                        break;
                    }
                    this.currentWorkingSubDir = dirNode;

                    this.subDirs = null;
                    try
                    {
                        this.subDirs = GetSubDirs(dirNode.Path);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }

                    if (this.subDirs != null && this.subDirs.Length > 0 && !this.stop)
                    {
                        try
                        {
                            this.guiFlagger.SignalBeginGUI();

                            this.form.MainForm.Invoke(new InvokeDelegate(this.AddSubDirsToSubDir));
                        }
                        finally
                        {
                            this.guiFlagger.SignalEndGUI();
                        }
                    }
                }
            }
            finally
            {
                this.currentWorkingSubDir = null;
                this.subDirs = null;
            }

            return(null);
        }
示例#9
0
 //-----------------------------------------------------------------------------//
 /// <summary>
 /// After Expanding a node, make sure two levels deeper are expanded.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TreeView1_AfterExpand(object sender, TreeViewEventArgs e)
 {
     if (!this.isGuiBeingChanged)
     {
         if (e.Node is KExplorerNode)
         {
             KExplorerNode kNode         = (KExplorerNode)e.Node;
             string        drive         = kNode.DirInfo.FullName.Substring(0, 1);
             Pipeline      drivePipeline = (Pipeline)this.drivePipelines[drive];
             drivePipeline.AddJob(new FolderWorkUnit(kNode, this.form, this));
         }
         else
         {
             KexplorerFtpNode ftpNode     = (KexplorerFtpNode)e.Node;
             Pipeline         ftppipeline = (Pipeline)this.drivePipelines[ftpNode.Site.host];
             ftppipeline.AddJob(new FtpFolderWorkUnit(ftpNode, this.form, this));
         }
     }
 }
示例#10
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// When a node is selected.  Start the job to load the datagrid.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeView1_AfterFtpSelect(object sender, TreeViewEventArgs e)
        {
            KexplorerFtpNode kNode = (KexplorerFtpNode)e.Node;

            if (kNode.Stale)
            {
                if (kNode.Path == null)
                {
                    Pipeline drivePipeline = (Pipeline)this.drivePipelines[kNode.Site.host];
                    if (drivePipeline == null)
                    {
                        drivePipeline = new Pipeline(this.form);

                        this.drivePipelines[kNode.Site.host] = drivePipeline;

                        drivePipeline.StartWork();
                    }
                    drivePipeline.AddJob(new FtpLoaderWorkUnit(kNode, kNode.Site, this.form, this));
                }
                else
                {
                    Pipeline drivePipeline = (Pipeline)this.drivePipelines[kNode.Site.host];
                    if (drivePipeline == null)
                    {
                        drivePipeline = new Pipeline(this.form);

                        this.drivePipelines[kNode.Site.host] = drivePipeline;

                        drivePipeline.StartWork();
                    }
                    drivePipeline.AddJob(new FtpFolderWorkUnit(kNode, this.form, this));
                }

                //this.pipeline.AddJob( new FolderWorkUnit( kNode, this.form, this ) );
            }

            // File List always gets done in the main pipeline.
            this.pipeline.AddPriorityJob(new FtpFileListWorkUnit(kNode, this.form, this));
        }
示例#11
0
 //-------------------------------------------------------------------
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="newForm"></param>
 /// <param name="flagger"></param>
 public FtpFileListWorkUnit(KexplorerFtpNode node, ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger)
 {
     this.kForm      = newForm;
     this.kNode      = node;
     this.guiFlagger = flagger;
 }
示例#12
0
        /**
         * Get the files.
         */
        private FtpFileInfo[] GetFiles(KexplorerFtpNode knode)
        {
            ArrayList      files       = new ArrayList();
            string         ftpfullpath = "ftp://" + kNode.Site.host + knode.Path;
            FtpWebResponse ftpResponse = null;
            FtpWebRequest  ftp         = null;

            try
            {
                ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);


                ftp.Credentials = new NetworkCredential(kNode.Site.username, kNode.Site.pwd);
                //userid and password for the ftp server to given

                ftp.KeepAlive = true;
                ftp.UseBinary = true;

                ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;



                ftpResponse = (FtpWebResponse)ftp.GetResponse();


                Stream responseStream = null;

                responseStream = ftpResponse.GetResponseStream();


                string strFile = null;

                try
                {
                    StreamReader reader = new StreamReader(responseStream);
                    while (true)
                    {
                        strFile = null;
                        try
                        {
                            strFile = reader.ReadLine();
                        }
                        catch (IOException e)
                        {
                            break;
                        }



                        if (strFile != null)
                        {
                            FtpFileInfo newFileInfo = new FtpFileInfo(strFile, kNode.Site.type);
                            if (!newFileInfo.isDir)
                            {
                                files.Add(newFileInfo);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    String x = e.Message;
                }



                try
                {
                    ftpResponse.Close();
                }
                catch (Exception e)
                {
                }
            }

            catch (WebException e)
            {
                return(null);
            }
            finally
            {
                if (ftpResponse != null)
                {
                    ftpResponse.Close();
                }
            }


            return((FtpFileInfo[])files.ToArray(typeof(FtpFileInfo)));
        }
示例#13
0
        public void Initialize(ISimpleKexplorerGUI newForm, FtpSite ftpSite)
        {
            this.isFtpSite = true;
            this.form = newForm;

            this.pipeline = new Pipeline(this.form);
            this.pipeline.StartWork();

               this.drivePipelines = new Hashtable();

            Pipeline drivePipeline = new Pipeline(this.form);
            this.drivePipelines[ftpSite.host] = drivePipeline;
            drivePipeline.StartWork();

            KexplorerFtpNode createdNode = new KexplorerFtpNode(ftpSite);
            this.form.TreeView1.Nodes.Add(createdNode);

            drivePipeline.AddJob(new FtpLoaderWorkUnit(createdNode, ftpSite, this.form, this));

            this.form.TreeView1.ContextMenu.Popup += new EventHandler(this.ContextMenu_Popup);

            this.form.TreeView1.AfterExpand += new TreeViewEventHandler(TreeView1_AfterExpand);

            this.form.TreeView1.KeyDown += new KeyEventHandler(TreeView1_KeyDown);

            this.form.TreeView1.AfterSelect += new TreeViewEventHandler(TreeView1_AfterFtpSelect);

            this.InitializeScriptManager();
        }
示例#14
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Job three is to load all directories beneath the first level of directories.
        /// After this, there is no more work created from this.
        /// </summary>
        /// <returns></returns>
        private IWorkUnit DoJobThree()
        {
            try
            {

                foreach  ( KexplorerFtpNode dirNode in this.createdNode.Nodes )
                {
                    if ( this.stop )
                    {
                        break;
                    }
                    this.currentWorkingSubDir = dirNode;

                    this.subDirs = null;
                    try
                    {

                        this.subDirs = GetSubDirs( dirNode.Path  );
                    }
                    catch (Exception e )
                    {
                        MessageBox.Show(e.Message);
                    }

                    if ( this.subDirs != null && this.subDirs.Length > 0 && !this.stop )
                    {
                        try
                        {
                            this.guiFlagger.SignalBeginGUI();

                            this.form.MainForm.Invoke( new InvokeDelegate( this.AddSubDirsToSubDir ));
                        }
                        finally
                        {
                            this.guiFlagger.SignalEndGUI();
                        }
                    }

                }

            }
            finally
            {
                this.currentWorkingSubDir = null;
                this.subDirs = null;
            }

            return null;
        }
示例#15
0
        //-----------------------------------------------------------------------------//
        /// 6<summary>
        /// Go through each sub-folder and load it's sub-folders.
        /// </summary>
        /// <returns></returns>
        private IWorkUnit DoJobTwo()
        {
            try
            {
                foreach (KexplorerFtpNode sNode in this.folderNode.Nodes)
                {
                    if (this.stop)
                    {
                        break;
                    }
                    this.currentSubFolderNode = sNode;

                    if (sNode.Nodes.Count > 0 && sNode.Stale)
                    {
                        try
                        {
                            this.guiFlagger.SignalBeginGUI();
                            this.form.MainForm.Invoke(new InvokeDelegate(this.ClearSubNode));
                        }
                        finally
                        {
                            this.guiFlagger.SignalEndGUI();
                        }

                        sNode.Stale = false;
                    }

                    if (sNode.Nodes.Count == 0)
                    {
                        try
                        {
                            this.subDirs = null;
                            String nextPath = sNode.Path;

                            this.subDirs = GetSubDirs(nextPath, 4);

                            if (this.subDirs == null)
                            {
                                this.YouWereAborted();
                            }
                            if (this.subDirs != null && this.subDirs.Length > 0 && !this.stop)
                            {
                                try
                                {
                                    this.guiFlagger.SignalBeginGUI();
                                    this.form.MainForm.Invoke(new InvokeDelegate(this.AddSubSubNodes));
                                }
                                finally
                                {
                                    this.guiFlagger.SignalEndGUI();
                                }
                            }
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }
                }
            }
            finally
            {
                this.subDirs = null;
                this.currentSubFolderNode = null;
            }



            return(null);
        }
示例#16
0
 //-------------------------------------------------------------------
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="newForm"></param>
 /// <param name="flagger"></param>
 public FtpFileListWorkUnit(KexplorerFtpNode node,  ISimpleKexplorerGUI newForm, IWorkGUIFlagger flagger )
 {
     this.kForm = newForm;
     this.kNode = node;
     this.guiFlagger = flagger;
 }
示例#17
0
        /**
         * Get the files.
         */
        private FtpFileInfo[] GetFiles(KexplorerFtpNode knode)
        {
            ArrayList files = new ArrayList();
            string ftpfullpath = "ftp://" + kNode.Site.host +knode.Path;
            FtpWebResponse ftpResponse = null;
            FtpWebRequest ftp = null;
            try
            {

                ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);

                ftp.Credentials = new NetworkCredential(kNode.Site.username, kNode.Site.pwd);
                //userid and password for the ftp server to given

                ftp.KeepAlive = true;
                ftp.UseBinary = true;

                ftp.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

                ftpResponse = (FtpWebResponse)ftp.GetResponse();

                Stream responseStream = null;

                responseStream = ftpResponse.GetResponseStream();

                string strFile = null;

                try
                {
                    StreamReader reader = new StreamReader(responseStream);
                    while (true)
                    {
                        strFile = null;
                        try
                        {
                            strFile = reader.ReadLine();
                        }
                        catch (IOException e)
                        {
                            break;
                        }

                        if (strFile != null)
                        {
                            FtpFileInfo newFileInfo = new FtpFileInfo(strFile, kNode.Site.type);
                            if ( !newFileInfo.isDir )
                            {

                                files.Add( newFileInfo );

                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    String x = e.Message;

                }

                try
                {
                    ftpResponse.Close();
                }
                catch (Exception e)
                {
                }
            }

            catch (WebException e)
            {

                return null;
            }
            finally
            {
                if (ftpResponse != null)
                {
                    ftpResponse.Close();
                }
            }

            return (FtpFileInfo[])files.ToArray(typeof(FtpFileInfo));
        }
示例#18
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Add the found sub-directories to the current sub dir.
        /// </summary>
        private void AddSubDirsToSubDir()
        {
            lock( this.form.TreeView1 )
            {
                KexplorerFtpNode[] nodes = new KexplorerFtpNode[ this.subDirs.Length ];

                for ( int i = 0; i < nodes.Length; i++ )
                {
                    nodes[i] = new KexplorerFtpNode(site, this.currentWorkingSubDir.Path + "/" + this.subDirs[i], this.subDirs[i]);
                    nodes[i].Collapse();

                }

                this.currentWorkingSubDir.Nodes.AddRange( nodes );
            }
        }
示例#19
0
        //-----------------------------------------------------------------------------//
        /// 6<summary>
        /// Go through each sub-folder and load it's sub-folders.
        /// </summary>
        /// <returns></returns>
        private IWorkUnit DoJobTwo()
        {
            try
            {
                foreach ( KexplorerFtpNode sNode in this.folderNode.Nodes )
                {
                    if ( this.stop )
                    {
                        break;
                    }
                    this.currentSubFolderNode = sNode;

                    if ( sNode.Nodes.Count > 0 && sNode.Stale )
                    {

                        try
                        {
                            this.guiFlagger.SignalBeginGUI();
                            this.form.MainForm.Invoke( new InvokeDelegate( this.ClearSubNode ));
                        }
                        finally
                        {
                            this.guiFlagger.SignalEndGUI();
                        }

                        sNode.Stale = false;

                    }

                    if ( sNode.Nodes.Count == 0 )
                    {
                        try
                        {
                            this.subDirs = null;
                            String nextPath = sNode.Path;

                            this.subDirs = GetSubDirs( nextPath, 4 );

                            if ( this.subDirs == null )
                            {
                                this.YouWereAborted();
                            }
                            if ( this.subDirs != null && this.subDirs.Length > 0 && !this.stop )
                            {
                                try
                                {

                                    this.guiFlagger.SignalBeginGUI();
                                    this.form.MainForm.Invoke( new InvokeDelegate( this.AddSubSubNodes ));
                                }
                                finally
                                {
                                    this.guiFlagger.SignalEndGUI();
                                }
                            }
                        }
                        catch (Exception )
                        {
                            continue;
                        }

                    }

                }

            }
            finally
            {
                this.subDirs = null;
                this.currentSubFolderNode = null;
            }

            return null;
        }
示例#20
0
        //-----------------------------------------------------------------------------//
        /// <summary>
        /// Add sub directories.
        /// </summary>
        private void AddSubNodes()
        {
            lock( this.form.TreeView1 )
            {

                KexplorerFtpNode[] nodes = new KexplorerFtpNode[ this.subDirs.Length ];

                for ( int i = 0; i < nodes.Length; i++ )
                {
                    nodes[i] = new KexplorerFtpNode( site, this.folderNode.Path + "/" + this.subDirs[i], this.subDirs[i] );

                }
                this.folderNode.Nodes.AddRange( nodes );

            }
        }