예제 #1
0
        /// <summary>
        /// 获取与指定对象关联的条件历史
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <param name="type">类型,如果为<see langword="null"/>则不限。</param>
        /// <returns></returns>
        public IEnumerable <SCCondition> GetConditionHistoryEntries(string id, string type)
        {
            SCConditionCollection entries = new SCConditionCollection();

            using (var context = DbHelper.GetDBContext(this.GetConnectionName()))
            {
                Database db = DatabaseFactory.Create(context);

                WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();
                builder.AppendItem("OwnerID", id);

                if (type != null)
                {
                    builder.AppendItem("Type", type);
                }

                var sql = @"SELECT *  FROM [SC].[Conditions] WHERE " + builder.ToSqlString(TSqlBuilder.Instance) + " ORDER BY [VersionEndTime] DESC, SortID ASC";
                var cmd = db.GetSqlStringCommand(sql);
                using (var dr = db.ExecuteReader(cmd))
                {
                    ORMapping.DataReaderToCollection(entries, dr);
                }

                return(entries);
            }
        }
예제 #2
0
        public void DuplicateUpdateConditionTest()
        {
            string ownerID = UuidHelper.NewUuidString();

            SCConditionCollection conditions = new SCConditionCollection();

            conditions.Add(new SCCondition()
            {
                OwnerID = ownerID, SortID = 0, Condition = "Users.Status == 1"
            });
            conditions.Add(new SCCondition()
            {
                OwnerID = ownerID, SortID = 1, Condition = "Users.Status == 3"
            });

            DBTimePointActionContext.Current.DoActions(() => SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions));

            SCConditionOwner originalOwner = SCConditionAdapter.Instance.Load(ownerID);

            conditions.RemoveAt(1);
            conditions[0].Condition = "Users.Status == 2";

            DBTimePointActionContext.Current.DoActions(() => SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions));

            SCConditionOwner oldOwner = SCConditionAdapter.Instance.Load(ownerID, string.Empty, originalOwner.Conditions[0].VersionStartTime);

            Assert.AreEqual(2, oldOwner.Conditions.Count);
            Assert.AreEqual(originalOwner.Conditions[0].Condition, oldOwner.Conditions[0].Condition);

            SCConditionOwner newOwner = SCConditionAdapter.Instance.Load(ownerID);

            Assert.AreEqual(1, newOwner.Conditions.Count);
            Assert.AreEqual(conditions[0].Condition, newOwner.Conditions[0].Condition);
        }
예제 #3
0
		/// <summary>
		/// 获取与指定对象关联的条件历史
		/// </summary>
		/// <param name="id">对象ID</param>
		/// <param name="type">类型,如果为<see langword="null"/>则不限。</param>
		/// <returns></returns>
		public IEnumerable<SCCondition> GetConditionHistoryEntries(string id, string type)
		{
			SCConditionCollection entries = new SCConditionCollection();
			using (var context = DbHelper.GetDBContext(this.GetConnectionName()))
			{
				Database db = DatabaseFactory.Create(context);

				WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();
				builder.AppendItem("OwnerID", id);

				if (type != null)
				{
					builder.AppendItem("Type", type);
				}

				var sql = @"SELECT *  FROM [SC].[Conditions] WHERE " + builder.ToSqlString(TSqlBuilder.Instance) + " ORDER BY [VersionEndTime] DESC, SortID ASC";
				var cmd = db.GetSqlStringCommand(sql);
				using (var dr = db.ExecuteReader(cmd))
				{
					ORMapping.DataReaderToCollection(entries, dr);
				}

				return entries;
			}
		}
