public static T GetGenericFromCfgFile <T>(string path, bool neccesary) { if (neccesary | ConfigFileHelper.IsFileExisting(path)) { var cfgFileMgr = new ConfigFileManager(path); return(cfgFileMgr.ConvertToGeneric <T>()); } return(default(T)); }
//# set internal void SetApplicationStartPolicy(FormType formType, string funcCodeOrRelativePath) { var formCFgDir = ""; if (formType == FormType.Mvi) { formCFgDir = _appCfgDir + "\\UIs\\WinForm\\Functions\\" + funcCodeOrRelativePath; } else if (formType == FormType.SviOfView) { formCFgDir = _appCfgDir + "\\UIs\\WinForm\\Views\\" + funcCodeOrRelativePath; } else { formCFgDir = _appCfgDir + "\\UIs\\WinForm\\Zones\\" + funcCodeOrRelativePath; } if (!DirectoryHelper.IsDirectoryExisting(formCFgDir)) { throw new ArgumentException(String.Format("Forn config Folder: {0} doesn't exist! ", formCFgDir)); } var startPolicy = new StartPolicy(); var cfgFile = formCFgDir + "\\StartPolicy"; if (!ConfigFileHelper.IsFileExisting(cfgFile)) { return; } try { var confFileMgr = new ConfigFileManager(cfgFile); startPolicy = confFileMgr.ConvertToGeneric <StartPolicy>(); ApplicationStartParamSet.VerifyPasswordAtStart = startPolicy.VerifyPasswordAtStartFlag.ToLower() == "false" ? false : (startPolicy.VerifyPasswordAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.VerifyPasswordAtStart); ApplicationStartParamSet.ShowSoftwareCoverAtStart = startPolicy.ShowSoftwareCoverAtStartFlag.ToLower() == "false" ? false : (startPolicy.ShowSoftwareCoverAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.ShowSoftwareCoverAtStart); ApplicationStartParamSet.LogonAtStart = startPolicy.LogonAtStartFlag.ToLower() == "false" ? false : (startPolicy.LogonAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.LogonAtStart); ApplicationStartParamSet.RunBootStrapperTasksAtStart = startPolicy.RunBootStrapperTasksAtStartFlag.ToLower() == "false" ? false : (startPolicy.RunBootStrapperTasksAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.RunBootStrapperTasksAtStart); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".SetApplicationStartParamSet Error: " + ex.Message); } }
internal void SetCultures(string cultureName) { var cfgFile = _cfgDir + "\\Cultures\\Cultures"; if (!ConfigFileHelper.IsFileExisting(cfgFile)) { return; } var cultures = new List <Culture>(); try { var cfgFileMgr = new ConfigFileManager(cfgFile); cultures = cfgFileMgr.ConvertToGeneric <List <Culture> >(); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".SetCultures Error: " + ex.Message); } if (cultures != null) { CultureHelper.Cultures = cultures; var defCulture = cultures.Find(x => x.IsDefault); if (defCulture != null) { this.DefaultCultureName = defCulture.Name; } else { this.DefaultCultureName = cultures.First().Name; } } else { throw new ArgumentException("Can't get valid Cultures!"); } var curCultureName = DefaultCultureName; if (!cultureName.IsNullOrEmpty() && CultureHelper.IsCultureNameValid(cultureName)) { curCultureName = cultureName; } CultureHelper.SetCurrentCulture(curCultureName); }
public static List <Annex> GetAnnexesFromCfgFile(string path, string kind, bool neccesary) { var annexes = new List <Annex>(); if (neccesary | ConfigFileHelper.IsFileExisting(path)) { var cfgFileMgr = new ConfigFileManager(path); var annexList = cfgFileMgr.ConvertToGeneric <List <Annex> >(); if (annexList.Count > 0) { foreach (var annex in annexList) { annex.ClassName = kind; annexes.Add(annex); } } } return(annexes); }
//#set internal void SetApplicationStartPolicy(string scenarioRelativePath) { var formCFgDir = _appCfgDir + "\\Uis\\Console\\Scenarios\\" + scenarioRelativePath; if (!DirectoryHelper.IsDirectoryExisting(formCFgDir)) { throw new ArgumentException(String.Format("Scenario Folder: {0} doesn't exist! ", formCFgDir)); } var startPolicy = new StartPolicy(); var cfgFile = formCFgDir + "\\StartPolicy"; if (!ConfigFileHelper.IsFileExisting(cfgFile)) { return; } try { var confFileMgr = new ConfigFileManager(cfgFile); startPolicy = confFileMgr.ConvertToGeneric <StartPolicy>(); ApplicationStartParamSet.VerifyPasswordAtStart = startPolicy.VerifyPasswordAtStartFlag.ToLower() == "false" ? false : (startPolicy.VerifyPasswordAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.VerifyPasswordAtStart); ApplicationStartParamSet.ShowSoftwareCoverAtStart = startPolicy.ShowSoftwareCoverAtStartFlag.ToLower() == "false" ? false : (startPolicy.ShowSoftwareCoverAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.ShowSoftwareCoverAtStart); ApplicationStartParamSet.LogonAtStart = startPolicy.LogonAtStartFlag.ToLower() == "false" ? false : (startPolicy.LogonAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.LogonAtStart); ApplicationStartParamSet.RunBootStrapperTasksAtStart = startPolicy.RunBootStrapperTasksAtStartFlag.ToLower() == "false" ? false : (startPolicy.RunBootStrapperTasksAtStartFlag.ToLower() == "true" ? true : ApplicationStartParamSet.RunBootStrapperTasksAtStart); } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".SetApplicationStartParamSet Error: " + ex.Message); } }
internal Startup(string appCode) { try { CentralData.InitCommonSettings(); //*ov- //EncryptionHelper.Key1 = GlobalConfiguration.GlobalKey2; //EncryptionHelper.Key2 = GlobalConfiguration.GlobalKey2; var executableDir = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); _startUpDir = Directory.GetParent(executableDir).ToString(); _startUpDir = Directory.GetParent(_startUpDir).ToString(); _startUpDir = Directory.GetParent(_startUpDir).ToString(); Directory.SetCurrentDirectory(_startUpDir); _cfgDir = _startUpDir + "\\Conf"; var cfgFile = _cfgDir + "\\GlobalSetting"; if (!ConfigFileHelper.IsFileExisting(cfgFile)) { throw new ArgumentException(" Must have a \"GlobalSetting\" config file in " + _cfgDir); } var cfgFileMgr = new ConfigFileManager(cfgFile); var globalSetting = cfgFileMgr.ConvertToGeneric <GlobalSetting>(); _appCfgDir = _cfgDir + "\\Apps\\" + appCode; cfgFile = _appCfgDir + "\\ApplicationSetting"; if (!ConfigFileHelper.IsFileExisting(cfgFile)) { throw new ArgumentException(" Must have a \"ApplicationSetting\" config file in " + _appCfgDir); } cfgFileMgr = new ConfigFileManager(cfgFile); ApplicationStartParamSet = cfgFileMgr.ConvertToGeneric <ApplicationSetting>(); var appDataDir = ""; if (ApplicationStartParamSet.ApplicationDataDir.IsNullOrEmpty()) { appDataDir = _startUpDir + "\\Data\\Apps\\" + appCode; } else { appDataDir = FileHelper.GetFilePath(ApplicationStartParamSet.ApplicationDataDir, _startUpDir + "\\Data" + appCode); } ApplicationStartParamSet.ApplicationDataDir = appDataDir; var appLibDir = ""; if (ApplicationStartParamSet.ApplicationLibDir.IsNullOrEmpty()) { appLibDir = _startUpDir + "\\Lib\\Apps\\" + appCode; } else { appLibDir = FileHelper.GetFilePath(ApplicationStartParamSet.ApplicationLibDir, _startUpDir + "\\Lib" + appCode); } ApplicationStartParamSet.ApplicationLibDir = appLibDir; var appTempDir = ""; if (ApplicationStartParamSet.ApplicationTempDir.IsNullOrEmpty()) { appTempDir = PathHelper.GetLastDriveName() + "\\tmp\\" + CentralData.ArchitectureCode + "\\" + appCode; } else { appTempDir = FileHelper.GetFilePath(ApplicationStartParamSet.ApplicationTempDir, _startUpDir + "\\Data\\" + appCode + "\\Tmp"); } ApplicationStartParamSet.ApplicationTempDir = appTempDir; var cblpDllPath = ""; if (ApplicationStartParamSet.CblpDllPath.IsNullOrEmpty()) { cblpDllPath = _startUpDir + "\\Program\\Apps\\" + appCode + "\\Cblp." + appCode + ".dll"; } else if (ApplicationStartParamSet.CblpDllPath.ToLower() == "none" | ApplicationStartParamSet.CblpDllPath.ToLower() == "no") { cblpDllPath = ""; } else { cblpDllPath = FileHelper.GetFilePath(ApplicationStartParamSet.CblpDllPath, _startUpDir + "\\Program\\Apps\\" + appCode); } ApplicationStartParamSet.CblpDllPath = cblpDllPath; var cblpAdapterFullClassName = ""; if (ApplicationStartParamSet.CblpAdapterClassFullName.IsNullOrEmpty()) { cblpAdapterFullClassName = "Ligg.EasyWinApp.Cblp." + appCode + "Adapter"; } ApplicationStartParamSet.CblpAdapterClassFullName = cblpAdapterFullClassName; //# following exchange data with globalsetting var bootStrapperTasksDllPath = ""; if (globalSetting.BootStrapperTasksDllPath.IsNullOrEmpty()) { bootStrapperTasksDllPath = _startUpDir + "\\Program\\BootStrapperTasks\\" + "BootStrapperTasks" + ".dll"; } else { bootStrapperTasksDllPath = FileHelper.GetFilePath(globalSetting.BootStrapperTasksDllPath, _startUpDir + "\\Program\\BootStrapperTasks"); } ApplicationStartParamSet.BootStrapperTasksDllPath = bootStrapperTasksDllPath; if (globalSetting.BootStrapperTaskNameSpace.IsNullOrEmpty()) { ApplicationStartParamSet.BootStrapperTaskNameSpace = "Ligg.EasyWinApp.BootStrapperTasks"; } if (!globalSetting.PhythonExePath.IsNullOrEmpty()) { var defLoc = Directory.GetParent(appLibDir).ToString(); defLoc = Directory.GetParent(defLoc).ToString(); var phythonExePath = FileHelper.GetFilePath(globalSetting.PhythonExePath, defLoc); ApplicationStartParamSet.PhythonExecPath = phythonExePath; SysProcessHelper.PythonExecPath = phythonExePath; } if (ApplicationStartParamSet.DefaultCulture.IsNullOrEmpty()) { ApplicationStartParamSet.DefaultCulture = globalSetting.DefaultCulture; } if (ApplicationStartParamSet.HelpdeskEmail.IsNullOrEmpty()) { ApplicationStartParamSet.HelpdeskEmail = globalSetting.HelpdeskEmail; } } catch (Exception ex) { throw new ArgumentException("\n>> " + GetType().FullName + ".Startup Error: " + ex.Message); } }