Beispiel #1
0
        public int Click(DailyClickInfo oClick)
        {
            string sql = @"
                    if exists( select top 1 * from product_dailyclick where productsysno=@productsysno and clickdate=@clickdate)
                        update product_dailyclick set clickcount = clickcount + @clickcount where productsysno=@productsysno and clickdate=@clickdate
                    else
                        insert into product_dailyclick(productsysno, clickdate, clickcount) values(@productsysno, @clickdate, @clickcount)";
            sql = sql.Replace("@productsysno", oClick.ProductSysNo.ToString());
            sql = sql.Replace("@clickdate", Util.ToSqlString(oClick.ClickDate));
            sql = sql.Replace("@clickcount", oClick.ClickCount.ToString());

            SqlCommand cmd = new SqlCommand(sql);
            return SqlHelper.ExecuteNonQuery(cmd);
        }
Beispiel #2
0
        public void Click(int productSysNo)
        {
            //˵���μ�biz.online.dailyClickManager.Count()
            lock ( locker )
            {
                if ( !ht.Contains(productSysNo))
                {
                    //������������produtSysNo��������һ����
                    DailyClickInfo oClick = new DailyClickInfo();

                    oClick.ClickDate = DateTime.Now.ToString(AppConst.DateFormat);
                    oClick.ClickCount = 1;
                    oClick.ProductSysNo = productSysNo;
                    ht.Add(productSysNo, oClick);
                }
                else
                {
                    DailyClickInfo oClick = ht[productSysNo] as DailyClickInfo;
                    string nowTime = DateTime.Now.ToString(AppConst.DateFormat);

                    //���ht�е�productSysNo���ǽ���ļ�¼�����ȸ�������ļ�¼�������ݿ⡣�����������productSysNo����Ϊ1��
                    if ( oClick.ClickDate != nowTime )
                    {
                        new DailyClickDac().Click(oClick);
                        oClick.ClickCount = 1;
                        oClick.ClickDate = nowTime;
                    }
                    else
                    {
                        //����ǽ����,������һ
                        oClick.ClickCount++;
                        //�����ǰ��������500���͸��µ����ݿ⡣
                        if ( oClick.ClickCount >= 5)
                        {
                            new DailyClickDac().Click(oClick);
                            oClick.ClickCount = 0;
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public int Insert(DailyClickInfo oParam)
        {
            string sql = @"INSERT INTO Product_DailyClick
                            (
                            ProductSysNo, ClickDate, ClickCount
                            )
                            VALUES (
                            @ProductSysNo, @ClickDate, @ClickCount
                            );set @SysNo = SCOPE_IDENTITY();";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int,4);
            SqlParameter paramClickDate = new SqlParameter("@ClickDate", SqlDbType.NVarChar,10);
            SqlParameter paramClickCount = new SqlParameter("@ClickCount", SqlDbType.Int,4);

            paramSysNo.Direction = ParameterDirection.Output;

            if ( oParam.ProductSysNo != AppConst.IntNull)
                paramProductSysNo.Value = oParam.ProductSysNo;
            else
                paramProductSysNo.Value = System.DBNull.Value;
            if ( oParam.ClickDate != AppConst.StringNull)
                paramClickDate.Value = oParam.ClickDate;
            else
                paramClickDate.Value = System.DBNull.Value;
            if ( oParam.ClickCount != AppConst.IntNull)
                paramClickCount.Value = oParam.ClickCount;
            else
                paramClickCount.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramClickDate);
            cmd.Parameters.Add(paramClickCount);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Beispiel #4
0
        public void Import()
        {
            if ( !AppConfig.IsImportable)
                throw new BizException("Is Importable is false");

            /*  do not  use the following code after Data Pour in */
            string sql = " select top 1 * from product_dailyclick ";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if ( Util.HasMoreRow(ds) )
                throw new BizException("the table product_dailyclick is not empty");

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //����3�·�����������
                string sql1 = @"select
                                pdc.sysno, con_product.newsysno as productsysno, countdate as clickdate, countnum as clickcount
                            from
                                ipp2003..product_daily_count as pdc,
                                ippconvert..productbasic as con_product
                            where
                                pdc.productsysno = con_product.oldsysno
                            and convert(datetime, pdc.countdate, 120) >= convert(datetime, '2005-03-01', 120)";
                DataSet ds1 = SqlHelper.ExecuteDataSet(sql1);
                foreach(DataRow dr1 in ds1.Tables[0].Rows)
                {
                    DailyClickInfo oInfo = new DailyClickInfo();
                    map(oInfo,dr1);
                    oInfo.ClickDate = Util.TrimDateNull(oInfo.ClickDate).ToString(AppConst.DateFormat);
                    new DailyClickDac().Insert(oInfo);
                }

            scope.Complete();
            }
        }
Beispiel #5
0
 public void map(DailyClickInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]);
     oParam.ClickDate = Util.TrimNull(tempdr["ClickDate"]);
     oParam.ClickCount = Util.TrimIntNull(tempdr["ClickCount"]);
 }