Exemple #1
0
        public bool Update(ADZoneInfo adZoneInfo)
        {
            Parameters cmdParams = GetParameters(adZoneInfo);

            cmdParams.AddInParameter("@ZoneId", DbType.Int32, adZoneInfo.ZoneId);
            return(DBHelper.ExecuteProc("PR_AD_ADZone_UPDATE", cmdParams));
        }
Exemple #2
0
        public bool Add(ADZoneInfo adZoneInfo)
        {
            Parameters cmdParams = GetParameters(adZoneInfo);

            cmdParams.AddInParameter("@ZoneId", DbType.Int32, GetMaxADZoneId());
            return(DBHelper.ExecuteProc("PR_Ad_ADZone_ADD", cmdParams));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         this.TxtZoneJSName.Text = this.GetJSFileName();
         this.DropFixedPosition.Attributes.Add("onchange", "ChangePositonShow(this)");
         this.DropFloatPosition.Attributes.Add("onchange", "ChangePositonShow(this)");
         this.DropMovePosition.Attributes.Add("onchange", "ChangePositonShow(this)");
         this.DropPopPosition.Attributes.Add("onchange", "ChangePositonShow(this)");
         if (BasePage.RequestString("Action") == "Modify")
         {
             int        id         = BasePage.RequestInt32("ZoneId");
             ADZoneInfo adZoneById = ADZone.GetAdZoneById(id);
             this.TxtZoneName.Text   = adZoneById.ZoneName;
             this.TxtZoneJSName.Text = adZoneById.ZoneJSName;
             this.TxtZoneIntro.Text  = adZoneById.ZoneIntro;
             this.InitRblADZoneType((int)adZoneById.ZoneType);
             if (adZoneById.DefaultSetting)
             {
                 this.InitRblADZoneDefaultSetting(0);
             }
             else
             {
                 this.InitRblADZoneDefaultSetting(1);
             }
             BasePage.SetSelectedIndexByValue(this.RadlShowType, adZoneById.ShowType.ToString());
             string flag = adZoneById.ZoneWidth.ToString() + "x" + adZoneById.ZoneHeight.ToString();
             this.InitDropADZoneSize(flag);
             this.TxtZoneWidth.Text  = adZoneById.ZoneWidth.ToString();
             this.TxtZoneHeight.Text = adZoneById.ZoneHeight.ToString();
             this.InitSetting(adZoneById.Setting, adZoneById.ZoneType);
             if (this.RadlDefaultSetting.SelectedValue == "1")
             {
                 this.InitShowPanel(adZoneById.ZoneType);
             }
             this.ChkActive.Checked = adZoneById.Active;
             this.EBtnAdZone.Text   = "修 改";
             this.HdnAction.Value   = "Modify";
             this.HdnZoneId.Value   = id.ToString();
             if ((adZoneById.ZoneType > ADZoneType.Banner) && (adZoneById.ZoneType == ADZoneType.Code))
             {
                 this.DropAdZoneSize.Enabled = false;
                 this.TxtZoneHeight.Enabled  = false;
                 this.TxtZoneWidth.Enabled   = false;
             }
         }
         else
         {
             this.InitRblADZoneType(1);
             this.InitRblADZoneDefaultSetting(0);
             this.InitDropADZoneSize(null);
             this.EBtnAdZone.Text = "添 加";
             this.HdnAction.Value = "Add";
         }
     }
 }
 protected void GdvADZone_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         ADZoneInfo dataItem = (ADZoneInfo)e.Row.DataItem;
         Label      label    = (Label)e.Row.FindControl("LabZoneType");
         Label      label2   = (Label)e.Row.FindControl("LabShowType");
         label.Text  = BasePage.EnumToHtml <ADZoneType>(dataItem.ZoneType);
         label2.Text = GetADZoneShowType()[dataItem.ShowType];
     }
 }