예제 #4
0
        public void UpdateConditionTest()
        {
            string ownerID = UuidHelper.NewUuidString();

            SCConditionCollection conditions = new SCConditionCollection();

            conditions.Add(new SCCondition()
            {
                OwnerID = ownerID, SortID = 0, Condition = "Users.Status == 1"
            });
            conditions.Add(new SCCondition()
            {
                OwnerID = ownerID, SortID = 1, Condition = "Users.Status == 3"
            });

            SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions);

            SCConditionOwner owner = SCConditionAdapter.Instance.Load(ownerID);

            Assert.AreEqual(ownerID, owner.OwnerID);
            Assert.AreEqual(conditions.Count, owner.Conditions.Count);

            for (int i = 0; i < owner.Conditions.Count; i++)
            {
                Assert.AreEqual(conditions[i].OwnerID, owner.Conditions[i].OwnerID);
                Assert.AreEqual(conditions[i].Condition, owner.Conditions[i].Condition);
            }
        }
예제 #5
0
        /// <summary>
        /// 计算一个Owner下的条件
        /// </summary>
        /// <param name="conditions"></param>
        /// <param name="description">辅助描述信息,用于错误信息或输出日志</param>
        /// <returns></returns>
        public SchemaObjectCollection Calculate(SCConditionCollection conditions, string description = "")
        {
            SchemaObjectCollection result = new SchemaObjectCollection();

            // 初始化基础数据,包括所有项目
            this.Context.EnsureInitialized();

            // 根据条件筛选结果
            this.Context.ExecutionWrapper(string.Format("计算{0}的条件", description),
                                          () => this.FilterItemsByConditions(conditions, result, description));

            return(result);
        }
        protected override object DoOperation(AUObjectOperationContext context)
        {
            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                SCConditionCollection collection = new SCConditionCollection();
                collection.Add(condition);
                AUConditionAdapter.Instance.UpdateConditions(this.scope.ID, "ADM", collection);

                scope.Complete();
            }

            return(this.scope);
        }
		protected override object DoOperation(AUObjectOperationContext context)
		{
			using (TransactionScope scope = TransactionScopeFactory.Create())
			{
				SCConditionCollection collection = new SCConditionCollection();
				collection.Add(condition);
				AUConditionAdapter.Instance.UpdateConditions(this.scope.ID, "ADM", collection);

				scope.Complete();
			}

			return this.scope;
		}
예제 #8
0
        public static ClientConditionItem[] ToClientObjectsArray(this SCConditionCollection pcObjects)
        {
            pcObjects.NullCheck("pcObjects");

            ClientConditionItem[] result = new ClientConditionItem[pcObjects.Count];

            int i = 0;

            foreach (SCCondition pcObj in pcObjects)
            {
                result[i++] = pcObj.ToClientObject();
            }

            return(result);
        }
예제 #9
0
        /// <summary>
        /// 根据ownerID和type加载ConditionOwner对象
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="type"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SCConditionCollection Load(string ownerID, string type, DateTime timePoint)
        {
            if (type.IsNullOrEmpty())
            {
                type = "Default";
            }

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("OwnerID", ownerID);
            builder.AppendItem("Type", type);

            SCConditionCollection conditions = this.Load(builder, timePoint);

            return(conditions);
        }
예제 #10
0
        /// <summary>
        /// 根据condition所提供的SQL查询条件查询
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SCConditionCollection Load(IConnectiveSqlClause condition, DateTime timePoint)
        {
            ConnectiveSqlClauseCollection timePointBuilder  = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);
            ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(condition, timePointBuilder);

            string sql = string.Format("SELECT * FROM {0} WHERE {1} ORDER BY SortID",
                                       this.GetMappingInfo().TableName,
                                       connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

            SCConditionCollection result = new SCConditionCollection();

            using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
            {
                using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
                {
                    ORMapping.DataReaderToCollection(result, reader);

                    return(result);
                }
            }
        }
