Пример #1
0
        public override MaxSerial CreateSerial(int ownerUserId, DateTime expriseDate, SerialType type, string data,out bool success)
        {
            using (SqlQuery query = new SqlQuery())
            {
                Guid serial = Guid.NewGuid();

                DateTime createDate = DateTimeUtil.Now;

                query.CommandText = "bx_CreateSerial";
                query.CommandType = System.Data.CommandType.StoredProcedure;
                query.CreateParameter<int>("@UserID", ownerUserId, SqlDbType.Int);
                query.CreateParameter<DateTime>("@ExpiresDate", expriseDate, SqlDbType.DateTime);
                query.CreateParameter<byte>("@Type", (byte)type, SqlDbType.TinyInt);
                query.CreateParameter<string>("@Data", data, SqlDbType.NVarChar, 1000);

                SqlParameter outputParam = query.CreateParameter<bool>("@Success", SqlDbType.Bit, ParameterDirection.Output);

                MaxSerial newSerial = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Next)
                    {
                        newSerial = new MaxSerial(reader);
                    }
                }

                success = (bool)outputParam.Value;
                return newSerial;
            }
        }
Пример #2
0
        public override MaxSerial GetSerial(Guid serial, SerialType serialType)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandType = System.Data.CommandType.StoredProcedure;
                query.CommandText = "bx_GetSerial";
                query.CreateParameter<Guid>("@Serial", serial, System.Data.SqlDbType.UniqueIdentifier);
                query.CreateParameter<byte>("@Type", (byte)serialType, System.Data.SqlDbType.TinyInt);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    MaxSerial resault = null;
                    while (reader.Next)
                    {
                        resault = new MaxSerial(reader);
                    }
                    return resault;
                }
            }
        }