Beispiel #1
0
        public void TestGiftCardPoolDA()
        {
            GiftCardPoolEntity entity = new GiftCardPoolEntity();

            GiftCardPoolDA.Insert(entity);
            Assert.AreNotEqual <int>(0, entity.SysNo);
            Debug.WriteLine(entity.SysNo.ToString());
            GiftCardPoolDA.Update(entity);
            GiftCardPoolDA.Delete(entity.SysNo);
        }
Beispiel #2
0
        private void ProcessEach(GCItemEntity gcItem)
        {
            DateTime beginDate    = DateTime.Now;
            string   barcodeParam = gcItem.BarPrefix + "%";
            int      activeCount  = GiftCardPoolDA.GetActiveCount(barcodeParam, gcItem.Amount);

            if (activeCount < ConstValues.AvailableCount)
            {
                //get identity, Initiate entity.SysNo
                if (entity.SysNo == 0)
                {
                    entity.IsStatusActive = false;
                    GiftCardPoolDA.Insert(entity);
                    GiftCardPoolDA.Delete(entity.SysNo);
                }
                //get barcode number
                string maxBarcode = GiftCardPoolDA.GetMaxBarcode(barcodeParam);
                long   barNumber  = long.Parse(maxBarcode.Substring(4));

                int i = activeCount;
                entity.IsStatusActive = true;
                entity.AmountType     = (int)gcItem.Amount;
                string msg = string.Empty;
                while (i < ConstValues.AvailableCount)
                {
                    ++entity.SysNo;
                    entity.Code    = GetGCCode(entity.SysNo);
                    entity.Barcode = string.Format("{0}{1}", gcItem.BarPrefix
                                                   , (++barNumber).ToString("0000000000"));
                    entity.Password = GetPassword();
                    GiftCardPoolDA.Insert(entity);
                    msg = string.Format("BarPrefix={0},AvailableCount={1},i={2}", gcItem.BarPrefix, ConstValues.AvailableCount, ++i);
                    WriteLog(msg);
                }
            }
            int logCount = ConstValues.AvailableCount - activeCount;

            if (logCount < 0)
            {
                logCount = 0;
            }
            string message = string.Format("{2} - 新增{0}条数据,花费{1}秒时间。", logCount.ToString(),
                                           (DateTime.Now - beginDate).TotalSeconds.ToString(),
                                           gcItem.BarPrefix);

            //LogHelper.WriteOverseaLog<GiftCardPoolEntity>(entity,
            //    string.Empty, string.Empty, "GiftCardPoolInterface",
            //    message, entity.SysNo.ToString());
            WriteLog(message);
        }
Beispiel #3
0
 public void Process()
 {
     try
     {
         WriteLog("开始循环礼品卡Item");
         List <GCItemEntity> gclist = GiftCardPoolDA.GetGCItemList();
         foreach (GCItemEntity item in gclist)
         {
             ProcessEach(item);
         }
     }
     catch (Exception er)
     {
         WriteLog("Exception:" + er.Message);
     }
 }
Beispiel #4
0
 public void TestSendMailInfo()
 {
     GiftCardPoolDA.SendMailInfo("testSubject", "testBody");
 }