Example #1
0
		protected void lnk_Delete_Click(object sender, System.EventArgs e)
		{
			if (!base.IsAuthorizedOp(ActionType.Delete.ToString()))
			{
				base.ShowAjaxMsg(this.UpdatePanel1, "Không có thẩm quyền");
			}
			else
			{
				int @int = WebUtils.GetInt((sender as LinkButton).CommandArgument);
				AdsInfo dataById = Ads.GetDataById(@int);
				if (dataById == null)
				{
					base.ShowAjaxMsg(this.UpdatePanel1, "没有找到此广告信息,广告不存在或者已删除");
				}
				else if (Ads.Delete(@int))
				{
					this.BindData();
					PageBase.log.AddEvent(base.LoginAccount.AccountName, "删除广告[" + dataById.AdName + "] thành công");
					base.ShowAjaxMsg(this.UpdatePanel1, "删除广告成功");
				}
				else
				{
					base.ShowAjaxMsg(this.UpdatePanel1, "删除广告失败");
				}
			}
		}
Example #2
0
        public void Show(string placement)
        {
            var adsPlacement = Settings.Placements.Find(x => x.Id == placement);

            if (!adsPlacement || !IsPlacementReady(adsPlacement))
            {
                return;
            }

            var provider = Settings.Providers.Find(x => x.IsReady());

            if (!provider)
            {
                return;
            }

            provider.Show(adsPlacement);

            var adsIndex = adsInfos.FindIndex(x => x.placement == adsPlacement.Id);

            if (adsIndex == -1)
            {
                adsInfos.Add(new AdsInfo()
                {
                    placement = adsPlacement.Id, startTime = DateTime.Now.ToUnixTime()
                });
            }
            else
            {
                adsInfos[adsIndex] = new AdsInfo()
                {
                    placement = adsPlacement.Id, startTime = DateTime.Now.ToUnixTime()
                };
            }
        }
 private static SqlParameter[] CreateAds(AdsInfo info)
 {
     return(new SqlParameter[]
     {
         new SqlParameter("@AdsId", info.AdsId),
         new SqlParameter("@AdsName", info.AdsName),
         new SqlParameter("@AdsSize", info.AdsSize),
         new SqlParameter("@AdsType", info.AdsType)
     });
 }
Example #4
0
        public static int Add(AdsInfo entity)
        {
            int result;

            if (entity == null)
            {
                result = 0;
            }
            else
            {
                result = BizBase.dbo.InsertModel <AdsInfo>(entity);
            }
            return(result);
        }
Example #5
0
    protected void BTN_Up_Click(object sender, EventArgs e)
    {
        if (CheckNull())
        {
            AdsInfo info = new AdsInfo();
            info.AdsId   = new Guid(ViewState["adsid"].ToString());
            info.AdsName = TB_AdsName.Text.Trim();
            info.AdsSize = TB_AdsSize.Text.Trim();
            info.AdsType = int.Parse(DDL_AdsType.SelectedValue);

            adsSiteDal.UpdateAds(info);
            CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLADSINFO);
            Response.Redirect("AddAds.aspx?siteid=" + Request.QueryString["siteid"]);
        }
    }
    /// <summary>
    /// 查找单个广告
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public AdsInfo SelectAdsInfo(Guid id)
    {
        DataTable dt   = DBHelper.ExecuteDataTable(SQL_SELECT_ADS_BY_ID, new SqlParameter("@AdsId", id));
        AdsInfo   info = null;

        foreach (DataRow dr in dt.Rows)
        {
            info         = new AdsInfo();
            info.AdsSize = dr["AdsSize"].ToString();
            info.AdsName = dr["AdsName"].ToString();
            info.AdsId   = new Guid(dr["AdsId"].ToString());
            info.AdsType = int.Parse(dr["AdsType"].ToString());
        }

        return(info);
    }
