Пример #1
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 subscribe ";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if ( Util.HasMoreRow(ds) )
                throw new BizException("the table subscribe 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))
            {

                string sql1 = @"select * from
                                (
                                select customername as username, email, registertime as createtime from ipp3..customer where emailstatus = 1
                                union all
                                select username, email, createtime from ipp2003..EmailSubscribe
                                ) as a
                                where a.username is not null
                                order by createtime";

                Hashtable ht = new Hashtable(20000);
                DataSet ds1 = SqlHelper.ExecuteDataSet(sql1);
                foreach(DataRow dr1 in ds1.Tables[0].Rows)
                {
                    if ( ht.ContainsKey(Util.TrimNull(dr1["email"])) )
                        continue;

                    SubscribeInfo  oInfo = new SubscribeInfo();
                    oInfo.Email = Util.TrimNull(dr1["email"]);
                    oInfo.UserName = Util.TrimNull(dr1["username"]);
                    oInfo.CreateTime = Util.TrimDateNull(dr1["createtime"]);

                    new SubscribeDac().Insert(oInfo);

                    ht.Add(oInfo.Email, null);
                }

            scope.Complete();
            }
        }
Пример #2
0
        public int Insert(SubscribeInfo oParam)
        {
            string sql = @"INSERT INTO subscribe
                            (
                            Email, UserName, CreateTime
                            )
                            VALUES (
                            @Email, @UserName, @CreateTime
                            );set @SysNo = SCOPE_IDENTITY();";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramEmail = new SqlParameter("@Email", SqlDbType.NVarChar,50);
            SqlParameter paramUserName = new SqlParameter("@UserName", SqlDbType.NVarChar,50);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);

            paramSysNo.Direction = ParameterDirection.Output;

            if ( oParam.Email != AppConst.StringNull)
                paramEmail.Value = oParam.Email;
            else
                paramEmail.Value = System.DBNull.Value;
            if ( oParam.UserName != AppConst.StringNull)
                paramUserName.Value = oParam.UserName;
            else
                paramUserName.Value = System.DBNull.Value;
            if ( oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramEmail);
            cmd.Parameters.Add(paramUserName);
            cmd.Parameters.Add(paramCreateTime);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Пример #3
0
        public void Insert(SubscribeInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

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

                if ( IsSubscribed(oParam.Email))
                    throw new BizException("�Ѿ�����");

                new SubscribeDac().Insert(oParam);

                scope.Complete();
            }
        }