Exemple #1
0
        private bool ShutdownArcMap()
        {
            IApplication pApp;
            IDocument pDoc;
            IMxDocument pMXDoc;
            IDocumentDirty2 pDocDirty;

            Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
            System.Object obj = Activator.CreateInstance(t);
            pApp = obj as IApplication;
            pDoc = pApp.Document;
            pMXDoc = (IMxDocument)pDoc;
            pDocDirty = (IDocumentDirty2)pMXDoc;
            pDocDirty.SetClean();
            Workspace = null;
            ScriptEngine.BroadcastProperty("Workspace", this.Workspace, this);
            ScriptEngine.BroadcastProperty("FeatureClass", null, this);
            _SDMGR = null;
            _PTMGR = null;
            pSelection = null;
            m_pGN = null;
            pSC = null;
            pEditor = null;
            pDoc = null;
            pMXDoc = null;
            pApp.Shutdown();
            //Process iProc = Process.GetCurrentProcess();
            //iProc.Kill();

            Logger.WriteLine("Closing Arcmap");
            return true;
        }
Exemple #2
0
        private bool OpenPageTemplate(string SDName, string SDType)
        {
            try
            {
                this.Logger.WriteLine("OpenPageTemplate:" + SDName);

                IMMPageTemplateName pPTName;
                IMMEnumPageTemplateName pEPT;

                if (SDName == "")
                {
                    this.Logger.WriteLine("PageTemplate Name not provided");
                    return false;
                }
                else
                {
                    if (_PTMGR == null)
                    {
                        _PTMGR = (IMMPageTemplateManager) new MMPageTemplateManager();
                    }
                    _PTMGR.Workspace = this.Workspace;
                    pPTName = new MMPageTemplateNameClass();
                    pPTName.Name = SDName;

                    if (SDType.ToUpper() == "SYSTEM")
                    {
                        pEPT = _PTMGR.GetPageTemplateNames(mmPageTemplateType.mmPTTSystem);
                    }
                    else
                    {
                        pEPT = _PTMGR.GetPageTemplateNames(mmPageTemplateType.mmPTTUser);
                    }
                    // Get list of Stored Displays.  We have to do this because we have not logged in to ArcFM.
                    pPTName = pEPT.Next();
                    while (pPTName != null)
                    {
                        if (pPTName.Name.Trim().ToUpper() == SDName.Trim().ToUpper())
                        {
                            SW1.Reset();
                            SW1.Start();
                            try
                            {
                                _PTMGR.OpenPageTemplate(pPTName);
                                SW1.Stop();
                                RecordActionTime("Open Page Template :", SW1.ElapsedMilliseconds);
                            }
                            catch (Exception EX)
                            {
                                this.Logger.WriteLine("Error Opening Page Tempate :" + EX.Message + ":" + EX.StackTrace);
                                SW1.Stop();
                            }
                            break;
                        }
                        pPTName = pEPT.Next();
                    }
                    if (pPTName == null)
                    {
                        this.Logger.WriteLine("PageTemplate not found:" + SDName);
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            }
            catch (Exception EX)
            {
                this.Logger.WriteLine("Error in OpenPageTempate:" + EX.Message + ":" + EX.StackTrace);
                return false;
            }
        }