Example #1
0
        public IItemNode GetFileInfo(IItemNode node)
        {
            switch (node.GetRoot.RootType.Type)
            {
            case CloudType.Dropbox:
                return(Dropbox.GetMetaData(node));

            case CloudType.GoogleDrive:
                Drivev2_File item = GoogleDrive.GetMetadataItem(node);
                node.Info.Size    = item.fileSize ?? -1;
                node.Info.Name    = item.title;
                node.Info.DateMod = item.modifiedDate ?? DateTime.Now;
                return(node);

            case CloudType.LocalDisk:
                return(LocalDisk.GetFileInfo(node));

            case CloudType.Mega:
                return(MegaNz.GetItem(node));

            default:
                throw new UnknowCloudNameException("Error Unknow Cloud Type: " + node.GetRoot.RootType.Type.ToString());
            }
        }
Example #2
0
        public ExplorerNode GetFileInfo(ExplorerNode node)
        {
            switch (node.GetRoot.NodeType.Type)
            {
            case CloudType.Dropbox:
                return(Dropbox.GetMetaData(node));

            case CloudType.GoogleDrive:
                GD_item item = GoogleDrive.GetMetadataItem(node);
                node.Info.Size    = item.fileSize;
                node.Info.Name    = item.title;
                node.Info.DateMod = DateTime.Parse(item.modifiedDate);
                return(node);

            case CloudType.LocalDisk:
                return(LocalDisk.GetFileInfo(node));

            case CloudType.Mega:
                return(MegaNz.GetItem(node));

            default:
                throw new UnknowCloudNameException("Error Unknow Cloud Type: " + node.GetRoot.NodeType.Type.ToString());
            }
        }
Example #3
0
        public static ExplorerNode GetListFileFolder(ExplorerNode node, bool folderonly = false, bool read_only = false)
        {
            bool         uri       = false;
            ExplorerNode root      = node.GetRoot;
            string       Email     = root.NodeType.Email;
            string       parent_ID = null;
            string       url       = null;
            Regex        rg;
            Match        match;

            if (string.IsNullOrEmpty(Email))
            {
                Email = AppSetting.settings.GetDefaultCloud(CloudType.GoogleDrive); uri = true;
            }

            //Find id folder
            if (uri)//folder url
            {
                if (root.NodeType.uri != null)
                {
                    url   = root.NodeType.uri.ToString();
                    rg    = new Regex(Rg_url_idFolder);
                    match = rg.Match(url);
                    if (match.Success)
                    {
                        parent_ID = match.Value;
                    }
                    else
                    {
                        rg    = new Regex(Rg_url_idFolderOpen);
                        match = rg.Match(url);
                        if (match.Success)
                        {
                            parent_ID = match.Value;
                        }
                    }
                }
            }
            else//explorer node
            {
                parent_ID = "root";//root
                if (!string.IsNullOrEmpty(node.Info.ID))
                {
                    parent_ID = node.Info.ID;                                     //id root or id node
                }
            }

            //if found id is folder
            if (!string.IsNullOrEmpty(parent_ID))
            {
                GD_Files_list list_ = Search("'" + parent_ID + "' in parents and trashed=false", Email);
                if (parent_ID == "root")//save root id
                {
                    foreach (GD_item item in list_.items)
                    {
                        foreach (GD_parent parent in item.parents)
                        {
                            if (parent.isRoot)
                            {
                                parent_ID = parent.id; break;
                            }
                        }
                        if (parent_ID != "root")
                        {
                            break;
                        }
                    }
                    node.Info.ID = parent_ID;
                    AppSetting.settings.SetRootID(Email, CloudType.GoogleDrive, parent_ID);
                }
                node.RenewChilds(list_.Convert(node));
                return(node);
            }
            else if (string.IsNullOrEmpty(url))
            {
                rg    = new Regex(Rg_url_idFile);
                match = rg.Match(url);
                if (match.Success)
                {
                    ExplorerNode n = new ExplorerNode();
                    n.Info.ID        = match.Value;
                    n.NodeType.Email = Email;
                    GD_item item = GoogleDrive.GetMetadataItem(n);
                    n.Info.Size     = item.fileSize;
                    n.Info.Name     = item.title;
                    n.Info.MimeType = item.mimeType;
                    AppSetting.UIMain.FileSaveDialog(PCPath.Mycomputer, item.title, PCPath.FilterAllFiles, n);
                    return(null);
                }
            }
            throw new Exception("Can't Analyze Data Input.");
        }
Example #4
0
            void work()
            {
                Thread.Sleep(500);
                foreach (ExplorerNode item in items)
                {
                    while (cancel)
                    {
                        Thread.Sleep(100); if (closedform)
                        {
                            return;
                        }
                    }
                    if (closedform)
                    {
                        return;
                    }
                    bool Iserror = false;
                    ui.UpdateText(AppSetting.lang.GetText(LanguageKey.DeleteForm_updatetext_Deleting.ToString()) + item);
                    try
                    {
                        switch (item.GetRoot.NodeType.Type)
                        {
                        case CloudType.Dropbox:
                            if (!Dropbox.Delete(item, PernamentDelete))
                            {
                                Iserror = true;
                            }
                            break;

                        case CloudType.GoogleDrive:
                            if (!GoogleDrive.File_trash(item, PernamentDelete))
                            {
                                Iserror = true;
                            }
                            break;

                        case CloudType.LocalDisk:
                            if (!LocalDisk.Delete(item, PernamentDelete))
                            {
                                Iserror = true;
                            }
                            break;

                        case CloudType.Mega:
                        default: throw new UnknowCloudNameException("Error Unknow Cloud Type: " + item.GetRoot.NodeType.Type.ToString());
                        }
                        if (!Iserror)
                        {
                            ui.UpdateText(AppSetting.lang.GetText(LanguageKey.DeleteForm_updatetext_Deleted.ToString()) + "\r\n");
                        }
                        else
                        {
                            ui.UpdateText(AppSetting.lang.GetText(LanguageKey.DeleteForm_updatetext_Error.ToString()) + "\r\n");
                            if (ui.AutoClose)
                            {
                                ui.SetAutoClose(false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ui.UpdateText(AppSetting.lang.GetText(LanguageKey.DeleteForm_updatetext_Error.ToString()) + "\r\nMessage:" + ex.Message + "\r\n");
                        if (ui.AutoClose)
                        {
                            ui.SetAutoClose(false);
                        }
                    }
                }
                if (ui.AutoClose)
                {
                    ui.Close_();
                }
                else
                {
                    ui.SetTextButtonCancel(AppSetting.lang.GetText(LanguageKey.BT_close.ToString()));
                    while (!ui.AutoClose)
                    {
                        Thread.Sleep(100);
                        if (cancel)
                        {
                            ui.Close_();
                        }
                    }
                }
            }