Esempio n. 1
0
        public static DataSet logicGetUid_pw(int uid)
        {
            String sql = "SELECT uid,username,email FROM `" + RCLogic.PW_TablePre + "members` WHERE uid = '" + uid.ToString() + "' LIMIT 0 , 1";

            DataSet ds = MySqlDBUtil.ExecuteQuery(sql);

            //if (ds.Tables()[0].size() > 0)
            if (ds.Tables[0].Rows.Count > 0)
            {
                //
            }
            else
            {
                Log.WriteStrByMySqlWarnning("mysql select", "can not find uid:" + uid.ToString() + " sql:" + sql);
            }

            return(ds);
        }
Esempio n. 2
0
        public static DataSet logicGetUid_x(int uid)
        {
            //String uid = "";
            String username = "";

            String sql = "";


            //
            DataSet ds = null;

            if (RCLogic.selectDB.sql.ToLower() == "mssql")
            {
                sql = "SELECT top 10 " + RCLogic.X_CloumnId + "," + RCLogic.X_CloumnNick + "," + RCLogic.X_CloumnMail + " FROM " + RCLogic.X_Table +
                      " WHERE " + RCLogic.X_CloumnId + " = '" + uid.ToString() + "'";


                //ds = MsSqlDB.ExecuteQuery(sql);
            }
            else if (RCLogic.selectDB.sql.ToLower() == "mysql")
            {
                sql = "SELECT " + RCLogic.X_CloumnId + "," + RCLogic.X_CloumnNick + "," + RCLogic.X_CloumnMail + " FROM `" + RCLogic.X_Table +
                      "` WHERE " + RCLogic.X_CloumnId + " = '" + uid.ToString() + "' LIMIT 0 , 1";

                ds = MySqlDBUtil.ExecuteQuery(sql);

                // if (ds.Tables()[0].size() > 0)
                if (ds.Tables[0].Rows.Count > 0)
                {
                }
                else
                {
                    Log.WriteStrByMySqlWarnning("mysql select", "can not find uid:" + uid.ToString() + " sql:" + sql);
                }
            }
            else
            {
                throw new IllegalArgumentException("can not find sql:" + RCLogic.selectDB.sql);
            }


            return(ds);
        }
Esempio n. 3
0
        public static String[] logicGetSid_x(int uid)
        {
            Boolean idFind = false;

            String[] s = new String[7];

            String sql;

            //
            sql = "SELECT * FROM `" + RCLogic.X_TableSession + "` WHERE " +
                  RCLogic.X_CloumnId
                  //"userid"
                  + " = '" + uid.ToString() + "' LIMIT 0 , 1";

            //
            DataSet ds = MySqlDBUtil.ExecuteQuery(sql);

            //if (ds.getTables(0).size() > 0)
            if (ds.Tables[0].Rows.Count > 0)
            {
                idFind = true;

                s[0] = ds.Tables[0].Rows[0][RCLogic.X_CloumnSessionId].ToString();        //ds.getTables(0).getRows(0).get(RCLogic.X_CloumnSessionId).toString();
                s[1] = uid.ToString();
                s[2] = idFind.ToString();

                //
                //                    s[3] = ds.getTables(0).getRows(0).get("ip1").toString();
                //                    s[4] = ds.getTables(0).getRows(0).get("ip2").toString();
                //                    s[5] = ds.getTables(0).getRows(0).get("ip3").toString();
                //                    s[6] = ds.getTables(0).getRows(0).get("ip4").toString();

                return(s);
            }

            //没有找到
            s[2] = idFind.ToString();

            return(s);
        }
