Beispiel #1
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);
        }
Beispiel #2
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);
 }
 private void frmSDEConnectionDetialInfo_Load(object sender, EventArgs e)
 {
     if (this.iworkspace_0 != null)
     {
         IEnumVersionInfo versions = (this.iworkspace_0 as IVersionedWorkspace2).Versions;
         versions.Reset();
         IVersionInfo info2 = versions.Next();
         string[]     items = new string[2];
         while (info2 != null)
         {
             items[0] = info2.VersionName;
             items[1] = info2.Description;
             ListViewItem item = new ListViewItem(items)
             {
                 Tag = info2
             };
             this.lvwVersions.Items.Add(item);
             info2 = versions.Next();
         }
         IHistoricalWorkspace  workspace         = this.iworkspace_0 as IHistoricalWorkspace;
         IEnumHistoricalMarker historicalMarkers = workspace.HistoricalMarkers;
         historicalMarkers.Reset();
         for (IHistoricalMarker marker2 = historicalMarkers.Next();
              marker2 != null;
              marker2 = historicalMarkers.Next())
         {
             this.cboHistoricalMarker.Properties.Items.Add(marker2.Name);
         }
         if (this.cboHistoricalMarker.Properties.Items.Count > 0)
         {
             this.cboHistoricalMarker.SelectedIndex = 0;
         }
     }
 }
Beispiel #4
0
 private void method_0()
 {
     if (this.iversionedWorkspace_0 != null)
     {
         this.btnOK.Enabled = false;
         this.string_1      = (this.iversionedWorkspace_0 as IVersion).VersionName;
         this.string_0      = null;
         IVersionInfo     versionInfo = this.iversionedWorkspace_0.DefaultVersion.VersionInfo;
         IEnumVersionInfo children    = versionInfo.Children;
         TreeNode         node        = new TreeNode(versionInfo.VersionName)
         {
             Tag = versionInfo
         };
         if (versionInfo.VersionName == this.string_1)
         {
             node.ImageIndex         = 1;
             node.SelectedImageIndex = 1;
         }
         else
         {
             node.ImageIndex         = 0;
             node.SelectedImageIndex = 0;
         }
         this.treeView1.Nodes.Add(node);
         this.method_1(node, children);
         node.ExpandAll();
     }
 }
Beispiel #5
0
 private void method_1()
 {
     if (this.iversionedWorkspace_0 != null)
     {
         this.VersionInfolist.Items.Clear();
         IEnumVersionInfo versions = this.iversionedWorkspace_0.Versions;
         versions.Reset();
         IVersionInfo info2 = versions.Next();
         string[]     items = new string[5];
         while (info2 != null)
         {
             string[] strArray2 = info2.VersionName.Split(new char[] { '.' });
             if (strArray2.Length > 1)
             {
                 items[0] = strArray2[1];
                 items[1] = strArray2[0];
             }
             else
             {
                 items[0] = strArray2[0];
                 items[1] = "";
             }
             items[2] = this.method_0(info2.Access);
             items[3] = info2.Created.ToString();
             items[4] = info2.Modified.ToString();
             this.VersionInfolist.Items.Add(new ListViewItem(items));
             info2 = versions.Next();
         }
     }
 }
        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";
        }
Beispiel #7
0
        public static List <IVersionInfo> GetVersionInfoList(IWorkspace pWS)
        {
            List <IVersionInfo> versionInfos = new List <IVersionInfo>();
            IEnumVersionInfo    versions     = (pWS as IVersionedWorkspace).Versions;

            for (IVersionInfo i = versions.Next(); i != null; i = versions.Next())
            {
                versionInfos.Add(i);
            }
            return(versionInfos);
        }
Beispiel #8
0
 /// <summary>
 ///     Creates a <see cref="IEnumerable{IVersionInfo}" /> from the enumeration.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns>
 ///     Returns a <see cref="IEnumerable{T}" /> representing the enumeration of version information.
 /// </returns>
 public static IEnumerable <IVersionInfo> AsEnumerable(this IEnumVersionInfo source)
 {
     if (source != null)
     {
         source.Reset();
         IVersionInfo vi;
         while ((vi = source.Next()) != null)
         {
             yield return(vi);
         }
     }
 }
