Exemple #1
0
 public FrmStatisticsConfig(IWorkspace pTmpWorkSpace)
 {
     _TmpWorkSpace = pTmpWorkSpace;
     if (pTmpWorkSpace != null)
     {
         SysCommon.ModSysSetting.CopyLayerTreeXmlFromDataBase(pTmpWorkSpace, _LayerTreePath);
         SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(pTmpWorkSpace);
         Exception   err                  = null;
         Dictionary <string, object> pDic = mSystable.GetRow("SYSSETTING", "SETTINGNAME='统计配置'", out err);
         if (pDic != null)
         {
             if (pDic.ContainsKey("SETTINGVALUE2"))
             {
                 if (pDic["SETTINGVALUE2"] != null)  //这里仅能成功导出当初以文件类型导入的BLOB字段
                 {
                     object tempObj = pDic["SETTINGVALUE2"];
                     IMemoryBlobStreamVariant pMemoryBlobStreamVariant = tempObj as IMemoryBlobStreamVariant;
                     IMemoryBlobStream        pMemoryBlobStream        = pMemoryBlobStreamVariant as IMemoryBlobStream;
                     if (pMemoryBlobStream != null)
                     {
                         try
                         {
                             pMemoryBlobStream.SaveToFile(_QueryConfigPath);
                         }
                         catch { return; }
                     }
                 }
             }
         }
     }
     InitializeComponent();
 }
 private void CopyConfigXml(string Settingname, string SettingPath)
 {
     try
     {
         SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(Plugin.ModuleCommon.TmpWorkSpace);
         Exception   err                  = null;
         Dictionary <string, object> pDic = mSystable.GetRow("SYSSETTING", "SETTINGNAME='" + Settingname + "'", out err);
         if (pDic != null)
         {
             if (pDic.ContainsKey("SETTINGVALUE2"))
             {
                 if (pDic["SETTINGVALUE2"] != null)  //这里仅能成功导出当初以文件类型导入的BLOB字段
                 {
                     object tempObj = pDic["SETTINGVALUE2"];
                     IMemoryBlobStreamVariant pMemoryBlobStreamVariant = tempObj as IMemoryBlobStreamVariant;
                     IMemoryBlobStream        pMemoryBlobStream        = pMemoryBlobStreamVariant as IMemoryBlobStream;
                     if (pMemoryBlobStream != null)
                     {
                         pMemoryBlobStream.SaveToFile(SettingPath);
                     }
                 }
             }
         }
     }
     catch (Exception err2)
     { }
 }
        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 #4
0
        //新增删除参数按钮 ygc 2012-8-31
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (textBoxSettingName.Text.Trim() == "")
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("请选择要删除的参数名");
                return;
            }
            DialogResult result = DevComponents.DotNetBar.MessageBoxEx.Show("确定要删除该配置信息吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result != DialogResult.OK)
            {
                return;
            }
            SysGisTable mSystable = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
            Exception   err       = null;
            bool        t         = mSystable.DeleteRows("SYSSETTING", "SETTINGNAME='" + textBoxSettingName.Text + "'", out err);

            if (t)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("成功删除该配置信息!", "提示");
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("删除该配置信息失败!" + err.ToString(), "提示");
                return;
            }
            textBoxSettingDescription.Text = "";
            textBoxSettingName.Text        = "";
            textBoxSettingValue.Text       = "";
            comboBoxDataType.Text          = "";
            RefreshDataView();
        }
