public Artifact(Artifact a) { this.repository = a.repository; this.uri = a.uri; this.versions = a.versions; if (System.IO.File.Exists(a.workingFile)) System.IO.File.Copy(a.workingFile, this.WorkingFileName); }
public IArtifact GetArtifactById( string id, string versionLabel ) { try { //Logger.LogMethod(); // enforce case rules Uri docUri = new Uri(Scheme + "://" + id); string key = docUri.Host + docUri.AbsolutePath; if( this.artifacts.ContainsKey( key ) ) { Artifact a = this.artifacts[ key ]; if( versionLabel != "" && a.VersionLabel != versionLabel ) { foreach( Artifact version in a.Versions ) { if( version.VersionLabel == versionLabel ) { return version; } } return null; } return a; } Proxy.NavigatorRef.Navigator navigator = Proxy.WebServiceController.GetNavigator( this.DefaultLibraryUrl ); if( navigator == null ) return null; Proxy.NavigatorRef.Item item = navigator.GetItem( docUri.OriginalString ); if( item == null ) return null; Artifact artifact = new Artifact( docUri, this ); this.AddArtifact( artifact ); return artifact; } catch( Exception ex ) { Logger.LogError( ex ); throw; } }
public void AddArtifact( Artifact a ) { try { //Logger.LogMethod(); if( this.artifacts.ContainsKey( a.Id ) ) this.artifacts.Remove( a.Id ); this.artifacts.Add( a.Id, a ); } catch( Exception ex ) { Logger.LogError( ex ); throw; } }
private Artifact BuildArtifact(Repository defaultRepository, Browser.BrowseDialog dlg) { Uri uri = new Uri(dlg.FileUrl); Repository selectedRepository = this.GetRepository(dlg.Url); selectedRepository = selectedRepository == null ? defaultRepository : selectedRepository; Artifact artifact = new Artifact(uri, selectedRepository); artifact.AddFieldRange(dlg.Fields); artifact.SetContentType(dlg.ContentType); selectedRepository.AddArtifact(artifact); return artifact; }
public void Add( Artifact a ) { this.artifacts.Add( a ); }
private static void SetVersionInfo(Artifact artifact, Proxy.UploaderRef.Uploader uploader, int version) { try { artifact.versionLabel = uploader.GetDocumentVersionString(artifact.uri.OriginalString, version); artifact.versionNumber = version; } catch (System.Exception ex) { Logger.LogError("Document library may have versioning disabled: Artifact ID = " + artifact.Id); Logger.LogError(ex); artifact.versionLabel = "1.0"; artifact.versionNumber = 0; } }
private void FetchVersions() { if (repository == null) return; try { //Logger.LogMethod(); Proxy.UploaderRef.Uploader uploader = Proxy.WebServiceController.GetUploader(repository.DefaultLibraryUrl); Artifact version = null; int versionCount = uploader.GetDocumentVersionCount(this.uri.OriginalString); for (int i = 0; i < versionCount; ++i) { version = new Artifact(this); SetVersionInfo(version, uploader, i); versions.Add(version); } if ((this.versionNumber == -1 || this.versionLabel == null) && version != null) { this.versionLabel = version.versionLabel; this.versionNumber = version.versionNumber; } } catch (Exception ex) { Logger.LogError(ex); } }
public IArtifact CreateNewVersion(string description, string availableFormats) { //Logger.LogMethod(); try { Proxy.UploaderRef.Uploader uploader = Proxy.WebServiceController.GetUploader(repository.DefaultLibraryUrl); if (!uploader.IsDocumentVersioningEnabledForWorkspace(this.uri.ToString())) throw new Exception("Versioning is not supported"); Artifact a = new Artifact(this); a.mode = Mode.NewVersion; a.versionNumber++; a.versions.Add(a); this.repository.AddArtifact(a); // causes this to be replaced by a return a; } catch (Exception ex) { Logger.LogError(ex); throw; } }