Beispiel #9
0
        public static List <string> GetParentVersionNameList(IVersion pVersion)
        {
            List <string> strs = new List <string>();

            if (pVersion.HasParent())
            {
                IEnumVersionInfo ancestors = pVersion.VersionInfo.Ancestors;
                for (IVersionInfo i = ancestors.Next(); i != null; i = ancestors.Next())
                {
                    strs.Add(i.VersionName);
                }
            }
            return(strs);
        }
 private void method_0()
 {
     if ((this.iversion_0 != null) && this.iversion_0.HasParent())
     {
         this.VersionListBox.Items.Clear();
         IEnumVersionInfo ancestors = this.iversion_0.VersionInfo.Ancestors;
         ancestors.Reset();
         for (IVersionInfo info2 = ancestors.Next(); info2 != null; info2 = ancestors.Next())
         {
             this.VersionListBox.Items.Add(info2.VersionName);
         }
         this.VersionListBox.SelectedIndex = 0;
     }
 }
Beispiel #11
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))
             {
             }
         }
     }
 }
Beispiel #12
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);
        }
Beispiel #13
0
        /// <summary>
        /// Builds a domain of the version names for a workspace
        /// </summary>
        /// <param name="wmxDb">A reference to the active Workflow Manager database</param>
        /// <param name="workspaceName">The human-readable name of the workspace whose versions to look up</param>
        /// <param name="extraValues">An array of string values to be added to the list</param>
        /// <returns>A coded value domain of strings</returns>
        public static IGPDomain BuildVersionsDomain(IJTXDatabase3 wmxDb, string workspaceName, string[] extraValues)
        {
            IGPCodedValueDomain domain = new GPCodedValueDomainClass();

            try
            {
                // Get all of the public versions connected to this workspace
                string               workspaceId        = Common.WmauHelperFunctions.LookupWorkspaceId(wmxDb, workspaceName);
                IWorkspace           workspace          = wmxDb.GetDataWorkspace(workspaceId, null);
                IVersionedWorkspace3 versionedWorkspace = workspace as IVersionedWorkspace3;
                IEnumVersionInfo     allValues          = versionedWorkspace.Versions;

                // Sort the types first
                SortedList <string, string> sortedValues = new SortedList <string, string>();
                IVersionInfo version;
                while ((version = allValues.Next()) != null)
                {
                    sortedValues.Add(version.VersionName, null);
                }

                // Add the extra values, if any
                if (extraValues != null)
                {
                    foreach (string s in extraValues)
                    {
                        sortedValues.Add(s, null);
                    }
                }

                // Add the sorted types to the domain
                foreach (string value in sortedValues.Keys)
                {
                    IGPValue tempGpVal = new GPStringClass();
                    tempGpVal.SetAsText(value);
                    domain.AddCode(tempGpVal, value);
                }
            }
            catch (System.Runtime.InteropServices.COMException comEx)
            {
                // If we run into an exception, send word up the chain
                throw new WmauException(WmauErrorCodes.C_VERSION_LOOKUP_ERROR, comEx);
            }

            return(domain as IGPDomain);
        }
Beispiel #14
0
        private void btnChangeVersion_Click(object sender, EventArgs e)
        {
            IWorkspace workspace = this.method_4();

            if (workspace != null)
            {
                IEnumVersionInfo versions = (workspace as IVersionedWorkspace2).Versions;
                frmSelectVersion version  = new frmSelectVersion
                {
                    EnumVersionInfo = versions
                };
                if (version.ShowDialog() == DialogResult.OK)
                {
                    this.string_1        = version.VersionName;
                    this.lblVersion.Text = this.string_1;
                }
            }
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public static ArrayList getVerionNameList(IWorkspace pWorkspace)
        {
            if (pWorkspace == null)
            {
                return(null);
            }
            IFeatureWorkspace    FeatureWorkspace   = pWorkspace as IFeatureWorkspace;
            IVersionedWorkspace3 VersionedWorkspace = FeatureWorkspace as IVersionedWorkspace3;
            ArrayList            VersionNames       = new ArrayList();
            IEnumVersionInfo     MulVersionInfo     = VersionedWorkspace.Versions;
            IVersionInfo         SiglVersionInfo    = MulVersionInfo.Next();

            while (SiglVersionInfo != null)
            {
                VersionNames.Add(SiglVersionInfo.VersionName);
                SiglVersionInfo = MulVersionInfo.Next();
            }
            return(VersionNames);
        }
Beispiel #17
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";
        }
