Ejemplo n.º 1
0
        /// <summary>
        /// Closes opened data source (destructs ProjectManager)
        /// </summary>
        /// <param name="index">index of data source in data sources table</param>
        /// <returns></returns>
        public static bool CloseSource(int index)
        {
            try
            {
                if (index >= 0 && index < sources.Count)
                {
                    ((CFEsource)sources[index]).PM.DestroyProjectManager();
                }
            }
            catch (SystemException e)
            {
                FE_error err = new FE_error("FEP004", "Reason: " + e.Message);
                FE_err_msg.show_err_msg(err);
                return(false);
            }
            catch (Ice.NoEndpointException) // lost of icegridnode, source can't be closed normally
            {
                OpenSrcCount--;
                return(true);
            }
            catch (System.Exception e)
            {
                FE_error err = new FE_error("FEP004", "Reason: " + e.Message);
                FE_err_msg.show_err_msg(err);
                return(false);
            }
#if (LADICI)
            MessageBox.Show("Zdroj " + index.ToString() + " byl zavren\n", "Ladici hlaska", MessageBoxButtons.OK);
#endif
            OpenSrcCount--;
            return(true);
        }
Ejemplo n.º 2
0
        // pridani noveho zdroje (otevre dialog pro vyber zdroje, pote ho otevre a vrati handle (index) )
        /// <summary>
        /// Creating new data source.
        /// Creates and openes source and returns handle on it.
        /// <b>notice: </b>when IceGridNode is not set as system service and some other FEplugin data source is already opened,
        /// then new data source can not be created.
        /// </summary>
        /// <param name="PersistID">Perzist ID of new source (path to Ferda project (.xfp) file)</param>
        /// <returns>Handle to newly created and opened data source.</returns>
        public static Int32 NewSource(string PersistID)
        {
            DirManager.SetHomeLMRA_dir(); // due to relative paths of pesist IDs

            // tries to create an instance of CFEsource class
            CFEsource NS;

            try
            {
                // controll if the file with FE project exists
                if (!File.Exists(PersistID))
                {
//#if (DEBUG)
//                    MessageBox.Show("aktualni adresar" + Directory.GetCurrentDirectory());
//#endif
                    throw new FE_error("FEP005", "Perzist ID: " + PersistID + "\n\nReason: project can't be loaded, file can't be found on given path");
                }

                // test, if IceGridNode is set as system service. If not and some other source is opened, new source can not be created.
                if (FEplugin_globals.IceConfig_initialized)
                {
                    if (FEplugin_globals.IceConfig.ProjectManagerOptions.IceGridAsService == false && OpenSrcCount >= 1)
                    {
                        throw new FE_error("FEP006");
                    }
                }

                NS = new CFEsource(PersistID);
                int index = sources.Add(NS);
                SrcCount++;
                OpenSrcCount++;
                return(index);
            }
            catch (FE_error e)
            {
                FE_err_msg.show_err_msg(e);
                return(-1);
            }
            catch (System.Exception e)
            {
                FE_error err = new FE_error("FEP005", "Reason: " + e.Message);
                FE_err_msg.show_err_msg(err);
                return(-1);
            }
            finally
            {
                DirManager.SetHomePrevious_dir();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Displays an message box with error code and message.
        /// </summary>
        /// <param name="error">Code of error</param>
        public static void show_err_msg(FE_error error)
        {
            string code    = error.code;
            string param   = "";
            string message = getMessageViaCode(code);

            if (!String.IsNullOrEmpty(error.param))
            {
                param = " (" + error.param + ")";
            }

            // displaying the error message
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show("Program error: " + code + "\n\n" + message + param, "ReportAsistent - FE plugin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 4
0
        ///////// METHODS ///////

        /// <summary>
        /// Construction of one FEplugin data source.
        /// </summary>
        /// <param name="path">Path to file with Ferda project</param>
        public CFEsource(string path)
        {
            // initialization of SourcePath
            SourcePath = path;

            // initialization of PM
            try
            {
                // changing current directory to Ferda FrontEnd directory
                DirManager.SetHomeFerdaFrontEnd_dir();

                // initialization of PM
                PM = new ProjectManager(new string[0], FEplugin_globals.IceConfig.ProjectManagerOptions);
                DirManager.SetHomePrevious_dir();


                // loading the project
                DirManager.SetHomeLMRA_dir();
                if (LoadProject() == false)
                {
                    throw new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: project can't be loaded");
                }
            }
            catch (FE_error)
            {
                throw;
            }
            catch (System.Exception e)
            {
                DestroyPM();
                FE_error err = new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: " + e.Message);
                throw (err);
            }
            finally
            {
                // changing actual directory to previous
                DirManager.SetHomePrevious_dir();
            }
        }
        ///////// METHODS ///////
        /// <summary>
        /// Construction of one FEplugin data source.
        /// </summary>
        /// <param name="path">Path to file with Ferda project</param>
        public CFEsource(string path)
        {
            // initialization of SourcePath
            SourcePath = path;

            // initialization of PM
            try
            {
                // changing current directory to Ferda FrontEnd directory
                DirManager.SetHomeFerdaFrontEnd_dir();

                // initialization of PM
                PM = new ProjectManager(new string[0], FEplugin_globals.IceConfig.ProjectManagerOptions);
                DirManager.SetHomePrevious_dir();

                // loading the project
                DirManager.SetHomeLMRA_dir();
                if (LoadProject() == false)
                    throw new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: project can't be loaded");
            }
            catch (FE_error)
            {
                throw;
            }
            catch (System.Exception e)
            {
                DestroyPM();
                FE_error err = new FE_error("FEP005", "Perzist ID: " + SourcePath + "\n\nReason: " + e.Message);
                throw (err);
            }
            finally
            {
                // changing actual directory to previous
                DirManager.SetHomePrevious_dir();
            }
        }
        // pridani noveho zdroje (otevre dialog pro vyber zdroje, pote ho otevre a vrati handle (index) )
        /// <summary>
        /// Creating new data source.
        /// Creates and openes source and returns handle on it.
        /// <b>notice: </b>when IceGridNode is not set as system service and some other FEplugin data source is already opened,
        /// then new data source can not be created.
        /// </summary>
        /// <param name="PersistID">Perzist ID of new source (path to Ferda project (.xfp) file)</param>
        /// <returns>Handle to newly created and opened data source.</returns>
        public static Int32 NewSource(string PersistID)
        {
            DirManager.SetHomeLMRA_dir(); // due to relative paths of pesist IDs

            // tries to create an instance of CFEsource class
            CFEsource NS;
            try
            {
                // controll if the file with FE project exists
                if (!File.Exists(PersistID))
                {
            //#if (DEBUG)
            //                    MessageBox.Show("aktualni adresar" + Directory.GetCurrentDirectory());
            //#endif
                    throw new FE_error("FEP005", "Perzist ID: " + PersistID + "\n\nReason: project can't be loaded, file can't be found on given path");
                }

                // test, if IceGridNode is set as system service. If not and some other source is opened, new source can not be created.
                if (FEplugin_globals.IceConfig_initialized)
                {
                    if (FEplugin_globals.IceConfig.ProjectManagerOptions.IceGridAsService == false && OpenSrcCount >= 1)
                    {
                        throw new FE_error("FEP006");
                    }
                }

                NS = new CFEsource(PersistID);
                int index = sources.Add(NS);
                SrcCount++;
                OpenSrcCount++;
                return index;
            }
            catch (FE_error e)
            {
                FE_err_msg.show_err_msg(e);
                return -1;
            }
            catch (System.Exception e)
            {
                FE_error err = new FE_error("FEP005", "Reason: " + e.Message);
                FE_err_msg.show_err_msg(err);
                return -1;
            }
            finally
            {
                DirManager.SetHomePrevious_dir();
            }
        }
 /// <summary>
 /// Closes opened data source (destructs ProjectManager)
 /// </summary>
 /// <param name="index">index of data source in data sources table</param>
 /// <returns></returns>
 public static bool CloseSource(int index)
 {
     try
     {
         if (index >= 0 && index < sources.Count)
         {
             ((CFEsource)sources[index]).PM.DestroyProjectManager();
         }
     }
     catch (SystemException e)
     {
         FE_error err = new FE_error("FEP004", "Reason: " + e.Message);
         FE_err_msg.show_err_msg(err);
         return false;
     }
     catch (Ice.NoEndpointException) // lost of icegridnode, source can't be closed normally
     {
         OpenSrcCount--;
         return true;
     }
     catch (System.Exception e)
     {
         FE_error err = new FE_error("FEP004", "Reason: " + e.Message);
         FE_err_msg.show_err_msg(err);
         return false;
     }
     #if (LADICI)
     MessageBox.Show("Zdroj " +index.ToString()+ " byl zavren\n", "Ladici hlaska", MessageBoxButtons.OK);
     #endif
     OpenSrcCount--;
     return true;
 }
        /// <summary>
        /// Displays an message box with error code and message.
        /// </summary>
        /// <param name="error">Code of error</param>
        public static void show_err_msg(FE_error error)
        {
            string code = error.code;
            string param = "";
            string message = getMessageViaCode(code);

            if (!String.IsNullOrEmpty(error.param))
            {
                param = " (" + error.param + ")";
            }

            // displaying the error message
            if(!String.IsNullOrEmpty(message))
                MessageBox.Show("Program error: " + code + "\n\n" + message + param, "ReportAsistent - FE plugin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }