public SPDocumentSetInstance GetDocumentSet(SPFolderInstance folder) { if (folder == null) { throw new JavaScriptException(this.Engine, "Error", "An instance of an SPFolder must be specified as the first argument."); } var result = DocumentSet.GetDocumentSet(folder.Folder); if (result == null) { return(null); } return(new SPDocumentSetInstance(this.Engine.Object.InstancePrototype, folder.Folder.ParentWeb.Site, folder.Folder.ParentWeb, result)); }
public SPListItemCollectionInstance GetItemsInFolder(SPViewInstance view, SPFolderInstance folder) { if (view == null) { throw new JavaScriptException(this.Engine, "Error", "A SPView must be specified as the first argument."); } if (folder == null) { throw new JavaScriptException(this.Engine, "Error", "A SPFolder must be specified as the second argument."); } var items = m_documentLibrary.GetItemsInFolder(view.View, folder.Folder); return(items == null ? null : new SPListItemCollectionInstance(this.Engine.Object.InstancePrototype, items)); }
public SPDocumentSetInstance CreateDocumentSet( [JSDoc("The folder to create the document set in.")] SPFolderInstance folder, [JSDoc("The name of the new document set.")] string name, [JSDoc("The content type id of the new documentset. Use new ContentTypeId('<CTID>')")] SPContentTypeIdInstance ctid, [JSDoc("Optional. Specifies a hashtable of fields that will be set on the document set where the key is the static field name.")] object properties, [JSDoc("Optional. Specifies a value that indicates if the default document set content will be provisioned. Default is true.")] object provisionDefaultContent, [JSDoc("Optional. Specifies the SPUser that created the document set.")] object user) { if (folder == null) { throw new JavaScriptException(this.Engine, "Error", "An instance of an SPFolder must be specified as the first argument."); } if (name.IsNullOrWhiteSpace()) { throw new JavaScriptException(this.Engine, "Error", "The name of the new document set must be specified."); } if (ctid == null) { throw new JavaScriptException(this.Engine, "Error", "The Content Type Id of the new document set must be specified."); } var htProperties = new Hashtable(); if (properties != null && properties != Null.Value && properties != Undefined.Value) { htProperties = SPHelper.GetFieldValuesHashtableFromPropertyObject(properties); } var bProvisionDefaultContent = true; if (provisionDefaultContent != null && provisionDefaultContent != Null.Value && provisionDefaultContent != Undefined.Value) { bProvisionDefaultContent = TypeConverter.ToBoolean(provisionDefaultContent); } DocumentSet result; var spUser = user as SPUserInstance; if (user == null || user == Null.Value || user == Undefined.Value || spUser == null) { result = DocumentSet.Create(folder.Folder, name, ctid.ContentTypeId, htProperties, bProvisionDefaultContent); } else { result = DocumentSet.Create(folder.Folder, name, ctid.ContentTypeId, htProperties, bProvisionDefaultContent, spUser.User); } if (result == null) { return(null); } return(new SPDocumentSetInstance(this.Engine.Object.InstancePrototype, folder.Folder.ParentWeb.Site, folder.Folder.ParentWeb, result)); }
public SPDocumentSetInstance Import(Base64EncodedByteArrayInstance bytes, string name, SPFolderInstance parentFolder, object ctid, object properties, object user) { if (bytes == null) { throw new JavaScriptException(this.Engine, "Error", "A base64 encoded byte array must be supplied as the first argument."); } if (name.IsNullOrWhiteSpace()) { throw new JavaScriptException(this.Engine, "Error", "The name of the new document set must be specified."); } if (parentFolder == null) { throw new JavaScriptException(this.Engine, "Error", "The parent folder must be specified."); } if (ctid == Undefined.Value && properties == Undefined.Value && user == Undefined.Value) { var r = DocumentSet.Import(bytes.Data, name, parentFolder.Folder); if (r == null) { return(null); } return(new SPDocumentSetInstance(this.Engine.Object.InstancePrototype, parentFolder.Folder.ParentWeb.Site, parentFolder.Folder.ParentWeb, r)); } var spCtId = ctid as SPContentTypeIdInstance; if (ctid == null || ctid == Null.Value || ctid == Undefined.Value || spCtId == null) { throw new JavaScriptException(this.Engine, "Error", "The Content Type Id of the imported document set must be specified."); } var spUser = user as SPUserInstance; if (user == null || user == Null.Value || user == Undefined.Value || spUser == null) { throw new JavaScriptException(this.Engine, "Error", "The user of the imported document set must be specified."); } var htProperties = new Hashtable(); if (properties != null && properties != Null.Value && properties != Undefined.Value) { htProperties = SPHelper.GetFieldValuesHashtableFromPropertyObject(properties); } var result = DocumentSet.Import(bytes.Data, name, parentFolder.Folder, spCtId.ContentTypeId, htProperties, spUser.User); if (result == null) { return(null); } return(new SPDocumentSetInstance(this.Engine.Object.InstancePrototype, parentFolder.Folder.ParentWeb.Site, parentFolder.Folder.ParentWeb, result)); }
public DiffResultInstance Diff(SPFolderInstance targetFolder, object recursive) { if (targetFolder == null) { throw new JavaScriptException(Engine, "Error", "Target Folder must be specified."); } var bRecurse = true; if (recursive != Undefined.Value && recursive != Null.Value && recursive != null) { bRecurse = TypeConverter.ToBoolean(recursive); } var sourceFolderInfo = new List <DiffInfoInstance>(); var targetFolderInfo = new List <DiffInfoInstance>(); var itemsIterator = new ContentIterator(); itemsIterator.ProcessFilesInFolder(m_folder, bRecurse, spFile => { var fileInfo = new DiffInfoInstance(Engine) { Url = spFile.Url.ReplaceFirstOccurenceIgnoreCase(m_folder.Url, ""), TimeLastModified = JurassicHelper.ToDateInstance(Engine, spFile.TimeLastModified) }; var fileBytes = spFile.OpenBinary(SPOpenBinaryOptions.SkipVirusScan); using (var md5 = MD5.Create()) { fileInfo.Hash = Convert.ToBase64String(md5.ComputeHash(fileBytes)); } sourceFolderInfo.Add(fileInfo); }, null); itemsIterator.ProcessFilesInFolder(targetFolder.Folder, bRecurse, spFile => { var fileInfo = new DiffInfoInstance(Engine) { Url = spFile.Url.ReplaceFirstOccurenceIgnoreCase(targetFolder.Folder.Url, ""), TimeLastModified = JurassicHelper.ToDateInstance(Engine, spFile.TimeLastModified) }; var fileBytes = spFile.OpenBinary(SPOpenBinaryOptions.SkipVirusScan); using (var md5 = MD5.Create()) { fileInfo.Hash = Convert.ToBase64String(md5.ComputeHash(fileBytes)); } targetFolderInfo.Add(fileInfo); }, null); var result = new DiffResultInstance(Engine); result.Process(sourceFolderInfo, targetFolderInfo); return(result); }