Beispiel #18
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            this.btnStart.Enabled = false;
            this.btnClose.Enabled = false;
            string text = this.VersionTreeView.SelectedNode.Text;

            try
            {
                IVersion         version  = this.iversionedWorkspace_0.FindVersion(text);
                IEnumVersionInfo children = version.VersionInfo.Children;
                if (children.Next() == null)
                {
                    MessageBox.Show("版本[" + text + "]无要合并的子版本!");
                    this.btnStart.Enabled = true;
                    this.btnClose.Enabled = true;
                    return;
                }
                this.txtMessage.Text = "开始合并";
                if (this.chkPost.Checked)
                {
                    children.Reset();
                    this.method_3(this.iversionedWorkspace_0, children, version.VersionName, true,
                                  this.chkDeleteOnPost.Checked);
                }
                this.method_3(this.iversionedWorkspace_0, version.VersionInfo.Children, version.VersionName, false,
                              false);
                this.txtMessage.Text = "合并完成";
            }
            catch (COMException exception)
            {
                if (exception.ErrorCode == -2147215997)
                {
                    MessageBox.Show("该用户不是版本 [" + text + "] 的所有者,无法修改版本的信息");
                }
                this.txtMessage.Text = "合并失败!";
            }
            this.btnStart.Enabled = true;
            this.btnClose.Enabled = true;
        }
Beispiel #19
0
 private void method_1(IVersionInfo iversionInfo_0, TreeNode treeNode_0)
 {
     try
     {
         treeNode_0.Expand();
         IEnumVersionInfo children = iversionInfo_0.Children;
         iversionInfo_0 = children.Next();
         while (iversionInfo_0 != null)
         {
             TreeNode node = new TreeNode(iversionInfo_0.VersionName)
             {
                 Tag = iversionInfo_0
             };
             treeNode_0.Nodes.Add(node);
             this.method_1(iversionInfo_0, node);
             iversionInfo_0 = children.Next();
         }
     }
     catch
     {
     }
 }
Beispiel #20
0
 private void method_1(TreeNode treeNode_0, IEnumVersionInfo ienumVersionInfo_0)
 {
     ienumVersionInfo_0.Reset();
     for (IVersionInfo info = ienumVersionInfo_0.Next(); info != null; info = ienumVersionInfo_0.Next())
     {
         TreeNode node = new TreeNode(info.VersionName)
         {
             Tag = info
         };
         if (info.VersionName == this.string_1)
         {
             node.ImageIndex         = 1;
             node.SelectedImageIndex = 1;
         }
         else
         {
             node.ImageIndex         = 0;
             node.SelectedImageIndex = 0;
         }
         treeNode_0.Nodes.Add(node);
         this.method_1(node, info.Children);
     }
 }
Beispiel #21
0
        public void GetVersionInfo(IWorkspace workspace)
        {
            if (workspace.Type != esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                return;
            }

            this.cboVersion.Properties.Items.Clear();
            IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspace;
            IEnumVersionInfo    enumVersionInfo    = versionedWorkspace.Versions;

            enumVersionInfo.Reset();
            IVersionInfo version = (IVersionInfo)enumVersionInfo.Next();

            if (version != null)
            {
                this.cboVersion.Properties.Items.Clear();
            }
            while (version != null)
            {
                this.cboVersion.Properties.Items.Add(version.VersionName);
                version = (IVersionInfo)enumVersionInfo.Next();
            }
        }
