public VersionOperationResult GetVersions(string fileName) { if (DwsHelper.CheckVisitor()) { return(null); } var url = this.RequestUrl + "/" + fileName; var path = RepositoryPath.Combine(this.RequestPath, fileName); var file = Node.Load <GenericContent>(path); if (file == null) { return(null); } var list = file.ContentListId; VersionOperationResult vr = new VersionOperationResult(); vr.results = new VersionResults(); vr.results.list = new VersionResultsList(); vr.results.list.id = list == 0 ? string.Empty : list.ToString(); vr.results.settings = new VersionResultsSettings(); vr.results.settings.url = url; vr.results.versioning = new VersionResultsVersioning(); vr.results.versioning.enabled = file.VersioningMode > VersioningType.None ? (byte)1 : (byte)0; List <VersionData> versionData = new List <VersionData>(); foreach (var version in file.Versions) { var createdBy = version.CreatedBy as User; var fileVersion = version as File; VersionData vd = new VersionData(); vd.version = String.Format("{0}{1}.{2}", file.Version == version.Version ? "@" : String.Empty, version.Version.Major, version.Version.Minor); vd.url = url + "?version=" + version.Version; vd.created = version.CreationDate.ToString(); vd.createdRaw = version.CreationDate.ToString("yyyy-MM-ddThh:mm:ssZ"); vd.createdBy = createdBy == null ? string.Empty : createdBy.Username; vd.createdByName = createdBy == null ? string.Empty : createdBy.DisplayName; vd.size = fileVersion == null ? (ulong)0 : (ulong)fileVersion.Size; vd.comments = version.GetProperty <string>("CheckInComments") ?? string.Empty; versionData.Add(vd); } vr.results.result = versionData.ToArray(); return(vr); }
public VersionOperationResult GetVersions(string fileName) { if (DwsHelper.CheckVisitor() || string.IsNullOrEmpty(fileName)) { return(null); } var url = this.RequestUrl + "/" + fileName; var path = RepositoryPath.Combine(this.RequestPath, fileName); var file = Node.Load <GenericContent>(path); if (file == null) { // maybe it is a full path or url (Office 2013) instead of a name path = DwsHelper.GetPathFromUrl(fileName); file = Node.Load <GenericContent>(path); // re-set the url if (file != null) { var bUrl = file.BrowseUrl; var domain = new Uri(this.RequestUrl).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped); // remove query string parameters url = new Uri(domain + bUrl).GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.SafeUnescaped); } } if (file == null) { return(null); } var list = file.ContentListId; var vr = new VersionOperationResult(); vr.results = new VersionResults(); vr.results.list = new VersionResultsList(); vr.results.list.id = list == 0 ? string.Empty : list.ToString(); vr.results.settings = new VersionResultsSettings(); vr.results.settings.url = url; vr.results.versioning = new VersionResultsVersioning(); vr.results.versioning.enabled = file.VersioningMode > VersioningType.None ? (byte)1 : (byte)0; var versionData = new List <VersionData>(); foreach (var version in file.Versions) { var createdBy = version.VersionModifiedBy as User; var fileVersion = version as File; var vd = new VersionData(); vd.version = String.Format("{0}{1}.{2}", file.Version == version.Version ? "@" : String.Empty, version.Version.Major, version.Version.Minor); vd.url = url + "?version=" + version.Version; vd.created = version.VersionCreationDate.ToString(); vd.createdRaw = version.VersionCreationDate.ToString("yyyy-MM-ddThh:mm:ssZ"); vd.createdBy = createdBy == null ? string.Empty : createdBy.Username; vd.createdByName = createdBy == null ? string.Empty : createdBy.DisplayName; vd.size = fileVersion == null ? (ulong)0 : (ulong)fileVersion.Size; vd.comments = version.GetProperty <string>("CheckInComments") ?? string.Empty; versionData.Add(vd); } vr.results.result = versionData.ToArray(); return(vr); }
public VersionOperationResult GetVersions(string fileName) { if (DwsHelper.CheckVisitor()) return null; var url = this.RequestUrl + "/" + fileName; var path = RepositoryPath.Combine(this.RequestPath, fileName); var file = Node.Load<GenericContent>(path); if (file == null) return null; var list = file.ContentListId; VersionOperationResult vr = new VersionOperationResult(); vr.results = new VersionResults(); vr.results.list = new VersionResultsList(); vr.results.list.id = list == 0 ? string.Empty : list.ToString(); vr.results.settings = new VersionResultsSettings(); vr.results.settings.url = url; vr.results.versioning = new VersionResultsVersioning(); vr.results.versioning.enabled = file.VersioningMode > VersioningType.None ? (byte)1 : (byte)0; List<VersionData> versionData = new List<VersionData>(); foreach (var version in file.Versions) { var createdBy = version.CreatedBy as User; var fileVersion = version as File; VersionData vd = new VersionData(); vd.version = String.Format("{0}{1}.{2}", file.Version == version.Version ? "@" : String.Empty, version.Version.Major, version.Version.Minor); vd.url = url + "?version=" + version.Version; vd.created = version.CreationDate.ToString(); vd.createdRaw = version.CreationDate.ToString("yyyy-MM-ddThh:mm:ssZ"); vd.createdBy = createdBy == null ? string.Empty : createdBy.Username; vd.createdByName = createdBy == null ? string.Empty : createdBy.DisplayName; vd.size = fileVersion == null ? (ulong)0 : (ulong)fileVersion.Size; vd.comments = version.GetProperty<string>("CheckInComments") ?? string.Empty; versionData.Add(vd); } vr.results.result = versionData.ToArray(); return vr; }