예제 #11
0
        private string GetUpdateSql(string ownerID, string type, SCConditionCollection conditions)
        {
            if (type.IsNullOrEmpty())
            {
                type = "Default";
            }

            conditions.ForEach(c => { c.OwnerID = ownerID; c.Type = type; });

            return(VersionStrategyUpdateSqlHelper.ConstructUpdateSql(null, (strB, context) =>
            {
                ConnectiveSqlClauseCollection connectiveBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder();

                WhereSqlClauseBuilder keyBuilder = new WhereSqlClauseBuilder();

                keyBuilder.AppendItem("OwnerID", ownerID);
                keyBuilder.AppendItem("type", type);

                connectiveBuilder.Add(keyBuilder);

                strB.AppendFormat("UPDATE {0} SET VersionEndTime = {1} WHERE {2}",
                                  this.GetMappingInfo().TableName, "@currentTime", connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

                for (int i = 0; i < conditions.Count; i++)
                {
                    SCCondition condition = conditions[i];

                    condition.SortID = i;
                    strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

                    condition.VersionEndTime = ConnectionDefine.MaxVersionEndTime;
                    condition.Type = type;
                    InsertSqlClauseBuilder insertBuilder = ORMapping.GetInsertSqlClauseBuilder(condition, this.GetMappingInfo(), "VersionStartTime");

                    insertBuilder.AppendItem("VersionStartTime", "@currentTime", "=", true);

                    strB.AppendFormat("INSERT INTO {0}{1}", this.GetMappingInfo().TableName, insertBuilder.ToSqlString(TSqlBuilder.Instance));
                }
            }));
        }
예제 #12
0
        private void DoSave()
        {
            SCConditionCollection conditions = this.gridMain.InitialData as SCConditionCollection;

            if (conditions != null)
            {
                var owner = PC.Adapters.SCConditionAdapter.Instance.Load(this.GroupObject.ID, "Default") ?? new SCConditionOwner()
                {
                    OwnerID = this.GroupObject.ID, Type = "Default"
                };

                var ownerConditions = owner.Conditions;

                owner.OwnerID = this.GroupObject.ID;

                owner.Conditions.ReplaceItemsWith(conditions, this.GroupObject.ID, "Default");

                try
                {
                    Util.EnsureOperationSafe();
                    DbUtil.GetEffectiveObject(this.GroupObject);

                    PC.Executors.SCObjectOperations.InstanceWithPermissions.UpdateGroupConditions(owner);
                    this.msg.Text             = "条件已保存完成";
                    this.gridMain.InitialData = new Services.ConditionSvc().GetGroupConditions(this.GroupObject.ID);
                    this.gridMain.DataBind();

                    if (this.chkAutoCalc.Checked)
                    {
                        this.postScript.Text = Util.SurroundScriptBlock("Sys.Application.add_init(function(){ document.getElementById('btnRecalc').click();});");
                    }
                }
                catch (Exception ex)
                {
                    WebUtility.ShowClientError(ex.GetRealException());
                    this.notice.AddErrorInfo(ex);
                    this.msg.Text = "操作遇到错误,可能没有成功保存条件";
                }
            }
        }
예제 #13
0
        private void FilterItemsByConditions(SCConditionCollection conditions, SchemaObjectCollection result, string description)
        {
            ProcessProgress.Current.MaxStep += conditions.Count;
            ProcessProgress.Current.Response();

            foreach (SCCondition condition in conditions)
            {
                if (condition.Condition.IsNotEmpty() && condition.Status == SchemaObjectStatus.Normal)
                {
                    try
                    {
                        foreach (SchemaObjectBase obj in this.Context.AllObjects)
                        {
                            this.Context.CurrentObject = obj;

                            try
                            {
                                //计算表达式
                                if ((bool)ExpressionParser.Calculate(condition.Condition, new CalculateUserFunction(CalculateObjectFunction), this.Context))
                                {
                                    result.AddNotExistsItem(obj);
                                }
                            }
                            finally
                            {
                                this.Context.CurrentObject = null;
                            }
                        }
                    }
                    catch (ParsingException ex)
                    {
                        ProcessProgress.Current.Error.WriteLine("解析{0}的条件{1}出错: {2}", description, condition.Condition, ex.Message);
                    }
                }
            }

            ProcessProgress.Current.Increment();
            ProcessProgress.Current.Response();
        }
예제 #14
0
		public void UpdateConditionTest()
		{
			string ownerID = UuidHelper.NewUuidString();

			SCConditionCollection conditions = new SCConditionCollection();

			conditions.Add(new SCCondition() { OwnerID = ownerID, SortID = 0, Condition = "Users.Status == 1" });
			conditions.Add(new SCCondition() { OwnerID = ownerID, SortID = 1, Condition = "Users.Status == 3" });

			SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions);

			SCConditionOwner owner = SCConditionAdapter.Instance.Load(ownerID);

			Assert.AreEqual(ownerID, owner.OwnerID);
			Assert.AreEqual(conditions.Count, owner.Conditions.Count);

			for (int i = 0; i < owner.Conditions.Count; i++)
			{
				Assert.AreEqual(conditions[i].OwnerID, owner.Conditions[i].OwnerID);
				Assert.AreEqual(conditions[i].Condition, owner.Conditions[i].Condition);
			}
		}
