public static void SaveRendererToByte(ref byte[] _RendererValue, ref string _RendererType, IRendererUI pRendererUI) { if (pRendererUI == null) { _RendererValue = null; _RendererType = enumRendererType.SimpleRenderer.ToString(); return; } _RendererType = pRendererUI.RendererType.ToString(); try { IPersistStream pPersistStream = pRendererUI.Renderer as IPersistStream; IStream pStream = new XMLStreamClass(); pPersistStream.Save(pStream, 0); IXMLStream pXMLStream = pStream as IXMLStream; _RendererValue = pXMLStream.SaveToBytes(); } catch (Exception ex) { _RendererValue = null; _RendererType = enumRendererType.SimpleRenderer.ToString(); } }
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("保存显示方案失败", "提示"); } }