Esempio n. 1
0
        // 2013-12-30: GreenRose
        // recommender controls Init
        public void InitRecommenderControl()
        {
            string      configPath = System.IO.Path.GetFullPath("Config.ini");
            IniFileEdit configInfo = new IniFileEdit(configPath);

            this.lblDefaultUrl.Text = configInfo.GetIniValue("DefaultURL", "DEFURL");

            if (_Kind == (int)UserKind.Recommender)
            {
                this.txtRecommenderUrl.Enabled = true;
            }
            else
            {
                this.txtRecommenderUrl.Enabled = false;
            }
        }
Esempio n. 2
0
        private void Loginuser_Load(object sender, EventArgs e)
        {
            string configPath = System.IO.Path.GetFullPath("Config.ini");

            IniFileEdit configInfo = new IniFileEdit(configPath);

            Database._IP         = configInfo.GetIniValue("Database", "IP");
            Users.WebResourceUrl = configInfo.GetIniValue("Web", "Resource");

            // server initialize
            string port = configInfo.GetIniValue("Chatting", "TcpPort");

            Server server = Server.GetInstance();

            server.AttachHandler(Users.GetInstance().NotifyOccured);
            server.AttachHandler(Chat.GetInstance().NotifyOccured);
            server.AttachHandler(Game.GetInstance().NotifyOccured);

            server.Connect("127.0.0.1", port);
        }
Esempio n. 3
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (textBoxSourcePath.Text.Trim().Length == 0 ||
                textBoxTargetPath.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入路径.");
                return;
            }

            if (Directory.Exists(textBoxSourcePath.Text) == false ||
                Directory.Exists(textBoxTargetPath.Text) == false)
            {
                MessageBox.Show("不正确的路径");
                return;
            }

            DateTime curTime      = DateTime.Now;
            string   newFolder    = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", curTime.Year, curTime.Month, curTime.Day, curTime.Hour, curTime.Minute, curTime.Second);
            string   targetFolder = string.Format("{0}\\{1}", textBoxTargetPath.Text, newFolder);

            if (Directory.CreateDirectory(targetFolder) == null)
            {
                MessageBox.Show("无法创建新的运行路径");
                return;
            }

            try
            {
                CopyFolder(textBoxSourcePath.Text, targetFolder);

                Process processInfo = RunServer(targetFolder);

                if (processInfo == null)
                {
                    return;
                }

                int serverPort = _StartPort;

                while (true)
                {
                    bool foundPort = false;

                    foreach (RunServerInfo runInfo in _ServerList)
                    {
                        if (runInfo._ServerPort == serverPort)
                        {
                            foundPort = true;
                            break;
                        }
                    }

                    if (foundPort == false)
                    {
                        break;
                    }

                    serverPort++;
                }

                IniFileEdit iniFile = new IniFileEdit(targetFolder + "\\Config.ini");
                iniFile.SetIniValue("Chatting", "TcpPort", serverPort.ToString());
                iniFile.SetIniValue("Download", "Folder", textBoxDownloadPath.Text);

                if (_ServerList.Count > 0)
                {
                    RunServerInfo oldServerInfo = _ServerList[_ServerList.Count - 1];

                    Client client = new Client(null);
                    if (client.Connect("127.0.0.1", oldServerInfo._ServerPort.ToString(), ProtocolType.Tcp) == true)
                    {
                        ResultInfo resultInfo = new ResultInfo();
                        client.Send(NotifyType.Notify_OldServer, resultInfo);
                    }
                }

                RunServerInfo serverInfo = new RunServerInfo();

                serverInfo._StarTime       = curTime;
                serverInfo._RunFolder      = newFolder;
                serverInfo._DownloadFolder = textBoxDownloadPath.Text;
                serverInfo._ServerPort     = serverPort;
                serverInfo._ProcessInfo    = processInfo;

                _ServerList.Add(serverInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }

            _UpdateServerList = true;
            //MessageBox.Show( "新的更新服务器已成功启动");
        }