示例#1
0
        //------------------------------------------
        #endregion
        #region --------------GetObject--------------
        public static AdvertismentsEntity GetObject(int advertiseID)
        {
            AdvertismentsEntity advertisment = AdvertismentsSqlDataPrvider.Instance.GetObject(advertiseID);

            //return the object
            return(advertisment);
        }
示例#2
0
        //------------------------------------------
        #endregion

        #region --------------GetAdForShow--------------
        public static AdvertismentsEntity GetAdForShow(int placeID, Guid OwnerID)
        {
            Languages           langID       = SiteSettings.GetCurrentLanguage();
            AdvertismentsEntity advertisment = AdvertismentsSqlDataPrvider.Instance.GetAdForShow(placeID, OwnerID, langID);

            //return the object
            return(advertisment);
        }
示例#3
0
 //------------------------------------------
 public static string GetAdvertiseFile(AdvertismentsEntity adv)
 {
     if (adv != null)
     {
         bool hasLink = !string.IsNullOrEmpty(adv.Url);
         return(GetAdvertiseFile(adv.FileType, adv.GetFileVirtualPath(), adv.AdvertiseID, adv.Width, adv.Height, adv.Title, hasLink));
     }
     else
     {
         return(null);
     }
 }
示例#4
0
        //------------------------------------------
        #endregion

        #region --------------Save--------------
        public bool Save(AdvertismentsEntity advertisments, SPOperation operation)
        {
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("Advertisments_Save", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@SPOperation", SqlDbType.Int, 4).Value = (int)operation;
                if (operation == SPOperation.Insert)
                {
                    myCommand.Parameters.Add("@AdvertiseID", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
                }
                else
                {
                    myCommand.Parameters.Add("@AdvertiseID", SqlDbType.Int, 4).Value = advertisments.AdvertiseID;
                }

                myCommand.Parameters.Add("@PlaceID", SqlDbType.Int, 4).Value            = advertisments.PlaceID;
                myCommand.Parameters.Add("@Url", SqlDbType.NVarChar, 256).Value         = advertisments.Url;
                myCommand.Parameters.Add("@FileExtension", SqlDbType.VarChar, 50).Value = advertisments.FileExtension;
                myCommand.Parameters.Add("@FileType", SqlDbType.Int, 4).Value           = (int)advertisments.FileType;
                myCommand.Parameters.Add("@IsActive", SqlDbType.Bit, 1).Value           = advertisments.IsActive;
                myCommand.Parameters.Add("@Weight", SqlDbType.Int, 4).Value             = advertisments.Weight;
                myCommand.Parameters.Add("@MaxApperance", SqlDbType.Int, 4).Value       = advertisments.MaxApperance;
                myCommand.Parameters.Add("@MaxClicks", SqlDbType.Int, 4).Value          = advertisments.MaxClicks;
                myCommand.Parameters.Add("@ApperanceCount", SqlDbType.Int, 4).Value     = advertisments.ApperanceCount;
                myCommand.Parameters.Add("@ClicksCount", SqlDbType.Int, 4).Value        = advertisments.ClicksCount;
                myCommand.Parameters.Add("@Title", SqlDbType.NVarChar, 256).Value       = advertisments.Title;
                myCommand.Parameters.Add("@LangID", SqlDbType.Int, 4).Value             = (int)advertisments.LangID;
                myCommand.Parameters.Add("@IsSmall", SqlDbType.Bit).Value = (bool)advertisments.IsSmall;
                //----------------------------------------------------------------------------------
                myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = advertisments.OwnerID;
                myCommand.Parameters.Add("@OwnerName", SqlDbType.VarChar).Value        = advertisments.OwnerName;
                //----------------------------------------------------------------------------------
                // Execute the command
                bool status = false;
                myConnection.Open();
                if (myCommand.ExecuteNonQuery() > 0)
                {
                    status = true;
                    //Get ID value from database and set it in object
                    advertisments.AdvertiseID = (int)myCommand.Parameters["@AdvertiseID"].Value;
                }
                myConnection.Close();
                return(status);
            }
        }
示例#5
0
        //------------------------------------------
        #endregion

        #region --------------GetAdForShowFile--------------
        public static string GetAdForShowFile(int placeID, Guid OwnerID)
        {
            Languages           langID       = SiteSettings.GetCurrentLanguage();
            AdvertismentsEntity advertisment = AdvertismentsSqlDataPrvider.Instance.GetAdForShow(placeID, OwnerID, langID);
            string adText = "";

            if (advertisment != null)
            {
                adText = GetAdvertiseFile(advertisment);
            }
            else
            {
                AdvPlacesEntity adPlace = AdvPlacesFactory.GetObject(placeID);
                if (adPlace != null)
                {
                    adText = AdvertismentsFactory.GetAdvertiseFile(adPlace.DefaultFileType, adPlace.DefaultFilePath, -1, adPlace.Width, adPlace.Height, "", false);
                }
            }
            return(adText);
        }
示例#6
0
 //------------------------------------------------------------------------
 public static string GetAdvertiseFileForAdmin(AdvertismentsEntity adv)
 {
     if (adv != null)
     {
         bool hasLink = !string.IsNullOrEmpty(adv.Url);
         int  width   = adv.Width;
         if (width > 450)
         {
             width = 450;
         }
         int ViewHeight = adv.Height;
         if (adv.IsSmall)
         {
             ViewHeight = Convert.ToInt16(adv.Height / 2);
         }
         return(GetAdvertiseFile(adv.FileType, adv.GetFileVirtualPath(), adv.AdvertiseID, width, ViewHeight, adv.Title, hasLink));
     }
     else
     {
         return(null);
     }
 }
示例#7
0
        //------------------------------------------
        #endregion

        #region --------------GetAdForShow--------------
        public AdvertismentsEntity GetAdForShow(int placeID, Guid OwnerID, Languages langID)
        {
            AdvertismentsEntity advertisment = null;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("Advertisments_GetAdForShow", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@PlaceID", SqlDbType.Int, 4).Value = placeID;
                myCommand.Parameters.Add("@LangID", SqlDbType.Int, 4).Value  = (int)langID;
                //---------------------------------------------------------------------
                if (OwnerID != null)
                {
                    Guid _OwnerID = new Guid(OwnerID.ToString());
                    // if (_OwnerID != Guid.Empty)
                    myCommand.Parameters.Add("@OwnerID", SqlDbType.UniqueIdentifier).Value = _OwnerID;
                }
                //---------------------------------------------------------------------
                // Execute the command
                myConnection.Open();
                using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dr.Read())
                    {
                        advertisment = PopulateEntity(dr);
                    }
                    dr.Close();
                }
                myConnection.Close();
                if (advertisment != null)
                {
                    IncreaseApperanceCount(advertisment.AdvertiseID);
                }
                return(advertisment);
            }
        }
