Exemplo n.º 1
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();
 }
Exemplo n.º 2
0
        private void openDataFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            string       path       = this.openDataFileDialog.FileName;
            FileStream   fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader rd         = new BinaryReader(fileStream);

            rd.BaseStream.Seek(0, SeekOrigin.Begin);
            byte[]          raw     = rd.ReadBytes((int)rd.BaseStream.Length);
            MemoryStream    buf     = new MemoryStream(raw);
            BinaryFormatter bf      = new BinaryFormatter();
            BookDetailList  another = bf.Deserialize(buf) as BookDetailList;

            // 释放文件流资源
            fileStream.Flush();
            fileStream.Close();
            fileStream.Dispose();
            // 合并数据表
            BookList.MergeWith(another);
            RefreshAllBookList();
        }
Exemplo n.º 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();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
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();
            

        }