예제 #15
0
        /// <summary>
        /// 修改条件
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="type"></param>
        /// <param name="conditions"></param>
        public void UpdateConditions(string ownerID, string type, SCConditionCollection conditions)
        {
            ownerID.CheckStringIsNullOrEmpty("ownerID");

            ORMappingItemCollection mappings = this.GetMappingInfo();

            string sql = this.GetUpdateSql(ownerID, type, conditions);

            AUCommon.DoDbAction(() =>
            {
                using (TransactionScope scope = TransactionScopeFactory.Create())
                {
                    DBTimePointActionContext.Current.TimePoint = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

                    WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

                    builder.AppendItem("OwnerID", ownerID);
                    builder.AppendItem("Type", type);

                    scope.Complete();
                }
            });
        }
예제 #16
0
        /// <summary>
        /// 修改条件
        /// </summary>
        /// <param name="ownerID"></param>
        /// <param name="type"></param>
        /// <param name="conditions"></param>
        public void UpdateConditions(string ownerID, string type, SCConditionCollection conditions)
        {
            ownerID.CheckStringIsNullOrEmpty("ownerID");

            ORMappingItemCollection mappings = this.GetMappingInfo();

            string sql = this.GetUpdateSql(ownerID, type, conditions);

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

                SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);
                //WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

                //builder.AppendItem("OwnerID", ownerID);
                //builder.AppendItem("Type", type);

                //SCSnapshotBasicAdapter.Instance.UpdateCurrentSnapshot(mappings.TableName, mappings.TableName + "_Current", builder);

                scope.Complete();
            }
        }
예제 #17
0
		/// <summary>
		/// 根据condition所提供的SQL查询条件查询
		/// </summary>
		/// <param name="condition"></param>
		/// <param name="timePoint"></param>
		/// <returns></returns>
		public SCConditionCollection Load(IConnectiveSqlClause condition, DateTime timePoint)
		{
			ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);
			ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(condition, timePointBuilder);

			string sql = string.Format("SELECT * FROM {0} WHERE {1} ORDER BY SortID",
				this.GetMappingInfo().TableName,
				connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

			SCConditionCollection result = new SCConditionCollection();

			AUCommon.DoDbAction(() =>
			{
				using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
				{
					using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
					{
						ORMapping.DataReaderToCollection(result, reader);
					}
				}
			});

			return result;
		}
예제 #18
0
        protected void SaveClick(object sender, EventArgs e)
        {
            try
            {
                var conditions = AU.Adapters.AUConditionAdapter.Instance.Load(this.CurrentScope.ID, AU.AUCommon.ConditionType);
                SCConditionCollection newCondition = new SCConditionCollection();
                newCondition.Add(new SCCondition(this.expression.Text)
                {
                    Description = this.txtDesc.Text, Type = AU.AUCommon.ConditionType
                });
                conditions.ReplaceItemsWith(newCondition, this.CurrentScope.ID, AU.AUCommon.ConditionType);
                AU.Adapters.AUConditionAdapter.Instance.UpdateConditions(this.CurrentScope.ID, AU.AUCommon.ConditionType, conditions);
                this.prompt.InnerText = "保存成功";

                if (this.chkAutoCalc.Checked)
                {
                    this.postScript.Text = Util.SurroundScriptBlock("Sys.Application.add_init(function(){ document.getElementById('btnRecalc').click();});");
                }
            }
            catch (Exception ex)
            {
                WebUtility.ShowClientError(ex);
            }
        }
		/// <summary>
		/// 计算一个Owner下的条件
		/// </summary>
		/// <param name="conditions"></param>
		/// <param name="description">辅助描述信息,用于错误信息或输出日志</param>
		/// <returns></returns>
		public SchemaObjectCollection Calculate(SCConditionCollection conditions, string description = "")
		{
			SchemaObjectCollection result = new SchemaObjectCollection();

			// 初始化基础数据,包括所有项目
			this.Context.EnsureInitialized();

			// 根据条件筛选结果
			this.Context.ExecutionWrapper(string.Format("计算{0}的条件", description),
				() => this.FilterItemsByConditions(conditions, result, description));

			return result;
		}
