示例#1
0
        /// <summary>
        /// 运行时预加载项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form_Main_Load(object sender, EventArgs e)
        {
            serverIP = IPAddress.Parse(Registry.ReadKey4Registry("PublishClient", "ServerIP"));
            uid = Registry.ReadKey4Registry("PublishClient", "CurrentUserID");
            idNumeric = int.Parse(uid);
            uid = idNumeric.ToString("D6");
            uac = Registry.ReadKey4Registry("PublishClient", "CurrentUserAccount");
            ucl = Registry.ReadKey4Registry("PublishClient", "CurrentUserName");
            upw = Registry.ReadKey4Registry("PublishClient", "CurrentUserPW");
            
            // 设置窗口属性
            this.Text = "教材补助经费评估软件 [" + ucl + "]" + " [#" + uid + "]";
            this.label_ClientName.Text = "[#" + uid + "] " + ucl;
            
            // 准备 TCP 监听
            tcpServerGet = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_BOOK_INFORMATION_PORT));
            tcpServerGet.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenBookInfo);
            

            // 准备数据集
            BookList = new BookInformationList();
            BookEval = new BookEvaluaionList();

            // 初始化列表显示
            ResetListView_Books();
        }
示例#2
0
        /// <summary>
        /// 运行时预加载项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form_Main_Load(object sender, EventArgs e)
        {
            serverIP  = IPAddress.Parse(Registry.ReadKey4Registry("PublishClient", "ServerIP"));
            uid       = Registry.ReadKey4Registry("PublishClient", "CurrentUserID");
            idNumeric = int.Parse(uid);
            uid       = idNumeric.ToString("D6");
            uac       = Registry.ReadKey4Registry("PublishClient", "CurrentUserAccount");
            ucl       = Registry.ReadKey4Registry("PublishClient", "CurrentUserName");
            upw       = Registry.ReadKey4Registry("PublishClient", "CurrentUserPW");

            // 设置窗口属性
            this.Text = "教材补助经费评估软件 [" + ucl + "]" + " [#" + uid + "]";
            this.label_ClientName.Text = "[#" + uid + "] " + ucl;

            // 准备 TCP 监听
            tcpServerGet = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_BOOK_INFORMATION_PORT));
            tcpServerGet.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenBookInfo);


            // 准备数据集
            BookList = new BookInformationList();
            BookEval = new BookEvaluaionList();

            // 初始化列表显示
            ResetListView_Books();
        }
示例#3
0
 public Form_Result(UserSet users, BookDetailList books, BookEvaluaionList ranks)
 {
     InitializeComponent();
     AppPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "const.bin";
     FileInfo fi = new FileInfo(AppPath);
     if (fi.Exists)
         LoadConstData(AppPath);
     else
     {
         FileStream fs = fi.Create(); fs.Close();
         Cost = new BookCosting();
         SaveConstData(AppPath);
     }
     UserList = users;
     BookList = books;
     BookEval = ranks;
     BuildFinalList();
     OnDisplay();
 }
示例#4
0
        private void tSMI_Sendto_Click(object sender, EventArgs e)
        {
            BookEvaluaionList data = new BookEvaluaionList();

            for (int i = 0, sz = listView_Books.SelectedItems.Count; i < sz; i++)
            {
                string        id  = listView_Books.SelectedItems[i].SubItems[0].Text;
                BookEvaluaion tmp = new BookEvaluaion();
                BookEval.tryFind(int.Parse(id), out tmp);
                data.Add(tmp);
            }
            byte[] raw;
            ToBytes <BookEvaluaionList> .GetBytes(ref data, out raw);

            TcpClientP home = new TcpClientP();

            home.Connect(new IPEndPoint(serverIP, Port.TCP_BOOK_EVALUATION_PORT));
            home.Write(raw);
            home.Close();
            MessageBox.Show("发送成功", "提示", MessageBoxButtons.OK);
        }
示例#5
0
        public Form_Result(UserSet users, BookDetailList books, BookEvaluaionList ranks)
        {
            InitializeComponent();
            AppPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "const.bin";
            FileInfo fi = new FileInfo(AppPath);

            if (fi.Exists)
            {
                LoadConstData(AppPath);
            }
            else
            {
                FileStream fs = fi.Create(); fs.Close();
                Cost = new BookCosting();
                SaveConstData(AppPath);
            }
            UserList = users;
            BookList = books;
            BookEval = ranks;
            BuildFinalList();
            OnDisplay();
        }
示例#6
0
        public void OnListenBookEvau(object sender, EventArgs e)
        {
            TcpClient tcpClient = sender as TcpClient;
            int       threadID  = Port.TCP_BOOK_EVALUATION_PORT % 10000;

            Console.WriteLine("On Listen...");
            using (NetworkStreamP buf = new NetworkStreamP(tcpClient.GetStream()))
            {
                buf.ReceiveBufferSize = tcpClient.ReceiveBufferSize;
                while (true)
                {
                    try
                    {
                        byte[]            raw; buf.Read(out raw);
                        MemoryStream      ms      = new MemoryStream(raw);
                        BinaryFormatter   bf      = new BinaryFormatter();
                        BookEvaluaionList another = bf.Deserialize(ms) as BookEvaluaionList;
                        Invoke(new AddBookEvauList_dele(AddBookEvauList), new object[] { another });
                    }
                    catch (Exception ex)
                    {
                        Type type = ex.GetType();
                        if (type == typeof(TimeoutException))
                        {   // 超时异常,不中断连接
                            Console.WriteLine("{0} [host {1}]: 数据超时失败!",
                                              DateTime.Now, threadID);
                        }
                        else
                        {
                            // 仍旧抛出异常,中断连接
                            Console.WriteLine("{0} [host {1}]: 中断连接异常原因:{2}!",
                                              DateTime.Now, threadID, type.Name);
                            throw ex;
                        }
                    }
                }
            }
        }
