示例#1
0
        public void CPS()
        {
            string strJump = Request.QueryString["jump"];
            if (Request.QueryString["site"] == "5")
            {
                #region 购酒网接口
                int intSiteID = int.Parse(Request.QueryString["site"]);
                string strUid = Request.QueryString["uid"];

                var cook = new HttpCookie("CPS_IN");
                cook.Values.Add("SiteID", intSiteID.ToString());
                cook.Values.Add("SiteUser", Server.UrlEncode(strUid));
                cook.Expires = DateTime.Now.AddDays(30);
                if (!string.IsNullOrEmpty(Request.QueryString["ex"]))
                {
                    if (Request.QueryString["ex"].Length > 200)
                    {
                        cook.Values.Add("SiteEx", Server.UrlEncode(Request.QueryString["ex"].Substring(0, 200).ToString()));
                    }
                    else
                    {
                        cook.Values.Add("SiteEx", Server.UrlEncode(Request.QueryString["ex"]));
                    }
                }
                Response.AppendCookie(cook);

                //记录链入日志
                try
                {
                    var lr = new Cps_LinkRecord();
                    lr.CpsID = intSiteID;
                    lr.URL = this.Request.Url.ToString();
                    if (string.IsNullOrEmpty(strJump))
                        strJump = "";
                    lr.TargetURL = strJump;
                    new CpsLinkRecordService().Add(lr);
                }
                catch (Exception exception)
                {
                    LogUtils.Log(
                        "[CPS]写入CPS调用日志发生错误。错误信息:" + exception.Message + "/" + exception.InnerException,
                        "[CPS]",
                        Category.Error,
                        this.Session.SessionID,
                        0,
                        "CPS");
                }
                #endregion
            }

            if (!string.IsNullOrWhiteSpace(strJump))
            {
                this.Response.Redirect(strJump);
            }
            else
            {
                this.Response.Redirect(Utils.GetWebSiteUrl);
            }
        }
        /// <summary>
        /// 插入一条CPS记录
        /// </summary>
        /// <param name="linkRecord">记录对象</param>
        /// <param name="transaction"></param>
        /// <returns>新增的ID</returns>
        public int Insert(Cps_LinkRecord linkRecord, SqlTransaction transaction)
        {
            //Create Procedure sp_Cps_LinkRecord_Insert
            //    @CpsID int,
            //    @URL nvarchar(1024),
            //    @TargetURL nvarchar(4000),
            //    @CreateTime datetime,
            //    @IsDelete int=default,
            //    @ExtField nvarchar(50)=default,
            //    @ReferenceID int output
            //As

            var paras = new List<SqlParameter>
                            {
                                this.sqlServer.CreateSqlParameter(
                                    "CpsID",
                                    SqlDbType.Int,
                                    linkRecord.CpsID,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "URL",
                                    SqlDbType.NVarChar,
                                    linkRecord.URL,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "TargetURL",
                                    SqlDbType.NVarChar,
                                    linkRecord.TargetURL,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "CreateTime",
                                    SqlDbType.DateTime,
                                    DateTime.Now,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "IsDelete",
                                    SqlDbType.Int,
                                    0,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ExtField",
                                    SqlDbType.NVarChar,
                                    linkRecord.ExtField,
                                    ParameterDirection.Input),
                                this.sqlServer.CreateSqlParameter(
                                    "ReferenceID",
                                    SqlDbType.Int,
                                    null,
                                    ParameterDirection.Output)
                            };

            this.sqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Cps_LinkRecord_Insert", paras, transaction);

            return (int)paras.Find(p => p.ParameterName == "ReferenceID").Value;
        }
 public int Add(Cps_LinkRecord linkRecord)
 {
     return cpsLinkRecordDa.Insert(linkRecord, null);
 }