Exemple #5
0
        public bool ImportData(string zoneId, string importDatabase)
        {
            bool          flag;
            Database      db      = DatabaseFactory.CreateDatabase();
            StringBuilder builder = new StringBuilder("");

            builder.Append(" SELECT ZoneID, ZoneName, ZoneJSName, ZoneIntro, ZoneType, DefaultSetting, ZoneSetting, ZoneWidth, ZoneHeight, ShowType, Active, UpdateTime FROM PE_AdZone ");
            OleDbConnection connection = new OleDbConnection("Provider = Microsoft.Jet.OleDb.4.0;Data Source = " + importDatabase);

            try
            {
                connection.Open();
                builder.Append("Where ZoneID IN (" + zoneId + ") ORDER BY ZoneID");
                OleDbCommand       command = new OleDbCommand(builder.ToString(), connection);
                NullableDataReader reader  = new NullableDataReader(command.ExecuteReader(CommandBehavior.CloseConnection));
                while (reader.Read())
                {
                    ADZoneInfo adZoneInfo = new ADZoneInfo();
                    adZoneInfo.ZoneId         = GetMaxADZoneId();
                    adZoneInfo.ZoneName       = reader.GetString("ZoneName");
                    adZoneInfo.ZoneJSName     = reader.GetString("ZoneJSName");
                    adZoneInfo.ZoneIntro      = reader.GetString("ZoneIntro");
                    adZoneInfo.ZoneType       = (ADZoneType)reader.GetInt32("ZoneType");
                    adZoneInfo.DefaultSetting = reader.GetBoolean("DefaultSetting");
                    adZoneInfo.Setting        = reader.GetString("ZoneSetting");
                    adZoneInfo.ZoneWidth      = reader.GetInt32("ZoneWidth");
                    adZoneInfo.ZoneHeight     = reader.GetInt32("ZoneHeight");
                    adZoneInfo.ShowType       = reader.GetInt32("ShowType");
                    adZoneInfo.Active         = reader.GetBoolean("Active");
                    adZoneInfo.UpdateTime     = reader.GetDateTime("UpdateTime");
                    DbCommand command2 = GetProcdbComm(db, "PR_Ad_ADZone_ADD", adZoneInfo);
                    try
                    {
                        db.ExecuteNonQuery(command2);
                        continue;
                    }
                    catch
                    {
                        reader.Close();
                        return(false);
                    }
                }
                flag = true;
            }
            catch
            {
                flag = false;
            }
            finally
            {
                connection.Close();
            }
            return(flag);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ADZoneInfo adZoneById = ADZone.GetAdZoneById(BasePage.RequestInt32("ZoneId"));

            if ((adZoneById == null) || string.IsNullOrEmpty(adZoneById.ZoneJSName))
            {
                this.TxtZoneCode.Text = "找不到指定的版位!";
            }
            else
            {
                this.TxtZoneCode.Text = "<script  type=\"text/javascript\" src='{PE.SiteConfig.adpath/}/" + adZoneById.ZoneJSName + "'></script>";
            }
        }
Exemple #7
0
        public static DataActionState Add(ADZoneInfo adZoneInfo)
        {
            DataActionState unknown = DataActionState.Unknown;

            if (!dal.Add(adZoneInfo))
            {
                return(unknown);
            }
            if (adZoneInfo.Active)
            {
                CreateJS(adZoneInfo.ZoneId.ToString(CultureInfo.CurrentCulture));
            }
            return(DataActionState.Successed);
        }
Exemple #8
0
        private static Parameters GetParameters(ADZoneInfo adZoneInfo)
        {
            Parameters parameters = new Parameters();

            parameters.AddInParameter("@ZoneName", DbType.String, adZoneInfo.ZoneName);
            parameters.AddInParameter("@ZoneJSName", DbType.String, adZoneInfo.ZoneJSName);
            parameters.AddInParameter("@ZoneIntro", DbType.String, adZoneInfo.ZoneIntro);
            parameters.AddInParameter("@ZoneType", DbType.Int32, adZoneInfo.ZoneType);
            parameters.AddInParameter("@DefaultSetting", DbType.Boolean, adZoneInfo.DefaultSetting);
            parameters.AddInParameter("@ZoneSetting", DbType.String, adZoneInfo.Setting);
            parameters.AddInParameter("@ZoneWidth", DbType.Int32, adZoneInfo.ZoneWidth);
            parameters.AddInParameter("@ZoneHeight", DbType.Int32, adZoneInfo.ZoneHeight);
            parameters.AddInParameter("@Active", DbType.Boolean, adZoneInfo.Active);
            parameters.AddInParameter("@ShowType", DbType.Int32, adZoneInfo.ShowType);
            parameters.AddInParameter("@UpdateTime", DbType.DateTime, adZoneInfo.UpdateTime);
            return(parameters);
        }
