Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 结束任务流程
        /// </summary>
        /// <param name="taskName"></param>
        public void FinishTask(string taskName)
        {
            IFeatureWorkspace   ws = Util.ServerWorkspace as IFeatureWorkspace;
            IVersionedWorkspace vw = ws as IVersionedWorkspace;

            if (taskName.ToLower() == vw.DefaultVersion.VersionName.ToLower())
            {
                return;
            }
            IVersion       ver = vw.FindVersion(taskName);
            IVersionEdit4  ve  = ver as IVersionEdit4;
            IWorkspaceEdit wse = ver as IWorkspaceEdit;

            wse.StartEditing(true);
            ve.Reconcile4(vw.DefaultVersion.VersionName, true, true, true, true);
            if (ve.CanPost())
            {
                ve.Post(vw.DefaultVersion.VersionName);
            }
            ITable       task_tbl = ws.OpenTable("TaskLog");
            IQueryFilter filter   = new QueryFilterClass();

            filter.WhereClause = "TaskName = '" + taskName + "'";
            ICursor cur = task_tbl.Search(filter, false);
            IRow    rw  = cur.NextRow();

            if (rw != null)
            {
                rw.set_Value(task_tbl.FindField("Status"), TaskManager.FINISH_STATUS);
                rw.set_Value(task_tbl.FindField("FinishDate"), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                rw.Store();
            }
            wse.StopEditing(true);
            ver.Delete();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取工作空间的默认版本
        /// </summary>
        /// <param name="eError"></param>
        /// <returns></returns>
        public string GetDefautVersionName(out Exception eError)
        {
            string verName = "";//默认版本名称

            eError = null;
            IVersionedWorkspace pVersionedWS = v_WSEdit as IVersionedWorkspace;

            if (pVersionedWS == null)
            {
                eError = new Exception("该数据还没有注册版本!");
                return("");
            }

            IVersion pDefVersion = pVersionedWS.DefaultVersion;  //默认版本

            if (pDefVersion == null)
            {
                eError = new Exception("获取默认版本出错!");
                return("");
            }
            if (pDefVersion.VersionInfo == null)
            {
                eError = new Exception("获取默认版本出错!");
                return("");
            }
            verName = pDefVersion.VersionInfo.VersionName;

            if (verName == "")
            {
                eError = new Exception("获取默认版本名称出错!");
                return("");
            }
            return(verName);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 切换到任务
        /// </summary>
        /// <param name="versionName"></param>
        public void ChangeToCheckInVersion(string versionName)
        {
            IVersionedWorkspace    vws  = Util.ServerWorkspace as IVersionedWorkspace;
            IVersion               ver  = vws.FindVersion(versionName);
            IMapAdmin3             ma   = this.axMapControl1.Map as IMapAdmin3;
            IBasicMap              bmap = this.axMapControl1.Map as IBasicMap;
            AppManager             am   = AppManager.GetInstance();
            IChangeDatabaseVersion cdv  = new ChangeDatabaseVersionClass();

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

            m_EditWorkspace = ver as IWorkspaceEdit2;
            FilterLayers();
            SetUpdateGridList(versionName);
            SetStatusLabel(versionName);
        }
Exemplo n.º 5
0
        private void frmHistorialMarkerManager_Load(object sender, EventArgs e)
        {
            IEnumHistoricalMarker historicalMarkers = this.m_pHistoricalWorkspace.HistoricalMarkers;

            historicalMarkers.Reset();
            IHistoricalMarker marker2 = historicalMarkers.Next();

            string[]            items = new string[2];
            IVersionedWorkspace pHistoricalWorkspace = this.m_pHistoricalWorkspace as IVersionedWorkspace;

            while (marker2 != null)
            {
                if (marker2.Name != "DEFAULT")
                {
                    items[0] = marker2.Name;
                    items[1] = marker2.TimeStamp.ToString();
                    ListViewItem item = new ListViewItem(items)
                    {
                        Tag = marker2
                    };
                    this.listView1.Items.Add(item);
                }
                marker2 = historicalMarkers.Next();
            }
        }
Exemplo n.º 6
0
 public void GetDifferences1(IWorkspace iworkspace_0, string string_0, string string_1,
                             TreeNodeCollection treeNodeCollection_0, IList ilist_0)
 {
     try
     {
         this.bool_0 = false;
         IFeatureWorkspace   iworkspace0        = iworkspace_0 as IFeatureWorkspace;
         IVersionedWorkspace versionedWorkspace = iworkspace_0 as IVersionedWorkspace;
         IFeatureWorkspace   featureWorkspace   = versionedWorkspace.FindVersion(string_0) as IFeatureWorkspace;
         IFeatureWorkspace   featureWorkspace1  = versionedWorkspace.FindVersion(string_1) as IFeatureWorkspace;
         ilist_0.Clear();
         DateTime now = DateTime.Now;
         ilist_0.Add(string.Concat("Version Difference Report - ", now.ToLongDateString()));
         ilist_0.Add(string.Concat("Parent/Grandparent/.. Version: ", string_0));
         ilist_0.Add(string.Concat("Child Version: ", string_1));
         ilist_0.Add("________________________________________________________");
         this.CheckDatasetForDifferences(treeNodeCollection_0, iworkspace0, featureWorkspace, featureWorkspace1,
                                         string_0, string_1, ilist_0);
         if (!this.bool_0)
         {
             ilist_0.Add("No differences found.");
         }
     }
     catch
     {
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 得到一个SDE数据库中的所有版本名称
 /// </summary>
 /// <param name="pWorkspace"></param>
 /// <returns></returns>
 public static string[] GetAllVersionName(IWorkspace pWorkspace)
 {
     string[] result = null;
     if (pWorkspace != null)
     {
         try
         {
             ArrayList           arr    = new ArrayList();
             IVersionedWorkspace pVerWs = pWorkspace as IVersionedWorkspace;
             if (pVerWs == null)
             {
                 return(null);
             }
             IEnumVersionInfo pEnumInfo = pVerWs.Versions;
             pEnumInfo.Reset();
             IVersionInfo pInfo = pEnumInfo.Next();
             while (pInfo != null)
             {
                 arr.Add(pInfo.VersionName.ToString());
                 pInfo = pEnumInfo.Next();
             }
             result = (string[])arr.ToArray(typeof(string));
         }
         catch (System.Exception ex)
         {
         }
     }
     return(result);
 }
Exemplo n.º 8
0
        private bool method_7(IVersionedWorkspace iversionedWorkspace_0, IEnumVersionInfo ienumVersionInfo_0,
                              string string_0, bool bool_2, bool bool_3)
        {
            bool flag = true;

            try
            {
                for (IVersionInfo i = ienumVersionInfo_0.Next(); i != null; i = ienumVersionInfo_0.Next())
                {
                    if (!bool_2)
                    {
                        if (this.method_8(iversionedWorkspace_0.FindVersion(i.VersionName) as IVersionEdit, string_0,
                                          bool_2, bool_3))
                        {
                            this.method_7(iversionedWorkspace_0, i.Children, i.VersionName, bool_2, bool_3);
                        }
                    }
                    else if (!this.method_7(iversionedWorkspace_0, i.Children, i.VersionName, bool_2, bool_3))
                    {
                        flag = false;
                    }
                    else if (
                        !this.method_8(iversionedWorkspace_0.FindVersion(i.VersionName) as IVersionEdit, string_0,
                                       bool_2, bool_3))
                    {
                        flag = true;
                    }
                }
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 9
0
 public void ChangeVersionByName(IGraphicsContainer igraphicsContainer_0, IFeatureWorkspace ifeatureWorkspace_0,
                                 string string_0)
 {
     try
     {
         if ((((igraphicsContainer_0 != null) && (ifeatureWorkspace_0 != null)) && (string_0.Length != 0)) &&
             (ifeatureWorkspace_0 is IVersionedWorkspace))
         {
             IVersionedWorkspace workspace     = ifeatureWorkspace_0 as IVersionedWorkspace;
             string       versionName          = (workspace as IVersion).VersionName;
             IPropertySet connectionProperties = (ifeatureWorkspace_0 as IWorkspace).ConnectionProperties;
             try
             {
                 connectionProperties.GetProperty("Version").ToString();
             }
             catch
             {
             }
             IVersion version = workspace.FindVersion(string_0);
             if (version == null)
             {
             }
             this.ChangeVersion(igraphicsContainer_0, ifeatureWorkspace_0, version as IFeatureWorkspace);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Exemplo n.º 10
0
 public void GetDifferences1(IWorkspace iworkspace_0, string string_0, string string_1,
                             TreeNodeCollection treeNodeCollection_0, IList ilist_0)
 {
     try
     {
         this.bool_0 = false;
         IFeatureWorkspace   workspace  = iworkspace_0 as IFeatureWorkspace;
         IVersionedWorkspace workspace2 = iworkspace_0 as IVersionedWorkspace;
         IFeatureWorkspace   workspace3 = workspace2.FindVersion(string_0) as IFeatureWorkspace;
         IFeatureWorkspace   workspace4 = workspace2.FindVersion(string_1) as IFeatureWorkspace;
         ilist_0.Clear();
         ilist_0.Add("Version Difference Report - " + DateTime.Now.ToLongDateString());
         ilist_0.Add("Parent/Grandparent/.. Version: " + string_0);
         ilist_0.Add("Child Version: " + string_1);
         ilist_0.Add("________________________________________________________");
         this.CheckDatasetForDifferences(treeNodeCollection_0, workspace, workspace3, workspace4, string_0,
                                         string_1, ilist_0);
         if (!this.bool_0)
         {
             ilist_0.Add("No differences found.");
         }
     }
     catch
     {
     }
 }
Exemplo n.º 11
0
        /// <summary>
        ///  删除当前版本
        /// </summary>
        /// <param name="pWorkspace">工作区</param>
        /// <param name="VersionName">版本名称</param>
        /// <returns></returns>
        public static bool DeleteVersion(IWorkspace pWorkspace, string VersionName)
        {
            IVersionedWorkspace pVerWorkspace = (IVersionedWorkspace)pWorkspace;
            IVersion            pVersion      = pVerWorkspace.FindVersion(VersionName);

            pVersion.Delete();
            return(true);
        }
        private void listProjects_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Need to clear the versions when selected
            this.listVersions.DataSource = null;

            string selectedProject = null;

            try
            {
                selectedProject = (string)this.listProjects.SelectedValue;
            }
            catch { return; }

            if (selectedProject == null)
            {
                return;
            }

            // Prompt the user to select a version. Open the database
            IPropertySet connectionProperties = new PropertySetClass();

            connectionProperties.SetProperty("SERVER", "malachite\\azgsgeodatabases");
            connectionProperties.SetProperty("INSTANCE", "sde:sqlserver:malachite\\azgsgeodatabases");
            connectionProperties.SetProperty("DATABASE", selectedProject);
            connectionProperties.SetProperty("AUTHENTICATION_MODE", "OSA");
            connectionProperties.SetProperty("VERSION", "dbo.Default");

            IWorkspaceFactory   wsFact = new SdeWorkspaceFactoryClass();
            IVersionedWorkspace vWs    = (IVersionedWorkspace)wsFact.Open(connectionProperties, 0);

            // Build a DataTable to bind to the listbox control
            DataTable verTable = new DataTable();

            DataColumn verName = new DataColumn();

            verName.ColumnName = "VersionName";
            verName.DataType   = typeof(string);

            verTable.Columns.Add(verName);

            IEnumVersionInfo theseVersions = vWs.Versions;
            IVersionInfo     aVersion      = theseVersions.Next();

            while (aVersion != null)
            {
                string   thisVersionName = (string)aVersion.VersionName;
                string[] Split           = thisVersionName.Split(new char[] { '.' });
                verTable.Rows.Add(Split[1]);
                aVersion = theseVersions.Next();
            }

            this.listVersions.DataSource    = verTable;
            this.listVersions.DisplayMember = "VersionName";
            this.listVersions.ValueMember   = "VersionName";
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Deletes the version (when it exists).
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">The name.</param>
        public static void DeleteVersion(this IVersionedWorkspace source, string name)
        {
            using (ComReleaser cr = new ComReleaser())
            {
                var version = source.GetVersion(name);
                cr.ManageLifetime(version);

                if (version != null)
                {
                    version.Delete();
                }
            }
        }
Exemplo n.º 14
0
        public void DeleteVersion(IWorkspace workspace, string versionName)
        {
            IVersionedWorkspace vw  = workspace as IVersionedWorkspace;
            IVersion            ver = vw.FindVersion(versionName);
            AppManager          am  = AppManager.GetInstance();

            if (am.CurrentVersion.VersionName == versionName)
            {
                MainForm mf = am.AppForm;
                mf.ChangeToDefaultVersion();
            }
            ver.Delete();
        }
Exemplo n.º 15
0
        public void DeleteTask(string taskName)
        {
            IFeatureWorkspace ws       = Util.ServerWorkspace as IFeatureWorkspace;
            ITable            task_tbl = ws.OpenTable("TaskLog");
            IQueryFilter      filter   = new QueryFilterClass();

            filter.WhereClause = "TaskName = '" + taskName + "'";
            ICursor        cur = task_tbl.Search(filter, false);
            IRow           rw  = cur.NextRow();
            IWorkspaceEdit wse = ws as IWorkspaceEdit;

            if (rw != null)
            {
                string status = rw.get_Value(task_tbl.FindField("Status")) as string;
                if (status == TaskManager.CHECKOUT_STATUS)
                {
                    wse.StartEditing(true);
                    rw.Delete();
                    wse.StopEditing(true);
                }
                else if (status == TaskManager.CHECKIN_STATUS)
                {
                    IVersionedWorkspace vw  = ws as IVersionedWorkspace;
                    IVersion            ver = vw.FindVersion(taskName);
                    ver.Delete();

                    wse.StartEditing(true);
                    rw.Delete();
                    wse.StopEditing(true);
                }
                wse.StartEditing(false);
                ITable       tgl_tbl    = ws.OpenTable("TaskGridLog");
                IQueryFilter tgl_filter = new QueryFilterClass();
                tgl_filter.WhereClause = "TaskName = '" + taskName + "'";
                tgl_tbl.DeleteSearchedRows(tgl_filter);
                wse.StopEditing(true);

                IQueryFilter checkItem_filter = new QueryFilterClass();
                checkItem_filter.WhereClause = "VersionName = '" + taskName + "'";
                wse.StartEditing(false);
                ITable checkItemPtn_fc = ws.OpenTable("CheckItemPtn");
                checkItemPtn_fc.DeleteSearchedRows(checkItem_filter);

                ITable checkItemLn_fc = ws.OpenTable("CheckItemLn");
                checkItemLn_fc.DeleteSearchedRows(checkItem_filter);

                ITable checkItemPoly_fc = ws.OpenTable("CheckItemPoly");
                checkItemPoly_fc.DeleteSearchedRows(checkItem_filter);
                wse.StopEditing(true);
            }
        }
Exemplo n.º 16
0
        public bool ExistVersion(IWorkspace workspace, string versionName)
        {
            IVersionedWorkspace vw = workspace as IVersionedWorkspace;

            try
            {
                IVersion ver = vw.FindVersion(versionName);
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 17
0
 public void List_CO_Versions(IWorkspace iworkspace_0)
 {
     if (iworkspace_0 is IVersionedWorkspace)
     {
         IVersionedWorkspace workspace = iworkspace_0 as IVersionedWorkspace;
         IEnumVersionInfo    versions  = workspace.Versions;
         versions.Reset();
         for (IVersionInfo info2 = versions.Next(); info2 != null; info2 = versions.Next())
         {
             if (!this.method_0(info2.VersionName, iworkspace_0 as IWorkspaceReplicas))
             {
             }
         }
     }
 }
Exemplo n.º 18
0
        public static List <IVersion> GetParentVersionList(IVersion pVersion)
        {
            List <IVersion> versions = new List <IVersion>();

            if (pVersion.HasParent())
            {
                IVersionedWorkspace versionedWorkspace = pVersion as IVersionedWorkspace;
                IEnumVersionInfo    ancestors          = pVersion.VersionInfo.Ancestors;
                IVersionInfo        versionInfo        = ancestors.Next();
                while (versionInfo != null)
                {
                    versions.Add(versionedWorkspace.FindVersion(versionInfo.VersionName));
                    versionInfo = ancestors.Next();
                }
            }
            return(versions);
        }
Exemplo n.º 19
0
        public IVersion CreateNewVersion(IVersionedWorkspace versionedWorkspace, string versionName, string parentVersionName)
        {
            IVersion newVersion = null;
            IVersion parentVersion = null;
            try
            {
                if (parentVersionName == "")
                {
                    parentVersion = versionedWorkspace.DefaultVersion;
                }
                else
                {
                    parentVersion = versionedWorkspace.FindVersion(parentVersionName);
                }
            }
            catch
            {
                MessageBox.Show("không tìm thấy version :" + parentVersionName);
            }

            try
            {
                /*
                *   Delete the version if it exists.
                */

                newVersion = versionedWorkspace.FindVersion(versionName);
                newVersion.Delete();
                newVersion = parentVersion.CreateVersion(versionName);
                //newVersion = new SeVersion(conn);
            }
            catch (Exception e)
            {
                //if( e.get.getSdeError() == IError.SE_VERSION_NOEXIST )
                try
                {
                    newVersion = parentVersion.CreateVersion(versionName);
                }
                catch (Exception se)
                {
                    MessageBox.Show(se.ToString());
                }
            }
            newVersion.Access = esriVersionAccess.esriVersionAccessPublic;
            return newVersion;
        }
Exemplo n.º 20
0
 private void method_1(IVersionedWorkspace iversionedWorkspace_1, TreeView treeView_0)
 {
     try
     {
         IVersionInfo versionInfo = iversionedWorkspace_1.DefaultVersion.VersionInfo;
         TreeNode     node        = new TreeNode(versionInfo.VersionName)
         {
             Tag = versionInfo
         };
         treeView_0.Nodes.Add(node);
         this.method_0(versionInfo, node);
         treeView_0.SelectedNode = node;
     }
     catch
     {
     }
 }
Exemplo n.º 21
0
        public void ChangeToCheckOutVerstion(string versionName)
        {
            this.superTabControl1.SelectedTabIndex = 1;
            IVersionedWorkspace    vws  = Util.ServerWorkspace as IVersionedWorkspace;
            IVersion               ver  = vws.DefaultVersion;
            IMapAdmin3             ma   = this.axMapControl2.Map as IMapAdmin3;
            IBasicMap              bmap = this.axMapControl2.Map as IBasicMap;
            AppManager             am   = AppManager.GetInstance();
            IChangeDatabaseVersion cdv  = new ChangeDatabaseVersionClass();

            ma.FireChangeVersion(am.CurrentVersion, ver);
            cdv.Execute(am.CurrentVersion, ver, bmap);

            am.CurrentVersion = ver;
            am.TaskName       = versionName;

            LocateTask(versionName);
        }
Exemplo n.º 22
0
        private bool method_3(IVersionedWorkspace iversionedWorkspace_1, IEnumVersionInfo ienumVersionInfo_0,
                              string string_0, bool bool_0, bool bool_1)
        {
            bool flag = true;

            try
            {
                for (IVersionInfo info = ienumVersionInfo_0.Next(); info != null; info = ienumVersionInfo_0.Next())
                {
                    IVersionEdit edit;
                    if (bool_0)
                    {
                        if (!this.method_3(iversionedWorkspace_1, info.Children, info.VersionName, bool_0, bool_1))
                        {
                            flag = false;
                            this.txtMessage.Text = "无法合并 " + info.VersionName + "的所有子版";
                        }
                        else
                        {
                            this.txtMessage.Text = "正在合并 " + info.VersionName;
                            edit = iversionedWorkspace_1.FindVersion(info.VersionName) as IVersionEdit;
                            if (!this.method_4(edit, string_0, bool_0, bool_1))
                            {
                                flag = true;
                            }
                        }
                    }
                    else
                    {
                        this.txtMessage.Text = "正在合并 " + info.VersionName;
                        edit = iversionedWorkspace_1.FindVersion(info.VersionName) as IVersionEdit;
                        if (this.method_4(edit, string_0, bool_0, bool_1))
                        {
                            this.method_3(iversionedWorkspace_1, info.Children, info.VersionName, bool_0, bool_1);
                        }
                    }
                }
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 23
0
 private void btnModifyVersion_Click(object sender, EventArgs e)
 {
     if (m_pWorkspace != null)
     {
         if (m_pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
         {
             if (m_pWorkspace is IVersionedWorkspace)
             {
                 m_pVersionedWorkspace = m_pWorkspace as IVersionedWorkspace;
             }
         }
     }
     //打开版本修改界面
     if (m_pVersionedWorkspace != null)
     {
         frmChangeVersion frmChangeVersion1 = new frmChangeVersion(m_pVersionedWorkspace);
         frmChangeVersion1.Show();
     }
 }
Exemplo n.º 24
0
 private void btnModifyVersion_Click(object sender, EventArgs e)
 {
     if (m_pWorkspace != null)
     {
         if (m_pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
         {
             if (m_pWorkspace is IVersionedWorkspace)
             {
                 m_pVersionedWorkspace = m_pWorkspace as IVersionedWorkspace;
             }
         }
     }
     //�򿪰汾�޸Ľ���
     if (m_pVersionedWorkspace != null)
     {
         frmChangeVersion frmChangeVersion1 = new frmChangeVersion(m_pVersionedWorkspace);
         frmChangeVersion1.Show();
     }
 }
Exemplo n.º 25
0
 private string method_0(string string_0)
 {
     if (this.iworkspace_0 is IVersionedWorkspace)
     {
         IVersionedWorkspace workspace = this.iworkspace_0 as IVersionedWorkspace;
         try
         {
             IVersion version = workspace.FindVersion(string_0);
             if (version.HasParent())
             {
                 return(version.VersionInfo.Parent.VersionName);
             }
         }
         catch
         {
         }
     }
     return("");
 }
Exemplo n.º 26
0
        /// <summary>
        ///     Gets the version.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">The name.</param>
        /// <returns>Returns a <see cref="IVersion" /> representing the version.</returns>
        public static IVersion GetVersion(this IVersionedWorkspace source, string name)
        {
            try
            {
                var version = source.FindVersion(name);
                version.RefreshVersion();

                return(version);
            }
            catch (COMException e)
            {
                if (e.ErrorCode == (int)fdoError.FDO_E_VERSION_NOT_FOUND ||
                    e.ErrorCode == (int)fdoError.FDO_E_SE_VERSION_NOEXIST)
                {
                    return(null);
                }

                throw;
            }
        }
Exemplo n.º 27
0
        public void ChangeToDefaultVersion()
        {
            IVersionedWorkspace    vws  = Util.ServerWorkspace as IVersionedWorkspace;
            IVersion               ver  = vws.DefaultVersion;
            IMapAdmin3             ma   = this.axMapControl2.Map as IMapAdmin3;
            IBasicMap              bmap = this.axMapControl2.Map as IBasicMap;
            AppManager             am   = AppManager.GetInstance();
            IChangeDatabaseVersion cdv  = new ChangeDatabaseVersionClass();

            cdv.Execute(am.CurrentVersion, ver, bmap);

            am.CurrentVersion = ver;
            am.TaskName       = "";

            IGraphicsContainer gcon = this.axMapControl2.ActiveView.GraphicsContainer;

            gcon.DeleteAllElements();
            this.axMapControl2.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
            this.lstGrids.Items.Clear();
        }
Exemplo n.º 28
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            if (this.int_0 == 0)
            {
                file.AddFilter(new MyGxFilterGeoDatabases(), true);
            }
            else
            {
                file.AddFilter(new MyGxFilterPersonalGeodatabases(), true);
            }
            if ((file.DoModalOpen() == DialogResult.OK) && (file.Items.Count > 0))
            {
                IGxObject obj2 = file.Items.get_Element(0) as IGxObject;
                if (obj2 is IGxDatabase)
                {
                    if (this.int_0 == 0)
                    {
                        this.iversionedWorkspace_0 = (obj2 as IGxDatabase).Workspace as IVersionedWorkspace;
                        if (this.iversionedWorkspace_0 == null)
                        {
                            MessageBox.Show("请选择企业数据库!");
                            this.textEdit1.Text = "";
                            this.btnOK.Enabled  = false;
                        }
                        else
                        {
                            this.textEdit1.Text = obj2.FullName;
                            this.btnOK.Enabled  = true;
                        }
                    }
                    else
                    {
                        this.textEdit1.Text     = obj2.FullName;
                        this.idatabaseCompact_0 = (obj2 as IGxDatabase).Workspace as IDatabaseCompact;
                        this.btnOK.Enabled      = this.idatabaseCompact_0 != null;
                    }
                }
            }
        }
Exemplo n.º 29
0
        private void AddVersionsToComb(IWorkspace pWorkSpace)
        {
            IVersionedWorkspace pVerWorkspace    = null;
            IEnumVersionInfo    pEnumVersionInfo = null;

            pVerWorkspace    = (IVersionedWorkspace)pWorkSpace;
            pEnumVersionInfo = pVerWorkspace.Versions;
            pEnumVersionInfo.Reset();

            IVersionInfo pVersionInfo = default(IVersionInfo);

            pVersionInfo = pEnumVersionInfo.Next();

            ////在组合框中加载sde的所有版本
            while (!(pVersionInfo == null))
            {
                cboVersion.Items.Add(pVersionInfo.VersionName);
                pVersionInfo = pEnumVersionInfo.Next();
            }
            cboVersion.Text = "SDE.DEFAULT";
        }
Exemplo n.º 30
0
        public static IFIDSet FindVersionDifferences(IWorkspace workspace, String sourceVersionName, String targetVersionName, String tableName, esriDifferenceType differenceType)
        {
            // Get references to the child and parent versions.
            IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
            IVersion            sourceVersion      = versionedWorkspace.FindVersion(sourceVersionName);
            IVersion            targetVersion      = versionedWorkspace.FindVersion(targetVersionName);

            // Cast to the IVersion2 interface to find the common ancestor.
            IVersion2 sourceVersion2        = (IVersion2)sourceVersion;
            IVersion  commonAncestorVersion = sourceVersion2.GetCommonAncestor(targetVersion);

            // Cast the child version to IFeatureWorkspace and open the table.
            IFeatureWorkspace targetFWS   = (IFeatureWorkspace)sourceVersion;
            ITable            targetTable = targetFWS.OpenTable(tableName);

            // Cast the common ancestor version to IFeatureWorkspace and open the table.
            IFeatureWorkspace commonAncestorFWS   = (IFeatureWorkspace)commonAncestorVersion;
            ITable            commonAncestorTable = commonAncestorFWS.OpenTable(tableName);

            // Cast to the IVersionedTable interface to create a difference cursor.
            IVersionedTable   versionedTable   = (IVersionedTable)targetTable;
            IDifferenceCursor differenceCursor = versionedTable.Differences(commonAncestorTable, differenceType, null);

            // Create output variables for the IDifferenceCursor.Next method and a FID set.
            IFIDSet fidSet        = new FIDSetClass();
            IRow    differenceRow = null;
            int     objectID      = -1;

            // Step through the cursor, showing the ID of each modified row.
            differenceCursor.Next(out objectID, out differenceRow);
            while (objectID != -1)
            {
                fidSet.Add(objectID);
                differenceCursor.Next(out objectID, out differenceRow);
            }

            fidSet.Reset();
            return(fidSet);
        }
Exemplo n.º 31
0
        public void StopEditing(bool saveChanges)
        {
            var workspaceEdit = CurrentWorkspace as IWorkspaceEdit2;

            if (CurrentWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                IVersionedWorkspace versionWorkspace = (IVersionedWorkspace)CurrentWorkspace;
                IVersion2           version2         = (IVersion2)versionWorkspace;

                if (version2 != null && version2.IsRedefined)
                {
                    IVersionEdit4 version4 = (IVersionEdit4)CurrentWorkspace;
                    version4.Reconcile4("SDE.DEFAULT",
                                        false,
                                        false,
                                        true,
                                        true);
                }
            }

            workspaceEdit.StopEditing(saveChanges);
        }
Exemplo n.º 32
0
        public static IFIDSet FindVersionDifferences(IWorkspace workspace, string childVersionName,
                                                     string parentVersionName, string tableName, esriDifferenceType differenceType)
        {
            IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
            IVersion            version            = versionedWorkspace.FindVersion(childVersionName);
            IVersion            version1           = versionedWorkspace.FindVersion(parentVersionName);
            IVersion            commonAncestor     = ((IVersion2)version).GetCommonAncestor(version1);
            ITable            table            = ((IFeatureWorkspace)version).OpenTable(tableName);
            ITable            table1           = ((IFeatureWorkspace)commonAncestor).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);
        }
Exemplo n.º 33
0
 public IVersion CreateNewVersion(IVersionedWorkspace versionedWorkspace, string versionName,esriVersionAccess access)
 {
     IVersion newVersion = null;
     IVersion parentVersion = null;
     try
     {
         /*
         *   Delete the version if it exists.
         */
         parentVersion = versionedWorkspace.DefaultVersion;
         newVersion = versionedWorkspace.FindVersion(versionName);
         newVersion.Delete();
         newVersion = parentVersion.CreateVersion(versionName);
         //newVersion = new SeVersion(conn);
     }
     catch (Exception e)
     {
         //if( e.get.getSdeError() == IError.SE_VERSION_NOEXIST )
         try
         {
             newVersion = parentVersion.CreateVersion(versionName);
         }
         catch (Exception se)
         {
             MessageBox.Show(se.ToString());
         }
     }
     newVersion.Access = access;
     return newVersion;
 }
Exemplo n.º 34
0
 public frmChangeVersion(IVersionedWorkspace _pVersionedWorkspace)
 {
     pVersionedWorkspace = _pVersionedWorkspace;
     InitializeComponent();
 }