Example #7
0
    protected void BTN_Add_Click(object sender, EventArgs e)
    {
        if (CheckNull())
        {
            if (DDL_SiteList.SelectedValue != Guid.Empty.ToString())
            {
                AdsInfo info = new AdsInfo(new Guid(DDL_SiteList.SelectedValue), TB_AdsName.Text.Trim(), TB_AdsSize.Text.Trim());
                info.AdsType = int.Parse(DDL_AdsType.SelectedValue);

                FUP_Up.SaveAs(Server.MapPath("~/adsimg") + "/" + info.AdsId + ".jpg");
                info.AdsPic = "/adsimg/" + info.AdsId + ".jpg";

                adsSiteDal.AddAds(info);
                CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLADSINFO);
                Response.Redirect("AddAds.aspx?siteid=" + info.SiteId);
            }
        }
    }
    /// <summary>
    /// 指定网站查找所有广告
    /// </summary>
    /// <returns></returns>
    public IList <AdsInfo> SelectAllAds()
    {
        DataTable       dt   = DBHelper.ExecuteDataTable(SQL_SELECT_ADS);
        IList <AdsInfo> list = new List <AdsInfo>();

        foreach (DataRow dr in dt.Rows)
        {
            AdsInfo info = new AdsInfo();
            info         = new AdsInfo();
            info.AdsSize = dr["AdsSize"].ToString();
            info.AdsName = dr["AdsName"].ToString();
            info.AdsId   = new Guid(dr["AdsId"].ToString());
            info.AdsType = int.Parse(dr["AdsType"].ToString());
            list.Add(info);
        }

        return(list);
    }
    /// <summary>
    /// 指定网站查找所有广告
    /// </summary>
    /// <param name="siteId"></param>
    /// <returns></returns>
    public IList <AdsInfo> SelectAllAdsBySiteId(Guid siteId)
    {
        DataTable       dt   = DBHelper.ExecuteDataTable(SQL_SELECT_ADS_BY_SITEID, new SqlParameter("@SiteId", siteId));
        IList <AdsInfo> list = new List <AdsInfo>();

        foreach (DataRow dr in dt.Rows)
        {
            AdsInfo info = new AdsInfo();
            info         = new AdsInfo();
            info.AdsSize = dr["AdsSize"].ToString();
            info.AdsName = dr["AdsName"].ToString();
            info.AdsId   = new Guid(dr["AdsId"].ToString());
            info.AdsType = int.Parse(dr["AdsType"].ToString());

            list.Add(info);
        }

        return(list);
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["adsid"]))
            {
                IList <AdsInfo> list = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == Request.QueryString["adsid"]).ToList();
                if (list.Count > 0)
                {
                    AdsInfo info = list[0];
                    ViewState["ImgUrl"] = info.AdsPic;
                    IList <SiteInfo> sitelist = CacheCollection.GetAllSiteList().Where(o => o.SiteId == info.SiteId).ToList();

                    LB_SiteUrl1.Text = sitelist[0].SiteUrl;

                    ViewState["SiteUrl"] = sitelist[0].SiteUrl;
                }
            }
        }
    }
Example #11
0
    protected void RPT_AdsList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Up")
        {
            AdsInfo info = adsSiteDal.SelectAdsInfo(new Guid(e.CommandArgument.ToString()));

            TB_AdsName.Text           = info.AdsName;
            TB_AdsSize.Text           = info.AdsSize;
            DDL_AdsType.SelectedValue = info.AdsType.ToString();
            ViewState["adsid"]        = info.AdsId.ToString();
            BTN_Up.Visible            = true;
            BTN_Add.Visible           = false;
        }
        if (e.CommandName == "De")
        {
            adsSiteDal.DeleteAds(new Guid(e.CommandArgument.ToString()));
            CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLADSINFO);
            Response.Redirect("AddAds.aspx?siteid=" + Request.QueryString["siteid"]);
        }
    }
Example #12
0
        private void InitForModify()
        {
            AdsInfo dataById = Ads.GetDataById(base.OpID);

            if (dataById != null)
            {
                this.adPlace = AdPlace.GetCacheAdPlaceById(dataById.PlaceID);
                ListItem listItem = this.ddlADPlace.Items.FindByValue(dataById.PlaceID.ToString());
                if (listItem != null)
                {
                    listItem.Selected = true;
                }
                this.TextBox1.Text   = dataById.AdName;
                this.Image1.ImageUrl = dataById.AdMediaPath;
                this.Image1.Attributes.Add("data-original", dataById.AdMediaPath);
                this.TextBox6.Text   = dataById.AdMediaPath;
                this.TextBox2.Text   = dataById.AdLink;
                this.timestart.Text  = dataById.BeginDate.ToString("yyyy-MM-dd");
                this.timeend.Text    = dataById.EndDate.ToString("yyyy-MM-dd");
                this.TextBox4.Text   = dataById.AdText;
                this.isaudit.Checked = dataById.IsAudit;
            }
        }
