public override void update() { CswNbtMetaDataNodeType ReportNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType("Report"); if (null != ReportNT) { CswNbtObjClassReport ReportNode = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId(ReportNT.NodeTypeId, OnAfterMakeNode : delegate(CswNbtNode newNode) { CswNbtObjClassReport report = newNode; report.ReportName.Text = "Custom Text Barcode"; report.Category.Text = "System Reports"; report.SQL.Text = "select UPPER('{text}') as text from dual"; CswNbtMetaDataObjectClass ReportGroupOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass(CswEnumNbtObjectClass.ReportGroupClass); CswNbtObjClassReportGroup SystemReportGroup = ReportGroupOC.getNodes(forceReInit: false, includeSystemNodes: true) .FirstOrDefault(ReportGroup => ((CswNbtObjClassReportGroup)ReportGroup).Name.Text == "System Reports"); if (null != SystemReportGroup) { report.ReportGroup.RelatedNodeId = SystemReportGroup.NodeId; } }); // upload .RPT string Filename = "customtextbarcode.rpt"; CswPropIdAttr PropId = new CswPropIdAttr(ReportNode.Node, ReportNode.RPTFile.NodeTypeProp); string Filepath = CswFilePath.getConfigurationFilePath(CswEnumSetupMode.NbtExe) + "\\" + Filename; byte[] ReportFile = File.ReadAllBytes(Filepath); const string ContentType = "application/octet-stream"; string Href; CswNbtSdBlobData SdBlobData = _CswNbtSchemaModTrnsctn.CswNbtSdBlobData; SdBlobData.saveFile(PropId.ToString(), ReportFile, ContentType, Filename, out Href); } // if( null != ReportNT ) } // update()
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; }
private void _uploadBlobData( CswNbtObjClassReport ReportNode, string Filename ) { CswPropIdAttr PropId = new CswPropIdAttr( ReportNode.Node, ReportNode.RPTFile.NodeTypeProp ); string Filepath = CswFilePath.getConfigurationFilePath( CswEnumSetupMode.NbtExe ) + "\\" + Filename; byte[] ReportFile = File.ReadAllBytes( Filepath ); const string ContentType = "application/octet-stream"; string Href; CswNbtSdBlobData SdBlobData = _CswNbtSchemaModTrnsctn.CswNbtSdBlobData; SdBlobData.saveFile( PropId.ToString(), ReportFile, ContentType, Filename, out Href ); }
} // update() private void _moveBlobData( CswNbtNodePropWrapper PropWrapper, CswNbtNode Node ) { if( Int32.MinValue != PropWrapper.JctNodePropId ) { CswNbtSdBlobData SdBlobData = _CswNbtSchemaModTrnsctn.CswNbtSdBlobData; CswPropIdAttr PropId = new CswPropIdAttr( Node.NodeId, PropWrapper.NodeTypePropId ); byte[] BlobData = new byte[0]; string ContentType = string.Empty; string FileName = string.Empty; CswTableSelect JctTS = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "getBlobData", "jct_nodes_props" ); { DataTable JctDT = JctTS.getTable( "jctnodepropid", PropWrapper.JctNodePropId ); foreach( DataRow Row in JctDT.Rows ) //should only be one { if( _CswNbtSchemaModTrnsctn.isColumnDefined( "jct_nodes_props", "blobdata" ) ) { BlobData = Row["blobdata"] as byte[]; } else { BlobData = new byte[0]; } FileName = Row["field1"].ToString(); ContentType = Row["field2"].ToString(); } if( null != BlobData ) { string Href; SdBlobData.saveFile( PropId.ToString(), BlobData, ContentType, FileName, out Href ); } } } }