using System; using System.Collections.Generic; using Oracle.ManagedDataAccess.Client; using System.Linq; using System.Web; namespace ReportWeb.Models { public class UserCoin { public UserCoin() { } public string msisdn { get; set; } public int rank { get; set; } public DateTime? start_time { get; set; } public DateTime? end_time { get; set; } public DateTime? last_update { get; set; } public int total_coin { get; set; } public string product_name { get; set; } public static List Parse(OracleDataReader reader) { List result = new List(); try { while (reader.Read()) { UserCoin UserCoin = new UserCoin(); for (int i = 0; i < reader.FieldCount; i++) { if (reader.GetName(i).ToUpper() == "MSISDN") { try { UserCoin.msisdn = reader.GetValue(i).ToString(); } catch { } } else if (reader.GetName(i).ToUpper() == "START_TIME") try { UserCoin.start_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "END_TIME") try { UserCoin.end_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "LAST_UPDATE") try { UserCoin.last_update = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "TOTAL_COIN") { try { UserCoin.total_coin = int.Parse(reader.GetValue(i).ToString()); } catch { } } else if (reader.GetName(i).ToUpper() == "PRODUCT_NAME") { try { UserCoin.product_name = (string)reader.GetValue(i); } catch { } } else if (reader.GetName(i).ToUpper() == "RANK") { try { UserCoin.rank = int.Parse(reader.GetValue(i).ToString()); } catch { } } } result.Add(UserCoin); } reader.Close(); } catch { } finally { try { reader.Close(); } catch { } } return result; } } }