Пример #1
0
        /// <summary>
        /// 应用程序启动
        /// </summary>
        protected void Application_Start(object sender, EventArgs e)
        {
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;

            Init();

            UserManager.Init();

            gmt.Server.Load();
            gmt.Server.newLoad();

            Log.Start();
            Network.Start();
            FTPManager.Load();
            TableManager.Start();
            TextManager.Load();
            RevolvingManager.Start();
            NoticeManager.Load();

            ActivityManger.Start();
            ServerListConfig.Load();
            GMTActivityMananger.start();
            GiftTable.Start();
            TimedMailSender.Init();
            RevolvingManager.UpdateService();
            PayType.LoadPayType();
        }
        /// <summary>
        /// 添加公告按钮点击响应
        /// </summary>
        //protected void addNoticeButton_Click(object sender, EventArgs e)
        //{
        //    if (this.titleTextBox.Text == "" ||
        //        this.detailTextBox.Text == "" ||
        //        this.idTextBox.Text == "")
        //    {
        //        return;
        //    }

        //    int id;
        //    if (!int.TryParse(this.idTextBox.Text, out id))
        //    {
        //        this.outputLabel.Text = "编号格式不对";
        //        return;
        //    }

        //    if (id < 50000 || id >= 52000)
        //    {
        //        this.outputLabel.Text = "编号只能在[50000,52000)之间";
        //        return;
        //    }

        //    Server	server	= Session["Server"] as Server;
        //    string account = Session["user"] as string;
        //    bool	isAdded	= NoticeManager.AddNotice(server, id, this.titleTextBox.Text, this.detailTextBox.Text.Replace("\r\n", "\\n"));
        //    NoticeManager.Save();

        //    if (isAdded)
        //    {
        //        this.noticeListBox.Items.Add(new ListItem(id + " " + this.titleTextBox.Text, id.ToString()));
        //    }
        //    else
        //    {
        //        for (int i = 0; i < this.noticeListBox.Items.Count; ++i)
        //        {
        //            ListItem item = this.noticeListBox.Items[i];
        //            if (item.Value == id.ToString())
        //            {
        //                item.Text = id + " " + this.titleTextBox.Text;
        //                break;
        //            }
        //        }
        //    }

        //    Notice.SendCommand(account, server, string.Format("ACN({0},{0},\"{2}\",{1},\"{3}\")", id, id + 10000, this.titleTextBox.Text, this.detailTextBox.Text.Replace("\r\n", "\\n")), text => this.outputLabel.Text = text);
        //}

        /// <summary>
        /// 移除公告按钮点击响应
        /// </summary>
        //protected void removeNoticeButton_Click(object sender, EventArgs e)
        //{
        //    if (this.noticeListBox.SelectedIndex < 0) { return; }

        //    Server server = Session["Server"] as Server;
        //    string account = Session["user"] as string;

        //    int id = int.Parse(this.noticeListBox.SelectedItem.Value);
        //    if (Notice.SendCommand(account, server, string.Format("DCN({0})", id), text => this.outputLabel.Text = text))
        //    {
        //        NoticeManager.RemoveNotice(server, id);
        //        NoticeManager.Save();
        //        this.noticeListBox.Items.RemoveAt(this.noticeListBox.SelectedIndex);
        //    }
        //}

        /// <summary>
        /// 发送到服务器按钮点击响应
        /// </summary>
        protected void sendButton_Click(object sender, EventArgs e)
        {
            Server server  = Session["Server"] as Server;
            string account = Session["user"] as string;

            foreach (var data in NoticeManager.GetNotice(server).List)
            {
                Notice.SendCommand(account, server, string.Format("ACN({0},{0},\"{2}\",{1},\"{3}\")", data.Id, data.Id + 10000, data.Title, data.Content), text => this.outputLabel.Text = text);
            }
        }
        /// <summary>
        /// 复制公告钮点击响应
        /// </summary>
        protected void copyNoticeButton_Click(object sender, EventArgs e)
        {
            gmt.Server server  = Session["Server"] as gmt.Server;
            string     account = Session["user"] as string;

            if (server == null)
            {
                return;
            }

            foreach (var item in this.selectListBox.Items)
            {
                if (item.ToString() == this.serverList.Text)
                {
                    continue;
                }

                NoticeManager.Copy(account, server, gmt.Server.GetServer(item.ToString()));
            }

            NoticeManager.Save();
        }