Example #13
0
    IEnumerator load()
    {
        WWWForm wwwform = new WWWForm();

        wwwform.AddField("appId", AppID);

        WWW www = new WWW(Url, wwwform);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log("Load moreapp failed");
            isLoaded = false;
        }
        else
        {
            Parse p = new Parse(www.text);
            adsinfo = p.GetAdsInfo();
            Invoke("LoadSprite", 0.5f);
            isLoaded = true;
        }
    }
 /// <summary>
 /// 更新一个广告位
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public int UpdateAds(AdsInfo info)
 {
     return(DBHelper.ExecuteNonQuery(SQL_UPDATE_ADS, CreateAds(info)));
 }
 /// <summary>
 /// 插入一个广告位
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public int AddAds(AdsInfo info)
 {
     return(DBHelper.ExecuteNonQuery(SQL_ADD_ADS, CreateAds(info)));
 }
Example #16
0
        public static MFTRecordOut GetCsvData(FileRecord fr, FileName fn, AdsInfo adsinfo)
        {
            var mftr = new MFTRecordOut
            {
                EntryNumber          = fr.EntryNumber,
                FileName             = fn.FileInfo.FileName,
                InUse                = fr.IsDeleted() == false,
                ParentPath           = _mft.GetFullParentPath(fn.FileInfo.ParentMftRecord.GetKey()),
                SequenceNumber       = fr.SequenceNumber,
                IsDirectory          = fr.IsDirectory(),
                ParentEntryNumber    = fn.FileInfo.ParentMftRecord.MftEntryNumber,
                ParentSequenceNumber = fn.FileInfo.ParentMftRecord.MftSequenceNumber,
                NameType             = fn.FileInfo.NameType,
                FnAttributeId        = fn.AttributeNumber
            };

            if (mftr.IsDirectory == false)
            {
                mftr.Extension = Path.GetExtension(mftr.FileName);

                var data = fr.Attributes.FirstOrDefault(t => t.AttributeType == AttributeType.Data);

                if (data != null)
                {
                    mftr.OtherAttributeId = data.AttributeNumber;
                }
            }

            mftr.FileSize = fr.GetFileSize();

            if (adsinfo != null)
            {
                mftr.FileName = $"{mftr.FileName}:{adsinfo.Name}";
                mftr.FileSize = adsinfo.Size;

                try
                {
                    mftr.Extension = Path.GetExtension(adsinfo.Name);
                }
                catch (Exception)
                {
                    //sometimes bad chars show up
                }

                if (adsinfo.Name == "Zone.Identifier")
                {
                    if (adsinfo.ResidentData != null)
                    {
                        mftr.ZoneIdContents = Encoding.GetEncoding(1252).GetString(adsinfo.ResidentData.Data);
                    }
                    else
                    {
                        mftr.ZoneIdContents = "(Zone.Identifier data is non-resident)";
                    }
                }
            }

            mftr.ReferenceCount = fr.GetReferenceCount();

            mftr.LogfileSequenceNumber = fr.LogSequenceNumber;

            var oid = (ObjectId)fr.Attributes.SingleOrDefault(t =>
                                                              t.AttributeType == AttributeType.VolumeVersionObjectId);

            if (oid != null)
            {
                mftr.ObjectIdFileDroid = oid.FileDroid.ToString();
            }

            var lus = (LoggedUtilityStream)fr.Attributes.FirstOrDefault(t =>
                                                                        t.AttributeType == AttributeType.LoggedUtilityStream);

            if (lus != null)
            {
                mftr.LoggedUtilStream = lus.Name;
            }

            var rp = fr.GetReparsePoint();

            if (rp != null)
            {
                mftr.ReparseTarget = rp.SubstituteName.Replace(@"\??\", "");
            }

            var si = (StandardInfo)fr.Attributes.SingleOrDefault(t =>
                                                                 t.AttributeType == AttributeType.StandardInformation);

            if (si != null)
            {
                mftr.UpdateSequenceNumber = si.UpdateSequenceNumber;

                mftr.Created0x10          = si.CreatedOn;
                mftr.LastModified0x10     = si.ContentModifiedOn;
                mftr.LastRecordChange0x10 = si.RecordModifiedOn;
                mftr.LastAccess0x10       = si.LastAccessedOn;

                mftr.Copied = si.ContentModifiedOn < si.CreatedOn;

                if (_fluentCommandLineParser.Object.AllTimeStampsAllTime || fn.FileInfo.CreatedOn != si.CreatedOn)
                {
                    mftr.Created0x30 = fn.FileInfo.CreatedOn;
                }

                if (_fluentCommandLineParser.Object.AllTimeStampsAllTime || fn.FileInfo.ContentModifiedOn != si.ContentModifiedOn)
                {
                    mftr.LastModified0x30 = fn.FileInfo.ContentModifiedOn;
                }

                if (_fluentCommandLineParser.Object.AllTimeStampsAllTime || fn.FileInfo.RecordModifiedOn != si.RecordModifiedOn)
                {
                    mftr.LastRecordChange0x30 = fn.FileInfo.RecordModifiedOn;
                }

                if (_fluentCommandLineParser.Object.AllTimeStampsAllTime || fn.FileInfo.LastAccessedOn != si.LastAccessedOn)
                {
                    mftr.LastAccess0x30 = fn.FileInfo.LastAccessedOn;
                }

                mftr.SecurityId = si.SecurityId;

                mftr.SiFlags = si.Flags;

                if (mftr.Created0x30.HasValue && mftr.Created0x10?.UtcTicks < mftr.Created0x30.Value.UtcTicks)
                {
                    mftr.Timestomped = true;
                }

                if (mftr.Created0x10?.Millisecond == 0 || mftr.LastModified0x10?.Millisecond == 0)
                {
                    mftr.uSecZeros = true;
                }
            }
            else
            {
                //no si, so update FN timestamps
                mftr.Created0x30          = fn.FileInfo.CreatedOn;
                mftr.LastModified0x10     = fn.FileInfo.ContentModifiedOn;
                mftr.LastRecordChange0x10 = fn.FileInfo.RecordModifiedOn;
                mftr.LastAccess0x10       = fn.FileInfo.LastAccessedOn;
            }

            return(mftr);
        }
Example #17
0
 public static bool Update(AdsInfo entity)
 {
     return(entity != null && BizBase.dbo.UpdateModel <AdsInfo>(entity));
 }
Example #18
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         AdsInfo adsInfo = new AdsInfo();
         if (base.IsEdit)
         {
             adsInfo = Ads.GetDataById(base.OpID);
         }
         adsInfo.PlaceID     = WebUtils.GetInt(this.ddlADPlace.SelectedValue);
         adsInfo.AdType      = 1;
         adsInfo.AdName      = WebUtils.GetString(this.TextBox1.Text);
         adsInfo.AdText      = this.TextBox4.Text;
         adsInfo.AdMediaPath = WebUtils.GetString(this.TextBox6.Text);
         adsInfo.AdLink      = WebUtils.GetString(this.TextBox2.Text);
         adsInfo.BeginDate   = WebUtils.GetDateTime(this.timestart.Text);
         adsInfo.EndDate     = WebUtils.GetDateTime(this.timeend.Text);
         adsInfo.IsAudit     = this.isaudit.Checked;
         adsInfo.Lang        = base.cultureLang;
         if (string.IsNullOrEmpty(adsInfo.AdName))
         {
             base.ShowMsg("请输入广告名称");
         }
         else if (adsInfo.EndDate < adsInfo.BeginDate)
         {
             base.ShowMsg("广告截止日期不能小于起始日期");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 adsInfo.Sort          = Ads.MaxSort + 1;
                 adsInfo.AutoTimeStamp = System.DateTime.Now;
                 if (Ads.Add(adsInfo) > 0)
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加广告[" + adsInfo.AdName + "] thành công");
                     base.Response.Redirect(string.Concat(new object[]
                     {
                         "AdsList.aspx?CatalogID=",
                         base.CurrentCatalogID,
                         "&Module=",
                         base.CurrentModuleCode,
                         "&PlaceID=",
                         WebUtils.GetQueryInt("PlaceID"),
                         "&action=View"
                     }));
                 }
                 else
                 {
                     base.ShowMsg("添加广告失败");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (Ads.Update(adsInfo))
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改广告[" + adsInfo.AdName + "] thành công");
                     base.Response.Redirect(string.Concat(new object[]
                     {
                         "AdsList.aspx?CatalogID=",
                         base.CurrentCatalogID,
                         "&Module=",
                         base.CurrentModuleCode,
                         "&PlaceID=",
                         adsInfo.PlaceID,
                         "&action=View"
                     }));
                 }
                 else
                 {
                     base.ShowMsg("修改广告失败");
                 }
             }
         }
     }
 }
