/// <summary>
        /// 立即兑换按钮点击事件
        /// 作者:姚东
        /// 时间:20101015
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExchange_Click(object sender, EventArgs e)
        {
            ////判断会员是否登录系统了
            //if (Session["UserGUID"] == null)
            //{
            //    PageHelper.ShowExceptionMessage("登录系统后才能进行礼品兑换!");
            //    return;
            //}

            BLL.Entity.GiftsEntity giftEntity  = new BLL.Entity.GiftsEntity(GiftGuid);
            BLL.Entity.PointEntity pointEntity = new BLL.Entity.PointEntity(Session["UserGUID"].ToString());

            //判断剩余积分是否够兑换礼品
            if (giftEntity.NeedPoint > pointEntity.RemainPoint)
            {
                PageHelper.ShowExceptionMessage(string.Format("您的余额为{0}个积分,兑换此礼品需要{1}个积分!",
                                                              pointEntity.RemainPoint.ToString(), giftEntity.NeedPoint.ToString()));
                return;
            }

            //判断礼品余量是否够兑换
            if (giftEntity.RemainAmount <= 0)
            {
                PageHelper.ShowExceptionMessage("暂时没有多余的礼品可被兑换,请稍后再试!");
                return;
            }

            //更新兑换记录
            BLL.Entity.ExchangeEntity exchangeEntity = new BLL.Entity.ExchangeEntity();
            exchangeEntity.ApplyTime   = DateTime.Now;
            exchangeEntity.GiftGuid    = GiftGuid;
            exchangeEntity.HuiYuanGuid = Session["UserGUID"].ToString();
            exchangeEntity.Memo        = "";
            exchangeEntity.Status      = 1;
            exchangeEntity.UsedPoint   = giftEntity.NeedPoint;

            ExchangeRule exchangeRule = new ExchangeRule();

            exchangeRule.Add(exchangeEntity);

            //更新积分信息
            pointEntity.RemainPoint = pointEntity.RemainPoint - giftEntity.NeedPoint;
            PointRule pointRule = new PointRule();

            pointRule.Update(pointEntity);

            //更新礼品余量
            giftEntity.RemainAmount -= 1;
            new GiftsRule().Update(giftEntity);

            PageHelper.ShowExceptionMessage("已发送兑换申请。");
        }
        /// <summary>
        /// 将文件从服务器下载到本地
        /// </summary>
        /// <param name="fileName">文件路径</param>
        /// <param name="resId">资源id</param>
        /// <param name="appId">附件id</param>
        public void DownLoad(string fileName, string resId, string appId)
        {
            using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
            {
                Resource res    = new Resource();
                string   userId = CommonUtil.GetSession(Session, "id");
                res.AddDownLoadNum(resId, appId, userId, db);
            }

            string loccalFile = fileName;// Constant.DISK_ADDRESS + fileName;

            try
            {
                if (!System.IO.File.Exists(loccalFile))
                {
                    throw new Exception("文件不存在");
                }

                //100K 每次读取文件,只读取100K
                //const long ChunkSize = 102400;

                //byte[] buffer = new byte[ChunkSize];

                //HttpContext.Response.Clear();

                //FileStream fs = new FileStream(loccalFile, FileMode.Open);

                //long dataLengthToRead = fs.Length;//获取下载的文件总大小

                #region 20150228 5920 Add 文件ID改成文件原名
                fileName = Path.GetFileName(fileName);
                Resource res = new Resource();
                fileName = res.GetFileOriginalName(fileName);
                #endregion

                HttpContext.Response.ContentType = "application/octet-stream";
                HttpContext.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName));

                Response.TransmitFile(loccalFile);

                //while (dataLengthToRead > 0 && HttpContext.Response.IsClientConnected)
                //{
                //    int lengthRead = fs.Read(buffer, 0, Convert.ToInt32(ChunkSize));//读取的大小
                //    HttpContext.Response.OutputStream.Write(buffer, 0, lengthRead);
                //    HttpContext.Response.Flush();
                //    dataLengthToRead = dataLengthToRead - lengthRead;
                //}

                //HttpContext.Response.Close();

                ////下载完成
                //if (dataLengthToRead == 0)
                //{
                //    if (fs != null)
                //    {
                //        fs.Close();
                //    }
                //}

                //下载资源时,可以获得积分
                PointRule pr = new PointRule();
                pr.AddPoint(resId, CommonUtil.GetSession(Session, "id"), "1");
                //下载资源时,可以获得积分
            }
            catch (Exception ex)
            {
                clsLog.ErrorLog("MineController", "DownLoad", ex.Message);

                HttpContext.Response.Write("<script type='text/javascript'>layer.alert(" + ex.Message + ")</script>");
            }
        }