Пример #1
0
        /// <summary>
        /// 根据TaskGuid得到UserAccomplishedTask
        /// </summary>
        /// <param name="strTaskGuid"></param>
        /// <returns></returns>
        public UserTaskCollection GetUserAccomplishedTasks(params string[] strTaskGuid)
        {
            UserTaskCollection utc = new UserTaskCollection();

            if (strTaskGuid.Length > 0)
            {
                InSqlClauseBuilder builder = new InSqlClauseBuilder();
                builder.AppendItem(strTaskGuid);

                string strSql = "SELECT * FROM WF.USER_ACCOMPLISHED_TASK WHERE (TASK_GUID " + builder.ToSqlStringWithInOperator(TSqlBuilder.Instance) + ")";
                using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
                {
                    Database db = DatabaseFactory.Create(dbi);

                    using (IDataReader dr = db.ExecuteReader(CommandType.Text, strSql))
                    {
                        while (dr.Read())
                        {
                            UserTask ut = new UserTask();

                            ORMapping.DataReaderToObject(dr, ut);

                            utc.Add(ut);
                        }
                    }
                }
            }

            return(utc);
        }
Пример #2
0
        public UserTaskCollection LoadUserTasksByActivity(string activityID, Action <InSqlClauseBuilder> action)
        {
            action.NullCheck("action");

            InSqlClauseBuilder builder = new InSqlClauseBuilder();

            action(builder);

            string sql = string.Format("SELECT * FROM WF.USER_TASK WHERE ACTIVITY_ID = {0}",
                                       TSqlBuilder.Instance.CheckUnicodeQuotationMark(activityID));

            if (builder.Count > 0)
            {
                sql += " AND " + builder.ToSqlStringWithInOperator(TSqlBuilder.Instance);
            }

            UserTaskCollection result = new UserTaskCollection();

            DataTable table = DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0];

            foreach (DataRow row in table.Rows)
            {
                UserTask task = new UserTask();

                ORMapping.DataRowToObject(row, task);

                result.Add(task);
            }

            return(result);
        }
Пример #3
0
        public UserTaskCollection LoadUserTasks(Action <WhereSqlClauseBuilder> action)
        {
            action.NullCheck("action");

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            action(builder);

            string sql = string.Format("SELECT * FROM WF.USER_TASK WHERE {0}", builder.ToSqlString(TSqlBuilder.Instance));

            UserTaskCollection result = new UserTaskCollection();

            DataTable table = DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0];

            foreach (DataRow row in table.Rows)
            {
                UserTask task = new UserTask();

                ORMapping.DataRowToObject(row, task);

                result.Add(task);
            }

            return(result);
        }
Пример #4
0
        public UserTaskCollection LoadUserTasks(string tableName, IConnectiveSqlClause wBuilder, OrderBySqlClauseBuilder orderByBuilder, int count, bool nolock = false)
        {
            UserTaskCollection result = new UserTaskCollection();
            string             top    = string.Empty;

            if (count >= 0)
            {
                top = string.Format("TOP {0}", count);
            }

            if (wBuilder.IsEmpty == false)
            {
                if (nolock)
                {
                    tableName += " (NOLOCK)";
                }

                string sql = string.Format("SELECT {0} * FROM {1} WHERE {2}",
                                           top,
                                           tableName,
                                           wBuilder.ToSqlString(TSqlBuilder.Instance));

                if (orderByBuilder.Count > 0)
                {
                    sql += " ORDER BY " + orderByBuilder.ToSqlString(TSqlBuilder.Instance);
                }

                DataTable table = DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0];

                foreach (DataRow row in table.Rows)
                {
                    UserTask task = new UserTask();

                    ORMapping.DataRowToObject(row, task);

                    result.Add(task);
                }
            }

            return(result);
        }
Пример #5
0
        public UserTaskCollection GetUserAccomplishedTasks(UserTaskIDType idType, UserTaskFieldDefine returnFields, bool nolock, params string[] ids)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(ids != null, "ids");

            UserTaskCollection utc = new UserTaskCollection();

            if (ids.Length > 0)
            {
                ORMappingItem keyItem = GetMappingItemFromIDType(idType);

                InSqlClauseBuilder iBuilder = new InSqlClauseBuilder();

                iBuilder.AppendItem(ids);

                string sql = string.Format("SELECT {0} FROM WF.USER_ACCOMPLISHED_TASK{1} WHERE {2} {3}",
                                           GetUserTaskSelectFields(returnFields),
                                           nolock ? "(NOLOCK)" : string.Empty,
                                           GetMappingItemFromIDType(idType).DataFieldName,
                                           iBuilder.ToSqlStringWithInOperator(TSqlBuilder.Instance));

                using (DbContext dbi = DbHelper.GetDBContext(GetConnectionName()))
                {
                    Database db = DatabaseFactory.Create(dbi);

                    using (IDataReader dr = db.ExecuteReader(CommandType.Text, sql))
                    {
                        while (dr.Read())
                        {
                            UserTask ut = new UserTask();

                            ORMapping.DataReaderToObject(dr, ut);

                            utc.Add(ut);
                        }
                    }
                }
            }

            return(utc);
        }
Пример #6
0
        public UserTaskCollection LoadUserTasks(string tableName, IConnectiveSqlClause builder)
        {
            UserTaskCollection result = new UserTaskCollection();

            if (builder.IsEmpty == false)
            {
                string sql = string.Format("SELECT * FROM {0} WHERE {1}",
                                           tableName, builder.ToSqlString(TSqlBuilder.Instance));

                DataTable table = DbHelper.RunSqlReturnDS(sql, GetConnectionName()).Tables[0];

                foreach (DataRow row in table.Rows)
                {
                    UserTask task = new UserTask();

                    ORMapping.DataRowToObject(row, task);

                    result.Add(task);
                }
            }

            return(result);
        }