Ejemplo n.º 1
0
        private bool CreateVersion(string sName, string sAddGUID)
        {
            IVersion pVersion;
            IVersion pNewVersion;
            IChangeDatabaseVersion pCV;
            ISet pVSet;
            IApplication pApp;
            IMxDocument pMXDoc;
            System.Guid VGuid;

            try
            {
                SW1.Reset();
                SW1.Start();

                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;

                VGuid = System.Guid.NewGuid();
                pVersion = (IVersion)Workspace;
                if (sAddGUID.ToUpper() == "TRUE")
                {
                    pNewVersion = pVersion.CreateVersion(sName + "_" + VGuid.ToString());
                }
                else
                {
                    pNewVersion = pVersion.CreateVersion(sName);
                }
                pCV = new ChangeDatabaseVersion();
                pVSet = pCV.Execute(pVersion, pNewVersion, (IBasicMap)pMXDoc.FocusMap);
                Workspace = (IWorkspace)pNewVersion;
                ScriptEngine.BroadcastProperty("Workspace", Workspace, this);

                SW1.Stop();

                RecordActionTime("CREATEVERSION:",SW1.ElapsedMilliseconds);

                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("CreateVersion error:" + EX.Message);
                return false;
            }
        }
Ejemplo n.º 2
0
        private bool ChangeVersion(string sName)
        {
            IVersion pVersion;
            IVersion pNewVersion;
            IVersionedWorkspace pVWKS;
            IChangeDatabaseVersion pCV;
            ISet pVSet;
            IApplication pApp;
            IMxDocument pMXDoc;
            IWorkspace pWKS;

            try
            {
                SW1.Reset();
                SW1.Start();

                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;

                pWKS = Workspace;
                pVWKS = (IVersionedWorkspace)Workspace;
                pVersion = (IVersion)pWKS;
                pNewVersion = pVWKS.FindVersion(sName);
                pCV = new ChangeDatabaseVersion();
                pVSet = pCV.Execute(pVersion, pNewVersion, (IBasicMap)pMXDoc.FocusMap);
                Workspace = (IWorkspace)pNewVersion;
                //SwizzleDatasets(pApp, (IFeatureWorkspace)pVersion, (IFeatureWorkspace)pNewVersion);
                ScriptEngine.BroadcastProperty("Workspace", Workspace, this);

                SW1.Stop();
                RecordActionTime("CHANGEVERSION" , SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("ChangeVersion error:" + EX.Message + " " + EX.StackTrace);
                return false;
            }
        }
Ejemplo n.º 3
0
        private bool CloseSession()
        {
            IChangeDatabaseVersion pCV;
            ISet pVSet;
            IVersion pVersion;
            IVersion pNewVersion;
            IWorkspace pWKS;
            IVersionInfo pVInfo;
            IApplication pApp;
            IMxDocument pMXDoc;
            IMMLoginUtils pMMLogin;

            try
            {
                SW1.Reset();
                SW1.Start();
                pMMLogin = new MMLoginUtils();
                pWKS = pMMLogin.LoginWorkspace;
                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;
                pVersion = (IVersion)pWKS;
                pVInfo = pVersion.VersionInfo;
                pNewVersion = (IVersion)pVInfo.Parent;
                pCV = new ChangeDatabaseVersion();
                pVSet = pCV.Execute(pVersion, pNewVersion, (IBasicMap)pMXDoc.FocusMap);
                SW1.Stop();
                RecordActionTime("CloseSession:", SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("CloseSession Error" + EX.Message + " " + EX.StackTrace);
                return false;
            }
        }
Ejemplo n.º 4
0
        public bool OPEN_ARCFM_SESSION(string sSessionName, string sConnStr)
        {
            IMxDocument pMXDoc;
            IApplication pApp;
            IMMLoginUtils pMMLogin;
            IMMPxLogin pPxLogin;
            IMMSessionManager2 pmmSessionMangerExt;
            IMMPxIntegrationCache pmmSessionMangerIntegrationExt;
            IMMSessionVersion pMMSessVer;
            IMMSession pMMSession;
            IMMPxApplication pPXApp;
            IWorkspace pWKS;
            IVersionedWorkspace pVWKS;
            IExtension pExt;
            IVersion pVersion;
            IVersion pNewVersion;
            IChangeDatabaseVersion pCV;
            ADODB.Connection pPXConnection;
            int iSessionID;

            SW1.Reset();
            SW1.Start();

            try
            {
                pMMLogin = new MMLoginUtils();
                pWKS = pMMLogin.LoginWorkspace;
                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;
                pExt = pApp.FindExtensionByName("Session Manager Integration Extension");
                pmmSessionMangerIntegrationExt = (IMMPxIntegrationCache)pExt;
                pPXApp = pmmSessionMangerIntegrationExt.Application;
                pPxLogin = pPXApp.Login;
                pmmSessionMangerExt = (IMMSessionManager2)pPXApp.FindPxExtensionByName("MMSessionManager");

                if (pPxLogin.Connection == null)
                {
                    pPXConnection = new Connection();
                    pPxLogin.ConnectionString = sConnStr;
                    pPXConnection.Open();
                    pPXApp.Startup(pPxLogin);
                }
                else
                {
                    pPXConnection = pPxLogin.Connection;
                }

                iSessionID = Convert.ToInt32(sSessionName);
                pMMSession = pmmSessionMangerExt.GetSession(iSessionID, false);
                pMMSessVer = (IMMSessionVersion)pMMSession;

                pVersion = (IVersion)pWKS;
                pVWKS = (IVersionedWorkspace)Workspace;
                Logger.WriteLine("Verion:" + pMMSessVer.get_Name());
                pNewVersion = pVWKS.FindVersion(pMMSessVer.get_Name());

                pCV = new ChangeDatabaseVersion();
                //pVSet = pCV.Execute(pVersion, pNewVersion, (IBasicMap)pMXDoc.FocusMap);
                SwizzleDatasets(pApp, (IFeatureWorkspace)pVersion, (IFeatureWorkspace)pNewVersion);
                Workspace = (IWorkspace)pNewVersion;
                StartEditor(Workspace);
                ScriptEngine.BroadcastProperty("Workspace", Workspace, this);

                SW1.Stop();
                RecordActionTime("OPEN_ARCFM_SESSION:", SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("TraceDownStream Failed: " + EX.Message);
                return false;
            }
        }