Example #19
0
    protected string GetAdsName(string adsId)
    {
        AdsInfo info = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == adsId).ToList()[0];

        return(info.AdsName);
    }
Example #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            IList <AdsInfo> adsList = CacheCollection.GetAllAdsInfo();

            Random  rand = new Random();
            AdsInfo info = adsList[rand.Next(adsList.Count)];

            IList <UserAdsInfo> list = uasDal.SelectAllUserAdsByAdsId(info.AdsId, 1);

            IList <ClickInfo> clickList = clickDal.SelectAllClickCount(DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd"));

            //获取访问IP
            string ip = Request.ServerVariables["REMOTE_ADDR"];
            //获取当天已经访问来了的IP
            IList <ClickIPInfo> ipList = clickDal.SelectAllClickIPByDate(DateTime.Now.ToString("yyyyMMdd"));
            //和当前IP相同的
            ipList = ipList.Where(o => o.VisitIP == ip).ToList();

            foreach (ClickIPInfo ipinfo in ipList)
            {
                //已经访问了该广告
                IList <UserAdsInfo> hadlist = list.Where(o => o.Id == ipinfo.UserAdsId).ToList();
                if (hadlist.Count > 0)
                {
                    list.Remove(hadlist[0]);
                }
            }

            if (list.Count == 0)
            {
                return;
            }

            foreach (ClickInfo cinfo in clickList)
            {
                if (cinfo.ClickCount >= rand.Next(6, 15))//10)
                {
                    IList <UserAdsInfo> hadlist = list.Where(o => o.Id == cinfo.UserAdsId).ToList();

                    if (hadlist.Count > 0)
                    {
                        FeeInfo finfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == hadlist[0].FeeId).ToList()[0];
                        if (finfo.AdsType == 1)
                        {
                            if (finfo.AdsCount == 1)
                            {
                                list.Remove(hadlist[0]);
                            }
                            else
                            {
                                if (cinfo.ClickCount >= rand.Next(14, 23))//18)
                                {
                                    list.Remove(hadlist[0]);
                                }
                            }
                        }
                        if (finfo.AdsType == 5)
                        {
                            if (cinfo.ClickCount >= rand.Next(22, 33)) //27)
                            {
                                list.Remove(hadlist[0]);
                            }
                        }
                    }
                }
            }

            if (list.Count == 0)
            {
                return;
            }

            UserAdsInfo uinfo = list[0];
            if (list.Count > 1)
            {
                uinfo = list[rand.Next(list.Count)];
            }

            ClickIPInfo iinfo = new ClickIPInfo();
            iinfo.VisitIP   = ip;
            iinfo.ClickId   = Guid.NewGuid();
            iinfo.VisitDate = DateTime.Now.ToString("yyyyMMdd");
            iinfo.UserAdsId = uinfo.Id;
            clickDal.InsertClickIP(iinfo);

            string param = "id=" + uinfo.Id + "&url=" + uinfo.AdsUrl;
            Response.Redirect("getclick.aspx?" + HttpUtility.UrlEncode(param));
        }
    }