Exemple #1
0
        public void UpdateFile(string folder, string file, byte[] data)
        {
            JObject card = cardarray.Children <JObject>()
                           .FirstOrDefault(o => o["name"].ToString() == folder);

            if (card == null)
            {
                throw new Exception("資料夾不存在");
            }

            JArray list = JArray.Parse(
                TrelloHelper.GetCardAttachmentList(_key, _token, card["id"].Value <string>()));    // file list

            JObject attachment = list.Children <JObject>()
                                 .FirstOrDefault(o => o["name"].ToString() == file);

            // 已存在,刪除檔案
            if (attachment != null)
            {
                TrelloHelper.DeleteAttachment(_key, _token,
                                              card["id"].Value <string>(), attachment["id"].Value <string>());
            }

            TrelloHelper.CreateAttachment(_key, _token, card["id"].Value <string>(), file, data);
        }
Exemple #2
0
        public void CreateFile(string folder, string name, byte[] file)
        {
            JObject obj = cardarray.Children <JObject>()
                          .FirstOrDefault(o => o["name"].ToString() == folder);

            if (obj == null)
            {
                throw new Exception("資料夾不存在");
            }

            JArray list = JArray.Parse(
                TrelloHelper.GetCardAttachmentList(_key, _token, obj["id"].Value <string>()));   // file list

            JObject attachment = list.Children <JObject>()
                                 .FirstOrDefault(o => o["name"].ToString() == name);

            if (attachment != null)
            {
                DeleteFile(folder, name);   //已存在,刪除檔案
            }
            TrelloHelper.CreateAttachment(_key, _token, obj["id"].Value <string>(), name, file);
        }