예제 #1
0
파일: DB.cs 프로젝트: NtreevSoft/Crashweb
        public static bool LoadDailyCount(int project_uid, short fromDate, short toDate, ForEachDailyCount func)
        {
            if (fromDate <= 0)
                fromDate = (short)kSampleBegin;
            if (toDate < 0)
                toDate = (short)kSampleEnd;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                try
                {
                    conn.Open();

                    SqlCommand cmd1 = new SqlCommand("usp_select_daily_count", conn);
                    cmd1.CommandType = CommandType.StoredProcedure;

                    cmd1.Parameters.AddWithValue("@project_uid", project_uid);
                    cmd1.Parameters.AddWithValue("@day_from", fromDate);
                    cmd1.Parameters.AddWithValue("@day_to", toDate);

                    SqlDataReader reader = cmd1.ExecuteReader();

                    while (reader.Read())
                    {
                        string date = reader.GetString(0);
                        int count = reader.GetInt32(1);

                        func(date, count);
                    }

                    reader.Close();
                }
                catch (System.Exception)
                {
                    return false;
                }
            }

            return true;
        }
예제 #2
0
파일: DB.cs 프로젝트: whoo24/Crashweb
        public static bool LoadDailyCount(int project_uid, short fromDate, short toDate, ForEachDailyCount func)
        {
            if (fromDate <= 0)
            {
                fromDate = (short)kSampleBegin;
            }
            if (toDate < 0)
            {
                toDate = (short)kSampleEnd;
            }

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                try
                {
                    conn.Open();

                    SqlCommand cmd1 = new SqlCommand("usp_select_daily_count", conn);
                    cmd1.CommandType = CommandType.StoredProcedure;

                    cmd1.Parameters.AddWithValue("@project_uid", project_uid);
                    cmd1.Parameters.AddWithValue("@day_from", fromDate);
                    cmd1.Parameters.AddWithValue("@day_to", toDate);

                    SqlDataReader reader = cmd1.ExecuteReader();

                    while (reader.Read())
                    {
                        string date  = reader.GetString(0);
                        int    count = reader.GetInt32(1);

                        func(date, count);
                    }

                    reader.Close();
                }
                catch (System.Exception)
                {
                    return(false);
                }
            }

            return(true);
        }