Exemple #1
0
        public IFIDSet FindHistoricalDifferences(IWorkspace workspace, string historicalMarkerName, string tableName,
                                                 esriDifferenceType differenceType)
        {
            IHistoricalWorkspace historicalWorkspace = (IHistoricalWorkspace)workspace;
            IHistoricalVersion   historicalVersion   =
                historicalWorkspace.FindHistoricalVersionByName(historicalWorkspace.DefaultMarkerName);
            IHistoricalVersion historicalVersion1 = historicalWorkspace.FindHistoricalVersionByName(historicalMarkerName);
            IFeatureWorkspace  featureWorkspace   = (IFeatureWorkspace)historicalVersion;
            IFeatureWorkspace  featureWorkspace1  = (IFeatureWorkspace)historicalVersion1;
            ITable             table            = featureWorkspace.OpenTable(tableName);
            ITable             table1           = featureWorkspace1.OpenTable(tableName);
            IDifferenceCursor  differenceCursor = ((IVersionedTable)table).Differences(table1, differenceType, null);
            IFIDSet            fIDSetClass      = new FIDSet();
            IRow row = null;
            int  num = -1;

            differenceCursor.Next(out num, out row);
            while (num != -1)
            {
                fIDSetClass.Add(num);
                differenceCursor.Next(out num, out row);
            }
            fIDSetClass.Reset();
            return(fIDSetClass);
        }
Exemple #2
0
        public void ChangeToArchivedVersion(string taskName, string timeStamp)
        {
            this.superTabControl1.SelectedTabIndex = 1;
            IHistoricalWorkspace   hws  = Util.ServerWorkspace as IHistoricalWorkspace;
            IVersionedWorkspace    vws  = hws as IVersionedWorkspace;
            DateTime               ts   = DateTime.Parse(timeStamp);
            IHistoricalVersion     ver  = hws.FindHistoricalVersionByTimeStamp(ts);
            IMapAdmin3             ma   = this.axMapControl2.Map as IMapAdmin3;
            IBasicMap              bmap = this.axMapControl2.Map as IBasicMap;
            AppManager             am   = AppManager.GetInstance();
            IChangeDatabaseVersion cdv  = new ChangeDatabaseVersionClass();

            if (am.CurrentVersion == null)
            {
                ma.FireChangeVersion(vws.DefaultVersion, ver as IVersion);
                cdv.Execute(vws.DefaultVersion, ver as IVersion, bmap);
            }
            else
            {
                ma.FireChangeVersion(am.CurrentVersion, ver as IVersion);
                cdv.Execute(am.CurrentVersion, ver as IVersion, bmap);
            }
            am.CurrentVersion = ver as IVersion;
            am.TaskName       = taskName;

            LocateTask(taskName);
            SetUpdateGridList(taskName);
        }
Exemple #3
0
 private void cboHistoricalMarker_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.cboHistoricalMarker.SelectedIndex != -1)
     {
         IHistoricalVersion version =
             (this.iworkspace_0 as IHistoricalWorkspace).FindHistoricalVersionByName(
                 this.cboHistoricalMarker.Text);
         this.lblDateTimeValue.Text = version.TimeStamp.ToString();
     }
 }
Exemple #4
0
 public void ChangeHistoricalVersionByName(IGraphicsContainer igraphicsContainer_0,
                                           IFeatureWorkspace ifeatureWorkspace_0, string string_0)
 {
     try
     {
         if ((((igraphicsContainer_0 != null) && (ifeatureWorkspace_0 != null)) && (string_0.Length != 0)) &&
             (ifeatureWorkspace_0 is IHistoricalWorkspace))
         {
             IHistoricalVersion version =
                 (ifeatureWorkspace_0 as IHistoricalWorkspace).FindHistoricalVersionByName(string_0);
             if (version != null)
             {
                 this.ChangeVersion(igraphicsContainer_0, ifeatureWorkspace_0, version as IFeatureWorkspace);
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
        /// <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();
            }
        }