using Oracle.ManagedDataAccess.Client; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace ReportWeb.Models { public class LuckyCode { public long id { get; set; } public string msisdn { get; set; } public string code { get; set; } public DateTime? insert_time { get; set; } public DateTime? expire_time { get; set; } public int period { get; set; } public int status { get; set; } public DateTime? confirm_time { get; set; } public int confirm_channel { get; set; } public int fee { get; set; } public int count_times { get; set; } public int code_type { get; set; } public static List Parse(OracleDataReader reader) { List result = new List(); try { while (reader.Read()) { LuckyCode chargeLog = new LuckyCode(); for (int i = 0; i < reader.FieldCount; i++) { if (reader.GetName(i).ToUpper() == "MSISDN") { try { chargeLog.msisdn = reader.GetValue(i).ToString(); } catch { } } else if (reader.GetName(i).ToUpper() == "CODE") { try { chargeLog.code = reader.GetValue(i).ToString(); } catch { } } else if (reader.GetName(i).ToUpper() == "INSERT_TIME") try { chargeLog.insert_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "EXPIRE_TIME") try { chargeLog.expire_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "CONFIRM_TIME") try { chargeLog.confirm_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "ID") try { chargeLog.id = long.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "STATUS") try { chargeLog.status = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "PERIOD") try { chargeLog.period = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "CONFIRM_CHANNEL") try { chargeLog.confirm_channel = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "FEE") try { chargeLog.fee = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "COUNT_TIMES") try { chargeLog.count_times = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "CODE_TYPE") try { chargeLog.code_type = int.Parse(reader.GetValue(i).ToString()); } catch { } } result.Add(chargeLog); } reader.Close(); } catch (Exception ex) { throw ex; } finally { try { reader.Close(); } catch { } } return result; } } }