예제 #1
0
        public static DataSet GetEvents(
            int moduleId,
            DateTime beginDate,
            DateTime endDate)
        {
            NpgsqlParameter[] arParams = new NpgsqlParameter[3];

            arParams[0]           = new NpgsqlParameter("moduleid", NpgsqlTypes.NpgsqlDbType.Integer);
            arParams[0].Direction = ParameterDirection.Input;
            arParams[0].Value     = moduleId;

            arParams[1]           = new NpgsqlParameter("begindate", NpgsqlTypes.NpgsqlDbType.Date);
            arParams[1].Direction = ParameterDirection.Input;
            arParams[1].Value     = beginDate;

            arParams[2]           = new NpgsqlParameter("enddate", NpgsqlTypes.NpgsqlDbType.Date);
            arParams[2].Direction = ParameterDirection.Input;
            arParams[2].Value     = endDate;

            return(NpgsqlHelper.ExecuteDataset(
                       ConnectionString.GetReadConnectionString(),
                       CommandType.StoredProcedure,
                       "mp_calendarevents_select_bydate(:moduleid,:begindate,:enddate)",
                       arParams));
        }
예제 #2
0
        public static void DatabaseHelperDoVersion2320PostUpgradeTasks(
            String overrideConnectionInfo)
        {
            string connectionString;

            if (
                (overrideConnectionInfo != null) &&
                (overrideConnectionInfo.Length > 0)
                )
            {
                connectionString = overrideConnectionInfo;
            }
            else
            {
                connectionString = ConnectionString.GetWriteConnectionString();
            }


            StringBuilder sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT  ");
            sqlCommand.Append("u.siteguid, ");
            sqlCommand.Append("ls.letterinfoguid, ");
            sqlCommand.Append("ls.userguid, ");
            sqlCommand.Append("u.email, ");
            sqlCommand.Append("ls.beginutc, ");
            sqlCommand.Append("ls.usehtml ");

            sqlCommand.Append("FROM ");
            sqlCommand.Append("mp_lettersubscriber ls ");
            sqlCommand.Append("JOIN ");
            sqlCommand.Append("mp_users u ");
            sqlCommand.Append("ON ");
            sqlCommand.Append("u.userguid = ls.userguid ");
            sqlCommand.Append(" ; ");

            DataSet ds = NpgsqlHelper.ExecuteDataset(
                connectionString,
                CommandType.Text,
                sqlCommand.ToString());

            DataTable dataTable = ds.Tables[0];

            foreach (DataRow row in dataTable.Rows)
            {
                DBLetterSubscription.Create(
                    Guid.NewGuid(),
                    new Guid(row["SiteGuid"].ToString()),
                    new Guid(row["LetterInfoGuid"].ToString()),
                    new Guid(row["UserGuid"].ToString()),
                    row["Email"].ToString().ToLower(),
                    true,
                    new Guid("00000000-0000-0000-0000-000000000000"),
                    Convert.ToDateTime(row["BeginUTC"]),
                    Convert.ToBoolean(row["UseHtml"])
                    );
            }
        }
예제 #3
0
        public static DataTable DatabaseHelperGetTable(
            String connectionString,
            String tableName,
            String whereClause)
        {
            StringBuilder sqlCommand = new StringBuilder();

            sqlCommand.Append("select * ");
            sqlCommand.Append("from " + tableName.ToLower() + " ");
            sqlCommand.Append(whereClause);
            sqlCommand.Append(" ; ");

            DataSet ds = NpgsqlHelper.ExecuteDataset(
                connectionString,
                CommandType.Text,
                sqlCommand.ToString());

            return(ds.Tables[0]);
        }
예제 #4
0
        public static void DatabaseHelperDoForumVersion2203PostUpgradeTasks(
            String overrideConnectionInfo)
        {
            string connectionString;

            if (
                (overrideConnectionInfo != null) &&
                (overrideConnectionInfo.Length > 0)
                )
            {
                connectionString = overrideConnectionInfo;
            }
            else
            {
                connectionString = ConnectionString.GetWriteConnectionString();
            }

            StringBuilder sqlCommand = new StringBuilder();

            sqlCommand.Append("SELECT subscriptionid ");
            sqlCommand.Append("FROM mp_forumsubscriptions ");
            sqlCommand.Append(" where (subguid is null OR subguid = '00000000-0000-0000-0000-000000000000') ");
            sqlCommand.Append(" ; ");

            DataSet ds = NpgsqlHelper.ExecuteDataset(
                connectionString,
                CommandType.Text,
                sqlCommand.ToString(),
                null);

            DataTable dataTable = ds.Tables[0];


            foreach (DataRow row in dataTable.Rows)
            {
                DatabaseHelperUpdateTableField(
                    "mp_forumsubscriptions",
                    "subscriptionid",
                    row["SubscriptionID"].ToString(),
                    "subguid",
                    Guid.NewGuid().ToString(),
                    "  ");
            }



            sqlCommand = new StringBuilder();
            sqlCommand.Append("SELECT threadsubscriptionid ");
            sqlCommand.Append("FROM mp_forumthreadsubscriptions ");
            sqlCommand.Append(" where (subguid is null OR subguid = '00000000-0000-0000-0000-000000000000') ");
            sqlCommand.Append(" ; ");

            ds = NpgsqlHelper.ExecuteDataset(
                connectionString,
                CommandType.Text,
                sqlCommand.ToString(),
                null);

            dataTable = ds.Tables[0];


            foreach (DataRow row in dataTable.Rows)
            {
                DatabaseHelperUpdateTableField(
                    "mp_ForumThreadSubscriptions",
                    "threadsubscriptionid",
                    row["ThreadSubscriptionID"].ToString(),
                    "subguid",
                    Guid.NewGuid().ToString(),
                    "  ");
            }
        }