示例#7
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            __tmp__     = new NotStatic();
            onlineUsers = new ClientTable();
            // 加载用户列表
            rtUserPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "uesrs.bin";
            FileInfo fi = new FileInfo(rtUserPath);

            if (fi.Exists)
            {
                LoadUsersData(rtUserPath);
            }
            else
            {
                FileStream fs = fi.Create(); fs.Close();
                users = new UserSet();
                SaveUsersData(rtUserPath);
            }

            // 调整窗口属性
            uid = Registry.ReadKey4Registry("PublishServer", "CurrentUserID");
            int idNumeric = int.Parse(uid);

            uid       = idNumeric.ToString("D6");
            uac       = Registry.ReadKey4Registry("PublishServer", "CurrentUserAccount");
            ucl       = Registry.ReadKey4Registry("PublishServer", "CurrentUserName");
            this.Text = "教材补助经费评估软件 [" + ucl + "]" + " [#" + uid + "]";

            // 开始 UDP 广播
            backgroundServer = new UDPMessage();
            Thread udpThread = new Thread(
                () => {
                backgroundServer.OnBroadcast(
                    threadID: 9999,
                    port: Port.DEFAULT_BROADCAST_PORT,
                    ver: VerMessage.PUBLIC_VERIFICATION
                    );
            }
                );

            udpThread.IsBackground = true;
            udpThread.Start();

            // 初始化用户个人信息
            this.label_AdminTitle.Text += "[#" + uid + "]";
            this.label_AdminName.Text   = ucl;

            // 所有 TCP 监听端口就绪
            tcpServerLogin = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_LOGIN_PORT));
            tcpServerLogin.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenClient);
            tcpServerBookEvau = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_BOOK_EVALUATION_PORT));
            tcpServerBookEvau.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenBookEvau);

            // 所有 TCP 客户端使用前初始化
            // tcpClientUserFile = new TcpClientP();

            // 初始化教材列表
            BookList = new BookDetailList();
            BookEval = new BookEvaluaionList();

            // 初始化列表显示
            ResetListView_Books();
            ResetListView_Users();
        }
示例#8
0
 private void AddBookEvauList(BookEvaluaionList val)
 {
     BookEval.MergeByBUIDWith(val);
 }
示例#9
0
 private void tSMI_Sendto_Click(object sender, EventArgs e)
 {
     BookEvaluaionList data = new BookEvaluaionList();
     for (int i = 0, sz = listView_Books.SelectedItems.Count; i < sz; i++)
     {
         string id = listView_Books.SelectedItems[i].SubItems[0].Text;
         BookEvaluaion tmp = new BookEvaluaion();
         BookEval.tryFind(int.Parse(id), out tmp);
         data.Add(tmp);
     }
     byte[] raw;
     ToBytes<BookEvaluaionList>.GetBytes(ref data, out raw);
     TcpClientP home = new TcpClientP();
     home.Connect(new IPEndPoint(serverIP, Port.TCP_BOOK_EVALUATION_PORT));
     home.Write(raw);
     home.Close();
     MessageBox.Show("发送成功", "提示", MessageBoxButtons.OK);
 }
示例#10
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            __tmp__ = new NotStatic();
            onlineUsers = new ClientTable();
            // 加载用户列表
            rtUserPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "uesrs.bin";
            FileInfo fi = new FileInfo(rtUserPath);
            if (fi.Exists)
                LoadUsersData(rtUserPath);
            else
            {
                FileStream fs = fi.Create(); fs.Close();
                users = new UserSet();
                SaveUsersData(rtUserPath);
            }

            // 调整窗口属性
            uid = Registry.ReadKey4Registry("PublishServer", "CurrentUserID");
            int idNumeric = int.Parse(uid);
            uid = idNumeric.ToString("D6");
            uac = Registry.ReadKey4Registry("PublishServer", "CurrentUserAccount");
            ucl = Registry.ReadKey4Registry("PublishServer", "CurrentUserName");
            this.Text = "教材补助经费评估软件 [" + ucl + "]" + " [#" + uid + "]";

            // 开始 UDP 广播
            backgroundServer = new UDPMessage();
            Thread udpThread = new Thread(
                () => {
                    backgroundServer.OnBroadcast(
                        threadID: 9999,
                        port: Port.DEFAULT_BROADCAST_PORT,
                        ver: VerMessage.PUBLIC_VERIFICATION
                    );
                }
            );
            udpThread.IsBackground = true;
            udpThread.Start();

            // 初始化用户个人信息
            this.label_AdminTitle.Text += "[#" + uid + "]";
            this.label_AdminName.Text = ucl;

            // 所有 TCP 监听端口就绪
            tcpServerLogin = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_LOGIN_PORT));
            tcpServerLogin.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenClient);
            tcpServerBookEvau = new TcpListenerP(new IPEndPoint(IPAddress.Any, Port.TCP_BOOK_EVALUATION_PORT));
            tcpServerBookEvau.OnThreadTaskRequest += new TcpListenerP.ThreadTaskRequest(OnListenBookEvau);

            // 所有 TCP 客户端使用前初始化
            // tcpClientUserFile = new TcpClientP();

            // 初始化教材列表
            BookList = new BookDetailList();
            BookEval = new BookEvaluaionList();

            // 初始化列表显示
            ResetListView_Books();
            ResetListView_Users();
            

        }
示例#11
0
 private void AddBookEvauList(BookEvaluaionList val)
 {
     BookEval.MergeByBUIDWith(val);
 }