Esempio n. 1
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetMarketSignInRP> pRequest)
        {
            var rp = pRequest.Parameters;
            EmptyResponseData   rd = new EmptyResponseData();
            MarketSignInBLL     marketSignInbll     = new MarketSignInBLL(CurrentUserInfo);
            MarketNamedApplyBLL marketNamedApplyBll = new MarketNamedApplyBLL(CurrentUserInfo);
            var marketNamedApplyEntityArray         = marketNamedApplyBll.QueryByEntity(new MarketNamedApplyEntity()
            {
                MarketEventID = rp.MarketEventID, VipId = rp.VipID
            }, null);

            if (marketNamedApplyEntityArray.Length != 0)
            {
                var marketSignInEntityArray = marketSignInbll.QueryByEntity(new MarketSignInEntity()
                {
                    EventID = rp.MarketEventID, VipID = rp.VipID
                }, null);
                if (marketSignInEntityArray.Length == 0)
                {
                    MarketSignInEntity marketSignInEntity = new MarketSignInEntity()
                    {
                        SignInID = Guid.NewGuid().ToString(),
                        OpenID   = "",
                        EventID  = rp.MarketEventID,
                        UserId   = pRequest.UserID,
                        VipID    = rp.VipID
                    };
                    marketSignInbll.Create(marketSignInEntity);
                }
                else
                {
                    throw new APIException("该会员已签到")
                          {
                              ErrorCode = 340
                          };
                }
            }
            else
            {
                throw new APIException("该会员没有申请该活动")
                      {
                          ErrorCode = 340
                      };
            }
            return(rd);
        }
        protected override void AjaxRequest(HttpContext pContext)
        {
            //string content = "";
            // string method = pContext.Request.QueryString["method"];
            MarketNamedApplyBLL marketNameApplyBll = new MarketNamedApplyBLL(CurrentUserInfo);
            EmptyResponseData   emptyRD            = new EmptyResponseData();

            MarketNamedApplyEntity[] marketNameApplyEntityArray = marketNameApplyBll.QueryByEntity(new MarketNamedApplyEntity()
            {
                Status = 20, CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null);
            if (marketNameApplyEntityArray.Length > 0)
            {
                for (int i = 0; i < marketNameApplyEntityArray.Length; i++)
                {
                    string url = this.GeneratedQR(marketNameApplyEntityArray[i].VipId, marketNameApplyEntityArray[0].MarketEventID);
                    marketNameApplyEntityArray[i].QRCodeUrl = url;
                    marketNameApplyBll.Update(marketNameApplyEntityArray[i]);
                }
                this.ExportExcel(pContext, CurrentUserInfo.CurrentUser.customer_id);
            }

            //pContext.Response.Write(content);
        }
        public void ExportExcel(HttpContext pContext, string CustomerID)
        {
            MarketNamedApplyBLL marketNamedApplyBll = new MarketNamedApplyBLL(CurrentUserInfo);
            VipBLL vip = new VipBLL(CurrentUserInfo);

            DataSet dsVip = marketNamedApplyBll.GetVipByMarketNamedApply(CustomerID);

            if (dsVip.Tables.Count > 0)
            {
                string MapUrl            = pContext.Server.MapPath(@"~/Framework/Upload/" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.ms") + ".xls");
                Aspose.Cells.License lic = new Aspose.Cells.License();
                lic.SetLicense("Aspose.Total.lic");
                Workbook  workbook = new Workbook();
                Worksheet sheet    = workbook.Worksheets[0];
                Cells     cells    = sheet.Cells;                      //单元格

                Style style1 = workbook.Styles[workbook.Styles.Add()]; //新增样式
                style1.HorizontalAlignment = TextAlignmentType.Center; //文字居中
                style1.Font.Name           = "宋体";                     //文字字体
                style1.Font.Size           = 14;                       //文字大小
                style1.Font.IsBold         = true;                     //粗体
                style1.IsTextWrapped       = true;                     //单元格内容自动换行
                style1.Borders[BorderType.LeftBorder].LineStyle   = CellBorderType.Thin;
                style1.Borders[BorderType.RightBorder].LineStyle  = CellBorderType.Thin;
                style1.Borders[BorderType.TopBorder].LineStyle    = CellBorderType.Thin;
                style1.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;

                Style style2 = workbook.Styles[workbook.Styles.Add()]; //新增样式
                style2.HorizontalAlignment = TextAlignmentType.Center; //文字居中
                style2.Font.Name           = "宋体";                     //文字字体
                style2.Font.Size           = 12;                       //文字大小
                style2.Borders[BorderType.LeftBorder].LineStyle   = CellBorderType.Thin;
                style2.Borders[BorderType.RightBorder].LineStyle  = CellBorderType.Thin;
                style2.Borders[BorderType.TopBorder].LineStyle    = CellBorderType.Thin;
                style2.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;

                //设置宽度
                cells.SetColumnWidth(1, 30);
                cells.SetColumnWidth(2, 30);
                cells.SetColumnWidth(3, 90);

                cells[0, 0].PutValue("会员姓名");
                cells[0, 0].SetStyle(style1);

                cells[0, 1].PutValue("会员电话");
                cells[0, 1].SetStyle(style1);

                cells[0, 2].PutValue("二维码路径");
                cells[0, 2].SetStyle(style1);


                cells.SetRowHeight(0, 30);
                cells.SetColumnWidth(0, 30);
                cells.SetRowHeight(1, 20);
                cells.SetColumnWidth(2, 90);

                #region 生成数据行

                for (int i = 0; i < dsVip.Tables[0].Rows.Count; i++)
                {
                    cells[i + 1, 0].PutValue(dsVip.Tables[0].Rows[i]["VipName"].ToString());
                    cells[i + 1, 0].SetStyle(style2);

                    cells[i + 1, 1].PutValue(dsVip.Tables[0].Rows[i]["Phone"].ToString());
                    cells[i + 1, 1].SetStyle(style2);

                    cells[i + 1, 2].PutValue(dsVip.Tables[0].Rows[i]["QRCodeUrl"].ToString());
                    cells[i + 1, 3].SetStyle(style2);
                }
                #endregion

                workbook.Save(MapUrl);

                Utils.OutputExcel(pContext, MapUrl);//输出Excel文件
            }
            else
            {
                throw new APIException("没有人报名");
            }
        }