Ejemplo n.º 1
0
        private static SameContainerUserAndContainerSnapshotCollection GetUpdateData(string containerID, string containerSchemaType, SameContainerUserAndContainerSnapshotCollection existedData, SchemaObjectCollection users)
        {
            SameContainerUserAndContainerSnapshotCollection updatedInfo = new SameContainerUserAndContainerSnapshotCollection();

            foreach (UserAndContainerSnapshot uacs in existedData)
            {
                if (users.ContainsKey(uacs.UserID))
                {
                    //原来是已删除的,现在改为Normal
                    if (uacs.Status != SchemaObjectStatus.Normal)
                    {
                        uacs.Status = SchemaObjectStatus.Normal;
                        updatedInfo.Add(uacs);
                    }
                }
                else
                {
                    //现在不存在了,状态需要改为已删除
                    uacs.Status = SchemaObjectStatus.Deleted;
                    updatedInfo.Add(uacs);
                }
            }

            return(updatedInfo);
        }
Ejemplo n.º 2
0
        private static SameContainerUserAndContainerSnapshotCollection GetInsertData(string containerID, string containerSchemaType, SameContainerUserAndContainerSnapshotCollection existedData, SchemaObjectCollection users)
        {
            SameContainerUserAndContainerSnapshotCollection newInfo = new SameContainerUserAndContainerSnapshotCollection();

            foreach (SchemaObjectBase user in users)
            {
                if (existedData.ContainsKey(user.ID) == false && newInfo.ContainsKey(user.ID) == false)
                {
                    UserAndContainerSnapshot uacs = new UserAndContainerSnapshot();

                    uacs.ContainerID         = containerID;
                    uacs.ContainerSchemaType = containerSchemaType;
                    uacs.UserID         = user.ID;
                    uacs.UserSchemaType = "Users";
                    uacs.Status         = SchemaObjectStatus.Normal;

                    newInfo.Add(uacs);
                }
            }

            return(newInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据Container来加载UserAndContainerSnapshot的信息
        /// </summary>
        /// <param name="containerID"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SameContainerUserAndContainerSnapshotCollection LoadByContainerID(string containerID, DateTime timePoint)
        {
            containerID.CheckStringIsNullOrEmpty("containerID");

            ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder();

            whereBuilder.AppendItem("ContainerID", containerID);

            ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(whereBuilder, timePointBuilder);

            string sql = string.Format("SELECT * FROM {0} WHERE {1}",
                                       this.GetLoadingTableName(timePoint), connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

            SameContainerUserAndContainerSnapshotCollection result = new SameContainerUserAndContainerSnapshotCollection();

            using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
            {
                using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
                {
                    while (reader.Read())
                    {
                        UserAndContainerSnapshot item = new UserAndContainerSnapshot();

                        ORMapping.DataReaderToObject(reader, item);

                        if (result.ContainsKey(item.UserID) == false)
                        {
                            result.Add(item);
                        }
                    }
                }
            }

            return(result);
        }
		private static SameContainerUserAndContainerSnapshotCollection GetUpdateData(string containerID, string containerSchemaType, SameContainerUserAndContainerSnapshotCollection existedData, SchemaObjectCollection users)
		{
			SameContainerUserAndContainerSnapshotCollection updatedInfo = new SameContainerUserAndContainerSnapshotCollection();

			foreach (UserAndContainerSnapshot uacs in existedData)
			{
				if (users.ContainsKey(uacs.UserID))
				{
					//原来是已删除的,现在改为Normal
					if (uacs.Status != SchemaObjectStatus.Normal)
					{
						uacs.Status = SchemaObjectStatus.Normal;
						updatedInfo.Add(uacs);
					}
				}
				else
				{
					//现在不存在了,状态需要改为已删除
					uacs.Status = SchemaObjectStatus.Deleted;
					updatedInfo.Add(uacs);
				}
			}

			return updatedInfo;
		}
		private static SameContainerUserAndContainerSnapshotCollection GetInsertData(string containerID, string containerSchemaType, SameContainerUserAndContainerSnapshotCollection existedData, SchemaObjectCollection users)
		{
			SameContainerUserAndContainerSnapshotCollection newInfo = new SameContainerUserAndContainerSnapshotCollection();

			foreach (SchemaObjectBase user in users)
			{
				if (existedData.ContainsKey(user.ID) == false && newInfo.ContainsKey(user.ID) == false)
				{
					UserAndContainerSnapshot uacs = new UserAndContainerSnapshot();

					uacs.ContainerID = containerID;
					uacs.ContainerSchemaType = containerSchemaType;
					uacs.UserID = user.ID;
					uacs.UserSchemaType = "Users";
					uacs.Status = SchemaObjectStatus.Normal;

					newInfo.Add(uacs);
				}
			}

			return newInfo;
		}
		/// <summary>
		/// 根据Container来加载UserAndContainerSnapshot的信息
		/// </summary>
		/// <param name="containerID"></param>
		/// <param name="timePoint"></param>
		/// <returns></returns>
		public SameContainerUserAndContainerSnapshotCollection LoadByContainerID(string containerID, DateTime timePoint)
		{
			containerID.CheckStringIsNullOrEmpty("containerID");

			ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

			WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder();

			whereBuilder.AppendItem("ContainerID", containerID);

			ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(whereBuilder, timePointBuilder);

			string sql = string.Format("SELECT * FROM {0} WHERE {1}",
				this.GetLoadingTableName(timePoint), connectiveBuilder.ToSqlString(TSqlBuilder.Instance));

			SameContainerUserAndContainerSnapshotCollection result = new SameContainerUserAndContainerSnapshotCollection();

			using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
			{
				using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
				{
					while (reader.Read())
					{
						UserAndContainerSnapshot item = new UserAndContainerSnapshot();

						ORMapping.DataReaderToObject(reader, item);

						if (result.ContainsKey(item.UserID) == false)
							result.Add(item);
					}
				}
			}

			return result;
		}