public PromotionsBonusSerialMgr(string connectionString)
 {
     _bonusDao = new PromotionsBonusSerialDao(connectionString);
     _pbsd = new PromotionsBonusSerialDao(connectionString);
 }
        //public HttpResponseBase PromotionsBonusSerialHistoryLists()
        //{
        //    List<PromotionsBonusSerialHistoryQuery> stores = new List<PromotionsBonusSerialHistoryQuery>();
        //    _promBnusSeralHitory = new PromotionsBonusSerialHistoryMgr(mySqlConnectionString);
        //    PromotionsBonusSerialHistoryQuery query = new PromotionsBonusSerialHistoryQuery();
        //    string json = string.Empty;
        //    try
        //    {
        //        int id = Convert.ToInt32(Request.Params["ids"]);
        //        stores = _promBnusSeralHitory.QueryById(id);

        //        foreach (var item in stores)
        //        {
        //            item.user_email = item.user_email.Split('@')[0] + "@***";
        //        }

        //        IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
        //        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
        //        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        //        json = "{success:true,items:" + JsonConvert.SerializeObject(stores, timeConverter) + "}";//返回json數據
        //    }
        //    catch (Exception ex)
        //    {
        //        Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
        //        logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
        //        logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
        //        log.Error(logMessage);
        //        json = "{success:true,data:[]}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}

        #endregion
        #endregion

        #region 序號兌換-檢視序號-插入數據+HttpResponseBase InsertPromotionsBonusSerial()
        #region
        //public HttpResponseBase InsertPromotionsBonusSerial()
        //{
        //    string json = string.Empty;
        //    try
        //    {
        //        _pbsd = new PromotionsBonusSerialDao(mySqlConnectionString);
        //        _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);
        //        PromotionsBonusSerial pbs = new PromotionsBonusSerial();
        //        int couts = Convert.ToInt32(Request.Params["xhsl"]);
        //        int lenghts = Convert.ToInt32(Request.Params["xhcd"]);
        //        int id = Convert.ToInt32(Request.Params["ids"]);
        //        Random rd = new Random();
        //        for (int i = 0; i < couts; i++)
        //        {
        //            string serials = CommonFunction.Getserials(lenghts, rd);
        //            List<PromotionsBonusSerial> ls = new List<PromotionsBonusSerial>();
        //            ls = _pbsd.YesOrNoExist(serials);
        //            if (ls.Single().serial == serials)
        //            {
        //                continue;
        //            }
        //            else
        //            {
        //                int count = _promBnusSeral.Save(serials, id);
        //                if (count > 0)
        //                {
        //                    continue;
        //                }
        //            }
        //        }
        //        json = "{success:true}";//返回json數據
        //    }
        //    catch (Exception ex)
        //    {
        //        Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
        //        logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
        //        logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
        //        log.Error(logMessage);
        //        json = "{success:false}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        #endregion

        public HttpResponseBase InsertPromotionsBonusSerial2()
        {
            string json = string.Empty;
            try
            {
                //SuccessNum = 0;
                _pbsd = new PromotionsBonusSerialDao(mySqlConnectionString);
                _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);
                PromotionsBonusSerial pbs = new PromotionsBonusSerial();
                int couts = Convert.ToInt32(Request.Params["xhsl"]);
                int lenghts = Convert.ToInt32(Request.Params["xhcd"]);
                int id = Convert.ToInt32(Request.Params["ids"]);
                Random rd = new Random();
                StringBuilder sb = new StringBuilder();
                _promBnusSeral = new PromotionsBonusSerialMgr(mySqlConnectionString);  
                //FileStream fs = new FileStream("D:\\2.txt", FileMode.OpenOrCreate);
                //StreamWriter sw = new StreamWriter(fs);
                for (int i = 0; i < couts; i++)
                {
                    string serials = CommonFunction.Getserials(lenghts, rd);
                    List<PromotionsBonusSerial> ls = new List<PromotionsBonusSerial>();
                    ls = _pbsd.YesOrNoExist(serials);
                    if (ls.Single().serial == serials)
                    {
                        continue;
                    }
                    else
                    {
                     //   SuccessNum=i+1;
                        //////
                      
                        //开始写入
                      //  sw.Write(SuccessNum+",");
                        //清空缓冲区
                     
                        sb.AppendFormat(" insert into promotions_bonus_serial(serial,active,promotion_id)values('{0}','{1}','{2}');", serials, 1, id);
                        if (sb.ToString().Length > 1000)
                        {
                            _promBnusSeral.AddPromoBonusSerial(sb);
                            sb.Clear();
                        }
                    }
                    
                }
                if (sb.ToString().Length > 0)
                {
                    _promBnusSeral.AddPromoBonusSerial(sb);
                    //執行事務
                }  
                //sw.Flush();
                //        //关闭流
                //sw.Close();
                //fs.Close();
                json = "{success:true}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }