| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 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 TicketObj
- {
- public long id { get; set; }
- public string msisdn { get; set; }
- public string ticket_code { get; set; }
- public DateTime? insert_time { get; set; }
- public DateTime? expire_time { get; set; }
- public DateTime? draw_time { get; set; }
- public int ticket_src { get; set; }
- public int prize_id { get; set; }
- public int status { get; set; }
- public static List<TicketObj> Parse(OracleDataReader reader)
- {
- List<TicketObj> result = new List<TicketObj>();
- try
- {
- while (reader.Read())
- {
- TicketObj chargeLog = new TicketObj();
- 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() == "TICKET_CODE")
- {
- try
- {
- chargeLog.ticket_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() == "PRIZE_ID")
- try
- {
- chargeLog.prize_id = int.Parse(reader.GetValue(i).ToString());
- }
- catch { }
- else if (reader.GetName(i).ToUpper() == "TICKET_SRC")
- try
- {
- chargeLog.ticket_src = int.Parse(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() == "DRAW_TIME")
- try
- {
- chargeLog.draw_time = reader.GetDateTime(i);
- if (chargeLog.draw_time > DateTime.Now)
- {
- // available
- chargeLog.status = 1;
- }
- else
- {
- chargeLog.status = 0;
- }
- }
- catch { }
- }
- result.Add(chargeLog);
- }
- reader.Close();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- try
- {
- reader.Close();
- }
- catch { }
- }
- return result;
- }
- }
- }
|