Exemple #5
0
        //当初当前系统参数的值,放在指定路径(限定该参数值是BLOB类型,并且存入时是选取文件存入的)
        private void buttonXExport_Click(object sender, EventArgs e)
        {
            if (!comboBoxDataType.Text.Contains("File"))
            {
                return;
            }
            SaveFileDialog pOpenFileDlg = new SaveFileDialog();

            pOpenFileDlg.Title = "选择文件";
            switch (comboBoxDataType.Text)
            {
            case "XmlFile":
                //弹出对话框供用户设置导出的xml文件

                pOpenFileDlg.Filter = "XML数据(*.xml)|*.xml";
                break;

            case "MxdFile":
                pOpenFileDlg.Filter = "mxd文件(*.mxd)|*.mxd";
                break;
            }
            if (pOpenFileDlg.ShowDialog() == DialogResult.OK)
            {   //获得系统参数表的BLOB字段值,并导出到指定文件中
                string      strPath              = pOpenFileDlg.FileName;
                SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
                Exception   err                  = null;
                Dictionary <string, object> pDic = mSystable.GetRow("SYSSETTING", "SETTINGNAME='" + this.textBoxSettingName.Text + "'", out err);
                if (pDic != null)
                {
                    if (pDic.ContainsKey("SETTINGVALUE2"))
                    {
                        if (pDic["SETTINGVALUE2"] != null)  //这里仅能成功导出当初以文件类型导入的BLOB字段
                        {
                            object tempObj = pDic["SETTINGVALUE2"];
                            IMemoryBlobStreamVariant pMemoryBlobStreamVariant = tempObj as IMemoryBlobStreamVariant;
                            IMemoryBlobStream        pMemoryBlobStream        = pMemoryBlobStreamVariant as IMemoryBlobStream;
                            if (pMemoryBlobStream != null)
                            {
                                pMemoryBlobStream.SaveToFile(strPath);
                                MessageBox.Show("将文件" + strPath + "导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);//ygc 2012-12-17 新增提示信息
                            }
                        }
                    }
                }
                mSystable = null;
            }
        }
Exemple #6
0
        private void RefreshDataView()
        {
            listView.Items.Clear();
            SysGisTable mSystable = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
            Exception   err       = null;
            //打开系统参数表
            List <Dictionary <string, object> > listdic = mSystable.GetRows("SYSSETTING", "", out err);

            if (listdic != null)
            {
                for (int i = 0; i < listdic.Count; i++)
                {
                    Dictionary <string, object> pDic = listdic[i];
                    ListViewItem pListViewItem       = new ListViewItem();
                    //参数名
                    if (pDic.ContainsKey("SETTINGNAME"))
                    {
                        if (pDic["SETTINGNAME"] != null)
                        {
                            pListViewItem.SubItems[0].Text = pDic["SETTINGNAME"].ToString();//比较特殊,默认已经有一个子项
                        }
                        //else
                        //{
                        //    pListViewItem.SubItems.Add("");
                        //}
                    }
                    //else
                    //{ pListViewItem.SubItems.Add(""); }
                    //参数值
                    if (pDic.ContainsKey("SETTINGVALUE"))
                    {
                        if (pDic["SETTINGVALUE"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["SETTINGVALUE"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //参数数据类型
                    if (pDic.ContainsKey("DATATYPE"))
                    {
                        if (pDic["DATATYPE"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["DATATYPE"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //参数描述
                    if (pDic.ContainsKey("DESCRIPTION"))
                    {
                        if (pDic["DESCRIPTION"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["DESCRIPTION"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //如果BLOB类型的字段有值
                    if (pDic.ContainsKey("SETTINGVALUE2"))
                    {
                        if (pDic["SETTINGVALUE2"] != null)
                        {
                            if (pListViewItem.SubItems[2].Text.Contains("File"))
                            {
                                pListViewItem.SubItems[1].Text = "*";
                            }
                        }
                    }
                    listView.Items.Add(pListViewItem);
                }
            }
            mSystable = null;
        }
Exemple #7
0
        private void UCSysSetting_Load(object sender, EventArgs e)
        {
            //数据类型下拉框
            comboBoxDataType.Items.Add("");
            comboBoxDataType.Items.Add("String");
            comboBoxDataType.Items.Add("Double");
            comboBoxDataType.Items.Add("Integer");
            comboBoxDataType.Items.Add("XmlFile");
            comboBoxDataType.Items.Add("MxdFile");
            //最初 不可导入、导出参数
            buttonXImport.Enabled = false;
            buttonXExport.Enabled = false;
            ///Zq 20111118  add
            buttonModify.Enabled = false;
            ///end
            SysGisTable mSystable = new SysCommon.Gis.SysGisTable(_TmpWorkSpace);
            Exception   err       = null;
            //打开系统参数表
            List <Dictionary <string, object> > listdic = mSystable.GetRows("SYSSETTING", "", out err);

            if (listdic != null)
            {
                for (int i = 0; i < listdic.Count; i++)
                {
                    Dictionary <string, object> pDic = listdic[i];
                    ListViewItem pListViewItem       = new ListViewItem();
                    //参数名
                    if (pDic.ContainsKey("SETTINGNAME"))
                    {
                        if (pDic["SETTINGNAME"] != null)
                        {
                            pListViewItem.SubItems[0].Text = pDic["SETTINGNAME"].ToString();//比较特殊,默认已经有一个子项
                        }
                        //else
                        //{
                        //    pListViewItem.SubItems.Add("");
                        //}
                    }
                    //else
                    //{ pListViewItem.SubItems.Add(""); }
                    //参数值
                    if (pDic.ContainsKey("SETTINGVALUE"))
                    {
                        if (pDic["SETTINGVALUE"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["SETTINGVALUE"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //参数数据类型
                    if (pDic.ContainsKey("DATATYPE"))
                    {
                        if (pDic["DATATYPE"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["DATATYPE"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //参数描述
                    if (pDic.ContainsKey("DESCRIPTION"))
                    {
                        if (pDic["DESCRIPTION"] != null)
                        {
                            pListViewItem.SubItems.Add(pDic["DESCRIPTION"].ToString());
                        }
                        else
                        {
                            pListViewItem.SubItems.Add("");
                        }
                    }
                    else
                    {
                        pListViewItem.SubItems.Add("");
                    }
                    //如果BLOB类型的字段有值
                    if (pDic.ContainsKey("SETTINGVALUE2"))
                    {
                        if (pDic["SETTINGVALUE2"] != null)
                        {
                            if (pListViewItem.SubItems[2].Text.Contains("File"))
                            {
                                pListViewItem.SubItems[1].Text = "*";
                            }
                        }
                    }
                    listView.Items.Add(pListViewItem);
                }
            }
            //判断导入、导出参数按钮的可用状态
            if (comboBoxDataType.Text.Contains("File"))
            {
                buttonXImport.Enabled = true;
                buttonXExport.Enabled = true;
            }
            else
            {
                buttonXImport.Enabled = false;
                buttonXExport.Enabled = false;
            }
            mSystable = null;
        }
Exemple #8
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)
                {
                }
            }
        }