Esempio n. 4
0
        public static String[] logicGetSid_dz(int uid)
        {
            Boolean idFind = false;

            String[] s = new String[7];

            String sql;

            //
            sql = "SELECT sid,ip1,ip2,ip3,ip4 FROM `" + RCLogic.DZ_TablePre + "common_session` WHERE uid = '" + uid.ToString() + "' LIMIT 0 , 1";

            //
            DataSet ds = MySqlDBUtil.ExecuteQuery(sql);

            //if (ds.getTables(0).size() > 0)
            if (ds.Tables[0].Rows.Count > 0)
            {
                idFind = true;

                s[0] = ds.Tables[0].Rows[0]["sid"].ToString();        //ds.getTables(0).getRows(0).get("sid").toString();
                s[1] = uid.ToString();
                s[2] = idFind.ToString();

                //
                s[3] = ds.Tables[0].Rows[0]["ip1"].ToString();
                s[4] = ds.Tables[0].Rows[0]["ip2"].ToString();
                s[5] = ds.Tables[0].Rows[0]["ip3"].ToString();
                s[6] = ds.Tables[0].Rows[0]["ip4"].ToString();

                return(s);
            }

            //没有找到
            s[2] = idFind.ToString();

            return(s);
        }
Esempio n. 5
0
        public static String[] createMySqlTable(String database, String engine)
        {
            //
            String[] createOk = { "True", "" };
            String   sql      = "";

            try
            {
                DataSet countRowDs         = null;
                String  createTableSql     = "";
                String  createTableDataSql = "";   //默认初始数据
                String  delTableSql        = "";

                String[] tableList =
                {
                    RCLogic.TableLog,
                    RCLogic.TableEveryDayLogin,
                    RCLogic.TableHonor,
                    RCLogic.TableUsers,
                    RCLogic.TableLvl,
                    RCLogic.TableLvlName
                };

                String tmpStr;

                //
                for (int i = 0; i < tableList.Length; i++)
                {
                    //这里有一个BUG,如果同时安装DISCUZ和PHPWDIN,数据库不删除
                    //则countTable为1 ,而且后面查不到该表,会出错,因为这张表在另一个数据库里
                    //用TABLE_SCHEMA解决试下

                    String countTableSql = "SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_NAME='" +
                                           tableList[i] + "' AND TABLE_SCHEMA ='" +
                                           database + "'";

                    DataSet countTableDs = MySqlDBUtil.ExecuteQuery(countTableSql);

                    int countTable = 0;

                    if (countTableDs.Tables[0].Rows.Count > 0)
                    {
                        tmpStr = countTableDs.Tables[0].Rows[0][0].ToString();

                        countTable = Integer.parseInt(tmpStr);
                    }



                    if (0 == countTable)
                    {
                        createTableSql = "";
                        createTableSql = createMySqlTableSql(tableList[i], engine);
                        MySqlDBUtil.ExecuteNonQuery(createTableSql);

                        //默认数据
                        createTableDataSql = "";
                        createTableDataSql = createMySqlTableDataSql(tableList[i]);

                        if (!String.IsNullOrEmpty(createTableDataSql))
                        {
                            MySqlDBUtil.ExecuteNonQuery(createTableDataSql);
                        }
                    }

                    if (countTable > 0 &&
                        (RCLogic.TableLog == tableList[i] && RCLogic.autoClearTableLog) ||
                        (RCLogic.TableEveryDayLogin == tableList[i] && RCLogic.autoClearTableEveryDayLogin))
                    {
                        delTableSql = "";
                        delTableSql = delMySqlTableSql(tableList[i]);
                        MySqlDBUtil.ExecuteNonQuery(delTableSql);

                        createTableSql = "";
                        createTableSql = createMySqlTableSql(tableList[i], engine);
                        MySqlDBUtil.ExecuteNonQuery(createTableSql);
                    }


                    //
                    String countRowSql = "SELECT COUNT(*) FROM " + tableList[i];



                    Console.Write(SR.GetString(SR.getDB_Log_Reading(), tableList[i]));
                    countRowDs = MySqlDBUtil.ExecuteQuery(countRowSql);
                    Console.WriteLine(", " + SR.GetString(SR.getDB_Log_Desc(),

                                                          //countRowDs.getTables(0).getRows(0).get(0).toString()
                                                          countRowDs.Tables[0].Rows[0][0].ToString()


                                                          ));
                }
            }
            catch (Exception exc)
            {
                createOk[0] = "False";
                createOk[1] = exc.Message;

                Log.WriteStrByException(RCLogic.CLASS_NAME, "createMySqlTable", exc.Message, exc.StackTrace);
            }

            return(createOk);
        }