예제 #1
0
        /// <summary>
        /// This will init a remote file directory
        /// </summary>
        /// <param name="path">The path to init</param>
        /// <param name="client">The client in which we are taking the file directory from</param>
        /// <param name="richTextBox1">The textbox in which we want to print the log to</param>
        public void InitRemote(string path, ClientThread client, ref RichTextBox richTextBox1)
        {
            this.log = richTextBox1;
            IsRemote = true;
            this.client = client;
            Messaging.SendCommand("return InitFTPDirectory('" + path + "');", client.GetClientSocket());
            FTPDirectory dir = (FTPDirectory)Messaging.RecieveFTPDirectory(client.GetClientSocket());

            treeListView1.CanExpandGetter = delegate(object x)
            {
                return ((FTPDirectory)x).IsFile == false;
            };
            treeListView1.ChildrenGetter = delegate(object x) { return GetRemoteChildren(x, client); };

            treeListView1.Roots = dir.Children;
        }
예제 #2
0
 void CheckHeartBeat(TcpClient heartbeat, ClientThread c)
 {
     Messaging.SendCommand("return GetCompDB()", c.GetClientSocket());
     string[] compDB = Messaging.RecieveComputerDetails(c.GetClientSocket());
     KnownClient kc = new KnownClient(compDB[0], compDB[2], compDB[1], "N/A", "N/A", compDB[3]);
     bool connected = true;
     do
     {
         try
         {
             if (heartbeat.Client.Poll(0, SelectMode.SelectRead))
             {
                 byte[] buff = new byte[1];
                 if (heartbeat.Client.Receive(buff, SocketFlags.Peek) == 0)
                 {
                     MessageBox.Show("Client left :: ");
                     connected = false;
                 }
             }
         }
         catch (Exception e)
         {
            // MessageBox.Show("Client left :: ");
             connected = false;
             objectListOffline.AddObject(kc);
             objectListView1.RemoveObject(c);
         }
        // if (heartbeat.GetStream().ReadByte() < 0 ) { MessageBox.Show("Gone"); }
     } while (connected);
 }
예제 #3
0
        private void AddClientToDatabase(ClientThread client)
        {
            Messaging.SendCommand("return GetProcessDetails();", client.GetClientSocket());
            List<Process> compProc = (List<Process>)Messaging.RecieveProcessDetails(client.GetClientSocket());

            List<string> procnames = new List<string>();

            foreach (Process proc in compProc)
            {
                procnames.Add(proc.GetName());
            }

            procnames = procnames.Distinct().ToList();

            db.AddProcesses(client.GetCompID().Trim(), procnames);

            Messaging.SendCommand("return GetSystemDB()", client.GetClientSocket());
            string[] sysDB = Messaging.RecieveComputerDetails(client.GetClientSocket());

            db.InsertIntoTable("SYSTEMCOMPONENTS", sysDB);

            Messaging.SendCommand("return GetCompDB()", client.GetClientSocket());
            string[] compDB = Messaging.RecieveComputerDetails(client.GetClientSocket());

            db.InsertIntoTable("COMPUTER", compDB);
        }
예제 #4
0
        public bool checkNewClient(ClientThread c)
        {
            string id = Messaging.SendNewCommand("return GetCompID()", c.GetClientSocket());

            bool isNew = db.CheckForNewComputer(id);

            return isNew;
        }
예제 #5
0
        public string SendFileToOtherClient(string source , int fileLength, string destination, ClientThread toClient )
        {
            //Send FTP file
            //Tell client to look for the file
            // Messaging.SendNewCommand("RemoteSendFTP('"+toClient.GetClientIP()+"',"+toClient.GetPort()+",'" + source + "');", this.GetClientSocket());
            //return toClient.RecieveFileFromOtherClient(destination, fileLength, this.GetClientIP(), this.GetPort());

            //Ok, this will be the new server. The server will send the file.
            //Server will tell the client to connect to it, and wait for the file to send

            Messaging.SendNewCommand("RemoteAcceptFTPFromClient('" + this.GetClientIP() + "', '" + destination + "'," + fileLength + ");", toClient.GetClientSocket());
            //this line tells the toClient that to connect to the ip address, the file will be this big and store it here
            Messaging.SendNewCommand("SendFTPToClient('"+source.Replace("\\", "\\\\")+"','"+this.GetClientIP()+"');", this.GetClientSocket());
            //Messaging.ClientFTPToClient(source, this.GetClientIP());
            return "Sent";
        }
예제 #6
0
        private void SendFolder(FTPDirectory ftp, ClientThread client, string pathToGo, FTP par)
        {
            if (Directory.Exists(ftp.Path))
            {
                ftp.GetChildren();
                foreach (FTPDirectory f in ftp.Children)
                {
                    SendFolder(f, client, pathToGo + "\\\\" + f.Name, par);
                }
            }
            else
            {

                Messaging.SendCommand("RemoteAcceptFTP(" + client.GetPort() + ",'" + pathToGo + "', " + new FileInfo(ftp.Path).Length + ");", client.GetClientSocket());
                //Messaging.RemoteAcceptFTP(client.GetClientSocket(), pathToGo);
                Messaging.FTPFile(ftp.Path, client.GetClientSocket());
                log.Text += ("\nFile successfully sent.\n");
                par.Refresh();
            }
        }
예제 #7
0
 /// <summary>
 /// Return the children directories of a remote directory, if any.
 /// </summary>
 /// <param name="node">The node is a GUID number, which points to the directory location on the remove machine.</param>
 /// <param name="client"></param>
 /// <returns></returns>
 private List<FTPDirectory> GetRemoteChildren(object node, ClientThread client)
 {
     this.client = client;
     Messaging.SendCommand("return GetFTPDirectory('" + ((FTPDirectory)node).GetID() + "');", client.GetClientSocket());
     FTPDirectory dir = (FTPDirectory)Messaging.RecieveFTPDirectory(client.GetClientSocket());
     return dir.Children;
 }