Beispiel #22
0
 private void method_2()
 {
     if (this.iworkspace_0 != null)
     {
         this.VersionInfolist.Items.Clear();
         IEnumVersionInfo versions = (this.iworkspace_0 as IVersionedWorkspace).Versions;
         versions.Reset();
         IVersionInfo info2 = versions.Next();
         string[]     items = new string[5];
         while (info2 != null)
         {
             string   versionName = info2.VersionName;
             string[] strArray2   = versionName.Split(new char[] { '.' });
             if (strArray2.Length > 1)
             {
                 items[0] = strArray2[1];
                 items[1] = strArray2[0];
             }
             else
             {
                 items[0] = strArray2[0];
                 items[1] = "";
             }
             items[2] = this.method_1(info2.Access);
             items[3] = info2.Created.ToString();
             items[4] = info2.Modified.ToString();
             ListViewItem item = new ListViewItem(items)
             {
                 Tag = info2
             };
             this.VersionInfolist.Items.Add(item);
             if ((this.int_0 == 0) && (versionName == this.object_0.ToString()))
             {
                 item.Selected = true;
             }
             info2 = versions.Next();
         }
         IHistoricalWorkspace  workspace         = this.iworkspace_0 as IHistoricalWorkspace;
         IEnumHistoricalMarker historicalMarkers = workspace.HistoricalMarkers;
         historicalMarkers.Reset();
         for (IHistoricalMarker marker2 = historicalMarkers.Next();
              marker2 != null;
              marker2 = historicalMarkers.Next())
         {
             this.cboHistoricalMarker.Properties.Items.Add(marker2.Name);
             if ((this.int_0 == 1) && (marker2.Name == this.object_0.ToString()))
             {
                 this.cboHistoricalMarker.SelectedIndex = this.cboHistoricalMarker.Properties.Items.Count - 1;
             }
         }
         if ((this.cboHistoricalMarker.Properties.Items.Count > 0) &&
             (this.cboHistoricalMarker.SelectedIndex == -1))
         {
             this.cboHistoricalMarker.SelectedIndex = 0;
         }
         this.dateTimePicker1.Value = DateTime.Now;
         if (this.int_0 == 0)
         {
             this.cboVersionType.SelectedIndex = 0;
             this.panelHistorical.Visible      = false;
         }
         else
         {
             if (this.int_0 == 2)
             {
                 this.dateTimePicker1.Value = (DateTime)this.object_0;
             }
             this.cboVersionType.SelectedIndex = 1;
             this.panelTransaction.Visible     = false;
             this.cboVersionType_SelectedIndexChanged(this, new EventArgs());
             this.rdoHistoryType_SelectedIndexChanged(this, new EventArgs());
         }
     }
 }
Beispiel #23
0
        public int UpdateAssets(List <AssetModified> assetModifieds)
        {
            int num;

            this.dtStartTime = DateTime.Now;
            Assets.logger.Debug(string.Concat("UpdateAssets start at ", this.dtStartTime.ToString()));
            IPropertySet propertySet = Assets.GetPropertySet();
            int          counter     = 0;

            try
            {
                IWorkspace          workspaceName      = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0);
                IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName;
                IEnumVersionInfo    enumVersionInfo    = versionedWorkspace.Versions;
                enumVersionInfo.Reset();
                IVersionInfo existversionInfo = enumVersionInfo.Next();
                while (existversionInfo != null)
                {
                    if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT"))
                    {
                        existversionInfo = enumVersionInfo.Next();
                    }
                    else
                    {
                        versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete();
                        break;
                    }
                }
                enumVersionInfo.Reset();
                IVersion version    = (IVersion)((IFeatureWorkspace)workspaceName);
                string   name       = version.VersionInfo.VersionName;
                IVersion dtsVersion = version.CreateVersion("DTS_EDIT");
                dtsVersion.Access      = esriVersionAccess.esriVersionAccessPublic;
                dtsVersion.Description = "Update DTS to MSD Ownership via DTS app";
                if (dtsVersion.VersionName.Contains("DTS_EDIT"))
                {
                    IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion;
                    IWorkspaceEdit          workspaceEdit          = (IWorkspaceEdit)dtsVersion;
                    IVersionEdit4           versionEdit            = (IVersionEdit4)workspaceEdit;
                    if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
                    {
                        multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                        versionEdit.Reconcile4("MSD.QC", true, false, false, false);
                        workspaceEdit.StartEditOperation();
                        ILog     log = Assets.logger;
                        DateTime now = DateTime.Now;
                        log.Debug(string.Concat("GetUpdateAssets start at ", now.ToString()));
                        counter = Assets.GetUpdateAssets(assetModifieds, counter, workspaceEdit);
                        ILog log1 = Assets.logger;
                        now = DateTime.Now;
                        log1.Debug(string.Concat("GetUpdateAssets end at ", now.ToString()));
                        if (versionEdit.CanPost())
                        {
                            versionEdit.Post("MSD.QC");
                        }
                        workspaceEdit.StopEditOperation();
                        workspaceEdit.StopEditing(true);
                    }
                }
                this.dtEndTime  = DateTime.Now;
                this.tsDiff     = this.dtEndTime.Subtract(this.dtStartTime);
                this.dlTimeDiff = this.tsDiff.TotalMilliseconds;
                Assets.logger.Debug(string.Concat("UpdateAssets end at ", this.dtStartTime.ToString(), " Total diff : ", this.dlTimeDiff.ToString()));
                num = counter;
            }
            catch (COMException cOMException)
            {
                COMException ex = cOMException;
                Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace));
                throw ex;
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                Assets.logger.Debug(string.Concat("Error from UpdateAssets : ", ex.Message, " ", ex.StackTrace));
                throw ex;
            }
            return(num);
        }