示例#8
0
        public AdvertismentsEntity GetObject(int advertiseID)
        {
            AdvertismentsEntity advertisments = null;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("Advertisments_GetOneByID", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@AdvertiseID", SqlDbType.Int, 4).Value = advertiseID;
                // Execute the command
                myConnection.Open();
                using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dr.Read())
                    {
                        advertisments = PopulateEntity(dr);
                    }
                    dr.Close();
                }
                myConnection.Close();
                return(advertisments);
            }
        }
示例#9
0
        public static string GetAdvertiseFileForAdmin(int adID)
        {
            AdvertismentsEntity adv = AdvertismentsFactory.GetObject(adID);

            return(GetAdvertiseFileForAdmin(adv));
        }
示例#10
0
 public static bool Save(AdvertismentsEntity advertisment, SPOperation operation)
 {
     return(AdvertismentsSqlDataPrvider.Instance.Save(advertisment, operation));
 }
示例#11
0
        //------------------------------------------
        #endregion

        #region --------------PopulateEntity--------------
        private AdvertismentsEntity PopulateEntity(IDataReader reader)
        {
            //Create a new Advertisments object
            AdvertismentsEntity advertisments = new AdvertismentsEntity();

            //Fill the object with data
            //AdvertiseID
            if (reader["AdvertiseID"] != DBNull.Value)
            {
                advertisments.AdvertiseID = (int)reader["AdvertiseID"];
            }
            //PlaceID
            if (reader["PlaceID"] != DBNull.Value)
            {
                advertisments.PlaceID = (int)reader["PlaceID"];
            }
            //Url
            if (reader["Url"] != DBNull.Value)
            {
                advertisments.Url = (string)reader["Url"];
            }
            //FileExtension
            if (reader["FileExtension"] != DBNull.Value)
            {
                advertisments.FileExtension = (string)reader["FileExtension"];
            }
            //FileType
            if (reader["FileType"] != DBNull.Value)
            {
                advertisments.FileType = (AdsTypes)reader["FileType"];
            }
            //IsActive
            if (reader["IsActive"] != DBNull.Value)
            {
                advertisments.IsActive = (bool)reader["IsActive"];
            }
            //Weight
            if (reader["Weight"] != DBNull.Value)
            {
                advertisments.Weight = (int)reader["Weight"];
            }
            //MaxApperance
            if (reader["MaxApperance"] != DBNull.Value)
            {
                advertisments.MaxApperance = (int)reader["MaxApperance"];
            }
            //MaxClicks
            if (reader["MaxClicks"] != DBNull.Value)
            {
                advertisments.MaxClicks = (int)reader["MaxClicks"];
            }
            //ApperanceCount
            if (reader["ApperanceCount"] != DBNull.Value)
            {
                advertisments.ApperanceCount = (int)reader["ApperanceCount"];
            }
            //ClicksCount
            if (reader["ClicksCount"] != DBNull.Value)
            {
                advertisments.ClicksCount = (int)reader["ClicksCount"];
            }
            //Title
            if (reader["Title"] != DBNull.Value)
            {
                advertisments.Title = (string)reader["Title"];
            }

            //Width
            if (reader["Width"] != DBNull.Value)
            {
                advertisments.Width = (int)reader["Width"];
            }
            //Height
            if (reader["Height"] != DBNull.Value)
            {
                advertisments.Height = (int)reader["Height"];
            }
            //LangID
            if (reader["LangID"] != DBNull.Value)
            {
                advertisments.LangID = (Languages)reader["LangID"];
            }
            if (reader["IsSmall"] != DBNull.Value)
            {
                advertisments.IsSmall = (bool)reader["IsSmall"];
            }
            //------------------------------------------------------------------
            //OwnerID
            if (reader["OwnerID"] != DBNull.Value)
            {
                advertisments.OwnerID = (Guid)reader["OwnerID"];
            }
            //------------------------------------------------------------------
            //OwnerName
            if (reader["OwnerName"] != DBNull.Value)
            {
                advertisments.OwnerName = (string)reader["OwnerName"];
            }
            //------------------------------------------------------------------
            //Return the populated object
            return(advertisments);
        }