public Document ImportDocumentAsNewVersion(Document doc, Stream contentStream, String mimeType, GenericOptions checkinOptions) { Feed <OutlineAtomContent> versions = doc.GetAllVersions <OutlineAtomContent>(null); List <Entry <OutlineAtomContent> > entries = versions.Entries; // If the document is not already checked out, check it out. if (!doc.IsCheckedOut()) { doc = doc.Checkout(); } Document checkinDoc = NewDocument(doc.GetPropertyValue("object_name").ToString()); if (!checkinOptions.ContainsParam("format")) { checkinOptions.SetQuery("format", doc.GetPropertyValue("a_content_type")); } if (!checkinOptions.ContainsParam("page")) { checkinOptions.SetQuery("page", 0); } if (!checkinOptions.ContainsParam("primary")) { checkinOptions.SetQuery("primary", true); } return(doc.CheckinMinor(doc, contentStream, mimeType, checkinOptions)); }
/// <summary> /// /// </summary> /// <param name="doc"></param> /// <param name="file"></param> /// <returns>RestDocument</returns> public Document ImportDocumentAsNewVersion(Document doc, FileInfo file) { GenericOptions checkinOptions = new GenericOptions(); checkinOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile(file.Name)); checkinOptions.SetQuery("page", 0); checkinOptions.SetQuery("primary", true); checkinOptions.SetQuery("version-label", "ImportAsNewVersion"); return(ImportDocumentAsNewVersion(doc, file.OpenRead(), ObjectUtil.getMimeTypeFromFileName(file.Name), checkinOptions)); }
protected void CreateRendition(int page, bool isPrimary) { List <string> idsWithRenditions = new List <string>(); List <DocumentTracker> newList = new List <DocumentTracker>(Tracker); double moveCount = Math.Ceiling(newList.Count * .30); for (int a = 0; a < moveCount; a++) { DocumentTracker aDoc = ObjectUtil.getRandomObjectFromList <DocumentTracker>(newList); // Make sure we do not use this again newList.Remove(aDoc); String objectId = aDoc.DocumentId; Document doc = CurrentRepository.GetSysObjectById <Document>(objectId); //getDocumentByQualification( //String.Format("dm_document where r_object_id = '{0}'", objectId), null); FileInfo file = ObjectUtil.getRandomFileFromDirectory(importFilesDirectory); String mimeType = ObjectUtil.getMimeTypeFromFileName(file.Name); // Upload the content as a new rendition GenericOptions rendOptions = new GenericOptions(); String format = ObjectUtil.getDocumentumFormatForFile(file.Extension); rendOptions.SetQuery("format", format); rendOptions.SetQuery("page", page); // If you want to allow multiple renditions of the same format, the modifier must be set, this makes the rendition unique in the list // the "modifier" is more like a label/tag for the rendition in the list. rendOptions.SetQuery("modifier", "Test"); // With primary false, will be added as a rendition rendOptions.SetQuery("primary", isPrimary); ContentMeta renditionMeta = doc.CreateContent(file.OpenRead(), mimeType, rendOptions); Feed <ContentMeta> contents = doc.GetContents <ContentMeta>(new FeedGetOptions { Inline = true }); List <Entry <ContentMeta> > entries = (List <Entry <ContentMeta> >)contents.Entries; WriteOutput("\t\t[AddRendition] - Rendition Added for RestDocument ID: " + doc.GetPropertyValue("r_object_id") + ":" + doc.GetPropertyValue("object_name")); foreach (Entry <ContentMeta> entry in entries) { ContentMeta rendition = entry.Content; WriteOutput("\t\t\tRendition Format: " + rendition.GetPropertyValue("full_format") + " Modifier: " + rendition.GetRepeatingString("page_modifier", 0)); //((Object[])rendition.getAttributeValue("page_modifier"))[0].ToString()); } idsWithRenditions.Add(objectId); } IDsWithRenditions = idsWithRenditions; }
private void SetModifier(GenericOptions options, string modifier) { if (!String.IsNullOrEmpty(modifier)) { options.SetQuery("modifier", modifier); } }
private void SetMediaUrlPolicy(GenericOptions options) { if (!options.ContainsParam(MEDIA_URL_POLICY)) { options.SetQuery(MEDIA_URL_POLICY, "all"); } }
/// <summary> /// /// </summary> /// <param name="repositoryUri"></param> /// <param name="newObj"></param> /// <param name="otherPartStream"></param> /// <param name="otherPartMime"></param> /// <param name="options"></param> /// <returns></returns> public EmailPackage ImportEmail(Document newObj, Stream otherPartStream, string otherPartMime, GenericOptions options) { Dictionary <Stream, string> otherParts = new Dictionary <Stream, string>(); otherParts.Add(otherPartStream, otherPartMime); options.SetQuery("folderId", this.GetPropertyValue("r_object_id")); Feed <Document> feed = Client.Post <Document, Feed <Document> >( Client.RepositoryBaseUri + LinkRelations.EMAILIMPORT, newObj, otherParts, options); return(ObjectUtil.getFeedAsEmailPackage(feed)); }
/// <summary> /// Called by CreateTempDocs in order to create parent/child folders and randomly move documents to parent/child folders. /// </summary> /// <param name="tracker"></param> protected void MoveToFolders() { //WriteOutput("Getting the holding folder for documents prior to Parent/Child movement..."); Folder tempFolder = CurrentRepository.GetFolderByQualification("dm_folder where any r_folder_path = '" + tempPath + "'", new FeedGetOptions { Inline = true, Links = true }); WriteOutput("\tMoveing Documents from folder: " + tempFolder.GetPropertyValue("object_name")); foreach (DocumentTracker trackerDoc in Tracker) { String parentFolderId = trackerDoc.ParentId; String childId = trackerDoc.ChildId; //WriteOutput("Getting the Parent/Child movement folder..."); String movePath = ProcessBasePath + trackerDoc.getPath(); // Our parentFolder/child tracker for doing record declaration later addSupportingDoc(movePath); Folder destinationDir = CurrentRepository.GetOrCreateFolderByPath(movePath); Document docToCopy = CurrentRepository.GetSysObjectById <Document>(trackerDoc.DocumentId); // getDocumentByQualification("dm_document where r_object_id = '" //+ trackerDoc.DocumentId + "'", new FeedGetOptions { Inline = true, Links = true }); // To copy the document, we need to get a reference object CheckDuplicates(docToCopy, ProcessBasePath + trackerDoc.getPath()); Document copiedDoc = destinationDir.CreateSubObject <Document>(docToCopy.CreateCopyObject <Document>(), null); WriteOutput("\t[CopyDocument] - Moveed RestDocument: " + copiedDoc.GetPropertyValue("object_name") + " ID:" + trackerDoc.DocumentId + " to " + ProcessBasePath + trackerDoc.getPath()); // Update the trackerDocumentId to the newly copied document trackerDoc.DocumentId = copiedDoc.GetPropertyValue("r_object_id").ToString(); } // Delete our temp folder GenericOptions options = new GenericOptions(); options.SetQuery("del-non-empty", true); options.SetQuery("del-all-links", true); tempFolder.Delete(options); WriteOutput("[DeleteFolderAndContents] - Deleted the holding folder and documents"); }
public D2Document ImportNewD2Document(FileInfo file, string documentName, string repositoryPath, D2Configuration d2config) { //if (!repositoryPath.StartsWith("/")) throw new Exception("Repository path " + repositoryPath + " is not valid." // + " The path must be a fully qualified path"); //Folder importFolder = getOrCreateFolderByPath(repositoryPath); //if (importFolder == null) throw new Exception("Unable to fetch or create folder by path: " + repositoryPath); D2Document newDocument = new D2Document(); newDocument.SetPropertyValue("object_name", documentName); newDocument.SetPropertyValue("r_object_type", "dm_document"); if (d2config != null) { newDocument.Configuration = d2config; } GenericOptions importOptions = new GenericOptions(); importOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile(file.Extension)); D2Document created = ImportD2DocumentWithContent(newDocument, file.OpenRead(), ObjectUtil.getMimeTypeFromFileName(file.Name), importOptions); return(created); }
/// <summary> /// Imports an email into the system /// </summary> /// <param name="file"></param> /// <param name="documentName"></param> /// <param name="repositoryPath"></param> /// <returns>EmailPackage</returns> public EmailPackage ImportEmail(FileInfo file, string documentName, string repositoryPath) { if (!repositoryPath.StartsWith("/")) { throw new Exception("Repository path " + repositoryPath + " is not valid." + " The path must be a fully qualified path"); } Folder importFolder = GetOrCreateFolderByPath(repositoryPath); if (importFolder == null) { throw new Exception("Unable to fetch or create folder by path: " + repositoryPath); } Document newDocument = NewDocument(documentName, DocumentType); GenericOptions importOptions = new GenericOptions(); importOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile(file.Extension)); EmailPackage email = importFolder.ImportEmail(newDocument, file.OpenRead(), ObjectUtil.getMimeTypeFromFileName(file.Name), importOptions); return(email); }
private void Temp() { if (CurrentRepository.isD2Rest()) { /* Get D2 Configs */ D2Configurations d2configs = CurrentRepository.GetD2Configurations(null); /* Get the Search Configurations from D2 Config */ SearchConfigurations searchConfigs = d2configs.getSearchConfigurations(); int i = 0; for (i = 0; i < searchConfigs.Entries.Count; i++) { /* For Each Search configuration, get the entry link */ SearchConfigLink scl = searchConfigs.Entries[i]; //Console.WriteLine("SearchConfigTitle=" + scl.title + ", SearchConfigId=" + scl.id + " LinkSrc: " + scl.content.Src); /* Ouput SearchConfiguration information for each SearchConfigLink */ SearchConfiguration sc = searchConfigs.getSearchConfiguration(scl.content.Src); //Console.WriteLine(sc.ToString()); } /* Get the Profile Configurations from D2 Config */ ProfileConfigurations profileConfigs = d2configs.getProfileConfigurations(); i = 0; // for (i=0; i < profileConfigs.Entries.Count; i++) //{ /* For each profile configuraton get the entry link */ ProfileConfigLink pcl = profileConfigs.Entries[i]; //Console.WriteLine("\n\nProfileConfigTitle=" + pcl.title + ", ProfileConfigId=" + pcl.id + " LinkSrc: " + pcl.content.Src); /* Output ProfileConfiguration information for each ProfileConfigLink */ ProfileConfiguration pc = profileConfigs.getProfileConfiguration(pcl.content.Src); //Console.WriteLine(pc.ToString()); D2Document d2doc = new D2Document(); d2doc.SetPropertyValue("object_name", "D2-ConfigTst-" + DateTime.Now.Ticks); d2doc.SetPropertyValue("primary_bus_owner", "Rest"); d2doc.SetPropertyValue("template_developers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("comm_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("business_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("compliance_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("brand_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("legal_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("ada_reviewers", new String[] { "dmadmin" }); d2doc.SetPropertyValue("template_admins", new String[] { "dmadmin" }); d2doc.SetPropertyValue("form_type", "ACT"); d2doc.SetPropertyValue("form_subtype", "Alternate Loan Notice"); d2doc.SetPropertyValue("document_subject", "Automatic payment"); d2doc.SetPropertyValue("requester", "dmadmin"); d2doc.SetPropertyValue("r_object_type", "wf_form_template"); d2doc.SetPropertyValue("r_is_virtual_doc", Convert.ToInt32(true)); d2doc.SetPropertyValue("import_archive", false); d2doc.SetPropertyValue("a_status", "Revise"); d2doc.SetPropertyValue("merge_needed", true); d2doc.SetPropertyValue("system_ver_available", true); D2Configuration d2config = new D2Configuration(); d2config.LifeCycle = "WF Template Lifecycle"; d2config.StartVersion = 0.5d; // This was an attempt to figure out what the properties_string/properties_xml properties that d2-config has. It was a fail // so will have to wait for documentation to update to reflect what these do. //d2config.PropertiesString = "title=BLAHBLAHBLAH"; d2doc.Configuration = d2config; GenericOptions importOptions = new GenericOptions(); importOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile("RestDotNetFramework.docx")); d2doc = CurrentRepository.ImportD2DocumentWithContent(d2doc, new FileInfo(@"C:\SamplesToImport\RestDotNetFramework.docx") .OpenRead(), ObjectUtil.getMimeTypeFromFileName("RestDotNetFramework.docx"), importOptions); if (d2doc != null) { Console.WriteLine("\n\nNew D2Document: \n" + d2doc.ToString()); } else { Console.WriteLine("Creation failed!"); } Console.WriteLine("=================================================================================="); Console.WriteLine("TaskList Basic Info:"); Feed <D2Task> taskFeed = CurrentRepository.GetD2TaskList(); List <D2Task> tasks = ObjectUtil.getFeedAsList(taskFeed); int taskNum = 0; foreach (D2Task task in tasks) { taskNum++; Console.WriteLine("TASK #" + taskNum + "-------------------------------------------------"); Console.WriteLine("\tTaskSubject: " + task.TaskSubject + " TaskInstructions: " + task.TaskInstructions); Console.WriteLine("\tForward Tasks: "); foreach (String key in task.TaskRequirements.ForwardTasks.Keys) { Console.WriteLine("\t\t" + "TaskName: " + key + " TaskId" + task.TaskRequirements.ForwardTasks[key]); } } Console.ReadLine(); } }
private void SetFormat(GenericOptions options, string format) { options.SetQuery("format", format); }