public static void saveFile(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            BinaryReader br = new BinaryReader(Request.postedFile.InputStream);

            byte[] FileData = new byte[Request.postedFile.InputStream.Length];
            for (int i = 0; i < Request.postedFile.InputStream.Length; i++)
            {
                FileData[i] = br.ReadByte();
            }

            string           Href       = string.Empty;
            CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(NbtResources);
            int BlobDataId = CswConvert.ToInt32(Request.Blob.BlobDataId);

            //IE9 sends the entire file url - we only want the file name
            string fileName = Path.GetFileName(Request.postedFile.FileName);

            BlobDataId = SdBlobData.saveFile(Request.propid, FileData, Request.postedFile.ContentType, fileName, out Href, BlobDataId);

            Request.Blob.BlobDataId  = BlobDataId;
            Request.Blob.ContentType = Request.postedFile.ContentType;
            Request.Blob.FileName    = fileName;
            Request.Blob.BlobUrl     = Href;

            Request.success = true;
            Return.Data     = Request;
        }
        public static void clearBlob(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;
            CswPropIdAttr   PropId       = new CswPropIdAttr(Request.propid);
            CswNbtNode      Node         = NbtResources.Nodes[PropId.NodeId];

            if (null != Node)
            {
                CswNbtMetaDataNodeTypeProp MetaDataProp = NbtResources.MetaData.getNodeTypeProp(PropId.NodeTypePropId);
                if (null != MetaDataProp)
                {
                    CswNbtNodePropWrapper FileProp = Node.Properties[MetaDataProp];
                    if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, MetaDataProp.getNodeType(), NbtResources.CurrentNbtUser) &&
                        NbtResources.Permit.isPropWritable(CswEnumNbtNodeTypePermission.Edit, MetaDataProp, null, FileProp))
                    {
                        CswNbtSdTabsAndProps tabsandprops = new CswNbtSdTabsAndProps(NbtResources);
                        tabsandprops.ClearPropValue(Request.propid, true);

                        Request.Blob    = new CswNbtSdBlobData.CswNbtBlob();
                        Request.success = true;

                        Return.Data = Request;
                    }
                    else
                    {
                        throw new CswDniException(CswEnumErrorType.Warning, "You do not have sufficient priveledges to clear this File property", "User " + NbtResources.CurrentNbtUser.UserId + " attempted to call clearBlob without sufficient priviledges.");
                    }
                }
            }
        }
        public static void getText(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            Stream stream = Request.postedFile.InputStream;

            using (StreamReader reader = new StreamReader(stream))
            {
                Request.filetext = reader.ReadToEnd();
            }
            Request.Blob.ContentType = Request.postedFile.ContentType;

            //IE9 sends the whole file url, we only want the filename
            string fileName = Path.GetFileName(Request.postedFile.FileName);

            Request.Blob.FileName = fileName;

            Return.Data = Request;
        }
        public static void getBlob(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            DataTable blobDataTbl;
            int       BlobDataId = CswConvert.ToInt32(Request.Blob.BlobDataId);
            int       PropId     = _getNodeTypePropIdFromJctNodePropId(NbtResources, CswConvert.ToInt32(Request.propid));
            CswNbtMetaDataNodeTypeProp MetaDataProp = NbtResources.MetaData.getNodeTypeProp(PropId);

            if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, MetaDataProp.getNodeType(), NbtResources.CurrentNbtUser))
            {
                //Get the file from blob_data
                if (String.IsNullOrEmpty(Request.date))
                {
                    CswTableSelect blobDataSelect = NbtResources.makeCswTableSelect("getBlob", "blob_data");
                    string         whereClause    = "where jctnodepropid = " + Request.propid;
                    if (Int32.MinValue != BlobDataId)
                    {
                        whereClause += " and blobdataid = " + Request.Blob.BlobDataId;
                    }
                    blobDataTbl = blobDataSelect.getTable(whereClause);
                }
                else //get the audited record
                {
                    int jctnodepropid = CswConvert.ToInt32(Request.propid);
                    CswArbitrarySelect blobDataAuditSelect = CswNbtSdBlobData.GetBlobAuditSelect(NbtResources, Request.date, jctnodepropid, BlobDataId);
                    blobDataTbl = blobDataAuditSelect.getTable();
                }

                foreach (DataRow row in blobDataTbl.Rows)
                {
                    Request.data             = row["blobdata"] as byte[];
                    Request.Blob.FileName    = row["filename"].ToString();
                    Request.Blob.ContentType = row["contenttype"].ToString();
                }

                if (null == Request.data || Request.data.Length == 0)
                {
                    bool UseNTPlaceHolder = CswConvert.ToBoolean(Request.usenodetypeasplaceholder);
                    if (UseNTPlaceHolder)
                    {
                        CswPrimaryKey NodeId = CswConvert.ToPrimaryKey(Request.nodeid);
                        CswNbtNode    Node   = NbtResources.Nodes[NodeId];
                        if (null != Node)
                        {
                            CswNbtMetaDataNodeType NodeType = Node.getNodeType();
                            if (null != NodeType && NodeType.IconFileName != string.Empty)
                            {
                                Request.Blob.FileName    = NodeType.IconFileName;
                                Request.Blob.ContentType = "image/png";
                                Request.data             = File.ReadAllBytes(Request.appPath + CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName);
                            }
                        }
                    }
                    else
                    {
                        Request.data             = File.ReadAllBytes(Request.appPath + "/Images/icons/300/_placeholder.gif");
                        Request.Blob.ContentType = "image/gif";
                        Request.Blob.FileName    = "empty.gif";
                    }
                }

                Return.Data = Request;
            } // NbtResources.Permit.canNodeType()
            else
            {
                throw new CswDniException(CswEnumErrorType.Warning, "You do no have sufficient priveledges to fetch this file.", "User " + NbtResources.CurrentNbtUser.UserId + " tried to fetch a file " + PropId + " they do not have permission on.");
            }
        }