public void DocumentSetCreationEnumerableTest() { var initializeSet = new Document[] { new Document("doc1"), new Document("doc2") }; _ = new DocumentSet(initializeSet); Assert.True(true); }
public void DocumentSetCreationParamsSingleTest() { var doc1 = new Document("doc1"); var documentSet = new DocumentSet(doc1); Assert.True(documentSet.Has(doc1)); }
public SPDocumentSetInstance AddDocumentSet(string name, object contentType, [DefaultParameterValue(null)] object properties, [DefaultParameterValue(true)] bool provisionDefaultContent) { var contentTypeId = SPContentTypeId.Empty; if (contentType is SPContentTypeIdInstance) { contentTypeId = (contentType as SPContentTypeIdInstance).ContentTypeId; } else if (contentType is SPContentTypeInstance) { contentTypeId = (contentType as SPContentTypeInstance).ContentType.Id; } else if (contentType is string) { contentTypeId = new SPContentTypeId(contentType as string); } if (contentTypeId == SPContentTypeId.Empty) { return(null); } var htProperties = SPHelper.GetFieldValuesHashtableFromPropertyObject(properties); var docSet = DocumentSet.Create(m_folder, name, contentTypeId, htProperties, provisionDefaultContent); return(new SPDocumentSetInstance(Engine.Object.InstancePrototype, null, null, docSet)); }
protected IXPathNavigable LoadContextItem(DocumentSet documentSet, ITaskItem input) { try { Log.LogMessage(MessageImportance.Low, Resources.SettingContextItem, input.ItemSpec); //TODO: use AnyURI when it supports windows paths var inputUri = new Uri(input.GetMetadata("FullPath")); var navigable = documentSet.Document(new AnyUri(inputUri)); return(navigable == null ? null : navigable.CreateNavigator()); } catch (XmlException ex) { Log.LogErrorFromException(ex, false, true, ex.SourceUri); return(null); } catch (ArgumentException ex) { Log.LogErrorFromException(ex, false, true, null); return(null); } catch (InvalidOperationException ex) { Log.LogErrorFromException(ex, false, true, null); return(null); } }
public string CreateDocumentSet(ClientContext ctx, List list, string title, bool autoDetectDocumentSetContentType, string contentTypeId = "") { var rootFolder = list.RootFolder; ContentType documentSetContentType = null; if (autoDetectDocumentSetContentType) { var contentTypes = list.ContentTypes; ctx.Load(contentTypes); ctx.ExecuteQueryWithIncrementalRetry(); if (!CanAutoDetectDocumentSetContentType(contentTypes)) { throw new Exception("Could not detect a unique Document Set Content Type. Try to use the Content Type Id Param instead"); } documentSetContentType = contentTypes.Single(x => x.Id.StringValue.StartsWith(DOCUMENT_SET_CONTENT_TYPE_START_ID)); } else { documentSetContentType = list.ContentTypes.GetById(contentTypeId); ctx.Load(documentSetContentType); ctx.ExecuteQueryWithIncrementalRetry(); } var result = DocumentSet.Create(ctx, rootFolder, title, documentSetContentType.Id); ctx.ExecuteQueryWithIncrementalRetry(); if (!String.IsNullOrEmpty(result.Value)) { return(result.Value); } return(null); }
public void DocumentSetEqualTwoEmptyTest() { var docSet1 = new DocumentSet(); var docSet2 = new DocumentSet(); Assert.Equal(docSet1, docSet2); }
public void AdvancedQueryAndOneNotExistingWordTest() { var expected = new DocumentSet(); var actual = engine.AdvancedSearch("test"); Assert.Equal(expected, actual); }
public static IList <string> selectedGroupNames = new List <string>(); //选择的组列表 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { try { ////check domain //if (ADValidationCheck.GetDirectoryEntryForCurrentUser() == null) //{ // TaskDialog.Show("信息", "需要连接goa网络。"); // return Result.Failed; //} APP.UIApp = commandData.Application; UIApplication uiapp = commandData.Application; Application app = uiapp.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; Selection sel = uidoc.Selection; View activeView = doc.ActiveView; ElementId activeViewId = activeView.Id; //获取所有文档列表 documentSet = app.Documents;//为已经打开的文档文件 if (documentSet.Size > 1) { foreach (Document document in documentSet)//获取所有的打开文档的标题列表 { string docName = document.Title; //TaskDialog.Show("Revit", docNmae); openFileNames.Add(docName); } //check opened window MainWindow form = APP.MainWindow; if (null != form && form.Visible == true) { form.Activate(); return(Result.Succeeded); } //show new window var p = Process.GetCurrentProcess(); var revitWindow = new WindowHandle(p.MainWindowHandle); if (null == form || form.IsDisposed) { form = new MainWindow(uidoc); } APP.MainWindow = form; form.Show(revitWindow); } else { TaskDialog.Show("Revit", "当前打开的Reivt文件只有一个,无法执行该插件。"); } } catch (Exception ex) { UserMessages.ShowErrorMessage(ex, null); } return(Result.Succeeded); }// excute
public SPDocumentSetInstance(ObjectInstance prototype, SPSite site, SPWeb web, DocumentSet documentSet) : this(prototype) { this.m_site = site; this.m_web = web; this.m_documentSet = documentSet; }
protected override void ExecuteCmdlet() { var list = List.GetListOrThrow(nameof(List), CurrentWeb, l => l.RootFolder, l => l.ContentTypes); var listContentType = ContentType.GetContentType(list); if (listContentType is null) { var siteContentType = ContentType.GetContentTypeOrThrow(nameof(ContentType), CurrentWeb); listContentType = new ContentTypePipeBind(siteContentType.Name).GetContentTypeOrThrow(nameof(ContentType), list); } listContentType.EnsureProperty(ct => ct.StringId); if (!listContentType.StringId.StartsWith("0x0120D520")) { throw new PSArgumentException($"Content type '{ContentType}' does not inherit from the base Document Set content type. Document Set content type IDs start with 0x120D520"); } // Create the document set var result = DocumentSet.Create(ClientContext, list.RootFolder, Name, listContentType.Id); ClientContext.ExecuteQueryRetry(); WriteObject(result.Value); }
public SPDocumentSetInstance Construct(object obj) { SPSite site = null; SPWeb web = null; DocumentSet result; if (obj is SPFolderInstance) { var folderInstance = obj as SPFolderInstance; result = DocumentSet.GetDocumentSet(folderInstance.Folder); } else if (obj is string) { var url = obj as string; SPFolder folder; if (SPHelper.TryGetSPFolder(url, out site, out web, out folder) == false) { throw new JavaScriptException(this.Engine, "Error", "No documentSet is available at the specified url."); } result = DocumentSet.GetDocumentSet(folder); } else { throw new JavaScriptException(this.Engine, "Error", "Cannot create a document set with the specified object: " + TypeConverter.ToString(obj)); } return(new SPDocumentSetInstance(this.InstancePrototype, site, web, result)); }
public void AdvancedQueryORTwoWordsFullSetTest() { var expected = new DocumentSet(buyCar, repairBuyCar, repairCar, buyBike, repairBike); var actual = engine.AdvancedSearch("+bike", "+car"); Assert.Equal(expected, actual); }
public void WithDocumentRemoved() { var doc1 = CreateSnapshot("col1/doc1"); var doc2 = CreateSnapshot("col1/doc2"); var doc3 = CreateSnapshot("col1/doc3"); // First create a set with 2 documents (doc1, doc2 and doc3) var set3 = DocumentSet.Empty(PathComparer.Instance) .WithDocumentAdded(doc1) .WithDocumentAdded(doc2) .WithDocumentAdded(doc3); // Now remove doc2 var set2 = set3.WithDocumentRemoved(doc2.Reference); // This shouldn't have modified the existing set Assert.Equal(3, set3.Count); Assert.Equal(new[] { doc1, doc2, doc3 }, set3.ToList()); // But the new set should only have two documents, still in order Assert.Equal(2, set2.Count); Assert.Equal(new[] { doc1, doc3 }, set2.ToList()); Assert.Equal(0, set2.IndexOf(doc1.Reference)); Assert.Equal(1, set2.IndexOf(doc3.Reference)); Assert.True(set2.TryGetDocument(doc1.Reference, out var result)); Assert.Same(doc1, result); Assert.False(set2.TryGetDocument(doc2.Reference, out result)); Assert.Null(result); Assert.True(set2.TryGetDocument(doc3.Reference, out result)); Assert.Same(doc3, result); // Trying to remove doc2 again should give the same reference back Assert.Same(set2, set2.WithDocumentRemoved(doc2.Reference)); }
private void Approve(CommandDocumentation model, CommandLineHelpConfiguration?configuration = null) { var pathProvider = new DefaultCommandLineHelpPathProvider(); var documentSet = new DocumentSet <IDocument>(); configuration ??= new ConfigurationProvider().GetDefaultCommandLineHelpConfiguration(); var commandPage = new CommandPage(documentSet, pathProvider, model, configuration); // add dummy application page and command page itself to document set // because command page will create a link to the application page // which would fail otherwise documentSet.Add(pathProvider.GetPath(model.Application), new TextDocument()); documentSet.Add(pathProvider.GetPath(model), commandPage); var doc = commandPage.GetDocument(); Assert.NotNull(doc); var markdown = doc.ToString(); var writer = new ApprovalTextWriter(markdown); Approvals.Verify(writer, new ApprovalNamer(relativeOutputDirectory: "../../../_referenceResults"), Approvals.GetReporter()); }
public void AdvancedQueryAndCarTest() { var expected = new DocumentSet(buyCar, repairBuyCar, repairCar); var actual = engine.AdvancedSearch("car"); Assert.Equal(expected, actual); }
public void AdvancedQueryNotOneWordTest() { var expected = new DocumentSet(); var actual = engine.AdvancedSearch("-bike"); Assert.Equal(expected, actual); }
/// <summary> /// Retrieve and return all linked-in IFC documents. /// </summary> public static List <Document> GetLinkedInIfcDocs( Application app) { List <Document> ifcdocs = null; DocumentSet docs = app.Documents; int n = docs.Size; JtLogger.Log(string.Format( "{0} open document{1}", n, Util.PluralSuffix(n))); foreach (Document d in docs) { string s = d.PathName; if (s.EndsWith(".ifc.RVT")) { if (null == ifcdocs) { ifcdocs = new List <Document>(); } ifcdocs.Add(d); } } return(ifcdocs); }
public void Execute(UIApplication app) { try { if (null != currentConfig) { DocumentSet docSet = app.Application.Documents; foreach (Document doc in docSet) { if (doc.IsWorkshared) { string centralPath = FileInfoUtil.GetCentralFilePath(doc); var fileFound = from file in currentConfig.files where file.centralPath.ToLower() == centralPath.ToLower() select file; if (fileFound.Count() > 0) { //apply config MessageBoxResult msgResult = MessageBox.Show("Configuration has been changed.\n" + centralPath, socketMessage, MessageBoxButton.OKCancel, MessageBoxImage.Question); if (msgResult == MessageBoxResult.OK) { ApplyConfiguration(doc, centralPath); } } } } } } catch (Exception ex) { string message = ex.Message; } }
public override void TreeToTreeTransform() { if (sourceDocument != null) { XdmNavigator contextItem = sourceDocument.CreateNavigator(); var documentSet = new DocumentSet(nameTable, stylesheet.InputSettings, schemaAware ? documentResolverSchemaAware : documentResolver, null, resourceResolver); DynamicContextSettings settings = new DynamicContextSettings(); settings.ContextItem = contextItem; settings.DocumentSet = documentSet; //DynamicContextSettings settings = new DynamicContextSettings { ContextItem = contextItem }; using (XdmDocumentWriter writer = XdmDocumentWriter.Create()) { stylesheet.ApplyTemplates(settings, writer); resultDocument = writer.Document; } } else { var documentSet = new DocumentSet(nameTable, stylesheet.InputSettings, documentResolver, null, resourceResolver); DynamicContextSettings settings = new DynamicContextSettings { DocumentSet = documentSet }; XmlQualifiedName qname = new XmlQualifiedName("main"); using (XdmDocumentWriter writer = XdmDocumentWriter.Create()) { stylesheet.CallTemplate(qname, settings, writer); resultDocument = writer.Document; } } }
public static bool IsDocumentSetItem(this SPListItem item) { bool documentSetItem = false; try { DocumentSet documentSet = null; if (null != item && null != item.File) { documentSet = DocumentSet.GetDocumentSet(item.File.ParentFolder); if (documentSet != null && documentSet.ContentType != null) { if (documentSet.ContentType.Id.IsChildOf(SPBuiltInContentTypeId.DocumentSet)) { documentSetItem = true; } } } } catch (NullReferenceException nullEx) { //TODO: Find a better way to do this //if our content type is null, then we are likely dealing with a document library //so we'll swallow this here } return(documentSetItem); }
public async Task <TrainingResults> Train(DocumentSet documentSet, TrainingHeader header, CancellationToken token) { Guard.NotNull(() => documentSet, documentSet); Guard.NotNull(() => header, header); Guard.NotNull(() => documentSet.Document, documentSet.Document); log.Debug("Train with {0} - {1}", documentSet.Document.Length, header); using (PerformanceTrace.Info(log, "Training...")) { var arff = CreateDataset(documentSet, token); if (arff == null) { throw new LearningException("Not enough documents to learn patterns"); } arff.CompactHeader(3); arff.CompactReviews(3); arff.CompactClass(3); if (arff.TotalDocuments < 10) { throw new LearningException("Not enough documents to learn patterns"); } token.ThrowIfCancellationRequested(); arff.Normalize(header.Normalization); SvmTrainClient train = new SvmTrainClient(arff); var model = await train.Train(header, token).ConfigureAwait(false); return(model); } }
public override void FileToFileTransform(Uri sourceUri, string resultFileLocation) { if (sourceUri != null) { using (XmlReader reader = XmlReader.Create(sourceUri.ToString(), schemaAware ? xmlReaderSettingsSchemaAware : xmlReaderSettings)) { document = new XdmDocument(reader, XmlSpace.Preserve); reader.Close(); } XdmNavigator contextItem = document.CreateNavigator(); var documentSet = new DocumentSet(nameTable, stylesheet.InputSettings, schemaAware ? documentResolverSchemaAware : documentResolver, null, resourceResolver); DynamicContextSettings settings = new DynamicContextSettings(); settings.ContextItem = contextItem; settings.DocumentSet = documentSet; //DynamicContextSettings settings = new DynamicContextSettings { ContextItem = contextItem }; stylesheet.SerializationSettings.CloseOutput = true; TextWriter writer = new StreamWriter(resultFileLocation); stylesheet.ApplyTemplates(settings, writer); writer.Close(); } else { var documentSet = new DocumentSet(nameTable, stylesheet.InputSettings, documentResolver, null, resourceResolver); DynamicContextSettings settings = new DynamicContextSettings { DocumentSet = documentSet }; stylesheet.SerializationSettings.CloseOutput = true; XmlQualifiedName qname = new XmlQualifiedName("main"); TextWriter writer = new StreamWriter(resultFileLocation); stylesheet.CallTemplate(qname, settings, writer); writer.Close(); } this.resultFile = resultFileLocation; }
protected void getDocSetsButton_Click(object sender, EventArgs e) { int count = 0; //Get the Shared Documents document libary SPWeb currentWeb = SPContext.Current.Web; SPDocumentLibrary sharedDocuments = (SPDocumentLibrary)currentWeb.Lists["Shared Documents"]; //Loop though all the folders. Some of them will be document sets //NOTE: don't use the sharedDocuments.Folders collection! Use sharedDocuments.RootFolder.SubFolders foreach (SPFolder currentFolder in sharedDocuments.RootFolder.SubFolders) { //Get the corresponding document set DocumentSet currentDocSet = DocumentSet.GetDocumentSet(currentFolder); //Strangely the previous line always returns a document set object //Even if the current folder is not a document set. So we use the //following test to find out if the current folder is a document set if (currentDocSet.Item != null) { //This folder is a document set. Increase the count count += 1; //Read some properties of the document set resultLabel.Text += "Name: " + currentFolder.Name + "<br />"; resultLabel.Text += "Content Type: " + currentDocSet.ContentType.Name + "<br />"; resultLabel.Text += "Document Count: " + currentDocSet.Folder.ItemCount + "<br />"; resultLabel.Text += "Welcome Page: " + currentDocSet.WelcomePageUrl + "<br /><br />"; } } //Display the count docSetCountLabel.Text = count.ToString(); }
private DocumentSet GetDocumentSet(DocumentSet request) { var id = request?.Id; DocumentSet ret = null; var query = DocQuery.ActiveQuery ?? Execute; DocPermissionFactory.SetSelect <DocumentSet>(currentUser, "DocumentSet", request.Select); DocEntityDocumentSet entity = null; if (id.HasValue) { entity = DocEntityDocumentSet.Get(id.Value); } if (null == entity) { throw new HttpError(HttpStatusCode.NotFound, $"No DocumentSet found for Id {id.Value}"); } if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW)) { throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route."); } ret = entity?.ToDto(); return(ret); }
public void UnlinkDocument(DocumentSet documentSet, Document document) { // This method deletes a document set link // // 1) Look for connection that is not voided // 2) Update the IsVoid flag to "Y"; EndDate to Today string ret = "Item updated successfully"; using (var connection = new SqlConnection(ConnString.ConnectionString)) { var commandString = ( "UPDATE [DocumentSetLink] " + " SET " + " [EndDate] = @EndDate" + ",[IsVoid] = @IsVoid " + " WHERE [UID] = @UID " ); using (var command = new SqlCommand( commandString, connection)) { command.Parameters.Add("@UID", SqlDbType.VarChar).Value = UID; command.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = DateTime.Today; command.Parameters.Add("@IsVoid", SqlDbType.Char).Value = 'Y'; connection.Open(); command.ExecuteNonQuery(); } } return; }
public void AdvancedQueryComplex2Test() { var expected = new DocumentSet(repairCar); var actual = engine.AdvancedSearch("+car", "repair", "-buy"); Assert.Equal(expected, actual); }
public IReadSession OpenReadSession() { var anchor = storageEngine.GetCurrentAnchor(); statistics.IncrementReadSessionsOpened(); lock (readSnapshotLock) { var documents = new DocumentSet(anchor); if (lastReadSnapshot != null && lastReadSnapshot.Anchor.Id == anchor.Id) { statistics.IncrementSnapshotReuse(); return new ReadSession(anchor, lastReadSnapshot, DisposeReadSession); } statistics.IncrementSnapshotRebuild(); if (lastReadSnapshot != null) { documents.InitializeFrom(lastReadSnapshot); } var visited = new HashSet<string>(StringComparer.OrdinalIgnoreCase); var visitor = new LoadEverythingVisitor(documents, encoders, visited); storageEngine.Visit(anchor, visitor); lastReadSnapshot = documents; if (lastReadSnapshot != null) { documents.RemoveExcept(visited); } return new ReadSession(anchor, documents, DisposeReadSession); } }
public void AdvancedQueryAndTwoWordsNonEmptyResultTest() { var expected = new DocumentSet(buyCar, repairBuyCar); var actual = engine.AdvancedSearch("buy", "car"); Assert.Equal(expected, actual); }
public void AdvancedQueryAndTwoWordsEmptyResultTest() { var expected = new DocumentSet(); var actual = engine.AdvancedSearch("test", "car"); Assert.Equal(expected, actual); }
protected override void ExecuteCmdlet() { var list = List.GetList(SelectedWeb); list.EnsureProperties(l => l.RootFolder, l => l.ContentTypes); // Try getting the content type from the Web var contentType = ContentType.GetContentType(SelectedWeb); // If content type could not be found but a content type ID has been passed in, try looking for the content type ID on the list instead if (contentType == null && !string.IsNullOrEmpty(ContentType.Id)) { contentType = list.ContentTypes.FirstOrDefault(ct => ct.StringId.Equals(ContentType.Id)); } else { // Content type has been found on the web, check if it also exists on the list if (list.ContentTypes.All(ct => !ct.StringId.Equals(contentType.Id.StringValue, System.StringComparison.InvariantCultureIgnoreCase))) { contentType = list.ContentTypes.FirstOrDefault(ct => ct.Name.Equals(ContentType.Name)); } } if (contentType == null) { throw new PSArgumentException("The provided contenttype has not been found", "ContentType"); } // Create the document set var result = DocumentSet.Create(ClientContext, list.RootFolder, Name, contentType.Id); ClientContext.ExecuteQueryRetry(); WriteObject(result.Value); }
public void AdvancedQueryAndBikeTest() { var expected = new DocumentSet(repairBike, buyBike); var actual = engine.AdvancedSearch("bike"); Assert.Equal(expected, actual); }
public LoadEverythingVisitor(DocumentSet set, IEncoderRegistry encoderRegistry, HashSet<string> visited) { this.set = set; this.encoderRegistry = encoderRegistry; this.visited = visited; }
/// <summary> /// Peforms a batch process on selected files /// </summary> public void BatchPrinting() { try { /// get files to process from user OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select all files to send to printer"; openFileDialog.Multiselect = true; openFileDialog.Filter = "RVT Files (*.rvt)|*.rvt"; DocumentSet docSet = new DocumentSet(); if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } /// create a document set of all selected files foreach (string fileName in openFileDialog.FileNames) { /// could directly deal with doc here but... /// just testing out DocumentSet Document doc = m_revitApp.Application.OpenDocumentFile(fileName); docSet.Insert(doc); } /// process each file in the Document set DocumentSetIterator docSetIter = docSet.ForwardIterator(); while (docSetIter.MoveNext()) { Document doc = docSetIter.Current as Document; ViewSet views = Utils.View.GetAvailableViewsToExport(doc); /// TBD: remove comments after figuring out /// why doc.EndTransaction() triggers asserts, /// Note that it still works , but the asserts can be a nuisance /// while dealing with multiple files 01/12/07 ///// align text middle and center //TextAlignFlags align = TextAlignFlags.TEF_ALIGN_MIDDLE ^ TextAlignFlags.TEF_ALIGN_CENTER; ///// the way to add an element for a document ///// in memory is within a transaction //if (doc.BeginTransaction()) { // /// to identify what is printed // foreach (Autodesk.Revit.DB.View view in views) { // XYZ origin = new XYZ(view.CropBox.Max.X, view.CropBox.Min.Y, 0.0); // doc.Create.NewTextNote(view, origin, GeomUtils.kXAxis, // view.ViewDirection, 15.0, .25, // align, view.ViewName); // } //} ///// TBD: Asserts "unnamed transaction" ... dunno why ////doc.EndTransaction(); //doc.Save(); ///// print now doc.Print(views); } /// feedback to user MessageBox.Show("Done Printing!"); } catch (Exception e) { MessageBox.Show(e.Message); } }
public LoadBlobVisitor(IEnumerable<string> paths, DocumentSet documents, IEncoderRegistry encoderRegistry) { pathsToLoad = new HashSet<string>(paths, StringComparer.OrdinalIgnoreCase); this.documents = documents; this.encoderRegistry = encoderRegistry; }
private void CopyFile(SPFile file, DocumentSet docSet) { string destinationFolderUrl = docSet.Item.ParentList.RootFolder.Url; destinationFolderUrl = (!destinationFolderUrl.EndsWith("/")) ? destinationFolderUrl + "/" : destinationFolderUrl; file.CopyTo(destinationFolderUrl + file.Name, true); //web.Update(); //return web.GetFile(web.Url + "/" + destinationFolderUrl + file.Name); }