Beispiel #1
0
        public List<List<string>> fetchAuthorityLists(ServerInfo info, Protocol pro)
        {
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }
            catch (Exception)
            {
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }

            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql1 = fetch.readSqlById(getAllAuthories);
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if (handle.connect())
            {
                List<List<string>> data1 = handle.query(sql1.getSql());
                handle.close();
                return data1;
            }

            return null;
        }
Beispiel #2
0
        public bool deleteUserInfo(ServerInfo info, Protocol pro)
        {
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }
            catch (Exception)
            {
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }

            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql = fetch.readSqlById("delete_user");
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if (handle.connect())
            {
                //与之相关的g_ins,gouts也应该删除
                sql.addParam("user", pro.param[0]);
                bool b = handle.execute(sql.getSql());
                handle.close();
                return b;

            }

            return false;
        }
Beispiel #3
0
 public List<List<string>> login(ServerInfo info, Protocol pro)
 {
     //fetch sql
     this.info = info;
     string sqlStorePath=null;
     try{
         sqlStorePath=this.info.confMap.value(strConfKey.SqlStorePath);
     }catch(Exception){
         sqlStorePath = DefaultConf.defaultSqlStorePath;
     }
     Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
     Sql_Struct sql = fetch.readSqlById(sqlName);
     if(sql.addParam(param1,pro.param[0])
         && sql.addParam(param2,pro.param[1]))
         Log.WriteLog(LogLevel.MSG,pro.param[0]+" is trying to login");
        //excute sql
     SqlHandle handle = new SqlHandle(info.dbInfo);
     if (handle.connect())
     {
         List<List<string>> data=handle.query(sql.getSql());
         handle.close();
         return data;
     }
     return null;
 }
Beispiel #4
0
        public List<List<string>> getAllUserInfo(ServerInfo info, Protocol pro)
        {
            //fetch sql
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }
            catch (Exception)
            {
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }
            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql = fetch.readSqlById(sqlName);

            //excute sql
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if (handle.connect())
            {
                List<List<string>> data = handle.query(sql.getSql());
                handle.close();
                return data;
            }
            return null;
        }
Beispiel #5
0
        public bool updateUserInfo(ServerInfo info, Protocol pro)
        {
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }
            catch (Exception)
            {
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }

            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql = fetch.readSqlById("get_loa_id_by_name");
            Sql_Struct sql2 = fetch.readSqlById("get_user_id_by_name");
            Sql_Struct sql3 = fetch.readSqlById("update_user_info");
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if (handle.connect())
            {
                sql.addParam("loaName", pro.param[2]);
                sql2.addParam("user", pro.param[0]);
                List<List<string>> data1 = handle.query(sql.getSql());
                List<List<string>> data2 = handle.query(sql2.getSql());

                if (data1 != null && data2 != null)
                {
                    sql3.addParam("passwd", pro.param[1]);
                    sql3.addParam("loa", data1[0][0]);
                    sql3.addParam("id", data2[0][0]);
                    bool b= handle.execute(sql3.getSql());
                    handle.close();
                    return b;
                }
                else
                {
                    return false;
                }

            }

            return false;
        }
Beispiel #6
0
        public bool Register_User_Info(ServerInfo info, Protocol pro)
        {
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }
            catch (Exception)
            {
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }

            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql = fetch.readSqlById("get_loa_id_by_name");
            Sql_Struct sql2 = fetch.readSqlById("register_user");
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if (handle.connect())
            {
                sql.addParam("loaName",pro.param[2]);
                List<List<string>> result = handle.query(sql.getSql());
                if (result == null || result.Count==0)
                    return false;
                sql2.addParam("user", pro.param[0]);
                sql2.addParam("passwd", pro.param[1]);
                sql2.addParam("loa", result[0][0]);
                bool b = handle.execute(sql2.getSql());
                handle.close();
                return b;

            }

            return false;
        }
Beispiel #7
0
        public List<List<List<string>>> getModifyingUserInfo(ServerInfo info, Protocol pro)
        {
            this.info = info;
            string sqlStorePath = null;
            try
            {
                sqlStorePath = this.info.confMap.value(strConfKey.SqlStorePath);
            }catch(Exception){
                sqlStorePath = DefaultConf.defaultSqlStorePath;
            }

            Fetch_Sql_From_Xml fetch = new Fetch_Sql_From_Xml(sqlStorePath);
            Sql_Struct sql = fetch.readSqlById(getModifyingUserInfoSqlName);
            Sql_Struct sql2 = fetch.readSqlById(getAllAuthories);
            SqlHandle handle = new SqlHandle(info.dbInfo);
            if(handle.connect()){
                sql.addParam("user",pro.param[0]);
                List<List<string>> data1=handle.query(sql.getSql());
                List<List<string>> data2=handle.query(sql2.getSql());
                List<List<List<string>>> mutilDatas=new List<List<List<string>>>();
                handle.close();
                mutilDatas.Add(data1);
                mutilDatas.Add(data2);
                return mutilDatas;
            }

            return null;
        }