Пример #1
0
 public Client(Socket c, Server s)
 {
     connectionID++;
         this.sock = c;
         this.server = s;
         stream = new NetworkStream(sock);
         callbackRead = new AsyncCallback(this.OnReadComplete);
         callbackWrite = new AsyncCallback(this.OnWriteComplete);
         buffer = new byte[256];
         writebuffer = new byte[256];
         user = new User();
         channel = new Channel();
 }
Пример #2
0
 public long CreateChannel(User u, string cTitle, string cURL)
 {
     long channelid = -1;
     try
     {
         SqlCommand cmd = new SqlCommand("EXEC SPCreateChannel @userid,@channeltitle,@channelurl", conn);
         cmd.Parameters.AddWithValue("@userid", u.ID);
         cmd.Parameters.AddWithValue("@channeltitle", cTitle);
         cmd.Parameters.AddWithValue("@channelurl", cURL);
         channelid = long.Parse(cmd.ExecuteScalar().ToString());
         cmd.Dispose();
     }
     catch (SqlException e)
     {
         channelid = -1;
         ReportError(e.Message);
     }
     catch (Exception e)
     {
         channelid = -1;
         ReportError(e.Message);
     }
     return channelid;
 }
Пример #3
0
        public string JoinChannel(User u, long ChannelID)
        {
            string url = null;
            try
            {
                SqlCommand cmd = new SqlCommand("EXEC SPJoinChannel @userid,@channelid", conn);
                cmd.Parameters.AddWithValue("@userid", u.ID);
                cmd.Parameters.AddWithValue("@channelid", ChannelID);
                url = cmd.ExecuteScalar().ToString();
                cmd.Dispose();
            }
            catch (SqlException e)
            {
                ReportError(e.Message);
                return null;
            }
            catch (Exception e)
            {
                ReportError(e.Message);
                return null;
            }

            return url;
        }
Пример #4
0
        /*
         * public ArrayList GetFriends(string userid, int status)
        {
            SqlCommand cmd = new SqlCommand("", conn);
            ArrayList friends = new ArrayList();
            SqlDataReader reader = null;

            //if ( status != -1 ) cmd.CommandText += " AND status=" + status;
            try
            {
                cmd.CommandText = "EXEC GetFriends @userid";
                cmd.Parameters.AddWithValue("@userid", userid);
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    friends.Add(new Friend(reader[0].ToString()));
                }
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("ERR!");
            }
            finally
            {
                if (reader != null) reader.Close();
            }

            return friends;
        }
         * */
        public string UpdateChannelTitle(User u, long ChannelID, string ChannelTitle)
        {
            SqlCommand cmd;
            try
            {
                cmd = new SqlCommand("SPUpdateChannelTitle", this.conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@userid", u.ID);
                cmd.Parameters.AddWithValue("@channelid", ChannelID);
                cmd.Parameters.AddWithValue("@channeltitle", ChannelTitle);
            //				SqlParameter myParm = cmd.Parameters.Add("@channeltitle", SqlDbType.NVarChar, 120, ChannelTitle);
            //				myParm.Value = ChannelTitle;
                cmd.ExecuteNonQuery();

                return "";
                //return cmd.ExecuteScalar ().ToString ();
            }
            catch
            {
                return null;
            }
        }
Пример #5
0
 public Channel(long id, Server.Client client)
 {
     ChannelID = id;
     ChannelClient = client;
     ChannelOwner = ChannelClient.user;
 }