Beispiel #1
0
        public List <SyncFileInfo> GetFiles(string folder)
        {
            List <SyncFileInfo> result = new List <SyncFileInfo>();

            JObject obj = cardarray.Children <JObject>()
                          .FirstOrDefault(o => o["name"].ToString() == folder);

            if (obj != null)
            {
                JArray list = JArray.Parse(
                    TrelloHelper.GetCardAttachmentList(_key, _token, obj["id"].Value <string>()));

                foreach (JObject o in list.Children <JObject>())
                {
                    result.Add(new SyncFileInfo()
                    {
                        Name       = o["name"].Value <string>(),
                        Path       = o["url"].Value <string>(),
                        CreateDate = TrelloHelper.IdToDatetime(o["id"].Value <string>()),
                        UpdateDate = TrelloHelper.IdToDatetime(o["id"].Value <string>()),
                        Size       = o["bytes"].Value <int>()
                    }
                               );
                }
            }

            return(result);
        }
Beispiel #2
0
        public List <SyncFolderInfo> GetFolders(bool withfile)
        {
            //cards in list
            List <SyncFolderInfo> folders = new List <SyncFolderInfo>();

            foreach (JObject o in cardarray.Children <JObject>())
            {
                // 排除 root card
                if (o["name"].Value <string>() == _rootname)
                {
                    continue;
                }

                folders.Add(new SyncFolderInfo()
                {
                    Name       = o["name"].Value <string>(),
                    Path       = o["url"].Value <string>(),
                    CreateDate = TrelloHelper.IdToDatetime(o["id"].Value <string>()),
                    UpdateDate = TrelloHelper.IdToDatetime(o["id"].Value <string>()),
                }
                            );
            }

            if (withfile)
            {
                foreach (var folder in folders)
                {
                    folder.Files = GetFiles(folder.Name);
                }
            }

            /*
             * 用 card 轉成 folder的資料
             * 處理成實際用的 folder
             */
            List <SyncFolderInfo> result = new List <SyncFolderInfo>();

            foreach (var f in folders)
            {
                // 先找出第一層,名字沒有 \ 的
                if (f.Name.Split('\\').Count() == 1)
                {
                    // card 名字放路徑
                    result.Add(GetFolder(f.Name, withfile, folders));
                }
            }

            return(result);
        }
Beispiel #3
0
        public void IdToDatetimeTest()
        {
            DateTime dt = TrelloHelper.IdToDatetime("4d5ea62fd76aa1136000000c");

            Debug.WriteLine(dt.ToString());
        }