예제 #20
0
		private string GetUpdateSql(string ownerID, string type, SCConditionCollection conditions)
		{
			if (type.IsNullOrEmpty())
				type = "Default";

			conditions.ForEach(c => { c.OwnerID = ownerID; c.Type = type; });

			return VersionStrategyUpdateSqlHelper.ConstructUpdateSql(null, (strB, context) =>
			{
				ConnectiveSqlClauseCollection connectiveBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder();

				WhereSqlClauseBuilder keyBuilder = new WhereSqlClauseBuilder();

				keyBuilder.AppendItem("OwnerID", ownerID);
				keyBuilder.AppendItem("type", type);

				connectiveBuilder.Add(keyBuilder);

				strB.AppendFormat("UPDATE {0} SET VersionEndTime = {1} WHERE {2}",
					this.GetMappingInfo().TableName, "@currentTime", connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

				for (int i = 0; i < conditions.Count; i++)
				{
					SCCondition condition = conditions[i];

					condition.SortID = i;
					strB.Append(TSqlBuilder.Instance.DBStatementSeperator);

					condition.VersionEndTime = ConnectionDefine.MaxVersionEndTime;
					condition.Type = type;
					InsertSqlClauseBuilder insertBuilder = ORMapping.GetInsertSqlClauseBuilder(condition, this.GetMappingInfo(), "VersionStartTime");

					insertBuilder.AppendItem("VersionStartTime", "@currentTime", "=", true);

					strB.AppendFormat("INSERT INTO {0}{1}", this.GetMappingInfo().TableName, insertBuilder.ToSqlString(TSqlBuilder.Instance));
				}
			});
		}
예제 #21
0
		/// <summary>
		/// 修改条件
		/// </summary>
		/// <param name="ownerID"></param>
		/// <param name="type"></param>
		/// <param name="conditions"></param>
		public void UpdateConditions(string ownerID, string type, SCConditionCollection conditions)
		{
			ownerID.CheckStringIsNullOrEmpty("ownerID");

			ORMappingItemCollection mappings = this.GetMappingInfo();

			string sql = this.GetUpdateSql(ownerID, type, conditions);

			AUCommon.DoDbAction(() =>
			{
				using (TransactionScope scope = TransactionScopeFactory.Create())
				{
					DBTimePointActionContext.Current.TimePoint = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

					WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

					builder.AppendItem("OwnerID", ownerID);
					builder.AppendItem("Type", type);

					scope.Complete();
				}
			});
		}
예제 #22
0
		public void DuplicateUpdateConditionTest()
		{
			string ownerID = UuidHelper.NewUuidString();

			SCConditionCollection conditions = new SCConditionCollection();

			conditions.Add(new SCCondition() { OwnerID = ownerID, SortID = 0, Condition = "Users.Status == 1" });
			conditions.Add(new SCCondition() { OwnerID = ownerID, SortID = 1, Condition = "Users.Status == 3" });

			DBTimePointActionContext.Current.DoActions(() => SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions));

			SCConditionOwner originalOwner = SCConditionAdapter.Instance.Load(ownerID);

			conditions.RemoveAt(1);
			conditions[0].Condition = "Users.Status == 2";

			DBTimePointActionContext.Current.DoActions(() => SCConditionAdapter.Instance.UpdateConditions(ownerID, "Default", conditions));

			SCConditionOwner oldOwner = SCConditionAdapter.Instance.Load(ownerID, string.Empty, originalOwner.Conditions[0].VersionStartTime);

			Assert.AreEqual(2, oldOwner.Conditions.Count);
			Assert.AreEqual(originalOwner.Conditions[0].Condition, oldOwner.Conditions[0].Condition);

			SCConditionOwner newOwner = SCConditionAdapter.Instance.Load(ownerID);

			Assert.AreEqual(1, newOwner.Conditions.Count);
			Assert.AreEqual(conditions[0].Condition, newOwner.Conditions[0].Condition);
		}
		private void FilterUsersByConditions(SCConditionCollection conditions, SchemaObjectCollection result, string description)
		{
			ProcessProgress.Current.MaxStep += conditions.Count;
			ProcessProgress.Current.Response();

			foreach (SCCondition condition in conditions)
			{
				if (condition.Condition.IsNotEmpty() && condition.Status == SchemaObjectStatus.Normal)
				{
					try
					{
						foreach (SCUser user in this.Context.AllObjects)
						{
							this.Context.CurrentObject = user;

							try
							{
								//计算表达式
								object booleanResult = ExpressionParser.Calculate(condition.Condition, new CalculateUserFunction(CalculateUserFunction), this.Context);
								if ((booleanResult is bool) == false)
									throw new FormatException("指定的表达式未能解析为Bool值:" + Environment.NewLine + condition.Condition);

								if ((bool)booleanResult)
								{
									result.AddNotExistsItem(user);
								}
							}
							finally
							{
								this.Context.CurrentObject = null;
							}
						}
					}
					catch (ParsingException ex)
					{
						ProcessProgress.Current.Error.WriteLine("解析{0}的条件{1}出错: {2}", description, condition.Condition, ex.Message);
					}
				}
			}

			ProcessProgress.Current.Increment();
			ProcessProgress.Current.Response();
		}
		private void FilterItemsByConditions(SCConditionCollection conditions, SchemaObjectCollection result, string description)
		{
			ProcessProgress.Current.MaxStep += conditions.Count;
			ProcessProgress.Current.Response();

			foreach (SCCondition condition in conditions)
			{
				if (condition.Condition.IsNotEmpty() && condition.Status == SchemaObjectStatus.Normal)
				{
					try
					{
						foreach (SchemaObjectBase obj in this.Context.AllObjects)
						{
							this.Context.CurrentObject = obj;

							try
							{
								//计算表达式
								if ((bool)ExpressionParser.Calculate(condition.Condition, new CalculateUserFunction(CalculateObjectFunction), this.Context))
								{
									result.AddNotExistsItem(obj);
								}
							}
							finally
							{
								this.Context.CurrentObject = null;
							}
						}
					}
					catch (ParsingException ex)
					{
						ProcessProgress.Current.Error.WriteLine("解析{0}的条件{1}出错: {2}", description, condition.Condition, ex.Message);
					}
				}
			}

			ProcessProgress.Current.Increment();
			ProcessProgress.Current.Response();
		}
		protected void SaveClick(object sender, EventArgs e)
		{
			try
			{
				var conditions = AU.Adapters.AUConditionAdapter.Instance.Load(this.CurrentScope.ID, AU.AUCommon.ConditionType);
				SCConditionCollection newCondition = new SCConditionCollection();
				newCondition.Add(new SCCondition(this.expression.Text) { Description = this.txtDesc.Text, Type = AU.AUCommon.ConditionType });
				conditions.ReplaceItemsWith(newCondition, this.CurrentScope.ID, AU.AUCommon.ConditionType);
				AU.Adapters.AUConditionAdapter.Instance.UpdateConditions(this.CurrentScope.ID, AU.AUCommon.ConditionType, conditions);
				this.prompt.InnerText = "保存成功";

				if (this.chkAutoCalc.Checked)
				{
					this.postScript.Text = Util.SurroundScriptBlock("Sys.Application.add_init(function(){ document.getElementById('btnRecalc').click();});");
				}
			}
			catch (Exception ex)
			{
				WebUtility.ShowClientError(ex);
			}
		}