Locate parent folder of NotesDocument instance - c#

Attempting to locate the parent folder/view of a given instance of the NotesDocument class within a C# application using the Domino interop.
The goal is to use the AllDocuments property on the NotesDatabase and then ignore any documents which have been discarded by the user. It appears the AllDocuments view returns documents which were deleted out of the $Trash and thus remain within the database as a point of reference; I want to ignore those documents. In addition ParentView and ParentDocumentUNID are both null.

When you say "deleted out of the $Trash" do you refer to soft-deleted documents that appear in the $Trash or hard-deleted documents that have left deletion stubs?
Assuming that through the interop you have access to the mentioned properties:
For soft-deleted documents, FolderReferences might help. However it requires the database to have the $FolderInfo and $FolderRefInfo hidden views.
Hard deleted documents (deletion stubs) should only appear in the AllDocuments NotesDocumentCollection if they were deleted after you obtained the collection. In this case IsDeleted NotesDocument property might help.
ParentDocumentUNID returns empty string for documents that are not responses, it has nothing to do with deletion though. ParentView returns the view the document was retrieved from, in this case Nothing, because the document was not retrieved from a view.

Related

Storing the state of a VSTO Outlook plugin with a draft message

I'm working on a VSTO plugin for Outlook (C#) and find nothing about saving or embedding the state/options of my plugin with a draft message.
Is there any mean to do that ?
Ex: if my plugin makes the message to be displayed in red, I want to have my draft re-opened written in red.
Any idea ?
Use the UserProperties.Add method which creates a new user property in the UserProperties collection. Use the UserProperties property to return the UserProperties object for an Outlook item. This applies to all Outlook items except for the NoteItem.
Use the Add method to create a new UserProperty for an item and add it to the UserProperties object. The Add method allows you to specify a name and type for the new property. When you create a new property, it can also be added as a custom field to the folder that contains the item (using the same name as the property) by setting the AddToFolderFields parameter to true when calling the Add method. That field can then be used as a column in folder views.
To set for the first time a property created by the UserProperties.Add method, use the UserProperty.Value property instead of the SetProperties and SetProperty methods of the PropertyAccessor object.
If you need to keep the data for the folder or Outlook account in general (not per item) you may consider the StorageItem instead. That is a message object in MAPI that is always saved as a hidden item in the parent folder and stores private data for Outlook solutions.
The Outlook object model does not provide any collection object for StorageItem objects. However, you can use Folder.GetTable to obtain a Table with all the hidden items in a Folder, when you specify the TableContents parameter as olHiddenItems. If keeping your data private is of a high concern, you should encrypt the data before storing it.
As Eugene advised, you can use MailItem.UserProperties collection to set/read your custom properties.
A couple points to consider - since named properties are a finite resource, you can have at most 32k of them per mailbox. Once you go over, the mailbox is pretty much dead. So use as few unique properties as possible, and definitely do not use anything dynamic, such as the message subject in the property name.
If you set a user property on an outgoing message, Outlook might force it to go out in the TNEF format. To prevent that from happening, set the property value using MailItem.PropertyAccessor.SetProperty. You can use the same DASL property name that your user property uses, but the point is to avoid using the UserPropeties collection. You can see the DASL property name in OutlookSpy (I am its author) - select a message with your user property set, click IMessage button, select your property, see the DASL edit box.

What is the meaning of the SVN statuses ContentStatus, NodeStatus, PropertyStatus, TextStatus?

I am writing a hookscript for TortoiseSVN using C# and SharpSvn.
It needs to get a list of external files/dirs that have been modified. I am using the method SvnClient.Status() that recursively returns SvnStatusEventArgs objects. These objects have the properties LocalContentStatus, LocalNodeStatus, LocalPropertyStatus and LocalTextStatus. I know that i have to use these properties to determine what I am dealing with (an external link, a modified file, ...) but I don't know what these properties exactly mean.
Correct me if I'm wrong, but I think LocalTextStatus is some kind of display name of the status and LocalPropertyStatus is the status of the path's properties (e.g. svn:externals or svn:needs-lock).
Thank you
ContentStatus refers to the status of the file contents. For example if you have modified a file, its ContentStatus would be modified. ContentStatus for a folder is not used and either none or not set.
PropertyStatus refers to the properties of the file or folder.
NodeStatus refers to the file or folder itself. For example status like added, deleted would show up here, but of course not a status like modified

