Esempio n. 1
0
        static void frmLaunch_Load(object sender, EventArgs e)
        {
            //close splasheriinooos
            if (frmSplashScreen == null)
            {
                return;
            }

            frmSplashScreen.Invoke(new Action(frmSplashScreen.Close));
            frmSplashScreen.Dispose();
            frmSplashScreen = null;
        }
Esempio n. 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            frmMap map = new frmMap();

            frmSplash splash = new frmSplash(Application.ProductName, Application.ProductVersion, map.Icon);

            splash.Progress = "Iniciando o sistema";
            splash.Show();
            splash.Wait(2000);

            splash.Dispose();

            Application.Run(map);
        }
Esempio n. 3
0
    public void main()
    {
        //=====================================================================
        // Procedure Name        : Main
        // Parameters Passed     : None
        // Returns               : None
        // Purpose               : Start of the software
        // Description           :
        // Assumptions           :
        // Dependencies          :
        // Author                : Deepak B.
        // Created               : 05.09.06
        // Revisions             :
        //=====================================================================
        //'note:
        //'this is first starting point of software
        //'this is a function which called first.
        //'do some software initialisation step here.
        //'like checking for user, checking for dependencies etc.

        frmSplash            objfrmSplashScreen = new frmSplash();
        frmAASInitialisation objfrmAASInitialisation;
        bool     blnResetCmd = false;
        string   strPath;
        clsTimer objTimeDelay = new clsTimer(null, 5000);
        bool     blnIsUpgradeSessionID;

        try {
            //---Initialize error handler
            subErrorHandlerInitialization(gobjErrorHandler);
            //'Added by pankaj on 29 Jan 08
            INI_SETTINGS_PATH = Application.StartupPath + "\\AAS.ini";
            //---Initialize database settings
            if (funcInitializeAppDatabaseSettings() == true)
            {
                //---read configuration settings
                if (!gobjHardwareLock.gfuncGetConfigurationSetting())
                {
                    //display msg -error in configuration settings initialization
                    gobjMessageAdapter.ShowMessage(constConfigurationError);
                    Application.DoEvents();
                    //'allow application to perfrom its panding work.
                    System.Environment.Exit(0);
                }
            }
            else
            {
                //---display msg -error in database initialization
                gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage);
                Application.DoEvents();
                System.Environment.Exit(0);
            }
            //'---------
            //---Display Splash screen
            objfrmSplashScreen.Show();
            //'put a delay of 3000 for splash screen.
            //Call objTimeDelay.subTime_Delay(2000)
            Application.DoEvents();
            //'now allow application to perfrom its panding work
            ////----- Added by Sachin Dokhale
            //objTimeDelay = Nothing
            ////-----
            //'--- Check for the previous instance of the application
            if (PrevInstance())
            {
                //'this function will find that ,is there any other instance of software is running
                //'or not.If running then prompt a message.
                gobjMessageAdapter.ShowMessage("Application Busy", "One instance of the application is already running" + vbCrLf + "Please close the previous instance", EnumMessageType.Information);
                System.Environment.Exit(0);
            }
            objTimeDelay.subTime_Delay(2000);
            objTimeDelay = null;
            Application.DoEvents();
            //---------------
            //INI_SETTINGS_PATH = Application.StartupPath & "\AAS.ini"
            //'---Initialize database settings
            //If funcInitializeAppDatabaseSettings() = True Then
            //    '---read configuration settings
            //    If Not gobjHardwareLock.gfuncGetConfigurationSetting() Then
            //        'display msg -error in configuration settings initialization
            //        Call gobjMessageAdapter.ShowMessage(constConfigurationError)
            //        Call Application.DoEvents()
            //        ''allow application to perfrom its panding work.
            //        End
            //    End If
            //Else
            //    '---display msg -error in database initialization
            //    Call gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage)
            //    Call Application.DoEvents()
            //    End
            //End If
            //---------
            //--path of AAS.ini file
            //INI_SETTINGS_PATH = Application.StartupPath & "\AAS.ini"

            //---Initialize database settings
            //If funcInitializeAppDatabaseSettings() = True Then
            //    '---read configuration settings
            //    If Not gobjHardwareLock.gfuncGetConfigurationSetting() Then
            //        'display msg -error in configuration settings initialization
            //        Call gobjMessageAdapter.ShowMessage(constConfigurationError)
            //        Call Application.DoEvents()
            //        ''allow application to perfrom its panding work.
            //        End
            //    End If
            //Else
            //    '---display msg -error in database initialization
            //    Call gobjMessageAdapter.ShowMessage("AAS ini Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage)
            //    Call Application.DoEvents()
            //    End
            //End If

            //---read hardware lock settings
            if (gobjHardwareLock.gfuncReadHardwareLockSetting() == false)
            {
                if (!IsNothing(objfrmSplashScreen))
                {
                    objfrmSplashScreen.Close();
                    objfrmSplashScreen.Dispose();
                    objfrmSplashScreen = null;
                }
                gobjMessageAdapter.ShowMessage("Hardware Lock Error", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage);
                //'prompt a error message if hardware lock failed.
                System.Environment.Exit(0);
            }

            //==========*********Modified by Saurabh**********=========
            if (gstructSettings.AppMode == EnumAppMode.DemoMode)
            {
                //--- To Get A New session ID and write it back to INI file.
                funcGetSessionID();

                //--- To Create Service LogBook Database Connection.
                gfuncCreateLogBookConnection();

                //--- To Create Userinfo Database Connection.
                gfuncCreateUserInfoConnection();

                //---Insert new row with new sessionsID and
                //---insert current  Date , time and day
                funcInsertLogData(gstructUserDetails.SessionID);
            }
            else
            {
                //--- To Get A New session ID and write it back to INI file.
                funcGetSessionID();

                gfuncCreateLogBookConnection();

                gfuncCreateUserInfoConnection();

                gSetInstrumentStartTime = System.DateTime.Now;
                gSetWStartTime          = System.DateTime.Now;
                gSetD2StartTime         = System.DateTime.Now;
            }
            //=========================================================

            //--close and dispose splash screen
            if (!IsNothing(objfrmSplashScreen))
            {
                objfrmSplashScreen.Close();
                Application.DoEvents();
                objfrmSplashScreen.Dispose();
                objfrmSplashScreen = null;
            }

            //Saurabh 31.07.07 to Check for Hydride Mode
            //---if application is already in hydride mode then display message box.
            if (gstructSettings.HydrideMode == 1)
            {
                gobjMessageAdapter.ShowMessage("HYDRIDE MODE", "CONFIGURATION", MessageHandler.clsMessageHandler.enumMessageType.InformativeMessage);
                Application.DoEvents();
            }
            //Saurabh 31.07.07 to Check for Hydride Mode

            if (gstructSettings.Enable21CFR == true)
            {
                //'check for 21 CFR

                frmLogin objfrmLogin = new frmLogin();
                if (objfrmLogin.ShowDialog() == DialogResult.OK)
                {
                    Application.DoEvents();
                    //If objfrmLogin.DialogResult = DialogResult.OK Then
                    if (!objfrmLogin.LoginSuccessfull)
                    {
                        return;
                    }
                }
                else
                {
                    System.Environment.Exit(0);
                }
                Application.DoEvents();
            }
            //'get a application path
            string strConfigPath;
            strConfigPath = Application.ExecutablePath;
            strConfigPath = Right(strConfigPath, Len("AAS_Service.exe"));

            //---check which executable file to run
            if (UCase(strConfigPath) == UCase("AAS_Service.exe"))
            {
                //'for normal application
                gstructSettings.EnableServiceUtility = true;
                gstructSettings.ExeToRun             = EnumApplicationMode.ServiceUtility;
            }
            else
            {
                //'for service utility
                gstructSettings.EnableServiceUtility = false;
                gstructSettings.ExeToRun             = EnumApplicationMode.AAS;
            }

            //---Initialize all global Variable here
            gobjCommProtocol = new clsCommProtocolFunctions();
            gobjfrmStatus    = new frmStatus();

            //--- Get the global variables from AAS.ini file
            gFuncLoadGlobals();


            //---Initialize gobjinst object
            if (funcInitInstrumentSettings() == true)
            {
                if (gstructSettings.AppMode == EnumAppMode.DemoMode | gstructSettings.AppMode == EnumAppMode.DemoMode_201 | gstructSettings.AppMode == EnumAppMode.DemoMode_203D)
                {
                    //---if demo mode then load gobjinst object from serialized file
                    funcLoadInstStatus();
                }
            }

            string strAANameVersion;
            bool   blnFlag;

            if (gstructSettings.ExeToRun == EnumApplicationMode.ServiceUtility)
            {
                //blnFlag = gobjCommProtocol.funcInitInstrument()
                blnFlag = true;
            }
            else
            {
                if (gstructSettings.AppMode == EnumAppMode.FullVersion_203 | gstructSettings.AppMode == EnumAppMode.FullVersion_203D | gstructSettings.AppMode == EnumAppMode.FullVersion_201)
                {
                    //'check for the real mode of application
                    //If Not gstructSettings.EnableServiceUtility Then    'ToChange
                    objfrmAASInitialisation = new frmAASInitialisation();
                    //'show the initialization form and start the initialization here
                    objfrmAASInitialisation.Show();
                    if (objfrmAASInitialisation.funcInstrumentInitialization())
                    {
                        //'start the initialization
                        //objfrmAASInitialisation.Close()
                        //objfrmAASInitialisation.Dispose()
                    }
                    else
                    {
                        objfrmAASInitialisation.Close();
                        objfrmAASInitialisation.Dispose();
                        System.Environment.Exit(0);
                        return;
                    }
                    //Else

                    //End If
                }
            }
            Application.DoEvents();

            //---Load the Methods from serialized file.
            if (!funcLoadMethods())
            {
                //---display Msg -error in loading methods

                //---commented on 10.04.09 for ver 4.85
                //Call gobjMessageAdapter.ShowMessage("Error in loading method settings file.", "Error", MessageHandler.clsMessageHandler.enumMessageType.ErrorMessage)
                //Call Application.DoEvents()
                //----------------

                //End
            }

            //---commented on 19.06.07
            //'check for the demo mode of application.
            if (gstructSettings.AppMode == EnumAppMode.DemoMode)
            {
                gintInstrumentBeamType = AAS203Library.Instrument.enumInstrumentBeamType.SingleBeam;
            }
            else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D)
            {
                gintInstrumentBeamType = AAS203Library.Instrument.enumInstrumentBeamType.DoubleBeam;
            }
            else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201)
            {
            }

            //Saurabh 28.07.07 To set Instrument title
            //'set the instrument title as par application mode.

            //--4.85  14.04.09
            if (gstructSettings.NewModelName == false)
            {
                if (gstructSettings.AppMode == EnumAppMode.FullVersion_203)
                {
                    gstrTitleInstrumentType = CONST_AA203_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.FullVersion_203D)
                {
                    gstrTitleInstrumentType = CONST_AA203D_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.FullVersion_201)
                {
                    gstrTitleInstrumentType = CONST_AA201_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode)
                {
                    gstrTitleInstrumentType = CONST_AA203_DemoVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D)
                {
                    gstrTitleInstrumentType = CONST_AA203D_DemoVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201)
                {
                    gstrTitleInstrumentType = CONST_AA201_DemoVersion;
                }
                else
                {
                    gstrTitleInstrumentType = CONST_AA203;
                }
            }
            else
            {
                if (gstructSettings.AppMode == EnumAppMode.FullVersion_203)
                {
                    gstrTitleInstrumentType = CONST_AA303_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.FullVersion_203D)
                {
                    gstrTitleInstrumentType = CONST_AA303D_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.FullVersion_201)
                {
                    gstrTitleInstrumentType = CONST_AA301_FullVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode)
                {
                    gstrTitleInstrumentType = CONST_AA303_DemoVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode_203D)
                {
                    gstrTitleInstrumentType = CONST_AA303D_DemoVersion;
                }
                else if (gstructSettings.AppMode == EnumAppMode.DemoMode_201)
                {
                    gstrTitleInstrumentType = CONST_AA301_DemoVersion;
                }
                else
                {
                    gstrTitleInstrumentType = CONST_AA303_FullVersion;
                }
            }
            //--4.85  14.04.09

            //Saurabh 28.07.07 To set Instrument title

            if (gstructSettings.EnableServiceUtility)
            {
                //'this will check which EXE to be run. either main exe or service exe.
                gobjMainService = new frmMDIMainService();
                Application.Run(gobjMainService);
            }
            else
            {
                gobjMain = new frmMDIMain();
                if (!objfrmAASInitialisation == null)
                {
                    objfrmAASInitialisation.Close();
                    objfrmAASInitialisation.Dispose();
                }
                Application.DoEvents();
                Application.Run(gobjMain);
            }


            funcExitApplicationSettings();
            //'fir deinitialise the application setting
            //'It Exit Application parameters
            gIntMethodID = 0;

            //---added by deepak on 19.07.07 to reset the instrument
            ////----- Modified by Sachin Dokhale
            if (gobjCommProtocol.mobjCommdll.gFuncIsPortOpen())
            {
                ////-----
                gobjCommProtocol.funcResetInstrument();
                //'serial communication function  to  Reset the Instrument
            }

            System.Environment.Exit(0);
        } catch (Exception ex) {
            //---------------------------------------------------------
            //Error Handling and logging
            gobjErrorHandler.ErrorDescription = ex.Message;
            gobjErrorHandler.ErrorMessage     = ex.Message;
            gobjErrorHandler.WriteErrorLog(ex);
            //---------------------------------------------------------
        } finally {
            //---------------------------------------------------------
            //Writing Execution log
            if (CONST_CREATE_EXECUTION_LOG == 1)
            {
                gobjErrorHandler.WriteExecutionLog();
            }
            Application.DoEvents();
            //---------------------------------------------------------
        }
    }