Esempio n. 1
0
        public static queue CreateDownloadQueue(Tranferclint client, int id, string typ, string saveName, long length)
        {
            try
            {
                //Same as above with some changes.
                var queue = new queue();
                queue._Type  = typ;
                queue.Client = client;

                queue.Filename = saveName;
                queue._Type    = typ;

                queue.Type = QueueType.Download;
                //Create our file stream for writing.
                queue.FS = new FileStream(saveName, FileMode.Create);
                //Fill the stream will 0 bytes based on the real size. So we can index write.

                queue.Length = length;
                queue.FS.SetLength(length);
                //Instead of generating an ID, we will set the ID that has been sent.
                queue.ID = id;
                return(queue);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static queue CreateUploadQueue(Tranferclint client, string fileName)
        {
            try
            {
                //We will create a new upload queue
                var queue = new queue();
                //Set our filename
                queue.Filename = fileName;
                // queue.Filename = fileName;

                queue._Type = Path.GetFileName(fileName).ToLower().Contains("jpg") || Path.GetFileName(fileName).ToLower().Contains("png") ? "Image" : "Video";



                //Set our client
                queue.Client = client;
                //Set our queue type to upload.
                queue.Type = QueueType.Upload;
                //Create our file stream for reading.
                queue.FS = new FileStream(fileName, FileMode.Open);
                //Create our transfer thread
                queue.Thread = new Thread(new ParameterizedThreadStart(transferProc));
                //   queue.Thread.IsBackground = true;
                //Generate our ID
                queue.ID = Application.Rand.Next();
                //Set our length to the size of the file.
                queue.Length = queue.FS.Length;
                return(queue);
            }
            catch
            {
                //If something goes wrong, return null
                return(null);
            }
        }
Esempio n. 3
0
 public void stop()
 {
     isconnct = false;
     try
     {
         // connect.close();
         _Tranferclint.Close();
         _QueueList.Clear();
         tansconnet.close();
         _Tranferclint = new Tranferclint();
     }
     catch { }
 }
Esempio n. 4
0
        public void Close()
        {
            try
            {
                //Remove the current queue from the client transfer list.
                Client.Transfers.Remove(ID);
            }
            catch { }
            Running = false;
            //Close the stream
            FS.Close();
            //Dispose the ResetEvent.
            pauseEvent.Dispose();

            Client = null;
        }
Esempio n. 5
0
 static void Upload(Tranferclint _Tranferclint, ListSQL _ListSQL)
 {
 }