Example #1
0
        private bool SetArcFMWorkspace()
        {
            IMMLoginUtils pMMLogin;

            try
            {
                SW1.Reset();
                SW1.Start();
                //                IMMStandardWorkspaces pMMWKS
                //                pMMWKS = new MM
                //                pMMLogin = new MMDefaultLoginObject();
                //                ESRI.ArcGIS.Framework.IAppROT pAppRot = new ESRI.ArcGIS.Framework.AppROT();
                //                ESRI.ArcGIS.Framework.IApplication pApp;
                //                if (pAppRot.Count > 0)
                //                    {
                //                        for (int i = 0; i < pAppRot.Count; i++)
                //                        {
                //                            if (pAppRot.get_Item(i) is ESRI.ArcGIS.ArcMapUI.IMxApplication)
                //                            {
                //                                pApp = (ESRI.ArcGIS.Framework.IApplication)pAppRot;
                //                                pMMProps = (IMMPropertiesExt3)pApp.FindExtensionByName("MMPropertiesExt");
                //                                pMMProps.DefaultWorkspace = Workspace;
                //                            }
                //                        }
                //                    }
                //                this.Logger.WriteLine("SetArcFMWorkspace");
                _SDMGR = new MMStoredDisplayManager();
                pMMLogin = new MMLoginUtils();
                this.Workspace = pMMLogin.LoginWorkspace;
                ScriptEngine.BroadcastProperty("Workspace", this.Workspace, null);

                SW1.Stop();
                _SDMGR.Workspace = this.Workspace;
                RecordActionTime("SETARCFMWORKSPACE:", SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("Error in SetArcFMWorkspace:" + EX.Message + ":" + EX.StackTrace);
                return false;
            }
        }
Example #2
0
        private bool OpenSession(string sSessionName, string sConnStr)
        {
            IMMLoginUtils pMMLogin;
            IMMPxLogin pPxLogin;
            IMMSessionManager2 pmmSessionMangerExt;
            IMMPxIntegrationCache pmmSessionMangerIntegrationExt;
            IMMSessionVersion pMMSessVer;
            IMMSession pMMSession;
            IMMPxApplication pPXApp;
            IWorkspace pWKS;
            IApplication pApp;
            IMxDocument pMXDoc;
            IExtension pExt;
            IVersion pVersion;
            IVersion pNewVersion;
            ADODB.Connection pPXConnection;
            int iSessionID;
            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;
                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;
                pNewVersion = pVersion.CreateVersion(pMMSessVer.get_Name());

                // Copy Properties
                //pOldPS = pWKS.ConnectionProperties;
                //pNewPS = new PropertySet();
                //pOldPropNames = new object[1];
                //pOldPropValues = new object[1];
                //pOldPS.GetAllProperties(out pOldPropNames[0], out pOldPropValues[0]);
                //for (int i = 0; i < pOldPS.Count; i++)
                //{
                //    if (pOldPropNames[i] != "VERSION")
                //    {
                //        pNewPS.SetProperty(pOldPropNames[i].ToString(), pOldPropValues[i].ToString());
                //    }
                //        else
                //    {
                //        pNewPS.SetProperty("VERSION", pNewVersion.VersionName);
                //    }
                //}
                /// Change Version
                SwizzleDatasets(pApp, (IFeatureWorkspace)pVersion, (IFeatureWorkspace)pNewVersion);
                Workspace = (IWorkspace)pNewVersion;
                ScriptEngine.BroadcastProperty("Workspace", this.Workspace, this);
                SW1.Stop();
                RecordActionTime("OpenSession", SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception Ex)
            {
                Logger.WriteLine("Error in OpenSession:" + Ex.Message);
                return false;
            }
        }
Example #3
0
        public bool CREATE_ARCFM_SESSION(string sConnStr)
        {
            IMxDocument pMXDoc;
            IApplication pApp;
            IMMLoginUtils pMMLogin;
            IMMPxLogin pPxLogin;
            IMMSessionManager2 pmmSessionMangerExt;
            IMMPxIntegrationCache pmmSessionMangerIntegrationExt;
            IMMSessionVersion pMMSessVer;
            IMMSession pMMSession;
            IMMPxApplication pPXApp;
            IWorkspace pWKS;
            IExtension pExt;
            IVersion pVersion;
            IVersion pNewVersion;
            ADODB.Connection pPXConnection;

            try
            {
                SW1.Reset();
                SW1.Start();
                pMMLogin = new MMLoginUtils();
                Logger.WriteLine("Get LoginWorkspace");
                pWKS = pMMLogin.LoginWorkspace;
                Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
                System.Object obj = Activator.CreateInstance(t);
                pApp = obj as IApplication;
                pMXDoc = (IMxDocument)pApp.Document;
                Logger.WriteLine("Find PX Framework");
                pExt = pApp.FindExtensionByName("Session Manager Integration Extension");
                pmmSessionMangerIntegrationExt = (IMMPxIntegrationCache)pExt;
                pPXApp = pmmSessionMangerIntegrationExt.Application;
                pPxLogin = pPXApp.Login;

                Logger.WriteLine("open Connection");
                if (pPxLogin == null)
                {
                    if (sConnStr != "")
                    {
                        pPxLogin = new PxLoginClass();
                        pPXConnection = new Connection();
                        pPXConnection.ConnectionString = sConnStr;
                        pPXConnection.Open();
                        pPxLogin.Connection = pPXConnection;
                        pPXApp.Startup(pPxLogin);
                    }
                    else
                    {
                        Logger.WriteLine("No PX Connection String provided");
                    }
                }
                else
                {
                    pPXConnection = pPxLogin.Connection;
                }

                Logger.WriteLine("Start PX");
                //pPXApp.Startup(pPxLogin);
                pmmSessionMangerExt = (IMMSessionManager2)pPXApp.FindPxExtensionByName("MMSessionManager");
                pMMSession = pmmSessionMangerExt.CreateSession();
                pMMSessVer = (IMMSessionVersion)pMMSession;

                pVersion = (IVersion)pWKS;
                Logger.WriteLine("Create PX version");
                pNewVersion = pVersion.CreateVersion(pMMSessVer.get_Name());

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

                //pMXDoc.ActiveView.Refresh();

                SW1.Stop();
                RecordActionTime("CREATE_ARCFM_SESSION:", SW1.ElapsedMilliseconds);
                //pMXDoc.ActiveView.Refresh();
                ScriptEngine.BroadcastProperty("Workspace", Workspace, this);
                StartEditor(Workspace);
                pMXDoc.ActiveView.Refresh();
                return true;
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("CREATE_ARCFM_SESSION Failed: " + EX.Message + " " + EX.StackTrace);
                return false;
            }
        }
Example #4
0
        private bool CreateSession(string sConnStr)
        {
            IMMLoginUtils pMMLogin;
            IMMPxLogin pPxLogin;
            IMMSessionManager2 pmmSessionMangerExt;
            IMMPxIntegrationCache pmmSessionMangerIntegrationExt;
            IMMSessionVersion pMMSessVer;
            IMMSession pMMSession;
            IMMPxApplication pPXApp;
            IWorkspace pWKS;
            IApplication pApp;
            IMxDocument pMXDoc;
            IExtension pExt;
            IVersion pVersion;
            IVersion pNewVersion;
            IPropertySet pOldPS;
            object[] pOldPropNames;
            object[] pOldPropValues;
            ADODB.Connection pPXConnection;

            try
            {
                SW1.Stop();
                SW1.Reset();
                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;

                if (pPxLogin == null)
                {
                    pPxLogin = (IMMPxLogin)new PxLogin();
                    pPXConnection = new Connection();
                    pPXConnection.ConnectionString = sConnStr;
                    pPXConnection.Open();
                    pPxLogin.Connection = pPXConnection;
                    pPXApp.Startup(pPxLogin);
                }
                else
                {
                    pPXConnection = pPxLogin.Connection;
                }
                pmmSessionMangerExt = (IMMSessionManager2)pPXApp.FindPxExtensionByName("MMSessionManager");
                pMMSession = pmmSessionMangerExt.CreateSession();
                pMMSessVer = (IMMSessionVersion)pMMSession;

                this.Logger.WriteLine("Session:" + pMMSessVer.get_Name());
                pVersion = (IVersion)pWKS;
                pOldPS = pWKS.ConnectionProperties;
                pOldPropNames = new object[1];
                pOldPropValues = new object[2];
                pOldPS.GetAllProperties(out pOldPropNames[0], out pOldPropValues[0]);

                pNewVersion = pVersion.CreateVersion(pMMSessVer.get_Name());

                SwizzleDatasets(pApp, (IFeatureWorkspace)pVersion, (IFeatureWorkspace)pNewVersion);
                this.Workspace = (IWorkspace)pNewVersion;
                ScriptEngine.BroadcastProperty("Workspace", this.Workspace, this);
                SW1.Stop();
                RecordActionTime("CreateSession:", SW1.ElapsedMilliseconds);
                return true;
            }
            catch (Exception Ex)
            {
                this.Logger.WriteLine("CreateArcFMSession Error" + Ex.Message + " " + Ex.StackTrace);
                return false;
            }
        }
Example #5
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;
            }
        }
Example #6
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;
            }
        }