Exemple #9
0
 public static void DeleteJS(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         string[]    strArray         = id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         string      advertisementDir = SiteConfig.SiteOption.AdvertisementDir;
         HttpContext current          = HttpContext.Current;
         if (current != null)
         {
             advertisementDir = current.Server.MapPath("~/" + advertisementDir);
         }
         for (int i = 0; i < strArray.Length; i++)
         {
             ADZoneInfo adZoneById = GetAdZoneById(DataConverter.CLng(strArray[i]));
             FileSystemObject.Delete(VirtualPathUtility.AppendTrailingSlash(advertisementDir) + adZoneById.ZoneJSName, FsoMethod.File);
         }
     }
 }
Exemple #10
0
        private static DbCommand GetProcdbComm(Database db, string proName, ADZoneInfo adZoneInfo)
        {
            DbCommand storedProcCommand = db.GetStoredProcCommand(proName);

            db.AddInParameter(storedProcCommand, "@ZoneId", DbType.Int32, adZoneInfo.ZoneId);
            db.AddInParameter(storedProcCommand, "@ZoneName", DbType.String, adZoneInfo.ZoneName);
            db.AddInParameter(storedProcCommand, "@ZoneJSName", DbType.String, adZoneInfo.ZoneJSName);
            db.AddInParameter(storedProcCommand, "@ZoneIntro", DbType.String, adZoneInfo.ZoneIntro);
            db.AddInParameter(storedProcCommand, "@ZoneType", DbType.Int32, adZoneInfo.ZoneType);
            db.AddInParameter(storedProcCommand, "@DefaultSetting", DbType.Boolean, adZoneInfo.DefaultSetting);
            db.AddInParameter(storedProcCommand, "@ZoneSetting", DbType.String, adZoneInfo.Setting);
            db.AddInParameter(storedProcCommand, "@ZoneWidth", DbType.Int32, adZoneInfo.ZoneWidth);
            db.AddInParameter(storedProcCommand, "@ZoneHeight", DbType.Int32, adZoneInfo.ZoneHeight);
            db.AddInParameter(storedProcCommand, "@Active", DbType.Boolean, adZoneInfo.Active);
            db.AddInParameter(storedProcCommand, "@ShowType", DbType.Int32, adZoneInfo.ShowType);
            db.AddInParameter(storedProcCommand, "@UpdateTime", DbType.DateTime, adZoneInfo.UpdateTime);
            return(storedProcCommand);
        }
Exemple #11
0
        private static ADZoneInfo GetAdZoneInfoFromrdr(NullableDataReader rdr)
        {
            ADZoneInfo info = new ADZoneInfo();

            info.ZoneId         = rdr.GetInt32("ZoneId");
            info.ZoneName       = rdr.GetString("ZoneName");
            info.ZoneJSName     = rdr.GetString("ZoneJSName");
            info.ZoneIntro      = rdr.GetString("ZoneIntro");
            info.ZoneType       = (ADZoneType)rdr.GetInt32("ZoneType");
            info.DefaultSetting = rdr.GetBoolean("DefaultSetting");
            info.Setting        = rdr.GetString("ZoneSetting");
            info.ZoneWidth      = rdr.GetInt32("ZoneWidth");
            info.ZoneHeight     = rdr.GetInt32("ZoneHeight");
            info.Active         = rdr.GetBoolean("Active");
            info.ShowType       = rdr.GetInt32("ShowType");
            info.UpdateTime     = rdr.GetDateTime("UpdateTime");
            return(info);
        }
        public void CreateJS(ADZoneInfo adZoneInfo, IList <AdvertisementInfo> advertisementInfoList)
        {
            this.zoneInfo = adZoneInfo;
            StringBuilder builder = new StringBuilder(this.GetZoneJSTemplate());

            builder.Append("var ZoneAD_" + adZoneInfo.ZoneId + "=new ");
            builder.Append(string.Concat(new object[] { this.zoneConfig[adZoneInfo.ZoneType], "ZoneAD(\"ZoneAD_", adZoneInfo.ZoneId, "\");" }));
            for (int i = 0; i < advertisementInfoList.Count; i++)
            {
                this.advertisementInfo        = advertisementInfoList[i];
                this.advertisementInfo.ZoneId = adZoneInfo.ZoneId.ToString(CultureInfo.CurrentCulture);
                if (this.advertisementInfo.Passed && (this.advertisementInfo.Days >= 0))
                {
                    builder.Append(this.CreatAdvertisementJS());
                }
            }
            builder.Append(this.CreateADZoneJS());
            FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Server.MapPath("~/" + SiteConfig.SiteOption.AdvertisementDir)) + adZoneInfo.ZoneJSName, builder.ToString());
        }
