public ParametriConto(ContrattoConto conto) { string exeConfigPath = typeof(ParametriConto).Assembly.Location; ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(); configMap.ExeConfigFilename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(exeConfigPath), "buonochiaro.config"); config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); if (conto.Tool_Parametri == null) { this.idScontrinoElettronico = conto.NumeroScontrinoFiscale; this.IdConto = conto.IdGestionale; this.IdChiamata = conto.Tool_IdTastoCustom; this.Stato = StatoConto.inizio; this.CategoriaPagamento = config.AppSettings.Settings["CategoriaPagamento"].Value; this.CodicePagamento = config.AppSettings.Settings["CodicePagamento"].Value; this._indiceParametri = null; this._codici = new List <BuonoPasto>(); } else if (conto.Tool_Parametri[0] == null) { this.idScontrinoElettronico = conto.NumeroScontrinoFiscale; this.IdConto = conto.IdGestionale; this.IdChiamata = conto.Tool_IdTastoCustom; this.Stato = StatoConto.inizio; this.CategoriaPagamento = config.AppSettings.Settings["CategoriaPagamento"].Value; this.CodicePagamento = config.AppSettings.Settings["CodicePagamento"].Value; this._indiceParametri = 0; this._codici = new List <BuonoPasto>(); } else { for (int i = 0; i < conto.Tool_Parametri.Length; i++) { ParametriConto par = new ParametriConto((conto.Tool_Parametri[i] ?? String.Empty).ToString()); if (par.IdConto != null) { this.idBuonoChiaro = par.idBuonoChiaro; this._codici = par.Codici; this.IdChiamata = par.IdChiamata; this.idScontrinoElettronico = par.idScontrinoElettronico; this.IdConto = par.IdConto; this.Stato = par.Stato; this.Totale = par.Totale; this.UltimaDomanda = par.UltimaDomanda; this.UltimaRisposta = par.UltimaRisposta; this.CategoriaPagamento = par.CategoriaPagamento; this.CodicePagamento = par.CodicePagamento; this._indiceParametri = i; } } } }
public ParametriConto(string xml) { string exeConfigPath = typeof(ParametriConto).Assembly.Location; ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(); configMap.ExeConfigFilename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(exeConfigPath), "buonochiaro.config"); config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); try { StringReader strReader = null; XmlSerializer serializer = null; XmlTextReader xmlReader = null; ParametriConto obj = null; try { strReader = new StringReader(xml); serializer = new XmlSerializer(this.GetType()); xmlReader = new XmlTextReader(strReader); obj = (ParametriConto)serializer.Deserialize(xmlReader); } catch (Exception exp) { //Handle Exception Code } finally { if (xmlReader != null) { xmlReader.Close(); } if (strReader != null) { strReader.Close(); } } this.idBuonoChiaro = obj.idBuonoChiaro; this._codici = obj.Codici; this.IdChiamata = obj.IdChiamata; this.idScontrinoElettronico = obj.idScontrinoElettronico; this.IdConto = obj.IdConto; this.Stato = obj.Stato; this.Totale = obj.Totale; this.UltimaDomanda = obj.UltimaDomanda; this.UltimaRisposta = obj.UltimaRisposta; this.CategoriaPagamento = obj.CategoriaPagamento; this.CodicePagamento = obj.CodicePagamento; } catch (Exception ex) { } }