コード例 #1
0
        /// <summary>
        /// 构造函数。
        /// </summary>
        /// <param name="sci"></param>
        /// <param name="userInfo"></param>
        /// <param name="ports"></param>
        public HostListenService(StartClassInfo sci,UserInfo userInfo, PortSettings ports)
        {
            this.sci = sci;
            this.userInfo = userInfo;
            this.ports = ports;

            this.udpSocket = new UDPSocket(this.ports.ClientCallback);
            this.udpSocket.Changed += this.RaiseChanged;
            this.udpSocket.DataArrival += new SocketDataArrivalEventHandler<Msg>(delegate(Msg sender)
            {
                try
                {
                    Thread thread = new Thread(new ThreadStart(delegate()
                    {
                        this.ReceiveClientData(sender);
                    }));
                    thread.IsBackground = true;
                    thread.Start();
                }
                catch (Exception e)
                {
                    UtilTools.OnExceptionRecord(e, typeof(UDPSocket));
                }
            });
            this.workUpTcpService = new WorkUpTcpService(this.ports.FileUpTransfer);
            this.workUpTcpService.Changed += this.RaiseChanged;
            this.workUpTcpService.DataArrival += new SocketDataArrivalEventHandler<FileMSG>(delegate(FileMSG sender)
            {
                this.ReceiveClientData(sender as UploadFileMSG);
            });
        }
コード例 #2
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 /// <param name="service"></param>
 public StudentLoginWindow(ICoreService service)
     : base(service)
 {
     this.hostIP = IPAddress.Parse(string.Format("{0}", service["host_ip"]));
     this.prots = service["portsettings"] as PortSettings;
     this.socket = new UDPSocket(this.prots.HostOrder);
     this.socket.DataArrival += this.receiveHostData;
     this.socket.Changed += this.showMessage;
     InitializeComponent();
 }
コード例 #3
0
 /// <summary>
 /// 
 /// </summary>
 public override void Dispose()
 {
     if (this.udpBroadcast != null)
     {
         this.udpBroadcast.Close();
         this.udpBroadcast.DataArrival -= this.ReceiveDataArrival;
         this.udpBroadcast = null;
     }
     if (this.fileDownTcpService != null)
     {
         this.fileDownTcpService.StopListen();
         this.fileDownTcpService.DataArrival -= this.ReceiveIssueWorkFile;
     }
     base.Dispose();
 }
コード例 #4
0
ファイル: UCLogin.cs プロジェクト: jeasonyoung/csharp_sfit
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UCLogin_Load(object sender, EventArgs e)
        {
            try
            {
                this.OnMessageEvent(MessageType.Normal, string.Empty);
                if (this.loginMethod != EnumLoginMethod.UnifiedLogin)
                {
                    this.txtUsername.DropDownStyle = ComboBoxStyle.DropDownList;
                    if (this.students != null)
                    {
                        foreach (Student stu in this.students)
                        {
                            string code = stu.StudentCode;
                            if (!string.IsNullOrEmpty(code) && code.Length > 2)
                            {
                                code = code.Substring(code.Length - 2);
                            }
                            stu.StudentName = string.Format("[{0}]{1}", code, stu.StudentName);
                        }
                        this.txtUsername.BeginUpdate();
                        this.txtUsername.DataSource = this.students;
                        this.txtUsername.DisplayMember = "StudentName";
                        this.txtUsername.ValueMember = "StudentID";
                        this.txtUsername.EndUpdate();
                    }
                    this.panelWork.Visible = (this.loginMethod == EnumLoginMethod.Password);
                }
                else
                {
                    this.panelWork.Visible = true;
                }

                #region 建立UDP监听。
                this.ports = this.CoreService["portsettings"] as PortSettings;
                this.hostIP = IPAddress.Parse(string.Format("{0}", this.CoreService["host_ip"]));

                this.socket = new UDPSocket(this.ports.HostOrder);
                this.socket.Changed += new Yaesoft.SFIT.Client.RaiseChangedHandler(delegate(string content)
                {
                    this.OnMessageEvent(MessageType.Normal, content);
                });
                this.socket.DataArrival += this.ReceiveHostData;
                this.socket.Start();
                #endregion
            }
            catch (Exception x)
            {
                this.OnMessageEvent(MessageType.Normal | MessageType.PopupWarn, "发生异常:" + x.Message);
            }
        }
コード例 #5
0
 /// <summary>
 /// 
 /// </summary>
 protected override void BeginRun()
 {
     if ((this.ports = this["portsettings"] as PortSettings) != null)
     {
         (this.udpBroadcast = new UDPSocket(this.ports.HostBroadcast)).Start();
     }
 }