Ejemplo n.º 1
0
        void manager_OnMessage(FoxundermoonLib.XmppEx.Data.Message msg)
        {
            switch (msg.Command.Name)
            {
            case Cmd.GetOnlineUsersResponse:
                //获取在线用户表
                p(msg.ToJson());
                break;

            case Cmd.OnLineAtOtherPlace:
                p("该用户在别的地方登陆");
                p(msg.ToJson());
                //你被顶掉线了
                break;

            case Cmd.UserLogin:
                var name = msg.GetProperty("UserName");
                p("用户 " + name + "上线了");
                break;
            }
            p("received a message");
            p(msg.ToJson());
            if (Cmd.GetOnlineUsersResponse.Equals(msg.Command.Name))
            {
                p("用户:" + msg.GetProperty("UserName"));
            }
            p("--------------------------------------------------------------------------");
            //DataTable responceDt = msg.DataTable;

            //foreach (var row in responceDt.Rows)
            //{
            //    //do some thing
            //}
        }
Ejemplo n.º 2
0
        public void Broadcast2resource(FoxundermoonLib.XmppEx.Data.Message message, string resource)
        {
            Message msg = new Message();

            if (null == message.FromUser)
            {
                msg.From = getJidFromUser(message.FromUser);
            }
            else
            {
                msg.From = getJidFromUser(message.FromUser);
            }
            msg.Body     = FoxundermoonLib.Encrypt.EncryptUtil.EncryptBASE64ByGzip(message.ToJson());
            msg.Subject  = message.GetJsonCommand();
            msg.Language = "BASE64";

            foreach (var cons in XmppConnectionDic)
            {
                XmppSeverConnection con = null;
                var hasCon = cons.Value.TryGetValue(resource, out con);
                if (hasCon)
                {
                    Jid to = new Jid(cons.Key + "@" + Config.ServerIp + "/" + resource);
                    msg.To = to;
                    try
                    {
                        con.Send(msg);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[email protected] message:" + e.Message);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 广播
        /// </summary>
        /// <param name="strMsg">广播的消息</param>
        ///
        public void Broadcast(FoxundermoonLib.XmppEx.Data.Message message)
        {
            Message msg = new Message();

            if (null != message.FromUser)
            {
                msg.From = getJidFromUser(message.FromUser);
            }
            else
            {
                msg.From = getJidFromUser(new FoxundermoonLib.XmppEx.Data.User("0", "server"));
            }
            msg.Body     = FoxundermoonLib.Encrypt.EncryptUtil.EncryptBASE64ByGzip(message.ToJson());
            msg.Subject  = message.GetJsonCommand();
            msg.Language = "BASE64";

            foreach (var cons in XmppConnectionDic)
            {
                foreach (var con in cons.Value)
                {
                    Jid to = new Jid(cons.Key + "@" + Config.ServerIp + "/" + con.Key);
                    msg.To = to;
                    try
                    {
                        con.Value.Send(msg);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[email protected] message:" + e.Message);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void UniCast(XmppSeverConnection contexCon, FoxundermoonLib.XmppEx.Data.Message message)
        {
            Message msg = new Message();

            if (null == message.FromUser)
            {
                msg.From = ServerJid;
            }
            else
            {
                msg.From = getJidFromUser(message.FromUser);
            }
            if (null != message.ToUser)
            {
                msg.To = getJidFromUser(message.ToUser);
            }
            msg.Language = "BASE64";
            msg.Subject  = message.GetJsonCommand();
            msg.Body     = FoxundermoonLib.Encrypt.EncryptUtil.EncryptBASE64ByGzip(message.ToJson());
            try
            {
                contexCon.Send(msg);
            }
            catch (Exception e)
            {
                Console.WriteLine("*****@*****.**" + e.Message);
            }
        }
Ejemplo n.º 5
0
        private async void processMessage(agsXMPP.XmppSeverConnection contextConnection, Message msg)
        {
            FoxundermoonLib.XmppEx.Data.Message message = new FoxundermoonLib.XmppEx.Data.Message();
            #region 转换Message
            var content = "";
            var command = "";

            if (!string.IsNullOrEmpty(msg.Language) && msg.Language.ToUpper().Contains("BASE64"))
            {
                content = EncryptUtil.DecryptBASE64ByGzip(msg.Body);
            }
            else
            {
                content = msg.Body;
                //dbmsg.Content = msg.Body;
            }
            if (msg.To != null && !string.IsNullOrEmpty(msg.To.User))
            {
                message.ToUser = new FoxundermoonLib.XmppEx.Data.User(msg.To.User, msg.To.Resource);
            }

            if (msg.From != null && msg.From.User != null)
            {
                message.FromUser = new FoxundermoonLib.XmppEx.Data.User(msg.From.User, msg.From.Resource);
            }
            command = msg.Subject;

            //转发 message
            // to != "0" and ""

            message.SetJsonMessage(content);
            message.SetJsonCommand(command);
            if (null != message.ToUser)
            {
                SmartBroadCast(message);
            }
            #endregion
            Console.WriteLine(message.ToJson(true));
            Console.WriteLine(message.GetJsonCommand());
            #region  数据表操作
            try
            {
                // default mysql datable
                databaseType dbt = getDatabaseType(message);
                if (dbt == databaseType.MySql)
                {
                    #region  数据表操作
                    if (message.DataTable != null && message.DataTable.Rows.Count > 0)
                    {
                        var sqlb = new StringBuilder();
                        #region insert
                        if (message.Command.Operation == "insert")
                        {
                            bool hasLID = false;
                            foreach (DataColumn dc in message.DataTable.DataColumns)
                            {
                                if ("LID".Equals(dc.ColumnName))
                                {
                                    hasLID = true;
                                }
                            }
                            try
                            {
                                sqlb.Append("INSERT INTO ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append(message.DataTable.Database).Append(".");
                                }
                                sqlb.Append(message.DataTable.TableName).Append("(");
                                var sbv = new StringBuilder();
                                foreach (FoxundermoonLib.XmppEx.Data.Column c in message.DataTable.DataColumns)
                                {
                                    sqlb.Append("").Append(c.ColumnName).Append(" , ");
                                    sbv.Append("@").Append(c.ColumnName).Append(",");
                                }
                                sqlb.Remove(sqlb.Length - 2, 2).Append(") VALUES (").Append(sbv.Remove(sbv.Length - 1, 1).Append(")").ToString());
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int l = r.ItemArray.GetLength(0);
                                    MySqlParameter[] ps = new MySqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new MySqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += MysqlHelper.ExecuteNonQuery(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                                if (hasLID)
                                {
                                    wrapReturnTable(message, dbt);  //返回ID  LID 对应表
                                }
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable insert");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.Command.Operation = "insertResponse";
                                UniCast(contextConnection, message);
                            }
                            //INSERT INTO `nj_gps档案记录`(`ID`, `用户`, `日期`, `档案号`, `坐标串`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5])
                        }
                        #endregion
                        #region  delete
                        else if (message.Command.Operation == "delete")
                        {
                            try
                            {
                                sqlb.Append("DELETE FROM ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("`").Append(message.DataTable.Database).Append("`.");
                                }
                                sqlb.Append("`").Append(message.DataTable.TableName).Append("` WHERE ")
                                .Append(message.Command.Condition);
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int l = r.ItemArray.GetLength(0);
                                    MySqlParameter[] ps = new MySqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new MySqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += MysqlHelper.ExecuteNonQuery(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable delete");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.DataTable         = null;
                                message.Command.Operation = "deleteResponse";
                                UniCast(contextConnection, message);
                            }
                        }
                        #endregion
                        #region update
                        else if (message.Command.Operation == "update")
                        {
                            //UPDATE `nj_gps档案记录` SET `ID`=[value-1],`用户`=[value-2],`日期`=[value-3],`档案号`=[value-4],`坐标串`=[value-5] WHERE 1
                            try
                            {
                                sqlb.Append("UPDATE ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("`").Append(message.DataTable.Database).Append("`.");
                                }
                                sqlb.Append("`").Append(message.DataTable.TableName).Append("` SET ");
                                foreach (FoxundermoonLib.XmppEx.Data.Column c in message.DataTable.DataColumns)
                                {
                                    sqlb.Append(c.ColumnName).Append("=@").Append(c.ColumnName).Append(",");
                                }
                                sqlb.Remove(sqlb.Length - 1, 1).Append(" WHERE ").Append(message.Command.Condition);
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int l = r.ItemArray.GetLength(0);
                                    MySqlParameter[] ps = new MySqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new MySqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += MysqlHelper.ExecuteNonQuery(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable update");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.DataTable         = null;
                                message.Command.Operation = "updateResponse";
                                UniCast(contextConnection, message);
                            }
                        }
                        #endregion
                        #region mutiQuery
                        var flag = true;
                        if (message.Command.Operation == "mutiquery")
                        {
                            #region 准备sql语句
                            if (string.IsNullOrEmpty(message.Command.Sql))
                            {
                                sqlb.Append("SELECT * FROM ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("`").Append(message.DataTable.Database).Append("`.");
                                }
                                if (string.IsNullOrEmpty(message.DataTable.TableName))
                                {
                                    message.Command.Name = Cmd.ErrorMessage;
                                    message.AddProperty("Message", "查询必须填写表名或者直接填写sql语句");
                                    message.AddProperty("error", "client error");
                                    message.AddProperty("errorMessage", "查询必须填写表名或者直接填写sql语句");
                                    message.SwitchDirection();
                                    UniCast(contextConnection, message);
                                    flag = false;
                                }
                                else
                                {
                                    sqlb.Append("`").Append(message.DataTable.TableName).Append("`");
                                    if (!string.IsNullOrEmpty(message.Command.Condition))
                                    {
                                        sqlb.Append(" WHERE ").Append(message.Command.Condition);
                                    }
                                }
                            }
                            else
                            {
                                sqlb.Append(message.Command.Sql);
                            }
                            #endregion
                            try
                            {
                                if (flag)
                                {
                                    var       sql = sqlb.ToString();
                                    DataTable dt  = null;
                                    foreach (DataRow r in message.DataTable.Rows)
                                    {
                                        int l = r.ItemArray.GetLength(0);
                                        MySqlParameter[] ps = new MySqlParameter[l];
                                        for (var i = 0; i < l; i++)
                                        {
                                            ps[i] = new MySqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                        }
                                        if (dt == null)
                                        {
                                            dt = MysqlHelper.ExecuteDataTable(sql, ps);
                                        }
                                        else
                                        {
                                            var appd = MysqlHelper.ExecuteDataTable(sql, ps);
                                            if (appd != null && appd.Rows.Count > 0)
                                            {
                                                foreach (DataRow _r in appd.Rows)
                                                {
                                                    dt.Rows.Add(dt.NewRow().ItemArray = _r.ItemArray);
                                                }
                                                appd.Clear();
                                                appd = null;
                                            }
                                        }
                                    }
                                    message.setDataTable(dt);
                                }
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable mutiquery");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.Command.Operation = "mutiQueryResponse";
                                UniCast(contextConnection, message);
                            }
                        }


                        #endregion
                    }
                    #endregion
                    #region runsql
                    if (message.Command != null && message.Command.Operation == "runsql" && !string.IsNullOrEmpty(message.Command.Sql))
                    {
                        int count = 0;
                        try
                        {
                            count = MysqlHelper.ExecuteNonQuery(message.Command.Sql);
                            message.SwitchDirection();
                            message.Command.Operation = "runsqlResponse";
                            message.AddProperty("Count", count + "");
                        }
                        catch (Exception e)
                        {
                            message.AddProperty("error", "server error@MessageHandler DataTable runsql");
                            message.AddProperty("errorMessage", e.Message);
                            Console.Write(e.Message);
                        }
                        finally
                        {
                            UniCast(contextConnection, message);
                        }
                    }
                    #endregion
                    #region query
                    if (message.Command.Operation == "query" && !string.IsNullOrEmpty(message.Command.Sql))
                    {
                        try
                        {
                            DataTable dt = MysqlHelper.ExecuteDataTable(message.Command.Sql);
                            message.setDataTable(dt);
                        }
                        catch (Exception e)
                        {
                            message.AddProperty("error", "server error@MessageHandler DataTable query");
                            message.AddProperty("errorMessage", e.Message);
                            Console.Write(e.Message);
                        }
                        finally
                        {
                            message.Command.Operation = "queryResponse";
                            message.SwitchDirection();
                            UniCast(contextConnection, message);
                        }
                    }
                    #endregion
                }
                else if (dbt == databaseType.Sql)
                {
                    #region  数据表操作
                    if (message.DataTable != null && message.DataTable.Rows.Count > 0)
                    {
                        var sqlb = new StringBuilder();
                        #region insert
                        if (message.Command.Operation == "insert")
                        {
                            bool hasLID = false;
                            foreach (DataColumn dc in message.DataTable.DataColumns)
                            {
                                if ("LID".Equals(dc.ColumnName))
                                {
                                    hasLID = true;
                                }
                            }
                            try
                            {
                                sqlb.Append("INSERT INTO ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append(message.DataTable.Database).Append(".");
                                }
                                sqlb.Append(message.DataTable.TableName).Append("(");
                                var sbv = new StringBuilder();
                                foreach (FoxundermoonLib.XmppEx.Data.Column c in message.DataTable.DataColumns)
                                {
                                    sqlb.Append("").Append(c.ColumnName).Append(" , ");
                                    sbv.Append("@").Append(c.ColumnName).Append(",");
                                }
                                sqlb.Remove(sqlb.Length - 2, 2).Append(") VALUES (").Append(sbv.Remove(sbv.Length - 1, 1).Append(")").ToString());
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int            l  = r.ItemArray.GetLength(0);
                                    SqlParameter[] ps = new SqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new SqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += SqlHelper.ExecteNonQueryText(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                                if (hasLID)
                                {
                                    wrapReturnTable(message, dbt);  //返回ID  LID 对应表
                                }
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable insert");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.Command.Operation = "insertResponse";
                                UniCast(contextConnection, message);
                            }
                            //INSERT INTO `nj_gps档案记录`(`ID`, `用户`, `日期`, `档案号`, `坐标串`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5])
                        }
                        #endregion
                        #region  delete
                        else if (message.Command.Operation == "delete")
                        {
                            try
                            {
                                sqlb.Append("DELETE FROM ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("[").Append(message.DataTable.Database).Append("].");
                                }
                                sqlb.Append("[").Append(message.DataTable.TableName).Append("] WHERE ")
                                .Append(message.Command.Condition);
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int            l  = r.ItemArray.GetLength(0);
                                    SqlParameter[] ps = new SqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new SqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += SqlHelper.ExecuteNonQuery(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable delete");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.DataTable         = null;
                                message.Command.Operation = "deleteResponse";
                                UniCast(contextConnection, message);
                            }
                        }
                        #endregion
                        #region update
                        else if (message.Command.Operation == "update")
                        {
                            //UPDATE `nj_gps档案记录` SET `ID`=[value-1],`用户`=[value-2],`日期`=[value-3],`档案号`=[value-4],`坐标串`=[value-5] WHERE 1
                            try
                            {
                                sqlb.Append("UPDATE ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("[").Append(message.DataTable.Database).Append("].");
                                }
                                sqlb.Append("[").Append(message.DataTable.TableName).Append("] SET ");
                                foreach (FoxundermoonLib.XmppEx.Data.Column c in message.DataTable.DataColumns)
                                {
                                    sqlb.Append(c.ColumnName).Append("=@").Append(c.ColumnName).Append(",");
                                }
                                sqlb.Remove(sqlb.Length - 1, 1).Append(" WHERE ").Append(message.Command.Condition);
                                var sql   = sqlb.ToString();
                                var count = 0;
                                foreach (DataRow r in message.DataTable.Rows)
                                {
                                    int            l  = r.ItemArray.GetLength(0);
                                    SqlParameter[] ps = new SqlParameter[l];
                                    for (var i = 0; i < l; i++)
                                    {
                                        ps[i] = new SqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                    }
                                    count += SqlHelper.ExecuteNonQuery(sql, ps);
                                }
                                message.AddProperty("Count", count.ToString());
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable update");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.DataTable         = null;
                                message.Command.Operation = "updateResponse";
                                UniCast(contextConnection, message);
                            }
                        }
                        #endregion
                        #region mutiQuery
                        var flag = true;
                        if (message.Command.Operation == "mutiquery")
                        {
                            #region 准备sql语句
                            if (string.IsNullOrEmpty(message.Command.Sql))
                            {
                                sqlb.Append("SELECT * FROM ");
                                if (!string.IsNullOrEmpty(message.DataTable.Database))
                                {
                                    sqlb.Append("[").Append(message.DataTable.Database).Append("].");
                                }
                                if (string.IsNullOrEmpty(message.DataTable.TableName))
                                {
                                    message.Command.Name = Cmd.ErrorMessage;
                                    message.AddProperty("Message", "查询必须填写表名或者直接填写sql语句");
                                    message.SwitchDirection();
                                    UniCast(contextConnection, message);
                                    flag = false;
                                }
                                else
                                {
                                    sqlb.Append("[").Append(message.DataTable.TableName).Append("]");
                                    if (!string.IsNullOrEmpty(message.Command.Condition))
                                    {
                                        sqlb.Append(" WHERE ").Append(message.Command.Condition);
                                    }
                                }
                            }
                            else
                            {
                                sqlb.Append(message.Command.Sql);
                            }
                            #endregion
                            try
                            {
                                if (flag)
                                {
                                    var       sql = sqlb.ToString();
                                    DataTable dt  = null;
                                    foreach (DataRow r in message.DataTable.Rows)
                                    {
                                        int            l  = r.ItemArray.GetLength(0);
                                        SqlParameter[] ps = new SqlParameter[l];
                                        for (var i = 0; i < l; i++)
                                        {
                                            ps[i] = new SqlParameter(message.DataTable.DataColumns[i].ColumnName, r.ItemArray[i]);
                                        }
                                        if (dt == null)
                                        {
                                            dt = SqlHelper.ExecuteDataTable(sql, ps);
                                        }
                                        else
                                        {
                                            var appd = SqlHelper.ExecuteDataTable(sql, ps);
                                            if (appd != null && appd.Rows.Count > 0)
                                            {
                                                foreach (DataRow _r in appd.Rows)
                                                {
                                                    dt.Rows.Add(dt.NewRow().ItemArray = _r.ItemArray);
                                                }
                                                appd.Clear();
                                                appd = null;
                                            }
                                        }
                                        message.setDataTable(dt);
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                message.AddProperty("error", "server error@MessageHandler DataTable mutiquery");
                                message.AddProperty("errorMessage", e.Message);
                                Console.Write(e.Message);
                            }
                            finally
                            {
                                message.SwitchDirection();
                                message.Command.Operation = "mutiQueryResponse";
                                UniCast(contextConnection, message);
                            }
                        }


                        #endregion
                    }
                    #endregion
                    #region runsql
                    if (message.Command != null && message.Command.Operation == "runsql" && !string.IsNullOrEmpty(message.Command.Sql))
                    {
                        int count = 0;
                        try
                        {
                            count = SqlHelper.ExecuteNonQuery(message.Command.Sql);
                            message.SwitchDirection();
                            message.Command.Operation = "runsqlResponse";
                            message.AddProperty("Count", count + "");
                        }
                        catch (Exception e)
                        {
                            message.AddProperty("error", "server error@MessageHandler DataTable runsql");
                            message.AddProperty("errorMessage", e.Message);
                            Console.Write(e.Message);
                        }
                        finally
                        {
                            UniCast(contextConnection, message);
                        }
                    }
                    #endregion
                    #region query
                    if (message.Command.Operation == "query" && !string.IsNullOrEmpty(message.Command.Sql))
                    {
                        try
                        {
                            DataTable dt = SqlHelper.ExecuteDataTable(message.Command.Sql, null);
                            message.setDataTable(dt);
                        }
                        catch (Exception e)
                        {
                            message.AddProperty("error", "server error@MessageHandler DataTable query");
                            message.AddProperty("errorMessage", e.Message);
                            Console.Write(e.Message);
                        }
                        finally
                        {
                            message.Command.Operation = "queryResponse";
                            message.SwitchDirection();
                            UniCast(contextConnection, message);
                        }
                    }
                    #endregion
                }



                #endregion

                #region 获取在线用户
                if (FoxundermoonLib.XmppEx.Command.Cmd.GetOnlineUsers.Equals(message.Command.Name))
                {
                    try
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("UserName");
                        dt.Columns.Add("Resource");
                        foreach (KeyValuePair <string, ConcurrentDictionary <string, agsXMPP.XmppSeverConnection> > item in XmppConnectionDic)
                        {
                            foreach (KeyValuePair <string, agsXMPP.XmppSeverConnection> con in item.Value)
                            {
                                var row = dt.NewRow();
                                row["UserName"] = item.Key;
                                row["Resource"] = con.Key;
                                dt.Rows.Add(row);
                            }
                        }
                        message.setDataTable(dt);
                    }
                    catch (Exception e)
                    {
                        message.AddProperty("error", "server error@MessageHandler getOnlineUser ");
                        message.AddProperty("errorMessage", e.Message);
                    }
                    finally
                    {
                        message.Command.Name = Cmd.GetOnlineUsersResponse;
                        message.SwitchDirection();
                        UniCast(contextConnection, message);
                    }
                }
            }
            catch (Exception e)
            {
                message.AddProperty("error", "server error@MessageHandler Datatable outer ");
                message.AddProperty("errorMessage", e.Message);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("server error@MessageHandler Datatable outer " + e.Message);
                try
                {
                    UniCast(contextConnection, message);
                }
                catch { }
            }
        }