|
using System;
using System.Collections.Generic;
using System.Text;
using Mullivan.SharePoint;
using System.IO;
using System.Web;
namespace Mullivan.SharePoint.Remote
{
public class SPItem
{
private SPContentType _contentType;
internal SPItem(SPContentType contentType, bool isNew)
{
_contentType = contentType;
this.Properties = new Dictionary<string, string>();
this.IsNew = isNew;
}
internal bool IsNew
{
get;
set;
}
public SPContentType ContentType
{
get { return _contentType; }
}
public Dictionary<string, string> Properties
{
get;
set;
}
public byte[] Binary
{
get;
set;
}
public int Id
{
get;
set;
}
public string Name
{
get;
set;
}
public string Extension
{
get;
set;
}
public string Folder
{
get;
set;
}
public string Version
{
get;
set;
}
public bool CheckedOut
{
get;
set;
}
public string CheckedoutUser
{
get;
set;
}
public string[] AttachmentUrls
{
get;
set;
}
public string GetUrl()
{
string docUrl = string.Empty;
docUrl = this.ContentType.List.FullUri.TrimEnd('/');
docUrl += "/";
if (!string.IsNullOrEmpty(this.Folder))
docUrl += this.Folder.Trim('/');
if (this.ContentType.List.BaseType == SPListBaseType.DocumentLibrary)
{
if (string.IsNullOrEmpty(this.Name))
this.Name = Guid.NewGuid().ToString().Trim('{', '}');
docUrl += this.Name;
docUrl += ".";
if (string.IsNullOrEmpty(this.Extension))
throw new Exception("Error generating the item's Url. The Extension property must be set when the item belongs to a Document Library.");
docUrl += this.Extension;
}
else
{
if (this.Id < 1)
throw new Exception("Error generating the item's Url. The ID property must be set when the item belongs to a List.");
docUrl += this.Id.ToString() + "_.000";
}
return HttpUtility.UrlPathEncode(docUrl);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.