public void ReadConfig(string folderName, AppSetting appSet, BackgroundWorker worker, IWin32Window own) { worker.ReportProgress(0, new WaitingFormProperties(Resources.Chargement, Resources.LodingConfigFiles)); foreach (XmlFile.ConfigFilesTypes ct in Enum.GetValues(typeof(XmlFile.ConfigFilesTypes))) { var fi = new FileInfo(folderName + "\\configs\\" + ct + ".config"); if (fi.Exists) { ConfigFiles[(int)ct] = new XmlFile(fi.FullName, ct); } else { MetroMessageBox.Show(own, Resources.MainForm_ReadWebConfig_Ce_dossier_ne_contient_pas_de_fichier_config_web, Resources.Erreur, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } DeserializeMainTabloidConfig(own); //read appsetting properties appSet.ReadAppSetting(ConfigFiles[(int)XmlFile.ConfigFilesTypes.appSettings], true); appSet.ReadConnectionSetting(ConfigFiles[(int)XmlFile.ConfigFilesTypes.connections], true, own); ////read tabloid config menu var tabloidmn = ConfigFiles[(int)XmlFile.ConfigFilesTypes.tabloidMenu].Xml.SelectSingleNode("/TabloidMenu"); if (tabloidmn != null) { TabloidConfigMenu.Deserialize("<TabloidMenu>" + tabloidmn.InnerXml + "</TabloidMenu>"); tabloidmn.InnerXml = ""; //remove tabloid content when readed } worker.ReportProgress(0, new WaitingFormProperties(Resources.Chargement, Resources.LodingGeoStyle)); //read olstyle file OlStyleCollection.Load(folderName); worker.ReportProgress(0, new WaitingFormProperties(Resources.Chargement, Resources.AutomaticViewBuilding)); AutomaticViewBuilder.SetTable(appSet.Schema);//automatic view is added on load and remove on save worker.ReportProgress(0, new WaitingFormProperties(Resources.Chargement, Resources.Validation)); WizardEvents.onConfigLoaded(appSet.Schema, own); }
/// <summary> /// Deserialize main tabloid config file /// </summary> public void DeserializeMainTabloidConfig(IWin32Window own) { var tabloid = ConfigFiles[(int)XmlFile.ConfigFilesTypes.tabloid].Xml.SelectSingleNode("/Tabloid"); if (tabloid != null) { try { TabloidConfig.Deserialize("<Tabloid>" + tabloid.InnerXml + "</Tabloid>"); tabloid.InnerXml = ""; //remove tabloid content when readed WizardEvents.OnDeserialize(); } catch (Exception e) { MetroMessageBox.Show(own, "Erreur au chargement de la configuration :" + e.ToString(), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }