using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Web;
using TABS.MailCarrier.WebSDK;
using TABS.MailCarrier.StgBase;

public class SpamMsg
{
    public int ID { get; set; }
    public DateTime RecvTime { get; set; }
    public string MailFrom { get; set; }
    public string Subject { get; set; }
    public int RecvBytes { get; set; }
    public int Flag { get; set; }
}

/// <summary>
/// 스팸알리미에 저장된 메시지 목록을 GridView에 출력하기 위한 데이터 소스 클래스입니다.
/// </summary>
public class SpamMsgDataSource
{
    private int _totalCount;

    public SpamMsgDataSource()
    {
    }

    public List<SpamMsg> GetMessages(string duId, int maximumRows, int startRowIndex)
    {
        List<SpamMsg> spamMsgList = new List<SpamMsg>();
        using (SqlConnection conn = new SqlConnection(GlobalConfig.ConnString))
        {
            DataSet ds = Mcsp.McSpamboxLogSelectPage(conn, new Guid(duId), startRowIndex / maximumRows, maximumRows, SqlString.Null);
            _totalCount = int.Parse(ds.Tables[0].Rows[0][0].ToString());
            foreach (DataRow row in ds.Tables[1].Rows)
            {
                SpamMsg spamMsg = new SpamMsg();
                spamMsg.ID = (int)row["sb_id"];
                spamMsg.RecvTime = (DateTime)row["sb_time"];
                spamMsg.MailFrom = (string)row["sb_fromaddr"];
                spamMsg.Subject = (string)row["sb_subject"];
                spamMsg.RecvBytes = (int)row["sb_recvbyte"];
                spamMsg.Flag = (int)row["sb_flag"];
                spamMsgList.Add(spamMsg);
            }
        }
        return spamMsgList;
    }


    public int TotalNumberOfProducts(string duId)
    {
        return _totalCount;
    }
}