using Newtonsoft.Json.Linq; using Oracle.ManagedDataAccess.Client; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace ReportWeb.Models { public class PrizeObj { public long id { get; set; } public string action_code { get; set; } public string msisdn { get; set; } public string code { get; set; } public int prize_id { get; set; } public string description { get; set; } public string description1 { get; set; } public string description2 { get; set; } public string prize_name { get; set; } public string prize_name1 { get; set; } public string prize_name2 { get; set; } public DateTime? code_time { get; set; } public DateTime? process_time { get; set; } public string process_by { get; set; } public int period { get; set; } public int times_prize { get; set; } public int status { get; set; } public int channel { get; set; } public int is_auto { get; set; } public int group_prize { get; set; } public int sub_group_prize { get; set; } public int code_type { get; set; } public string statusStr { get; set; } public static List Parse(OracleDataReader reader) { List result = new List(); try { while (reader.Read()) { PrizeObj chargeLog = new PrizeObj(); for (int i = 0; i < reader.FieldCount; i++) { if (reader.GetName(i).ToUpper() == "ID") try { chargeLog.id = long.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "ACTION_CODE") { try { chargeLog.action_code = reader.GetValue(i).ToString(); } catch { } } else 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() == "PRIZE_ID") try { chargeLog.prize_id = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "PRIZE_NAME") { try { JObject json = JObject.Parse(reader.GetValue(i).ToString()); chargeLog.prize_name = (String)json.GetValue("prizeName"); chargeLog.prize_name1 = (String)json.GetValue("prizeName1"); chargeLog.prize_name2 = (String)json.GetValue("prizeName2"); } catch { } } else if (reader.GetName(i).ToUpper() == "DESCRIPTION") { try { JObject json = JObject.Parse(reader.GetValue(i).ToString()); chargeLog.description = (String)json.GetValue("description"); chargeLog.description1 = (String)json.GetValue("description1"); chargeLog.description2 = (String)json.GetValue("description2"); } catch { } } else if (reader.GetName(i).ToUpper() == "CODE_TIME") try { chargeLog.code_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "PROCESS_TIME") try { chargeLog.process_time = reader.GetDateTime(i); } catch { } else if (reader.GetName(i).ToUpper() == "PROCESS_BY") { try { chargeLog.process_by = 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() == "TIMES_PRIZE") try { chargeLog.times_prize = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "CHANNEL") try { chargeLog.channel = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "IS_AUTO") try { chargeLog.is_auto = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "GROUP_PRIZE") try { chargeLog.group_prize = int.Parse(reader.GetValue(i).ToString()); } catch { } else if (reader.GetName(i).ToUpper() == "SUB_GROUP_PRIZE") try { chargeLog.sub_group_prize = 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; } } }