Пример #1
0
        public override TList <InspectSituation> GetPaged(TransactionManager transactionManager, string whereClause, string orderBy, int start, int pageLength, out int count)
        {
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.InspectSituation_GetPaged", this._useStoredProcedure);

            database.AddInParameter(command, "@WhereClause", DbType.String, whereClause);
            database.AddInParameter(command, "@OrderBy", DbType.String, orderBy);
            database.AddInParameter(command, "@PageIndex", DbType.Int32, start);
            database.AddInParameter(command, "@PageSize", DbType.Int32, pageLength);
            IDataReader reader            = null;
            TList <InspectSituation> rows = new TList <InspectSituation>();

            try
            {
                try
                {
                    if (transactionManager != null)
                    {
                        reader = Utility.ExecuteReader(transactionManager, command);
                    }
                    else
                    {
                        reader = Utility.ExecuteReader(database, command);
                    }
                    InspectSituationProviderBaseCore.Fill(reader, rows, 0, 0x7fffffff);
                    count = rows.Count;
                    if (reader.NextResult() && reader.Read())
                    {
                        count = reader.GetInt32(0);
                    }
                    return(rows);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(rows);
        }
Пример #2
0
        public override TList <InspectSituation> Find(TransactionManager transactionManager, SqlFilterParameterCollection parameters, string orderBy, int start, int pageLength, out int count)
        {
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.InspectSituation_Find_Dynamic", typeof(InspectSituationColumn), parameters, orderBy, start, pageLength);

            if (parameters != null)
            {
                for (int i = 0; i < parameters.Count; i++)
                {
                    SqlFilterParameter parameter = parameters[i];
                    database.AddInParameter(command, parameter.Name, parameter.DbType, parameter.Value);
                }
            }
            TList <InspectSituation> rows = new TList <InspectSituation>();
            IDataReader reader            = null;

            try
            {
                if (transactionManager != null)
                {
                    reader = Utility.ExecuteReader(transactionManager, command);
                }
                else
                {
                    reader = Utility.ExecuteReader(database, command);
                }
                InspectSituationProviderBaseCore.Fill(reader, rows, 0, 0x7fffffff);
                count = rows.Count;
                if (!reader.NextResult())
                {
                    return(rows);
                }
                if (reader.Read())
                {
                    count = reader.GetInt32(0);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(rows);
        }
Пример #3
0
        public override InspectSituation GetByInspectSituationID(TransactionManager transactionManager, int inspectSituationID, int start, int pageLength, out int count)
        {
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.InspectSituation_GetByInspectSituationID", this._useStoredProcedure);

            database.AddInParameter(command, "@InspectSituationID", DbType.Int32, inspectSituationID);
            IDataReader reader            = null;
            TList <InspectSituation> rows = new TList <InspectSituation>();

            try
            {
                if (transactionManager != null)
                {
                    reader = Utility.ExecuteReader(transactionManager, command);
                }
                else
                {
                    reader = Utility.ExecuteReader(database, command);
                }
                InspectSituationProviderBaseCore.Fill(reader, rows, start, pageLength);
                count = -1;
                if (reader.NextResult() && reader.Read())
                {
                    count = reader.GetInt32(0);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            if (rows.Count == 1)
            {
                return(rows[0]);
            }
            if (rows.Count != 0)
            {
                throw new DataException("Cannot find the unique instance of the class.");
            }
            return(null);
        }
Пример #4
0
        public override TList <InspectSituation> GetByProjectCode(TransactionManager transactionManager, string projectCode, int start, int pageLength, out int count)
        {
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.InspectSituation_GetByProjectCode", this._useStoredProcedure);

            database.AddInParameter(command, "@ProjectCode", DbType.AnsiString, projectCode);
            IDataReader reader            = null;
            TList <InspectSituation> rows = new TList <InspectSituation>();

            try
            {
                if (transactionManager != null)
                {
                    reader = Utility.ExecuteReader(transactionManager, command);
                }
                else
                {
                    reader = Utility.ExecuteReader(database, command);
                }
                InspectSituationProviderBaseCore.Fill(reader, rows, start, pageLength);
                count = -1;
                if (!reader.NextResult())
                {
                    return(rows);
                }
                if (reader.Read())
                {
                    count = reader.GetInt32(0);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(rows);
        }
Пример #5
0
        public override TList <InspectSituation> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count)
        {
            count = -1;
            if (whereClause.IndexOf(";") > -1)
            {
                return(new TList <InspectSituation>());
            }
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.InspectSituation_Find", this._useStoredProcedure);
            bool        flag     = false;

            if (whereClause.IndexOf(" OR ") > 0)
            {
                flag = true;
            }
            database.AddInParameter(command, "@SearchUsingOR", DbType.Boolean, flag);
            database.AddInParameter(command, "@InspectSituationID", DbType.Int32, DBNull.Value);
            database.AddInParameter(command, "@InspectSituationNO", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@ProjectCode", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@InspectDate", DbType.DateTime, DBNull.Value);
            database.AddInParameter(command, "@Weather", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@InspectUserIpecialty", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@InspectUser", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@KeyPoint", DbType.AnsiString, DBNull.Value);
            database.AddInParameter(command, "@Status", DbType.Int32, DBNull.Value);
            whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|");
            string[] textArray = whereClause.ToLower().Split(new char[] { '|' });
            char[]   trimChars = new char[] { '=' };
            char[]   chArray2  = new char[] { '\'' };
            foreach (string text in textArray)
            {
                if (text.Trim().StartsWith("inspectsituationid ") || text.Trim().StartsWith("inspectsituationid="))
                {
                    database.SetParameterValue(command, "@InspectSituationID", text.Replace("inspectsituationid", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("inspectsituationno ") || text.Trim().StartsWith("inspectsituationno="))
                {
                    database.SetParameterValue(command, "@InspectSituationNO", text.Replace("inspectsituationno", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("projectcode ") || text.Trim().StartsWith("projectcode="))
                {
                    database.SetParameterValue(command, "@ProjectCode", text.Replace("projectcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("inspectdate ") || text.Trim().StartsWith("inspectdate="))
                {
                    database.SetParameterValue(command, "@InspectDate", text.Replace("inspectdate", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("weather ") || text.Trim().StartsWith("weather="))
                {
                    database.SetParameterValue(command, "@Weather", text.Replace("weather", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("inspectuseripecialty ") || text.Trim().StartsWith("inspectuseripecialty="))
                {
                    database.SetParameterValue(command, "@InspectUserIpecialty", text.Replace("inspectuseripecialty", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("inspectuser ") || text.Trim().StartsWith("inspectuser="******"@InspectUser", text.Replace("inspectuser", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else if (text.Trim().StartsWith("keypoint ") || text.Trim().StartsWith("keypoint="))
                {
                    database.SetParameterValue(command, "@KeyPoint", text.Replace("keypoint", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
                else
                {
                    if (!text.Trim().StartsWith("status ") && !text.Trim().StartsWith("status="))
                    {
                        throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + text);
                    }
                    database.SetParameterValue(command, "@Status", text.Replace("status", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2));
                }
            }
            IDataReader reader            = null;
            TList <InspectSituation> rows = new TList <InspectSituation>();

            try
            {
                if (transactionManager != null)
                {
                    reader = Utility.ExecuteReader(transactionManager, command);
                }
                else
                {
                    reader = Utility.ExecuteReader(database, command);
                }
                InspectSituationProviderBaseCore.Fill(reader, rows, start, pageLength);
                if (reader.NextResult() && reader.Read())
                {
                    count = reader.GetInt32(0);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(rows);
        }