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 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()
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 ); }
} //threadCallBack() private void _generateCTab(CswNbtResources CswNbtResources, CswPrimaryKey NodePK) { CswNbtSdBlobData sdBlobData = new CswNbtSdBlobData(CswNbtResources); CswNbtNode node = CswNbtResources.Nodes.GetNode(NodePK); foreach (CswNbtNodePropWrapper molProp in node.Properties[(CswEnumNbtFieldType)CswEnumNbtFieldType.MOL]) { CswNbtNodePropMol AsMol = molProp.AsMol; string href; string error; string formatted; sdBlobData.saveMol(AsMol.getMol(), new CswPropIdAttr(node, AsMol.NodeTypeProp).ToString(), out href, out formatted, out error); } }
public static void SaveMolPropFile(ICswResources CswResources, MolDataReturn Return, MolData ImgData) { CswNbtResources NBTResources = (CswNbtResources)CswResources; string Href; CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(NBTResources); string FormattedMolString; string errorMsg; SdBlobData.saveMol(ImgData.molString, ImgData.propId, out Href, out FormattedMolString, out errorMsg); ImgData.molString = FormattedMolString; ImgData.href = Href; ImgData.errorMsg = errorMsg; Return.Data = ImgData; }
/// <summary> /// Add values to the NodeType Properties of a Node. /// </summary> /// <param name="Node">The Node whose properties are being filled in.</param> /// <param name="CurrentIndex">The current index in the ProductSize array in a CswC3Product object. This is ONLY needed for Size Nodes.</param> public void addNodeTypeProps(CswNbtNode Node, int CurrentIndex = 0) { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(Node.NodeTypeId); foreach (CswNbtMetaDataNodeTypeProp NTP in NodeType.getNodeTypeProps()) { if (null != Node.Properties[NTP] && _Mappings.ContainsKey(NTP.PropName)) { C3Mapping C3Mapping = _Mappings[NTP.PropName]; switch (Node.Properties[NTP].getFieldTypeValue()) { case CswEnumNbtFieldType.MOL: if (false == string.IsNullOrEmpty(C3Mapping.C3ProductPropertyValue)) { string propAttr = new CswPropIdAttr(Node, NTP).ToString(); string molData = C3Mapping.C3ProductPropertyValue; CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(_CswNbtResources); MolecularGraph Mol = MoleculeBuilder.CreateMolFromString(molData); if (false == Mol.ContainsInvalidAtom()) { string Href; string FormattedMolString; string errorMsg; SdBlobData.saveMol(molData, propAttr, out Href, out FormattedMolString, out errorMsg, Node: Node); } else { _CswNbtResources.logMessage("Failed to save the MOL file for product with ProductId " + _ProductToImport.ProductId + " during the C3 import process because it contained an invalid atom."); } } break; default: CswNbtSubField SubField = NTP.getFieldTypeRule().SubFields[(CswEnumNbtPropColumn)C3Mapping.NBTSubFieldPropColName]; if (null != SubField) { Node.Properties[NTP].SetSubFieldValue(SubField, C3Mapping.C3ProductPropertyValue); } break; } } //if( null != Node.Properties[NTP] && _Mappings.ContainsKey( NTP.PropName ) ) } //foreach( CswNbtMetaDataNodeTypeProp NTP in NodeType.getNodeTypeProps() ) } //addNodeTypeProps()
/// <summary> /// Handles when the property value is copied to another node /// </summary> public void CopyGeneric(CswNbtNodePropData Source) { // Default, just copy the data values CswEnumNbtFieldType FieldType = Source.getFieldTypeValue(); ICswNbtFieldTypeRule FieldTypeRule = _CswNbtResources.MetaData.getFieldTypeRule(FieldType); foreach (CswNbtSubField SubField in FieldTypeRule.SubFields) { if (SubField.Column == CswEnumNbtPropColumn.Field1_FK) { //Implementing FieldType specific behavior here. Blame Steve. if (FieldType == CswEnumNbtFieldType.ViewReference) { //we want to copy views to the new node by value, so changes to the view on either node don't affect the other CswNbtView View = _CswNbtResources.ViewSelect.restoreView(new CswNbtViewId(Source.Field1_Fk)); CswNbtView ViewCopy = new CswNbtView(_CswNbtResources); ViewCopy.saveNew(View.ViewName, View.Visibility, View.VisibilityRoleId, View.VisibilityUserId, View); SetSubFieldValue(CswEnumNbtSubFieldName.ViewID, ViewCopy.ViewId); } else { SetSubFieldValue(SubField.Name, Source.Field1_Fk); } } // if( SubField.Column == CswEnumNbtPropColumn.Field1_FK ) else { SetSubFieldValue(SubField.Name, Source.GetPropRowValue(SubField)); } } // foreach( CswNbtSubField SubField in NodeTypeProp.getFieldTypeRule().SubFields ) // Also copy Gestalt, which usually isn't listed as a subfield SetSubFieldValue(CswEnumNbtSubFieldName.Gestalt, Source.Gestalt); SetSubFieldValue(CswEnumNbtSubFieldName.GestaltSearch, Source.GestaltSearch); //Case 31362 - also copy Blob_Data if necessary if (Source.getFieldTypeValue() == CswEnumNbtFieldType.MOL || Source.getFieldTypeValue() == CswEnumNbtFieldType.Image || Source.getFieldTypeValue() == CswEnumNbtFieldType.File) { CswNbtSdBlobData.CopyBlobData(_CswNbtResources, Source.JctNodePropId, JctNodePropId); } }
} // 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 ); } } } }
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."); } }
public void SetImages(string Date = "") { CswNbtSdBlobData sdBlobData = new CswNbtSdBlobData(_CswNbtResources); _Images = sdBlobData.GetImages(NodeId, JctNodePropId, Date); }