Пример #1
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();
            }
        }
Пример #2
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();
            }
        }