コード例 #1
0
ファイル: Chat.cs プロジェクト: VulpesSARL/Fox-SDC
        public RESTStatus GetPendingChatMessages(SQLLib sql, object dummy, NetworkConnectionInfo ni)
        {
            if (ni.HasAcl(ACLFlags.ComputerLogin) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            string MachineID = ni.Username;

            ChatList2      = new PushChatMessageList();
            ChatList2.List = new List <PushChatMessage>();

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("select * from Chats where [Read]=0 AND MachineID=@m AND ToClient=1 ORDER BY DT ASC",
                                                     new SQLParam("@m", MachineID));
                while (dr.Read())
                {
                    PushChatMessage pch = new PushChatMessage();
                    pch.ID   = Convert.ToInt64(dr["ID"]);
                    pch.DT   = SQLLib.GetDTUTC(dr["DT"]);
                    pch.Name = Convert.ToString(dr["Name"]);
                    pch.Text = Convert.ToString(dr["Text"]);
                    ChatList2.List.Add(pch);
                }
                dr.Close();
            }

            return(RESTStatus.Success);
        }
コード例 #2
0
ファイル: Chat.cs プロジェクト: VulpesSARL/Fox-SDC
        public RESTStatus GetPendingChatData(SQLLib sql, object dummy, NetworkConnectionInfo ni, string MachineID)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            ChatList      = new PushChatMessageList();
            ChatList.List = new List <PushChatMessage>();
            List <Int64> IDs = new List <long>();

            lock (ni.sqllock)
            {
                SqlDataReader dr = sql.ExecSQLReader("select * from Chats where [Read]=0 AND MachineID=@m AND ToClient=0 ORDER BY DT ASC",
                                                     new SQLParam("@m", MachineID));
                while (dr.Read())
                {
                    IDs.Add(Convert.ToInt64(dr["ID"]));
                    PushChatMessage pch = new PushChatMessage();
                    pch.ID   = Convert.ToInt64(dr["ID"]);
                    pch.DT   = SQLLib.GetDTUTC(dr["DT"]);
                    pch.Name = Convert.ToString(dr["Name"]);
                    pch.Text = Convert.ToString(dr["Text"]);
                    ChatList.List.Add(pch);
                }
                dr.Close();
            }

            foreach (Int64 id in IDs)
            {
                lock (ni.sqllock)
                {
                    sql.ExecSQL("UPDATE Chats SET [Read]=1 WHERE ID=@id",
                                new SQLParam("@id", id));
                }
            }

            return(RESTStatus.Success);
        }