Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a new version in the database.
        /// </summary>
        /// <param name="source">The workspace that creates the version.</param>
        /// <param name="name">The name of the version.</param>
        /// <param name="access">The access level of the version.</param>
        /// <param name="description">The description of the version.</param>
        /// <param name="deleteExisting">Flag to delete version if it exists</param>
        /// <returns>
        ///     Returns the <see cref="IVersion" /> representing the version that was created; otherwise <c>null</c>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///     name
        ///     or
        ///     description
        /// </exception>
        public static IVersion CreateVersion(this IWorkspace source, string name, esriVersionAccess access, string description, bool deleteExisting)
        {
            if (source == null)
            {
                return(null);
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            if (deleteExisting)
            {
                source.DeleteVersion(name);
            }

            // Create the version
            IMMVersioningUtils versioningUtils = new MMVersioningUtilsClass();

            return(versioningUtils.CreateVersionFromBase(source, name, description, access));
        }
Ejemplo n.º 2
0
        private string method_1(esriVersionAccess esriVersionAccess_0)
        {
            switch (esriVersionAccess_0)
            {
            case esriVersionAccess.esriVersionAccessPrivate:
                return("私有");

            case esriVersionAccess.esriVersionAccessProtected:
                return("保护");
            }
            return("公共");
        }
Ejemplo n.º 3
0
        public IVersion CreateNewVersion(IVersionedWorkspace versionedWorkspace, string versionName, string parentVersionName,esriVersionAccess access)
        {
            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=access;
            return newVersion;
        }
        /// <summary>
        /// Called when a step of this type is executed in the workflow.
        /// </summary>
        /// <param name="JobID">ID of the job being executed</param>
        /// <param name="StepID">ID of the step being executed</param>
        /// <param name="argv">Array of arguments passed into the step's execution</param>
        /// <param name="ipFeedback">Feedback object to return status messages and files</param>
        /// <returns>Return code of execution for workflow path traversal</returns>
        public int Execute(int jobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            if (jobID <= 0)
            {
                throw (new ArgumentOutOfRangeException("JobID", jobID, "Job ID must be a positive value"));
            }

            System.Diagnostics.Debug.Assert(m_ipDatabase != null);

            IJTXJobManager pJobMan = m_ipDatabase.JobManager;
            IJTXJob2       pJob    = pJobMan.GetJob(jobID) as IJTXJob2;

            // Make sure all the information exists to create this verion
            if (pJob.ActiveDatabase == null)
            {
                System.Windows.Forms.MessageBox.Show("Job does not have a data workspace");
                return(-1);
            }
            if (pJob.ParentVersion == "")
            {
                System.Windows.Forms.MessageBox.Show("Job does not have a parent version");
                return(-1);
            }
            string strVersionNameOverride;
            bool   bVNOverride = StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strVersionNameOverride);

            if (pJob.VersionName == "" & !bVNOverride)
            {
                System.Windows.Forms.MessageBox.Show("The job does not have a version name");
                return(-1);
            }

            IVersion pNewVersion;
            string   strVersionName;

            if (bVNOverride)
            {
                strVersionName = strVersionNameOverride;
            }
            else
            {
                strVersionName = pJob.VersionName;
            }

            int index = strVersionName.IndexOf(".", 0);

            if (index >= 0)
            {
                strVersionName = strVersionName.Substring(index + 1);
            }

            esriVersionAccess verAccess   = esriVersionAccess.esriVersionAccessPrivate;
            string            strVerScope = "";

            if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strVerScope))
            {
                strVerScope = strVerScope.ToLower().Trim();

                if (strVerScope == "public")
                {
                    verAccess = esriVersionAccess.esriVersionAccessPublic;
                }
                else if (strVerScope == "protected")
                {
                    verAccess = esriVersionAccess.esriVersionAccessProtected;
                }
            }

            pJob.VersionName = strVersionName;
            pNewVersion      = pJob.CreateVersion(verAccess);

            if (pNewVersion == null)
            {
                throw (new System.SystemException("Unable to create version"));
            }

            IPropertySet pOverrides = new PropertySetClass();

            pOverrides.SetProperty("[VERSION]", pNewVersion.VersionName);
            IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_VERSION);

            if (pActType != null)
            {
                pJob.LogJobAction(pActType, pOverrides, "");
            }

            JTXUtilities.SendNotification(Constants.NOTIF_VERSION_CREATED, m_ipDatabase, pJob, pOverrides);

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pNewVersion);

            return(0);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Creates the version or returns the version that already exists.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="name">The name.</param>
        /// <param name="access">The access.</param>
        /// <param name="description">The description.</param>
        /// <returns>
        ///     Returns a <see cref="IVersion" /> representing the version.
        /// </returns>
        public static IVersion CreateVersion(this IVersionedWorkspace source, string name, esriVersionAccess access, string description)
        {
            try
            {
                var version = source.DefaultVersion.CreateVersion(name);
                version.Access = access;

                if (!string.IsNullOrEmpty(description))
                {
                    version.Description = description.Length > 64 ? description.Substring(0, 64) : description; // The size limit on the description is 62 characters.
                }
                return(version);
            }
            catch (COMException e)
            {
                if (e.ErrorCode == (int)fdoError.FDO_E_VERSION_ALREADY_EXISTS)
                {
                    return(source.GetVersion(name));
                }

                throw;
            }
        }