private object ConvertByte2Object(byte[] objValue) { if (objValue == null || objValue.Length == 0) { return(null); } IMemoryBlobStream pMemory = new MemoryBlobStreamClass(); pMemory.ImportFromMemory(ref objValue[0], (uint)objValue.GetLength(0)); return(pMemory); }
private void WriteMapToDB(IMap pMap, Dictionary <string, object> pDic, string strCondition) { //linyand add set map SpatialReference //pMap.SpatialReference = LoadProjectedCoordinateSystem(); IPersistStream pPersistStream = pMap as IPersistStream; IStream pStream = new XMLStreamClass(); pPersistStream.Save(pStream, 0); IXMLStream pXMLStream = pStream as IXMLStream; byte[] RenderByte = pXMLStream.SaveToBytes(); IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass(); pMemoryBlobStream.ImportFromMemory(ref RenderByte[0], (uint)RenderByte.GetLength(0)); pDic.Add(SysCommon.ModSysSetting._MxdListTable_MapField, pMemoryBlobStream); //采用更新blob字段的方法 SysGisTable sysTable = new SysGisTable(Plugin.ModuleCommon.TmpWorkSpace); Exception eError = null; object objValue = sysTable.GetFieldValue(SysCommon.ModSysSetting._MxdListTable, SysCommon.ModSysSetting._MxdListTable_MapField, strCondition, out eError); bool flag = false; if (objValue == null) { flag = sysTable.NewRow(SysCommon.ModSysSetting._MxdListTable, pDic, out eError); } else { flag = sysTable.UpdateRow(SysCommon.ModSysSetting._MxdListTable, strCondition, pDic, out eError); } sysTable = null; if (flag) { MessageBox.Show("保存显示方案成功!", "提示"); } else { MessageBox.Show("保存显示方案失败", "提示"); } }