Exemplo n.º 1
0
 void OnRegistering(RegisterEntiy regInfo)
 {
     if (Registering != null)
     {
         Registering(regInfo);
     }
 }
Exemplo n.º 2
0
        public bool AddProxy(RegisterEntiy info)
        {
            var cmd = conn.CreateCommand();

            cmd.CommandText = "INSERT INTO TProxyClient VALUES(@Ip,@HttpPort,@SocketPort,@UName,@UPwd,@Time)";
            SqlParameter ip         = new SqlParameter("@Ip", info.Ip);
            SqlParameter httpPort   = new SqlParameter("@HttpPort", info.HttpPort);
            SqlParameter socketPort = new SqlParameter("@SocketPort", info.SocketPort);
            SqlParameter uName      = new SqlParameter("@UName", info.UName);
            SqlParameter uPwd       = new SqlParameter("@UPwd", info.UPwd);
            SqlParameter time       = new SqlParameter("@Time", DateTime.Now.Ticks);

            cmd.Parameters.Add(ip);
            cmd.Parameters.Add(httpPort);
            cmd.Parameters.Add(socketPort);
            cmd.Parameters.Add(uName);
            cmd.Parameters.Add(uPwd);
            cmd.Parameters.Add(time);
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                cmd.Dispose();
                return(false);
            }
            cmd.Dispose();
            return(true);
        }
Exemplo n.º 3
0
        public bool RegisterProxy(RegisterEntiy regInfo)
        {
            IProxyServiceCallback callbackInstance = OperationContext.Current.GetCallbackChannel <IProxyServiceCallback>();

            if (!CallBackDic.Keys.Contains(regInfo.Ip))
            {
                if (dataManager.AddProxy(regInfo))
                {
                    CallBackDic.Add(regInfo.Ip, callbackInstance);
                    OnRegistering(regInfo);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }