Ejemplo n.º 1
0
        //------------------------------------------
        #endregion

        #region --------------Save--------------

        public ExecuteCommandStatus Save(AdvPlacesEntity advPlaces, SPOperation operation)
        {
            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("AdvPlaces_Save", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                //PlaceID
                myCommand.Parameters.Add("@SPOperation", SqlDbType.Int, 4).Value          = (int)operation;
                myCommand.Parameters.Add("@PlaceID", SqlDbType.Int, 4).Value              = advPlaces.PlaceID;
                myCommand.Parameters.Add("@PlaceIdentifier", SqlDbType.VarChar, 32).Value = advPlaces.PlaceIdentifier;
                myCommand.Parameters.Add("@Title", SqlDbType.NVarChar, 64).Value          = advPlaces.Title;
                myCommand.Parameters.Add("@Width", SqlDbType.Int, 4).Value  = advPlaces.Width;
                myCommand.Parameters.Add("@Height", SqlDbType.Int, 4).Value = advPlaces.Height;
                myCommand.Parameters.Add("@DefaultFilePath", SqlDbType.NVarChar, 128).Value = advPlaces.DefaultFilePath;
                myCommand.Parameters.Add("@DefaultFileType", SqlDbType.Int, 4).Value        = (AdsTypes)advPlaces.DefaultFileType;
                myCommand.Parameters.Add("@ActiveAdvertiseID", SqlDbType.Int, 4).Value      = advPlaces.ActiveAdvertiseID;
                myCommand.Parameters.Add("@IsRandom", SqlDbType.Bit, 1).Value             = advPlaces.IsRandom;
                myCommand.Parameters.Add("@EnableSeparatedAd", SqlDbType.Bit, 1).Value    = advPlaces.EnableSeparatedAd;
                myCommand.Parameters.Add("@EnableSeparatedCount", SqlDbType.Int, 4).Value = advPlaces.EnableSeparatedCount;
                myCommand.Parameters.Add("@PlaceType", SqlDbType.Int, 4).Value            = (int)advPlaces.PlaceType;
                // Execute the command
                myConnection.Open();
                ExecuteCommandStatus status = (ExecuteCommandStatus)myCommand.ExecuteScalar();
                myConnection.Close();
                return(status);
            }
        }
Ejemplo n.º 2
0
        //------------------------------------------
        #endregion

        #region --------------GetObject--------------
        public static AdvPlacesEntity GetObject(int placeID)
        {
            AdvPlacesEntity advPlaces = AdvPlacesSqlDataPrvider.Instance.GetObject(placeID);

            //return the object
            return(advPlaces);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public static string GetSeparatedAdForShow(int placeID, Guid OwnerID)
        {
            string                     adText           = "";
            AdvPlacesEntity            adPlace          = AdvPlacesFactory.GetObject(placeID);
            List <AdvertismentsEntity> advertismentList = AdvertismentsSqlDataPrvider.Instance.GetSeparatedAdForShow(placeID, OwnerID, adPlace.EnableSeparatedCount);

            foreach (AdvertismentsEntity advertisment in advertismentList)
            {
                if (advertisment != null)
                {
                    adText += GetAdvertiseFile(advertisment);
                }
                else
                {
                    if (adPlace != null)
                    {
                        adText += AdvertismentsFactory.GetAdvertiseFile(adPlace.DefaultFileType, adPlace.DefaultFilePath, -1, adPlace.Width, adPlace.Height, "", false);
                    }
                }
            }
            return(adText);
        }
Ejemplo n.º 5
0
        public AdvPlacesEntity GetObject(int placeID)
        {
            AdvPlacesEntity advPlaces = null;

            using (SqlConnection myConnection = GetSqlConnection())
            {
                SqlCommand myCommand = new SqlCommand("AdvPlaces_GetOneByID", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                // Set the parameters
                myCommand.Parameters.Add("@PlaceID", SqlDbType.Int, 4).Value = placeID;
                // Execute the command
                myConnection.Open();
                using (SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    if (dr.Read())
                    {
                        advPlaces = PopulateEntity(dr);
                    }
                    dr.Close();
                }
                myConnection.Close();
                return(advPlaces);
            }
        }
Ejemplo n.º 6
0
 /*
  #region --------------Create--------------
  * /// <summary>
  * /// Creates AdvPlaces object by calling AdvPlaces data provider create method.
  * /// <example>[Example]bool status=AdvPlacesFactory.Create(advPlaces);.</example>
  * /// </summary>
  * /// <param name="advPlaces">The AdvPlaces object.</param>
  * /// <returns>Status of create operation.</returns>
  * public static bool Create(AdvPlacesEntity advPlaces)
  * {
  *  return AdvPlacesSqlDataPrvider.Instance.Create(advPlaces);
  * }
  * //------------------------------------------
  #endregion
  *
  #region --------------Update--------------
  * /// <summary>
  * /// Updates AdvPlaces object by calling AdvPlaces data provider update method.
  * /// <example>[Example]bool status=AdvPlacesFactory.Update(advPlaces);.</example>
  * /// </summary>
  * /// <param name="advPlaces">The AdvPlaces object.</param>
  * /// <returns>Status of update operation.</returns>
  * public static bool Update(AdvPlacesEntity advPlaces)
  * {
  *  bool status =AdvPlacesSqlDataPrvider.Instance.Update(advPlaces);
  *  if (status)
  *  {
  *      string cacheKey = GetChacheKey(advPlaces.PlaceID);
  *      OurCache.Remove(cacheKey);
  *  }
  *  return status;
  * }
  * //------------------------------------------
  #endregion
  */
 #region --------------Save--------------
 public static ExecuteCommandStatus Save(AdvPlacesEntity advPlaces, SPOperation operation)
 {
     return(AdvPlacesSqlDataPrvider.Instance.Save(advPlaces, operation));
 }
Ejemplo n.º 7
0
        //------------------------------------------
        #endregion

        #region --------------PopulateEntity--------------
        private AdvPlacesEntity PopulateEntity(IDataReader reader)
        {
            //Create a new AdvPlaces object
            AdvPlacesEntity advPlaces = new AdvPlacesEntity();

            //Fill the object with data
            //PlaceID
            if (reader["PlaceID"] != DBNull.Value)
            {
                advPlaces.PlaceID = (int)reader["PlaceID"];
            }
            //PlaceIdentifier
            if (reader["PlaceIdentifier"] != DBNull.Value)
            {
                advPlaces.PlaceIdentifier = (string)reader["PlaceIdentifier"];
            }
            //Title
            if (reader["Title"] != DBNull.Value)
            {
                advPlaces.Title = (string)reader["Title"];
            }
            //Width
            if (reader["Width"] != DBNull.Value)
            {
                advPlaces.Width = (int)reader["Width"];
            }
            //Height
            if (reader["Height"] != DBNull.Value)
            {
                advPlaces.Height = (int)reader["Height"];
            }
            //DefaultFilePath
            if (reader["DefaultFilePath"] != DBNull.Value)
            {
                advPlaces.DefaultFilePath = (string)reader["DefaultFilePath"];
            }
            //DefaultFileType
            if (reader["DefaultFileType"] != DBNull.Value)
            {
                advPlaces.DefaultFileType = (AdsTypes)reader["DefaultFileType"];
            }
            //ActiveAdvertiseID
            if (reader["ActiveAdvertiseID"] != DBNull.Value)
            {
                advPlaces.ActiveAdvertiseID = (int)reader["ActiveAdvertiseID"];
            }
            //IsRandom
            if (reader["IsRandom"] != DBNull.Value)
            {
                advPlaces.IsRandom = (bool)reader["IsRandom"];
            }
            //EnableSeparatedAd
            if (reader["EnableSeparatedAd"] != DBNull.Value)
            {
                advPlaces.EnableSeparatedAd = (bool)reader["EnableSeparatedAd"];
            }
            //EnableSeparatedCount
            if (reader["EnableSeparatedCount"] != DBNull.Value)
            {
                advPlaces.EnableSeparatedCount = (int)reader["EnableSeparatedCount"];
            }
            //PlaceType
            if (reader["PlaceType"] != DBNull.Value)
            {
                advPlaces.PlaceType = (AdvPlaceTypes)reader["PlaceType"];
            }
            //Return the populated object
            return(advPlaces);
        }