Public Sub SetFolderRules() Const IR_AuthenticationTicket As String = "sid-xxxxxxxxxxxxxx" Const IR_FolderPath As String = "/public" Const IRFolderRule_AllowableFileTypes As String = "doc,xls,jpg,bmp" '"*" for all type of documents Const IRFolderRule_AllowCheckIns As Boolean = True Const IRFolderRule_AllowCheckouts As Boolean = False Const IRFolderRule_AllowDocumentDeletes As Boolean = False Const IRFolderRule_AllowFolderDeletes As Boolean = False Const IRFolderRule_AllowNewDocuments As Boolean = False Const IRFolderRule_AllowNewFolders As Boolean = False Const IRFolderRule_AllowClassifiedDocuments As Boolean = True Const ApplytoTree As Boolean = False 'apply to sub folders or not Dim IR_Obj As InfoRouter.srv Dim xmldoc As System.Xml.XmlDocument Try xmldoc = New System.Xml.XmlDocument xmldoc.LoadXml("<Rules/>") Dim xmlelem As System.Xml.XmlElement 'Allowable file extensions xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "AllowableFileTypes") xmlelem.SetAttribute("Value", IRFolderRule_AllowableFileTypes) xmldoc.DocumentElement.AppendChild(xmlelem) 'CheckIns - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "Checkins") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowCheckIns, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'Checkouts - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "Checkouts") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowCheckouts, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'DocumentDeletes - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "DocumentDeletes") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowDocumentDeletes, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'FolderDeletes - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "FolderDeletes") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowFolderDeletes, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'NewDocuments - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "NewDocuments") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowNewDocuments, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'NewFolders - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "NewFolders") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowNewFolders, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) 'ClassifiedDocuments - allows, disallows xmlelem = xmldoc.CreateElement("Rule") xmlelem.SetAttribute("Name", "ClassifiedDocuments") xmlelem.SetAttribute("Value", IIf(IRFolderRule_AllowClassifiedDocuments, "allows", "disallows")) xmldoc.DocumentElement.AppendChild(xmlelem) Dim xmlResponse As System.Xml.XmlElement IR_Obj = New InfoRouter.srv xmlResponse = IR_Obj.SetFolderRules(IRAuthenticationTicket, IR_FolderPath, xmldoc.DocumentElement, ApplytoTree) If xmlResponse.GetAttribute("success") = "true" Then Console.WriteLine("Rules applied successfully") Else Console.WriteLine("Rules cannot be applied :" & xmlResponse.GetAttribute("error")) End If xmlResponse = Nothing Catch ex As Exception Console.WriteLine("error:" & ex.Message) Finally xmldoc = Nothing IR_Obj = Nothing End Try End Sub
|