コード例 #1
0
        protected override void OnBeforeInstall (IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            FileInfo fileInfo = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string execTestFile = Context.Parameters["RunInstallationTest"];
            execTestFile = Path.Combine(fileInfo.DirectoryName,execTestFile);
            Process tapTestProcess = Process.Start(execTestFile,"-testtap");
            tapTestProcess.WaitForExit();
            int tapTestResult = tapTestProcess.ExitCode;

            if(tapTestResult == -0) {
                TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" + 
                    System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                dialog.ShowDialog();
                dialog.Dispose();
                return;
            }

            // The tap interface driver are not installed
            if (tapTestResult == -5) {
                TapInterfaceTestResDialog openVPnDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +
                                System.Environment.NewLine + "The installation process can be completed only installing the tap interface drivers. " +
                                System.Environment.NewLine + "It is possible to install the openVpn drivers from this windows. ",true,true);
                if((openVPnDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) && (openVPnDialog.installOpenVpn())) {
                        string execOpenVPNFile = Context.Parameters["RunOpenVpnInstallation"];
                        execOpenVPNFile = Path.Combine(fileInfo.DirectoryName,execOpenVPNFile);
                        Process openVPNProcess = Process.Start(execOpenVPNFile);
                        openVPNProcess.WaitForExit();
                        openVPnDialog.Dispose();
                        tapTestResult = openVPNProcess.ExitCode;
                }
                else {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine + 
                        "TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +  System.Environment.NewLine + 
                        "The installation process will stop");
                }

                if (tapTestResult!=0) {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine + 
                        "OPENVPN INSTALLATION PROCESS - The tap interface drivers has not been correctly installed. " + 
                        System.Environment.NewLine + "The NetProxy installation process will stop");
                }

                if(tryAddressesSetting(execTestFile) == 0) {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                        System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                } 
                return;
                
            }

            // The ip address and the mac address don't match
            if (tapTestResult == -4) {
                if(tryAddressesSetting(execTestFile) == 0) {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                        System.Environment.NewLine + "The TAP interface is correctly installed and configured",false,false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                } 
                return;
            }

            // Other error in the tap interface test
            displayOtherErrorDialogs (tapTestResult);
            
        }
コード例 #2
0
        protected override void OnBeforeInstall(IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);

            FileInfo fileInfo     = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string   execTestFile = Context.Parameters["RunInstallationTest"];

            execTestFile = Path.Combine(fileInfo.DirectoryName, execTestFile);
            Process tapTestProcess = Process.Start(execTestFile, "-testtap");

            tapTestProcess.WaitForExit();
            int tapTestResult = tapTestProcess.ExitCode;

            if (tapTestResult == -0)
            {
                TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                 System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                dialog.ShowDialog();
                dialog.Dispose();
                return;
            }

            // The tap interface driver are not installed
            if (tapTestResult == -5)
            {
                TapInterfaceTestResDialog openVPnDialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" +
                                                                                        System.Environment.NewLine + "The installation process can be completed only installing the tap interface drivers. " +
                                                                                        System.Environment.NewLine + "It is possible to install the openVpn drivers from this windows. ", true, true);
                if ((openVPnDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) && (openVPnDialog.installOpenVpn()))
                {
                    string execOpenVPNFile = Context.Parameters["RunOpenVpnInstallation"];
                    execOpenVPNFile = Path.Combine(fileInfo.DirectoryName, execOpenVPNFile);
                    Process openVPNProcess = Process.Start(execOpenVPNFile);
                    openVPNProcess.WaitForExit();
                    openVPnDialog.Dispose();
                    tapTestResult = openVPNProcess.ExitCode;
                }
                else
                {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine +
                                        "TAP INTERFACE TEST - NO TAP-WIN32 INTERFACE FOUND" + System.Environment.NewLine +
                                        "The installation process will stop");
                }

                if (tapTestResult != 0)
                {
                    throw new Exception(System.Environment.NewLine + System.Environment.NewLine +
                                        "OPENVPN INSTALLATION PROCESS - The tap interface drivers has not been correctly installed. " +
                                        System.Environment.NewLine + "The NetProxy installation process will stop");
                }

                if (tryAddressesSetting(execTestFile) == 0)
                {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                     System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                }
                return;
            }

            // The ip address and the mac address don't match
            if (tapTestResult == -4)
            {
                if (tryAddressesSetting(execTestFile) == 0)
                {
                    TapInterfaceTestResDialog dialog = new TapInterfaceTestResDialog("TAP INTERFACE TEST - SUCCESSFULLY RUN" +
                                                                                     System.Environment.NewLine + "The TAP interface is correctly installed and configured", false, false);
                    dialog.ShowDialog();
                    dialog.Dispose();
                }
                return;
            }

            // Other error in the tap interface test
            displayOtherErrorDialogs(tapTestResult);
        }