All pastes #77926 Raw Edit

Stuff

public text v1 · immutable
·published 2006-07-03 15:53 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Net;
using System.Text;

using CI.Utils;
using CI.Data.Interfaces;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace CI.Data
{
    public class Url : IDbDataReaderPopulate
    {
        private long m_UrlId;
        private string m_Url;
        private int m_UrlDomainId;
        private int? m_CompanyId;
        private string m_CompanyName;
        private UrlType? m_UrlType;
        private string m_HttpStatusCode;
        private string m_ImagePath;
        private bool? m_ActiveFlag;
        private DateTime m_DateRecorded;

        public long UrlId { get { return m_UrlId; } set { m_UrlId = value; } }
        public string UrlValue { get { return m_Url; } set { m_Url = value; } }
        public int UrlDomainId { get { return m_UrlDomainId; } set { m_UrlDomainId = value; } }
        public int? CompanyId { get { return m_CompanyId; } set { m_CompanyId = value; } }
        public UrlType? UrlType { get { return m_UrlType; } set { m_UrlType = value; } }
        public string HttpStatusCode { get { return m_HttpStatusCode; } set { m_HttpStatusCode = value; } }
        public string ImagePath { get { return m_ImagePath; } set { m_ImagePath = value; } }
        public bool? ActiveFlag { get { return m_ActiveFlag; } set { m_ActiveFlag = value; } }
        public DateTime DateRecorded { get { return m_DateRecorded; } set { m_DateRecorded = value; } }
        public string CompanyName { get { return m_CompanyName; } }

        public static void Inactivate(long urlId, HttpStatusCode httpStatusCode)
        {
             Common.ExecuteNonQuery("agent_Url_Inactivate", urlId, httpStatusCode);
        }

        public static void IncreaseRetryCount(long urlId, HttpStatusCode httpStatusCode)
        {
            Common.ExecuteNonQuery("agent_Url_IncreaseRetryCount", urlId, httpStatusCode);
        }

        public static void UpdateMimeType(long urlId, string mimeType, HttpStatusCode httpStatusCode)
        {
            Common.ExecuteNonQuery("agent_Url_UpdateMimeType", urlId, mimeType, httpStatusCode);
        }

        public static Url RetrieveByUrlId(long urlId)
        {
            return Common.Populate<Url>(true, "analyst_Url_RetrieveByUrlId", urlId);
        }

        public static Url RetrieveByUrl(string url)
        {
            return Common.Populate<Url>(true, "analyst_Url_RetrieveByUrl", url);
        }

        public static void UpdateCompany(long urlId, int? companyId, UrlType? urlType, bool? activeFlag)
        {
            Common.ExecuteNonQuery("analyst_Url_UpdateCompanyByUrlId", urlId, companyId, urlType, Convert.ToInt32(activeFlag));
        }

        public static void Insert(string url, int? companyId, UrlType? urlType, string httpStatusCode, string imagePath, bool? activeFlag)
        {
            Common.ExecuteNonQuery("analyst_Url_Insert",
                url,
                companyId,
                urlType,
                httpStatusCode,
                imagePath,
                activeFlag);
        }

        public static void RemoveCompany(long urlId)
        {
            Common.ExecuteNonQuery("analyst_Url_RemoveCompany", urlId);
        }

        public static void Update(long urlId, string url, int urlDomainId, int? companyId, UrlType? urlType, string httpStatusCode, string imagePath, bool? activeFlag, DateTime dateRecorded)
        {
            Common.ExecuteNonQuery("analyst_Url_Update", 
                urlId, 
                url, 
                urlDomainId, 
                companyId, 
                urlType, 
                httpStatusCode, 
                imagePath, 
                activeFlag, 
                dateRecorded);
        }

        public static List<Url> RetrieveByCompanyIdUrlType(int companyId, UrlType urlType)
        {
            return Common.Populate<Url>("analyst_Url_RetrieveByCompanyIdUrlTypeId", companyId, urlType);
        }

        #region IDbDataReaderPopulate Members

        public void IDbDataReaderPopulate(DbDataReader reader)
        {
            m_UrlId = (long)reader["UrlId"];
            m_Url = (string)reader["Url"];
            m_UrlDomainId = (int)reader["UrlDomainId"];
            m_CompanyId = StringUtils.DBInt(reader["CompanyId"]);
            if (StringUtils.DBInt(reader["UrlTypeId"]).HasValue)
                m_UrlType = (UrlType)StringUtils.DBInt(reader["UrlTypeId"]);
            m_HttpStatusCode = StringUtils.DBString(reader["ImagePath"]);
            m_ImagePath = StringUtils.DBString(reader["ImagePath"]);
            m_ActiveFlag = StringUtils.DBNullableBoolean(reader["ActiveFlag"]);
            m_DateRecorded = (DateTime)reader["DateRecorded"];
            m_CompanyName = StringUtils.DBString(reader["CompanyName"]);
        }

        #endregion
    }
}