Пример #1
0
        private void FrmHistoryView_Load(object sender, EventArgs e)
        {
            ClsHistory.WorkSpace = ClsDBInfo.SdeWorkspace;

            m_pHistoricalWorkspace = ClsHistory.WorkSpace as IHistoricalWorkspace;
            ClsHistory.OpenConn();


            DTPickerL.Format       = DateTimePickerFormat.Custom;
            DTPickerL.CustomFormat = "MM/dd/yyy HH:mm:ss tt";
            DTPickerL.Value        = ClsHistory.GetSystemTime();

            DTPickerR.Format       = DateTimePickerFormat.Custom;
            DTPickerR.CustomFormat = "MM/dd/yyy HH:mm:ss tt";
            DTPickerR.Value        = ClsHistory.GetSystemTime();

            ////分别添加工作空间中现有历史标记到左右Cbo
            ClsHistory.AddHisMarkerToCbo(ref CboMarkerL);
            ClsHistory.AddHisMarkerToCbo(ref CboMarkerR);
            rdoTimeL.Checked = true;
            rdoTimeR.Checked = true;
            m_bHasLoad       = true;
        }
Пример #2
0
        /// <summary>
        /// 加载历史数据
        /// </summary>
        /// <param name="vData"></param>
        /// <remarks></remarks>
        private void AddHisLayer(object vData, string sfunLR, Collection <object> pHisLyrColl)
        {
            string dTimeStamp  = string.Empty;
            string strName     = null;
            string sHTableName = null;
            string sName       = null;
            int    i           = 0;

            IFeatureWorkspace pFeatureWorkspace = default(IFeatureWorkspace);
            IFeatureClass     pFeatCls          = default(IFeatureClass);
            //Dim pFeatLayer As IFeatureLayer
            IFeatureLayer pFeatLyr     = default(IFeatureLayer);
            string        strCondition = null;

            if (ClsHistory.WorkSpace == null)
            {
                return;
            }
            pFeatureWorkspace = ClsHistory.WorkSpace as IFeatureWorkspace;
            if (pHisLyrColl.Count == 0)
            {
                if (GetHisLayerColl() == false)
                {
                    return;
                }
            }

            try
            {
                if (m_sMorTSelected == "0")
                {
                    m_pHistoricalVersion = m_pHistoricalWorkspace.FindHistoricalVersionByName(vData.ToString());
                    dTimeStamp           = String.Format(m_pHistoricalVersion.TimeStamp.ToString(), "yyyy-MM-dd HH:mm:ss");
                    //格式化时间
                }
                else if (m_sMorTSelected == "1")
                {
                    dTimeStamp = String.Format(vData.ToString(), "yyyy-MM-dd HH:mm:ss");
                }

                //FrmProgressBar progressBar = new FrmProgressBar(true);
                //progressBar.SetMax(pHisLyrColl.Count);
                //progressBar.SetStep(1);
                //progressBar.ShowNew();
                //progressBar.SetInfo("正在加载历史图层...");
                for (i = 0; i < pHisLyrColl.Count; i++)
                {
                    pFeatLyr = pHisLyrColl[i] as IFeatureLayer;
                    strName  = ((IDataset)pFeatLyr.FeatureClass).Name;

                    //查找对应的历史图层名_H%
                    try
                    {
                        sHTableName = ClsHistory.GetTableNameRec(strName, ClsHistory.Connection);
                        if (string.IsNullOrEmpty(sHTableName))
                        {
                            MessageBoxEx.Show("不存在'" + strName + "'图层的历史数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //progressBar.PerformOneStep();
                            continue;
                        }
                    }
                    catch (Exception)
                    {
                        //progressBar.PerformOneStep();
                        continue;
                    }

                    //按时间戳进行点查询
                    strCondition = "GDB_FROM_DATE <= TO_DATE('" + Convert.ToString(dTimeStamp) + "','yyyy-MM-dd HH24:mi:ss') AND GDB_TO_DATE > TO_DATE('" + Convert.ToString(dTimeStamp) + "','yyyy-MM-dd HH24:mi:ss')";

                    IQueryFilter             pFilter       = default(IQueryFilter);
                    IFeatureLayer            pTmpLayer     = default(IFeatureLayer);
                    IFeatureLayer            pNewFeatLyr   = default(IFeatureLayer);
                    IFeatureLayerDefinition2 pFeatLayerDef = default(IFeatureLayerDefinition2);
                    IFeatureSelection        pFeatSel      = default(IFeatureSelection);

                    pFilter             = new QueryFilter();
                    pFilter.SubFields   = "*";
                    pFilter.WhereClause = strCondition;

                    pFeatCls  = pFeatureWorkspace.OpenFeatureClass(sHTableName);
                    pTmpLayer = new FeatureLayer();
                    pTmpLayer.FeatureClass = pFeatCls;
                    pFeatSel = pTmpLayer as IFeatureSelection;
                    pFeatSel.SelectFeatures(pFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
                    pFeatLayerDef = pTmpLayer as IFeatureLayerDefinition2;

                    pFeatLayerDef.DefinitionExpression = strCondition;

                    //IFields fields = pTmpLayer.FeatureClass.Fields;
                    //int indext = fields.FindField("GDB_FROM_DATE");

                    //object str = pTmpLayer.FeatureClass.GetFeature(1).get_Value(indext);

                    //string  str=pTmpLayer.FeatureClass.get
                    //对历史图层命名
                    if (m_sMorTSelected == "0")
                    {
                        sName = strName + "[" + vData + "]";
                    }
                    else if (m_sMorTSelected == "1")
                    {
                        sName = strName + "[" + Convert.ToString(dTimeStamp) + "]";
                    }
                    else
                    {
                        //progressBar.CloseBar();
                        return;
                    }

                    //按照选择集生成新的图层pNewFeatLyr
                    pNewFeatLyr = pFeatLayerDef.CreateSelectionLayer(sName, true, "", "");

                    //添加历史图层到对应的MapCtl中
                    if (sfunLR == "0")
                    {
                        if (this.MapLeft.Map != null)
                        {
                            if (LayerExist((Map)this.MapLeft.Map, sName) == false)
                            {
                                //MapLeft.ClearLayers();
                                MapLeft.Map.AddLayer(pNewFeatLyr);
                            }
                        }
                    }
                    else if (sfunLR == "1")
                    {
                        if (this.MapRight.Map != null)
                        {
                            if (LayerExist((Map)this.MapRight.Map, sName) == false)
                            {
                                //MapRight.ClearLayers();
                                MapRight.Map.AddLayer(pNewFeatLyr);
                            }
                        }
                    }
                    //progressBar.PerformOneStep();
                }
            }
            catch (Exception)
            {
                //g_ErrorHandle.HandleError(true, "错误文件名:" + "WHFHistory_frmHisDoubView" + ";错误过程名:AddHisLayer" + ";错误行数: " + g_ErrorHandle.GetErrorLineNumberString(Erl()), Err().Number, Err().Source, Err().Description);
            }
            finally
            {
                //if (frmCnProgress.IsDisposed == false)
                //    frmCnProgress.Close();
            }
        }