Exemple #13
0
 public static void CreateJS(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         string[] strArray = id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         ADZoneJS ejs      = new ADZoneJS();
         for (int i = 0; i < strArray.Length; i++)
         {
             ADZoneInfo adZoneById = GetAdZoneById(DataConverter.CLng(strArray[i]));
             if (adZoneById.Active)
             {
                 IList <AdvertisementInfo> aDList = Advertisement.GetADList(adZoneById.ZoneId, adZoneById.ShowType);
                 if (aDList.Count > 0)
                 {
                     ejs.CreateJS(adZoneById, aDList);
                 }
             }
         }
     }
 }
 protected void EBtnAdZone_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         ADZoneInfo adZoneInfo = new ADZoneInfo();
         adZoneInfo.ZoneName       = this.TxtZoneName.Text.Trim();
         adZoneInfo.ZoneJSName     = this.TxtZoneJSName.Text.Trim();
         adZoneInfo.ZoneIntro      = this.TxtZoneIntro.Text.Trim();
         adZoneInfo.ZoneType       = (ADZoneType)DataConverter.CLng(this.RadlZoneType.SelectedValue);
         adZoneInfo.DefaultSetting = this.GetDefaultSetting(this.RadlDefaultSetting.SelectedValue);
         adZoneInfo.Setting        = this.GetZoneSetting(adZoneInfo.DefaultSetting);
         adZoneInfo.ZoneWidth      = DataConverter.CLng(this.TxtZoneWidth.Text.Trim());
         adZoneInfo.ZoneHeight     = DataConverter.CLng(this.TxtZoneHeight.Text.Trim());
         adZoneInfo.ShowType       = DataConverter.CLng(this.RadlShowType.SelectedValue);
         adZoneInfo.Active         = this.ChkActive.Checked;
         adZoneInfo.UpdateTime     = DateTime.Now;
         if (this.HdnAction.Value.Trim() == "Modify")
         {
             adZoneInfo.ZoneId = DataConverter.CLng(this.HdnZoneId.Value.Trim());
             if (ADZone.Update(adZoneInfo))
             {
                 BasePage.ResponseRedirect("ADZoneManage.aspx");
             }
             else
             {
                 AdminPage.WriteErrMsg("更新出错!", "ADZone.aspx?ZoneId=" + adZoneInfo.ZoneId);
             }
         }
         else if (ADZone.Add(adZoneInfo) == DataActionState.Successed)
         {
             BasePage.ResponseRedirect("ADZoneManage.aspx");
         }
         else
         {
             AdminPage.WriteErrMsg("添加出错!", "ADZone.aspx");
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int zoneId = BasePage.RequestInt32("ZoneId");

            if (string.Compare(BasePage.RequestString("Type"), "Zone", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (Advertisement.GetADList(zoneId).Count == 0)
                {
                    this.ShowJS.InnerHtml = "版位中暂时还未添加广告,请添加后再进行预览!";
                }
                else
                {
                    ADZoneInfo adZoneById = ADZone.GetAdZoneById(zoneId);
                    if (adZoneById != null)
                    {
                        this.ShowJS.InnerHtml = "<script  type=\"text/javascript\" src='" + base.ResolveUrl("~/" + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.AdvertisementDir) + adZoneById.ZoneJSName) + "?temp=" + DataSecurity.RandomNum() + "'></script>";
                    }
                }
            }
            else
            {
                this.ShowAd();
            }
        }
Exemple #16
0
 public static bool Update(ADZoneInfo adZoneInfo)
 {
     return(dal.Update(adZoneInfo));
 }