private void SaveConfig(string strConfigName, string strConfigValue)
        {
            SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
            Dictionary <string, object> pDic = new Dictionary <string, object>();

            //参数名
            pDic.Add("SETTINGNAME", strConfigName);

            pDic.Add("SETTINGVALUE", strConfigValue);

            Exception err  = null;
            bool      bRes = false;

            if (mSystable.ExistData("SYSSETTING", "SETTINGNAME='" + strConfigName + "'"))
            {
                bRes = mSystable.UpdateRow("SYSSETTING", "SETTINGNAME='" + strConfigName + "'", pDic, out err);
            }
            else
            {
                bRes = mSystable.NewRow("SYSSETTING", pDic, out err);
            }


            mSystable = null;
        }
Exemple #2
0
        //更新系统参数表
        private void buttonXOK_Click(object sender, EventArgs e)
        {
            if (textBoxSettingName.Text.Trim() == "")
            {
                MessageBox.Show("请输入参数名");
                return;
            }
            SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
            Dictionary <string, object> pDic = new Dictionary <string, object>();

            //参数名
            pDic.Add("SETTINGNAME", textBoxSettingName.Text);
            //参数数据类型
            pDic.Add("DATATYPE", comboBoxDataType.Text);
            //参数描述
            pDic.Add("DESCRIPTION", textBoxSettingDescription.Text);
            //参数值(分简单参数值和文件型参数值)
            if (!comboBoxDataType.Text.Contains("File"))
            {
                pDic.Add("SETTINGVALUE", textBoxSettingValue.Text);
            }
            else
            {
                if (File.Exists(textBoxSettingValue.Text))
                {
                    IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();

                    pBlobStream.LoadFromFile(textBoxSettingValue.Text);
                    pDic.Add("SETTINGVALUE2", pBlobStream);
                }
            }
            Exception err  = null;
            bool      bRes = false;

            if (!_isAdd)
            {
                bRes = mSystable.UpdateRow("SYSSETTING", "SETTINGNAME='" + this.textBoxSettingName.Text + "'", pDic, out err);
            }
            else
            {
                bRes = mSystable.NewRow("SYSSETTING", pDic, out err);
            }
            if (!bRes)
            {
                MessageBox.Show(err.Message);
                mSystable = null;
                return;
            }
            if (!_isAdd)    //修改参数
            {
                _CurListItem.SubItems[2].Text = comboBoxDataType.Text;
                _CurListItem.SubItems[3].Text = textBoxSettingDescription.Text;
                if (!comboBoxDataType.Text.Contains("File"))
                {
                    _CurListItem.SubItems[1].Text = textBoxSettingValue.Text;
                }
            }
            else    //添加参数
            {
                ListViewItem pItem = new ListViewItem();
                pItem.SubItems[0].Text = textBoxSettingName.Text;
                pItem.SubItems.Add(""); pItem.SubItems.Add(""); pItem.SubItems.Add("");

                pItem.SubItems[2].Text = comboBoxDataType.Text;
                pItem.SubItems[3].Text = textBoxSettingDescription.Text;
                if (!comboBoxDataType.Text.Contains("File"))
                {
                    pItem.SubItems[1].Text = textBoxSettingValue.Text;
                }
                listView.Items.Add(pItem);
                _CurListItem = pItem;
            }
            _isAdd    = false; //添加完以后,添加状态消失
            mSystable = null;
        }
        private void SaveInitState()
        {
            Plugin.Application.IAppDBIntegraRef _pDBIntegra = _hook as Plugin.Application.IAppDBIntegraRef;
            string strTmpPath  = Application.StartupPath + "\\..\\Temp\\Tmpmxd" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".mxd";
            string strTmpPath2 = Application.StartupPath + "\\..\\Temp\\Tmpmxd" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + "_.mxd";

            if (!System.IO.Directory.Exists(Application.StartupPath + "\\..\\Temp"))
            {
                System.IO.Directory.CreateDirectory(Application.StartupPath + "\\..\\Temp");
            }
            IMxdContents pMxdC;

            pMxdC = _pDBIntegra.MapControl.Map as IMxdContents;

            IMapDocument pMapDocument = new MapDocumentClass();

            //创建地图文档
            pMapDocument.New(strTmpPath);

            //保存信息
            IActiveView pActiveView = _pDBIntegra.MapControl.Map as IActiveView;

            pMapDocument.ReplaceContents(pMxdC);

            try//yjl20110817 防止保存时,其他程序也在打开这个文档而导致共享冲突从而使系统报错
            {
                pMapDocument.Save(true, true);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pMapDocument);
                pMapDocument = null;
                pMapDocument = new MapDocumentClass();
                pMapDocument.Open(strTmpPath, "");
                GeoLayerTreeLib.LayerManager.ModuleMap.SetLayersVisibleAttri(pMapDocument, true);
                ModPublicFun.WriteLog("pMapDocument.Save start");
                pMapDocument.SaveAs(strTmpPath2, true, true);
                ModPublicFun.WriteLog("pMapDocument.Save false");
            }
            catch (Exception ex)
            {
                if (ex != null)
                {
                    ModPublicFun.WriteLog(ex.Message);
                }
            }
            pMapDocument.Close();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pMapDocument);
            pMapDocument = null;
            try
            {
                System.IO.File.Delete(strTmpPath);
            }
            catch (Exception err2)
            {
            }
            if (System.IO.File.Exists(strTmpPath2))
            {
                SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(Plugin.ModuleCommon.TmpWorkSpace);
                Dictionary <string, object> pDic = new Dictionary <string, object>();
                //参数名
                pDic.Add("SETTINGNAME", "初始加载地图文档");
                //参数数据类型
                pDic.Add("DATATYPE", "MxdFile");
                //参数描述
                //pDic.Add("DESCRIPTION", textBoxSettingDescription.Text);
                //参数值(分简单参数值和文件型参数值)

                IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();
                pBlobStream.LoadFromFile(strTmpPath2);
                pDic.Add("SETTINGVALUE2", pBlobStream);

                Exception err  = null;
                bool      bRes = false;
                if (mSystable.ExistData("SYSSETTING", "SETTINGNAME='初始加载地图文档'"))
                {
                    bRes = mSystable.UpdateRow("SYSSETTING", "SETTINGNAME='初始加载地图文档'", pDic, out err);
                }
                else
                {
                    bRes = mSystable.NewRow("SYSSETTING", pDic, out err);
                }
                if (!bRes)
                {
                    MessageBox.Show("保存出错:" + err.Message);
                }
                try
                {
                    System.IO.File.Delete(strTmpPath2);
                }
                catch (Exception err2)
                {
                }
            }
        }