Unique identifier for Interop.ListObject from VSTO - C#

I need a way to insert (or use an already implemented property that could serve as) a unique identifier into a Microsoft.Office.Interop.Excel.ListObject instance.
The problem is that when I'm creating a new ListObject as:
var excelTable = worksheet.ListObjects.Add(ExcelInterop.XlListObjectSourceType.xlSrcExternal, DUMMY_CONNECTIONSTRING, false, true, cellRange);
I cannot rely on the Name property of excelTable to browse for it in the collection since the user could change the value of that property anytime afterwards.
After browsing trough the object properties I found nothing I could use out of the box (like a Tag property for example, which exists in a Microsoft.Office.Tools.Excel.ListObjecttype of object I cannot use at this point due to dependencies) ...and other weird stuff like a DisplayName that appears not only unable to be set directly but also to reflect the exact same value that the Name property has at all times (Why would you want to have 2 properties that reflect the same value at any time?).
I've thought on either creating my own implementation of this class or probably use the Comment property to store a GUID (which I don't know why kinda feels wrong):
excelTable.Comment = Guid.NewGuid().ToString();
Can you suggest of another way to accomplish this task?
Thanks a lot!
It is quite frustrating that there is no "Tag" (or similar) property that you could set on Excel objects. I'm facing the same issues as you. Here are two options that you can use:
alternative text property (for the table it is only visible by right clicking the table, selecting table and alternative text). This is probably a bit cleaner than Comment since the UI for comment is always visible.
you could also generate a wrapper object that contains a direct reference to the ListObject. So one wrapper object for each created ListObject. This works fine until you save / open the workbook again. If you need to be able to identify the table again after reopening the workbook you would still need to write some id to Comment or Alternative text. You could probably do a clean implementation by using events like BeforeSave and AfterSave (add alternative text before save so it saves to disk, then remove it again after save so that the user doesn't see it. When the workbook opens you load up your wrapper objects and remove the alternative text).

How do I check if any of the current document type's ancestors are a specific type in Umbraco?

I'm trying to write some logic which applies to pages of any of a group of document types in Umbraco.
I'd like to say 'is this document's type, or any of it's parent document types equal to a certain type', but I can't work out how to even get to the document type structure.
I tried using 'HasProperty' with a property defined on the parent to achieve the same effect (because the properties are inherited) - but if the property doesn't have a value, then HasProperty returns False (which seems broken to me, but apparently is just how it works).
Using Razor in Umbraco v6.1.5 (Assembly version: 1.0.4993.19246).
(For now I'll have to check if the NodeTypeAlias is in a big list I suppose).
You can't retrieve the DocumentType hierarchy from the published cache, i.e. from the Node or IPublishedContent objects.
However, what you could do is:
On application start generate a Collection<DocumentType> object of all the content (not media, member) DocumentType objects and cache it. I certainly wouldn't do this from the UI as querying the DocumentType will cause calls to the database, so caching and reusing the objects is much better.
Possibly add the same code to the AfterNew event of a DocumentType. This way new DocumentType objects are also added to the cached list.
Create an extension method like the existing IsDocumentType(string documentTypeAlias) which queries the cached list.
The following code will retrieve the parent structure, you just need to add a while(docType.MasterContentType != null) construct:
DocumentType docType = DocumentType.GetByAlias("ContentPage");
DocumentType parentDocType = new DocumentType(docType.MasterContentType);`
Edit:
If you want to go down the root of having a property on the IPublishedContent or Node instance then I would adopt a similar approach.
Have all doc types inherit from a single doc type which has a label property called parentDocTypeAliases.
On the Newing event of a Document, add the aliases of the parent doc types as a cmma delimited list to the parentDocTypeAliases property. You'll still need the code listed above to query the doc type hierarchy.
Create a new extension method (e.g. InheritsFromDocumentType(string documentTypeAlias)) that queries the csv value.
You can do 'is this document's type, or any of it's parent document types equal to a certain type' with the following:
node.AncestorsOrSelf().FirstOrDefault(x => x.DocumentTypeAlias == "your doctype alias");
This will return an IPublishedContent object of the first node it encounters of type "your doctype alias".
Source: http://our.umbraco.org/documentation/Reference/Mvc/querying

Umbraco: differences between Node, DynamicNode, Content

Then there are many class that represents Umbraco documents:
1) umbraco.cms.businesslogic.Content
2) umbraco.cms.businesslogic.web.Document
3) umbraco.MacroEngines.DynamicNode
4) umbraco.presentation.nodeFactory.Node
Are there any others?
Can you explain what they do, and when to use them?
umbraco.MacroEngines.DynamicNode and umbraco.presentation.nodeFactory.Node seem the same. Perhaps it is better to use Node class because it is faster?
I have a theory:
umbraco.cms.businesslogic.Content and umbraco.cms.businesslogic.web.Document are the representation of cmsContent and cmsDocument DB tables.
umbraco.presentation.nodeFactory.Node and umbraco.MacroEngines.DynamicNode represents the node cached in XML file, to utilize into website.
The first is the simply Node, the second is the same Node with added dynamic properties, one for property defined in nodeType.
So, I think that Node is faster than DynamicNode
Is there someone that can confirm this?
Based on personal use:
Content: Never use it directly, rather use the Document|Media|Member api (which inherits from this class).
Document: Use it for Create|Update|Delete operations. It does all of its operation directly to DB, so it should be used for Reading only when you need to values directly from the db.
Node: Use this most: when Reading|Displaying data through usercontrols, code libraries, xslt extensions, etc.
DynamicNode: Razor macros. I have not yet use this one enough to provide more info.
See below for more detail, but no, Node and DynamicNode are not the same (DynamicNode uses Examine and will also fall back to reading from the DB if needed).
umbraco.cms.businesslogic.Content:
Content is an intermediate layer between CMSNode and classes which will use generic data. Content is a datastructure that holds generic data defined in its corresponding ContentType. Content can in some sence be compared to a row in a database table, its ContentType holds a definition of the columns and the Content contains the data. Note that Content data in umbraco is not tabular but in a treestructure.
I have never had the need to use this class directly though, as all of its operations are handled by the corresponding subclass, e.g: Document, Media, Member. This class in turns inherits from CMSNode which is the base class for every piece of content data inside umbraco
umbraco.cms.businesslogic.web.Document:Document represents a webpage, published Documents are exposed to the runtime/the public website in a cached xml document.
Use this class when referencing nodes from your "Content Section". It handles CRUD operations. Through this class you also get a reference to the DataType of each property in case you want to render those controls in an aspx page.
umbraco.NodeFactory.Node: It implements the INode interface which exposes read-only methods. All of its information comes from the umbraco cached xml. You will not get access to the controls of each property, rather the values of each formatted depending on the datatype.
You can only use this class for reading operations. It makes it really fast to show data since everything comes from cache (published nodes only).
umbraco.MacroEngines.DynamicNode: It was implemented to work with razor macros. It uses NodeFactory under the hood, which means it also access the cached xml. Although if you use the related DynamicMedia be careful as it uses: 1: ExamineIndex which strips out any html tags, 2: it falls back to its default Media type (db if it isn't in runtime cache) in umbraco_v4.11.5.
Same as the above.
I just know the difference between Document and Node.
The Node class uses the data stored in the umbraco cache, the Document class will get data directly from the database.
Node is faster than Document.
Node only returns the content that is saved and published.
95% of time you should use Node.
Content allows you to retrieve/edit any content (page/media/..) from DB (including non-published content), Document allows you to retrieve/edit only page content from DB (including non-published content), Node is used for fast read-only access to (published only) page content from the XML cache and Dynamic Node is comparable to Node but implemented in later versions of Umbraco for macros using Razor

Categories