Beispiel #24
0
        public void UpdateAssetsTest()
        {
            RuntimeManager.Bind(ProductCode.Desktop);
            (new AoInitializeClass()).Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
            IPropertySet propertySet = new PropertySetClass();

            propertySet.SetProperty("Server", "RJMSDDBT02");
            propertySet.SetProperty("Instance", "sde:oracle11g:gisdevl");
            propertySet.SetProperty("Database", "GISDEVL");
            propertySet.SetProperty("user", "MSD");
            propertySet.SetProperty("password", "jc_tc1954");
            propertySet.SetProperty("version", "MSD.QC");
            int flag = 0;

            try
            {
                IWorkspace          workspaceName      = (new SdeWorkspaceFactoryClass()).Open(propertySet, 0);
                IVersionedWorkspace versionedWorkspace = (IVersionedWorkspace)workspaceName;
                IEnumVersionInfo    enumVersionInfo    = versionedWorkspace.Versions;
                enumVersionInfo.Reset();
                IVersionInfo existversionInfo = enumVersionInfo.Next();
                while (existversionInfo != null)
                {
                    if (!existversionInfo.VersionName.Trim().Equals("MSD.DTS_EDIT"))
                    {
                        existversionInfo = enumVersionInfo.Next();
                    }
                    else
                    {
                        versionedWorkspace.FindVersion("MSD.DTS_EDIT").Delete();
                        flag = 1;
                        break;
                    }
                }
                enumVersionInfo.Reset();
                IVersion version    = (IVersion)((IFeatureWorkspace)workspaceName);
                string   name       = version.VersionInfo.VersionName;
                IVersion dtsVersion = version.CreateVersion("DTS_EDIT");
                dtsVersion.Access      = esriVersionAccess.esriVersionAccessPublic;
                dtsVersion.Description = "Update DTS to MSD Ownership via DTS app";
                if (dtsVersion.VersionName.Contains("DTS_EDIT"))
                {
                    IMultiuserWorkspaceEdit multiuserWorkspaceEdit = (IMultiuserWorkspaceEdit)dtsVersion;
                    IWorkspaceEdit          workspaceEdit          = (IWorkspaceEdit)dtsVersion;
                    IVersionEdit4           versionEdit            = (IVersionEdit4)workspaceEdit;
                    if (multiuserWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
                    {
                        multiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                        versionEdit.Reconcile4("MSD.QC", true, false, false, false);
                        workspaceEdit.StartEditOperation();
                        IFeature featureEdit = ((IFeatureWorkspace)workspaceEdit).OpenFeatureClass("SWRAINGAUGE").GetFeature(330);
                        // Convert.ToString(featureEdit[6]);
                        Convert.ToString(featureEdit.Value[6]);
                        int      Totalfield          = featureEdit.Fields.FieldCount;
                        int      ownershipindex      = featureEdit.Fields.FindField("OWNERSHIP");
                        int      lastmodifieddtindex = featureEdit.Fields.FindField("LAST_MODIFIED_DATE");
                        DateTime lastmodifieddt      = DateTime.Now.Date;
                        //featureEdit[ownershipindex] = "1";
                        //featureEdit[lastmodifieddtindex] = lastmodifieddt.Date;
                        featureEdit.Value[ownershipindex]      = "1";
                        featureEdit.Value[lastmodifieddtindex] = lastmodifieddt.Date;
                        featureEdit.Store();
                        if (versionEdit.CanPost())
                        {
                            versionEdit.Post("MSD.QC");
                        }
                        workspaceEdit.StopEditOperation();
                        workspaceEdit.StopEditing(true);
                    }
                }
            }
            catch (COMException cOMException)
            {
                if (cOMException.ErrorCode == -2147217147)
                {
                }
            }
            catch (Exception exception)
            {
            }
        }
Beispiel #25
0
        /// <summary>
        /// 签出数据
        /// </summary>
        /// <param name="pMasterWorkspace">源工作空间</param>
        /// <param name="featureClassName">要素类的名字</param>
        /// <param name="featureDatasetName">数据集的名字</param>
        /// <param name="checkoutName">版本名称</param>
        /// <param name="onlySchema">是否只签出结构</param>
        /// <param name="reuseSchema">是否重用已有的结构</param>
        /// <param name="fileName">文件名</param>
        /// <param name="dataExtractionType">数据提取的类型(checkout或只导出数据)</param>
        /// <param name="replicaModelType">简单图层或与源工作空间结构相同</param>
        public void CheckOut(IWorkspace pMasterWorkspace,
                             string[] featureClassName,   //要素类类的名字
                             string[] featureDatasetName, //数据集的名字
                             string checkoutName,
                             bool onlySchema,
                             bool reuseSchema,
                             string fileName,
                             esriDataExtractionType dataExtractionType,
                             esriReplicaModelType replicaModelType)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            bool             hasVersion       = false;
            string           versionName      = System.IO.Path.GetFileNameWithoutExtension(fileName);
            IEnumVersionInfo pEnumVersionInfo = (pMasterWorkspace as IVersionedWorkspace).Versions;

            if (pEnumVersionInfo != null)
            {
                pEnumVersionInfo.Reset();
                IVersionInfo pVersionInfo = pEnumVersionInfo.Next();
                while (pVersionInfo != null)
                {
                    if (pVersionInfo.VersionName == "SDE." + checkoutName)
                    {
                        hasVersion = true;
                        break;
                    }
                    pVersionInfo = pEnumVersionInfo.Next();
                }
            }
            if (hasVersion)
            {
                IVersion pVersion = (pMasterWorkspace as IVersionedWorkspace).FindVersion(versionName);
                if (pVersion != null)
                {
                    pVersion.Delete();
                }
            }

            IPropertySet pCheckOutPropSet = new PropertySetClass();

            pCheckOutPropSet.SetProperty("Database", fileName);
            IWorkspaceFactory pCheckOutWorkFact = new AccessWorkspaceFactoryClass();
            string            path = System.IO.Path.GetDirectoryName(fileName);
            IWorkspaceName    pCheckOutWorkspaceName = pCheckOutWorkFact.Create(path, checkoutName, pCheckOutPropSet, 0);
            IName             pName = pCheckOutWorkspaceName as IName;
            IWorkspace        pCheckOutWorkspace = pName.Open() as IWorkspace;

            if (pCheckOutWorkspace != null)
            {
                IFeatureWorkspace   pMasterFeaWorkspace = pMasterWorkspace as IFeatureWorkspace;
                IFeatureClass       pFeaClass;
                IFeatureDataset     pFeatureDataset;
                IDataset            pDS;
                IEnumNameEdit       pEnumNameEdit = new NamesEnumeratorClass();
                IEnumName           pEnumName;
                IReplicaDescription pRepDescription = new ReplicaDescriptionClass();

                for (int i = 0; i < featureClassName.Length; i++)
                {
                    pFeaClass = pMasterFeaWorkspace.OpenFeatureClass(featureClassName[i]);
                    pDS       = pFeaClass as IDataset;
                    pEnumNameEdit.Add(pDS.FullName as IName);
                }

                for (int i = 0; i < featureDatasetName.Length; i++)
                {
                    pFeatureDataset = pMasterFeaWorkspace.OpenFeatureDataset(featureDatasetName[i]);
                    pDS             = pFeatureDataset as IDataset;
                    pEnumNameEdit.Add(pDS.FullName as IName);
                }

                pEnumName = pEnumNameEdit as IEnumName;
                pRepDescription.Init(pEnumName, pCheckOutWorkspaceName, false, dataExtractionType);
                pRepDescription.ReplicaModelType = replicaModelType;//简单图层类型或与SDE数据库一样
                ICheckOut pCheckOut = new CheckOutClass();
                try
                {
                    pCheckOut.CheckOutData(pRepDescription, true, checkoutName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("可能是备份的SDE数据没有注册为版本,或者是由于该文件名上次已经作为一个版本号存在数据库中。" + ex.ToString());
                }
                pCheckOutWorkspace = null;
                GC.Collect();
            }
        }