Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // LiveUpdateTest();

            var swType = SWType.GetFromProgID(PROG_ID);

            if (swType == null)
            {
                logger.Error("\n ERROR: GetFromProgID returned null\n" +
                             " - Exiting Program");

                promptToExitProgram();

                return;
            }

            ISldWorks swApp = CreateSWInstance.Create(swType);

            if (swApp == null)
            {
                logger.Error("\n ERROR: Could not get reference to " +
                             "SolidWorks App\n - Exiting Program");

                promptToExitProgram();

                return;
            }

            var path = "C:\\Users\\bolinger\\Desktop\\test install\\toppAppDBdaemon\\blob\\C-HSSX.blob.SLDPRT";

            DocumentSpecification documentSpecification =
                SWDocSpecification.GetDocumentSpecification(swApp, path);

            if (documentSpecification == null)
            {
                logger.Error("\n ERROR: Could not Get Document Specification for file: " +
                             path + "\n - Exiting Program");

                promptToExitProgram();

                return;
            }

            logger.Debug("\n Getting Model from Document Specification");

            ModelDoc2 model = (ModelDoc2)swApp.OpenDoc7(
                documentSpecification);

            if (model == null)
            {
                logger.Error("\n ERROR: Could not get Model from " +
                             "Document Specification\n - Exiting Program");

                promptToExitProgram();

                return;
            }

            Config.model = model;

            logger.Debug("\n Getting Equation Manager from Model");

            EquationMgr equationManager = model.GetEquationMgr();

            if (equationManager == null)
            {
                logger.Error("\n ERROR: Could not get Equation Manager from Model\n" +
                             " - Exiting Program");

                promptToExitProgram();

                return;
            }

            Config.equationManager = equationManager;

            logger.Debug("\n SolidWorks App Instance Initialized - Starting Microservice Daemon");

            Daemon.Start();

            promptToExitProgram();

            logger.Debug("\n Closing Open SolidWorks Documents" +
                         "\n - Exiting Microservice");
            swApp.CloseAllDocuments(true);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            /*
             * Assumptions this program makes:
             *  - There is only one instance of a
             *  - SLDWORKS.exe process occuring
             *      If there is more than one, this program
             *      may also create an additional instance - not verified -
             *      occasionall, this program will still run but on the
             *      background process.
             *          This program DOES NOT make an instance visible
             *          therefor if this program opporates on an additional
             *          SLDWORKS.exe process it will do so invisibily
             */

            /*
             * Pass to SW Daemon .blob to open:
             *      the SWdaemon.config file contains
             *      the runtime config info in 0's and 1's then
             *      deleminated by a ! after which is the .blob
             *      to open followed by another !
             */

            Console.WriteLine("TOPP App SolidWorks C# Daemon Start");

            var installRoot = InstallRoot.GetInstallRoot();

            var installDirectory = installRoot + "SolidWorks Daemon\\";

            ValidateInstallDirectory(installDirectory);

            var databaseInstallCheckFileName = ".git";

            var localBlobDatabaseInstancePath = installDirectory + "blob\\"
                                                + databaseInstallCheckFileName;

            ValidateLocalBlobDatabase(
                localBlobDatabaseInstancePath,
                installDirectory);

            var programStateFileName = "SWmicroservice.config";

            var programStatePath = installDirectory + programStateFileName;

            ValidateSWconfigFile(programStatePath, programStateFileName);

            Console.WriteLine(programStatePath);

            InitializeFile(programStatePath, programStateFileName, "011!");

            var GUIconfigFileName = "GUI.config";

            var GUIconfigPath = installDirectory + GUIconfigFileName;

            var GUIjarPath = installDirectory + "toppApp.jar";

            if (!File.Exists(GUIjarPath))
            {
                ValidateGUIconfigFile(GUIconfigPath, GUIconfigFileName,
                                      installDirectory + "\\toppApp.jar");

                InitializeFile(GUIconfigPath, GUIconfigFileName, "00");
            }

            var DDTOfileName = "DDTO.blemp";

            var DDTOpath = installDirectory + DDTOfileName;

            ValidateDDTO(DDTOpath, DDTOfileName);

            Daemon.Start(
                installDirectory,
                programStatePath,
                GUIconfigPath,
                DDTOpath
                );

            Console.WriteLine("TOPP App SolidWorks C# Daemon Exit");
        }