コード例 #1
0
        /// <summary>
        /// 将模式对象的修改提交到数据库
        /// </summary>
        /// <param name="obj">对其进行更新的<typeparamref name="T"/>对象。</param>
        public void Update(T obj)
        {
            obj.NullCheck("obj");

            this.MergeExistsObjectInfo(obj);

            SchemaObjectUpdateActionCollection actions = GetActions("Update");

            actions.Prepare(obj);

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                obj.Properties.Write();

                string sql = VersionSchemaObjectUpdateSqlBuilder.Instance.ToUpdateSql(obj, this.GetMappingInfo());

                DateTime dt = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

                SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);

                actions.Persist(obj);

                scope.Complete();
            }
        }
コード例 #2
0
		public SchemaObjectUpdateActionCollection GetActions(string operation)
		{
			SchemaObjectUpdateActionCollection actions = new SchemaObjectUpdateActionCollection();

			foreach (SchemaObjectUpdateActionConfigurationElement actionElem in this.Actions)
			{
				try
				{
					if (actionElem.Operation == operation)
						actions.Add((ISchemaObjectUpdateAction)actionElem.CreateInstance());
				}
				catch (Exception ex)
				{
					WriteToLog(ex);
				}
			}

			return actions;
		}
コード例 #3
0
        /// <summary>
        /// 更新模式对象的状态到数据库
        /// </summary>
        /// <param name="obj">对其进行更新的<typeparamref name="T"/>对象。</param>
        /// <param name="status">表示状态的<see cref="SchemaObjectStatus"/>值之一。</param>
        public void UpdateStatus(T obj, SchemaObjectStatus status)
        {
            obj.Status = status;

            string sql = VersionSchemaObjectUpdateStatusSqlBuilder.Instance.ToUpdateSql(obj, this.GetMappingInfo());

            SchemaObjectUpdateActionCollection actions = GetActions("UpdateStatus");

            actions.Prepare(obj);

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DateTime dt = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

                SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);

                actions.Persist(obj);

                scope.Complete();
            }
        }
コード例 #4
0
        public SchemaObjectUpdateActionCollection GetActions(string operation)
        {
            SchemaObjectUpdateActionCollection actions = new SchemaObjectUpdateActionCollection();

            foreach (SchemaObjectUpdateActionConfigurationElement actionElem in this.Actions)
            {
                try
                {
                    if (actionElem.Operation == operation)
                    {
                        actions.Add((ISchemaObjectUpdateAction)actionElem.CreateInstance());
                    }
                }
                catch (Exception ex)
                {
                    WriteToLog(ex);
                }
            }

            return(actions);
        }