public List <ShareSpace> getSubSpaces(ShareSpace parentSpace) { List <ShareSpace> shareSubSpaces = new List <ShareSpace>(); SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); PaginationRecord pg = new PaginationRecord(); pg.Limit = 10; pg.Page = "F"; FolderOptionsRecord options = new FolderOptionsRecord(); options.SortDir = "DESC"; GetSubSpacesResult subSpacesResult = spaceApi.GetSubSpaces(parentSpace.Key, pg.ToJson(), parentSpace.Key, options.ToJson(), null, "myvmoso"); if (subSpacesResult.Hdr.Rc == 0) { List <SpaceV2Record> subSpaces = subSpacesResult.Folders; foreach (SpaceV2Record subSpace in subSpaces) { ShareSpace childSpace = new ShareSpace(subSpace.Key, subSpace.DisplayName, subSpace); shareSubSpaces.Add(childSpace); } } else { log.Error("Error accesing subspaces for parent space " + parentSpace.Name); } return(shareSubSpaces); }
public List <ShareSpace> GetRootSpaces() { log.Debug("Getting root spaces..."); SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); GetSpacesResult getSpacesResult = spaceApi.GetSpaces(CUSTOM_SPACE_TAG); if (getSpacesResult.Hdr.Rc == 0) { List <SpaceV2Record> spaces = getSpacesResult.Folders; List <ShareSpace> shareSpaces = new List <ShareSpace>(); foreach (SpaceV2Record space in spaces) { if (space.NameKey.Equals(CORPORATE_SPACE) || space.NameKey.Equals(CUSTOM_SPACE) || space.NameKey.Equals(MUTUAL_SPACE) || space.NameKey.Equals(PUBLIC_SPACE)) { ShareSpace shareSpace = new ShareSpace(space.Key, space.DisplayName, space); shareSpaces.Insert(0, shareSpace); } } return(shareSpaces); } else { throw new Exception("Vmoso error getting root spaces. Rc=" + getSpacesResult.Hdr.Rc); } }
public ShareFileItem createFile(FileInfo fileInfo, String title, String description, List <String> spaceKeys, Bitmap icon) { try { FileRecord fileRecord = VmosoFileUtils.uploadFile(session, fileInfo.FullName, title, description, true); if (spaceKeys != null) { SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(fileRecord.Key, shareInput); if (shareResult.Hdr.Rc == 0) { FileApi fileApi = new FileApi(session.GetApiClient()); ViewFileResult viewFileResult = fileApi.ViewFile(fileRecord.Key); if (viewFileResult.Hdr.Rc == 0) { fileRecord = viewFileResult.File; } else { throw new Exception("Vmoso error getting created link. Rc=" + viewFileResult.Hdr.Rc); } } else { throw new Exception("Vmoso error sharing link. Rc=" + shareResult.Hdr.Rc); } } ShareFileItem item = new ShareFileItem(fileRecord.Name, fileRecord.Description); item.Key = fileRecord.Key; item.FileInfo = fileInfo; item.SetIcon(icon); item.Record = fileRecord; List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in fileRecord.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } catch (Exception ex) { throw new Exception("Error creating file", ex); } }
public ShareLinkItem createBookmarkAsDocument(Uri link, String title, String description, List <String> spaceKeys, Bitmap icon) { try { DocumentApi documentApi = new DocumentApi(session.GetApiClient()); LinkV2Record linkRecord = new LinkV2Record(); linkRecord.Link = link.ToString(); linkRecord.Title = title; linkRecord.Text = description; linkRecord.Type = "link"; CreateDocumentInput createDocumentInput = new CreateDocumentInput(linkRecord); CreateDocumentResult createDocumentResult = documentApi.CreateDocument(createDocumentInput); if (createDocumentResult.Hdr.Rc == 0) { DocumentV2Record createdDocument = createDocumentResult.Document; LinkV2Record createdLink = null; if (spaceKeys != null) { SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(createdDocument.Key, shareInput); if (shareResult.Hdr.Rc == 0) { LinkApi linkApi = new LinkApi(session.GetApiClient()); GetLinkResult getLinkResult = linkApi.GetLink(createdDocument.Key); if (getLinkResult.Hdr.Rc == 0) { createdLink = getLinkResult.Link; } else { throw new Exception("Vmoso error getting created link. Rc=" + getLinkResult.Hdr.Rc); } } else { throw new Exception("Vmoso error sharing link. Rc=" + shareResult.Hdr.Rc); } } ShareLinkItem item = new ShareLinkItem(createdLink.Title, createdLink.Text); item.Key = createdLink.Key; item.Link = new Uri(createdLink.Link); item.Record = createdLink; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in createdLink.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error creating link. Rc=" + createDocumentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso error creating link", ex); } }
public ShareLinkItem updateBookmark(String key, Uri link, String title, String description, List <String> spaceKeys, Bitmap icon) { try { LinkApi linkApi = new LinkApi(session.GetApiClient()); DocumentApi documentApi = new DocumentApi(session.GetApiClient()); GetLinkResult getLinkResult = linkApi.GetLink(key); if (getLinkResult.Hdr.Rc == 0) { LinkV2Record existingLink = getLinkResult.Link; existingLink.Link = link.ToString(); existingLink.Title = title; existingLink.Text = description; existingLink.Type = "link"; //UpdateLinkInput updateLinkInput = new UpdateLinkInput(existingLink); //UpdateLinkResult updateLinkResult = linkApi.UpdateLink(key, updateLinkInput); UpdateDocumentInput updateDocumentInput = new UpdateDocumentInput(existingLink); UpdateDocumentResult updateDocumentResult = documentApi.UpdateDocument(key, updateDocumentInput); if (updateDocumentResult.Hdr.Rc == 0) { DocumentV2Record updatedDocument = updateDocumentResult.Document; SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); // Remove spaces foreach (DisplayRecord destination in updatedDocument.Destinations) { if (!spaceKeys.Contains(destination.Key)) { List <String> itemKeysToRemove = new List <String>() { updatedDocument.Key }; RemoveObjectsInput removeObjectsInput = new RemoveObjectsInput(destination.Key, itemKeysToRemove); RemoveObjectsResult removeObjectsResult = spaceApi.RemoveObjects(destination.Key, removeObjectsInput); if (removeObjectsResult.Hdr.Rc != 0) { throw new Exception("Vmoso error removing bookmark from space. Rc=" + removeObjectsResult.Hdr.Rc); } } else { spaceKeys.Remove(destination.Key); } } if (spaceKeys.Count > 0) { ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(updatedDocument.Key, shareInput); if (shareResult.Hdr.Rc != 0) { throw new Exception("Vmoso error sharing bookmark. Rc=" + shareResult.Hdr.Rc); } } getLinkResult = linkApi.GetLink(updatedDocument.Key); if (getLinkResult.Hdr.Rc == 0) { LinkV2Record updatedLink = getLinkResult.Link; ShareLinkItem item = new ShareLinkItem(updatedLink.Title, updatedLink.Text); item.Key = updatedLink.Key; item.Link = new Uri(updatedLink.Link); item.Record = updatedLink; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in updatedLink.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error getting updated link. Rc=" + getLinkResult.Hdr.Rc); } } else { throw new Exception("Vmoso error updating link. Rc=" + updateDocumentResult.Hdr.Rc); } } else { throw new Exception("Vmoso error getting link to update. Rc=" + getLinkResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso error getting link to update", ex); } }
public ShareFileItem updateFile(String key, FileInfo fileInfo, String title, String description, List <String> spaceKeys, Bitmap icon) { try { FileApi fileApi = new FileApi(session.GetApiClient()); ViewFileResult viewFileResult = fileApi.ViewFile(key); if (viewFileResult.Hdr.Rc == 0) { FileRecord existingFile = viewFileResult.File; existingFile.Name = title; existingFile.Description = description; UpdateFileInput updateFileInput = new UpdateFileInput(existingFile, null); UpdateFileResult updateFileResult = fileApi.UpdateFile(key, updateFileInput); if (updateFileResult.Hdr.Rc == 0) { FileRecord updatedFile = updateFileResult.Updated; SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); // Remove spaces foreach (DisplayRecord destination in updatedFile.Destinations) { if (!spaceKeys.Contains(destination.Key)) { List <String> itemKeysToRemove = new List <String>() { updatedFile.Key }; RemoveObjectsInput removeObjectsInput = new RemoveObjectsInput(destination.Key, itemKeysToRemove); RemoveObjectsResult removeObjectsResult = spaceApi.RemoveObjects(destination.Key, removeObjectsInput); if (removeObjectsResult.Hdr.Rc != 0) { throw new Exception("Vmoso error removing file from space. Rc=" + removeObjectsResult.Hdr.Rc); } } else { spaceKeys.Remove(destination.Key); } } if (spaceKeys.Count > 0) { ShareObjectInput shareInput = new ShareObjectInput(null, spaceKeys, null); ShareObjectResult shareResult = spaceApi.ShareObject(updatedFile.Key, shareInput); if (shareResult.Hdr.Rc != 0) { throw new Exception("Vmoso error sharing file. Rc=" + shareResult.Hdr.Rc); } } viewFileResult = fileApi.ViewFile(updatedFile.Key); if (viewFileResult.Hdr.Rc == 0) { updatedFile = viewFileResult.File; ShareFileItem item = new ShareFileItem(updatedFile.Name, updatedFile.Description); item.Key = updatedFile.Key; item.FileInfo = fileInfo; item.Record = updatedFile; item.SetIcon(icon); List <ShareSpace> itemSpaces = new List <ShareSpace>(); foreach (DisplayRecord spaceDisplayRecord in updatedFile.Destinations) { ShareSpace space = new ShareSpace(spaceDisplayRecord.Key, spaceDisplayRecord.DisplayName, null); itemSpaces.Add(space); } item.Spaces = itemSpaces; return(item); } else { throw new Exception("Vmoso error getting updated file. Rc=" + viewFileResult.Hdr.Rc); } } else { throw new Exception("Vmoso error updating file. Rc=" + updateFileResult.Hdr.Rc); } } else { throw new Exception("Vmoso error getting file to update. Rc=" + viewFileResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Vmoso updating file", ex); } }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { AlbumApi = new AlbumApi(this); AnmmarApi = new AnmmarApi(this); AnnouncementApi = new AnnouncementApi(this); AssessmentsMessages = new AssessmentsMessages(this); AttendanceApi = new AttendanceApi(this); AuthorizationApi = new AuthorizationApi(this); BadgeApi = new BadgeApi(this); BehaviourApi = new BehaviourApi(this); CalendarApi = new CalendarApi(this); CertificateApi = new CertificateApi(this); ClassApi = new ClassApi(this); ConfigurationMangerApi = new ConfigurationMangerApi(this); CopyApi = new CopyApi(this); CourseApi = new CourseApi(this); CourseCatalogueApi = new CourseCatalogueApi(this); CourseGroupAuthors = new CourseGroupAuthors(this); CourseImageApi = new CourseImageApi(this); CourseRequestsApi = new CourseRequestsApi(this); CoursesProgress = new CoursesProgress(this); DiscussionApi = new DiscussionApi(this); EduShareApi = new EduShareApi(this); EvaluationApi = new EvaluationApi(this); EventApi = new EventApi(this); FileApi = new FileApi(this); FormsTemplatesApi = new FormsTemplatesApi(this); GradeApi = new GradeApi(this); GradeBookApi = new GradeBookApi(this); HelpApi = new HelpApi(this); IenApi = new IenApi(this); InvitationApi = new InvitationApi(this); InviteApi = new InviteApi(this); LanguageApi = new LanguageApi(this); LearningObjectivesApi = new LearningObjectivesApi(this); LearningPathApi = new LearningPathApi(this); LTILMSConsumerApi = new LTILMSConsumerApi(this); MaterialApi = new MaterialApi(this); MaterialSeenByUser = new MaterialSeenByUser(this); MembersApi = new MembersApi(this); MentorApi = new MentorApi(this); NotificationsApi = new NotificationsApi(this); OfferApi = new OfferApi(this); Office365 = new Office365(this); OfficeAddInApi = new OfficeAddInApi(this); Onenote = new Onenote(this); OrganizationUserAPI = new OrganizationUserAPI(this); OutcomesApi = new OutcomesApi(this); PointsApi = new PointsApi(this); PollApi = new PollApi(this); PrerequisitesApi = new PrerequisitesApi(this); QtiInteroperability = new QtiInteroperability(this); QuestionBankApi = new QuestionBankApi(this); ReflectionApi = new ReflectionApi(this); RelatedCoursesApi = new RelatedCoursesApi(this); ReportApi = new ReportApi(this); RoleManagementApi = new RoleManagementApi(this); ScheduleVisitApi = new ScheduleVisitApi(this); SchoolTypeApi = new SchoolTypeApi(this); SessionApi = new SessionApi(this); SpaceApi = new SpaceApi(this); StudentApi = new StudentApi(this); SubjectApi = new SubjectApi(this); SystemAdministrationApi = new SystemAdministrationApi(this); SystemReportsApi = new SystemReportsApi(this); TagsApi = new TagsApi(this); Themes = new Themes(this); TimeTableApi = new TimeTableApi(this); ToolConsumerProfileApi = new ToolConsumerProfileApi(this); TourApi = new TourApi(this); TrackApi = new TrackApi(this); TrainingPlanApi = new TrainingPlanApi(this); UserApi = new UserApi(this); UserProfileApi = new UserProfileApi(this); UserProgressApi = new UserProgressApi(this); UserSettingsApi = new UserSettingsApi(this); WallApi = new WallApi(this); BaseUri = new System.Uri("https://xwinji.azurewebsites.net"); SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); }