Exemple #1
0
        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);
        }
Exemple #2
0
        static FileUploadData FillUploadData(SqlDataReader dr)
        {
            FileUploadData d = new FileUploadData();

            d.Direction        = Convert.ToInt32(dr["Direction"]);
            d.FileLastModified = SQLLib.GetDTUTC(dr["FileLastModified"]);
            d.ID          = Convert.ToInt64(dr["ID"]);
            d.LastUpdated = SQLLib.GetDTUTC(dr["DTUpdated"]);
            d.MachineID   = Convert.ToString(dr["MachineID"]);
            d.MD5CheckSum = Convert.ToString(dr["MD5Sum"]);
            d.OverrideMeteredConnection = Convert.ToInt32(dr["OverrideMeteredConnection"]) == 1 ? true : false;
            d.ProgressSize       = Convert.ToInt64(dr["ProgressSize"]);
            d.RemoteFileLocation = Convert.ToString(dr["RemoteFileLocation"]);
            d.Size        = Convert.ToInt64(dr["Size"]);
            d.RequestOnly = Convert.ToInt32(dr["RequestOnly"]) == 1 ? true : false;
            return(d);
        }
Exemple #3
0
        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);
        }