Beispiel #1
0
 void Dispose()
 {
     GroupManager.ItemsTransferWork.Remove(this);
     GroupManager            = null;
     item                    = null;
     clientTo                = null;
     chunksSizesToUploadMega = null;
     mega_up                 = null;
     completionHandle        = null;
 }
Beispiel #2
0
        public void AddItems(List <ExplorerNode> items, ExplorerNode fromfolder, ExplorerNode savefolder, bool AreCut)
        {
            ItemsTransferManager gr = new ItemsTransferManager(items, fromfolder, savefolder, AreCut);

            GroupsWork.Add(gr);
            Thread thr = new Thread(GroupsWork[GroupsWork.IndexOf(gr)].LoadListItems);

            thr.Start();
            LoadGroupThreads.Add(thr);
        }
Beispiel #3
0
        public TransferBytes(TransferItem item, ItemsTransferManager GroupManager, object clientTo = null)
        {
            if (item.From.node.Info.Size == 0)
            {
                item.ErrorMsg = "File size zero."; Dispose();
            }
            this.item         = item;
            this.GroupManager = GroupManager;
            Type_root_to      = this.item.To.node.GetRoot.NodeType.Type;
            Type_root_from    = this.item.From.node.GetRoot.NodeType.Type;

            if (GroupManager.AreCut && (Type_root_to | CloudType.LocalDisk) == Type_root_from &&
                item.To.node.GetRoot.Info.Name == item.From.node.GetRoot.Info.Name)
            {
                LocalDisk.AutoCreateFolder(this.item.To.node.Parent);
                File.Move(item.From.node.GetFullPathString(), item.To.node.GetFullPathString());
                item.status = StatusTransfer.Moved;
                Dispose();
            }
            else
            {
                if (item.buffer == null)
                {
                    item.buffer = new byte[128 * 1024];
                }
                if (clientTo != null)
                {
                    this.clientTo = clientTo;
                }
                if (item.To.node.GetRoot.NodeType.Type == CloudType.Mega)
                {
                    InitUploadMega();                                                      //InitUploadMega
                }
                //Make Stream From
                item.From.stream = AppSetting.ManageCloud.GetFileStream(item.From.node, item.SaveSizeTransferSuccess,
                                                                        item.From.node.Info.Size - 1, item.To.node.GetRoot.NodeType.Type != CloudType.LocalDisk, item.dataCryptoMega);
                //Make Stream To
                if (item.ChunkUploadSize > 0)
                {
                    MakeNextChunkUploadInStreamTo(true);                          //upload to cloud
                }
                else
                {
                    this.item.To.stream = AppSetting.ManageCloud.GetFileStream(item.To.node, item.SizeWasTransfer); //download to disk
                }
                item.status = StatusTransfer.Running;
                item.From.stream.BeginRead(item.buffer, 0, item.buffer.Length, new AsyncCallback(GetFrom), 0);
            }
        }
Beispiel #4
0
 public void ReadData()
 {
     if (ReadWriteData.Exists(ReadWriteData.File_DataUploadDownload))
     {
         var readerjson = ReadWriteData.Read(ReadWriteData.File_DataUploadDownload);
         if (readerjson != null)
         {
             List <JsonDataSaveGroup> json_groups = JsonConvert.DeserializeObject <List <JsonDataSaveGroup> >(readerjson.ReadToEnd());
             foreach (JsonDataSaveGroup json_group in json_groups)
             {
                 ItemsTransferManager group = new ItemsTransferManager(json_group);
                 this.GroupsWork.Add(group);
             }
         }
     }
 }