/// <summary> /// Loads the FrontEndConfig.xml file from the directory, where /// the FerdaFrontEnd.exe file is located /// </summary> /// <exception cref="T:System.Exception"> /// The loading of the file failed (perhaps the file is not there) /// </exception> /// <returns>FrontEndConfig object that contains project configuration info /// </returns> public static FrontEndConfig Load() { // cesta a nazev file FrontEndConfig string str = DirManager.get_FerdaFrontEnd_dir() + @"\FrontEndConfig.xml"; System.IO.FileStream fs; //tries to open the file try { fs = new System.IO.FileStream(str.ToString(), System.IO.FileMode.Open); } catch (Exception e) { throw new FE_error("FEP002"); } FrontEndConfig config = new FrontEndConfig(); //tries to deserialize the FrontEndConfig.xml file try { XmlSerializer s = new XmlSerializer(typeof(FrontEndConfig)); TextReader r = new StreamReader(fs); config = (FrontEndConfig)s.Deserialize(r); r.Close(); } finally { fs.Close(); } return(config); }
/// <summary> /// Static constructor - performs the initialization (global objects). /// Presence of Ferda libraries is checked and missing libraries are found in Ferda install directory and copied /// into LM-RA directory. /// Here is a list of required Ferda libraries: /// <ul> /// <li>FerdaProjectManager.dll</li> /// <li>FerdaBoxInterfaces.dll</li> /// <li>FerdaBoxInterfaces.dll</li> /// <li>FerdaBase.dll</li> /// <li>FerdaHelpers.dll</li> /// </ul> /// </summary> static FEplugin_init() { success = true; try { #region Controling of presence of required Ferda DataMiner libraries and copying them if they are missing string app_file = Assembly.GetExecutingAssembly().FullName; string app_dir = Assembly.GetExecutingAssembly().Location; // directory where libraries are copied to app_dir = app_dir.Replace(@"\FEplugin_cs.dll", ""); string lib_dir = DirManager.get_FerdaFrontEnd_dir(); // directory, where the libraries are placed (Ferda FrontEnd dir) if (String.IsNullOrEmpty(lib_dir)) { throw new FE_error("FEP001"); } // libraries required for FEplugin FE Plugin string[] Libraries = new string[] { //"FerdaProjectManager.dll", "FerdaModulesManager.dll", "FerdaBoxInterfaces.dll", "FerdaBase.dll", "FerdaHelpers.dll" }; foreach (string lib in Libraries) { string source_name = lib_dir + @"\" + lib; string target_name = app_dir + @"\" + lib; if (File.Exists(source_name)) { DateTime source_time = File.GetLastWriteTime(source_name); DateTime target_time; if (File.Exists(target_name)) { target_time = File.GetLastWriteTime(target_name); if (target_time.CompareTo(source_time) < 0) // copying the file { File.Copy(source_name, target_name); } } else { File.Copy(source_name, target_name); } } else // file with name "source_name" wasn't found { throw new FE_error("FEP003", source_name); } // initialization of global objects FEplugin_globals.init(); if (FEplugin_globals.IceConfig_initialized == false) { throw new FE_error("FEP002"); } } #endregion } catch (FE_error e) { FE_err_msg.show_err_msg(e); success = false; } catch (Exception) { success = false; } }