Example #1
0
        public AUSchemaCategory LoadByID(string id, DateTime timePoint)
        {
            var conditions = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
            where.AppendItem("ID", id);
            conditions.Add(where);
            AUSchemaCategory cate = null;

            AUCommon.DoDbAction(() =>
            {
                using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
                {
                    VersionedObjectAdapterHelper.Instance.FillData(ORMapping.GetMappingInfo(typeof(AUSchemaCategory)).TableName, conditions, this.GetConnectionName(),
                                                                   reader =>
                    {
                        if (reader.Read())
                        {
                            cate = new AUSchemaCategory();
                            ORMapping.DataReaderToObject <AUSchemaCategory>(reader, cate);
                        }
                    });
                }
            });

            return(cate);
        }
        protected override void DoValidate(object objectToValidate, object currentObject, string key, ValidationResults validateResults)
        {
            AUSchemaCategory cate = SchemaCategoryAdapter.Instance.LoadByID((string)objectToValidate);

            if (cate == null || cate.Status != SchemaObjectStatus.Normal)
            {
                this.RecordValidationResult(validateResults, string.Format("指定的类别ID \"{0}\"无效。", objectToValidate), currentObject, key);
            }
        }
Example #3
0
 public static ClientAUSchemaCategory ToClientCategory(this AUSchemaCategory category)
 {
     return(category != null ? new ClientAUSchemaCategory
     {
         ID = category.ID,
         Name = category.Name,
         FullPath = category.FullPath,
         ParentID = category.ParentID,
         Rank = category.Rank,
         Status = (ClientSchemaObjectStatus)category.Status,
         VersionEndTime = category.VersionEndTime,
         VersionStartTime = category.VersionStartTime
     } : null);
 }
Example #4
0
        public void UpdateCategory(AUSchemaCategory category)
        {
            if (category == null)
            {
                throw new ArgumentNullException("category");
            }

            string sql = UpdateBuilder.Instance.ToUpdateSql(category, this.GetMappingInfo());

            AUCommon.DoDbAction(() =>
            {
                using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
                {
                    DateTime point            = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());
                    category.VersionStartTime = point;
                }
            });
        }