예제 #1
0
        /// <summary>
        /// This method is only used if Solid Edge is in SEEC mode.
        /// This will perform the actual processing of the background sheet replacements
        /// </summary>
        /// <param name="TargetDoc"></param>
        /// <param name="TemplateDoc"></param>
        internal void ProcessSeecDocuments(SEDocument TargetDoc, SEDocument TemplateDoc)
        {
            // Initialize the SEEC Controller
            using (SEECController _sc = new SEECController(SEApplication))
            {
                // Confirm we are in SEEC mode
                if (!_sc.IsInSEECMode())
                {
                    CustomEvents.OnProgressChanged("Solid Edge is not in SEEC mode!");
                    throw new Exception("Solid Edge is not in SEEC mode!");
                }


                // Launch the file lookup window to select an already open file from SE. This is the target document for the replacements.
                CustomEvents.OnProgressChanged("Launching the file lookup");
                TargetDoc = SolidEdgeDocumentController.LoadOpenDocument(SEApplication);
                if (TargetDoc == null)
                {
                    throw new Exception("No target document selected!");
                }

                // Call the SEEC method to search for the item and rev provided by the user for the template draft doc.
                _sc.FetchTeamcenterFilesForItem(TemplateDoc);
                if (string.IsNullOrWhiteSpace(TemplateDoc.FullFilePath))
                {
                    CustomEvents.OnProgressChanged("Unable to find a file to open from TC!");
                    throw new Exception("Unable to find a file to open from TC!");
                }

                // Turn display alerts off and attempt to load the found template file into the cache
                SEApplication.DisplayAlerts = false;
                _sc.DownloadTCFileToCache(TemplateDoc);
                if (string.IsNullOrWhiteSpace(TemplateDoc.FullFilePath))
                {
                    throw new Exception("Failed to download file from TC!");
                }
                SEApplication.DisplayAlerts = true;


                // Attempt to open the template document from the local SEEC cache
                CustomEvents.OnProgressChanged("Loading up the template document");
                SolidEdgeDocumentController.OpenDocument(SEApplication, TemplateDoc, true);
                if (TargetDoc.SEDocumentInstance == null)
                {
                    throw new Exception("Template document failed to load!");
                }

                performSheetReplacement(TargetDoc, TemplateDoc);
            }
        }