private void GetPaperMetadata(IPaperModel model, IMainPresenter presenter, string docId, string memberId) { IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetPaperMetadataUrl = ApplicationResource.ActionGetPaperDocMetadata; service.UserAgentVersion = ApplicationResource.UserAgent; string paperAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices serviceFolderInfo = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); serviceFolderInfo.PaperDocFolderInfoUrl = ApplicationResource.ActionPaperDocFolderInfo; serviceFolderInfo.UserAgentVersion = ApplicationResource.UserAgent; string folderPath = @"/"; try { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Retrieving Paper doc metadata for id: {0}", docId)); }, null); } //get paper doc folder info to add to listview object IDataResponse responseFolderInfo = serviceFolderInfo.GetPaperDocFolderInfo(docId, paperAccessToken, memberId); if (responseFolderInfo.StatusCode == HttpStatusCode.OK) { if (responseFolderInfo.Data != null) { string data = responseFolderInfo.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data); int resultCount = 0; if (data != "{}") { resultCount = jsonData["folders"].Count; for (int i = 0; i < resultCount; i++) { dynamic folders = jsonData["folders"][i]; dynamic folderPathobj = folders["name"]; string folderPathNext = folderPathobj.Value as string; folderPath = folderPath + folderPathNext + "/"; } } } } //now get remainder of metadata IDataResponse response = service.GetPaperMetadata(docId, paperAccessToken, memberId); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data); dynamic paperDocIdobj = jsonData["doc_id"]; dynamic ownerobj = jsonData["owner"]; dynamic paperNameobj = jsonData["title"]; dynamic createdDateobj = jsonData["created_date"]; dynamic statusobj = jsonData["status"][".tag"]; dynamic revisionobj = jsonData["revision"]; dynamic lastUpdatedDateobj = jsonData["last_updated_date"]; dynamic lastEditorobj = jsonData["last_editor"]; string paperDocId = paperDocIdobj.Value as string; string owner = ownerobj.Value as string; string paperName = paperNameobj.Value as string; DateTime createdDate = DateTime.MinValue; if (createdDateobj != null) { createdDate = createdDateobj; } string status = statusobj.Value as string; UInt64 revision = 0; if (revisionobj != null) { revision = revisionobj; } DateTime lastUpdatedDate = DateTime.MinValue; if (lastUpdatedDateobj != null) { lastUpdatedDate = lastUpdatedDateobj; } string lastEditor = lastEditorobj.Value as string; // update model PaperListViewItemModel lvItem = new PaperListViewItemModel() { PaperId = paperDocId, Owner = owner, PaperName = paperName, FolderPath = folderPath, CreatedDate = createdDate, Status = status, Revision = revision, LastUpdatedDate = lastUpdatedDate, LastEditor = lastEditor, MemberId = memberId, IsChecked = true }; model.Paper.Add(lvItem); } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_GET_PAPER_METADATA, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } }