Exemplo n.º 1
0
        public Main()
        {
            InitializeComponent();

            this.dataGridView1.DataSource
                = loadData();

            dataGridView1.Columns["Id"].Visible = false;
            dataGridView1.Columns["Password"].Visible = false;
            dataGridView1.Columns["CreateTime"].Visible = false;

            LogicHandle lgH = new LogicHandle();
            try
            {
                ServiceController serviceObject = lgH.GetServiceObject();

                string status = serviceObject.Status.ToString();

                if (status == "Running")
                {
                    label1.Text = "服务已启动!";
                    //Operate(true);
                }
                else
                {
                    label1.Text = "服务已停止!";
                };
            }
            catch (Exception ex)
            {

                string exMsg = ex.Message;

                if (exMsg == "在计算机“.”上没有找到服务 LYSendMessage。")
                {
                    label1.Text = "服务未安装,请先安装服务!";

                };
            };
        }
Exemplo n.º 2
0
        private void SevUp_Click(object sender, EventArgs e)
        {
            LogicHandle lgH
                = new LogicHandle();
            ServiceController serviceObject
                = lgH.GetServiceObject();
            try
            {
                lgH.StarService(serviceObject);

                label1.Text = "服务已启动!";
            }
            catch (Exception ex)
            {

                label1.Text = "启动服务失败:" + ex.Message;
            };
        }
Exemplo n.º 3
0
        private void SevDown_Click(object sender, EventArgs e)
        {
            LogicHandle lgH = new LogicHandle();
            ServiceController serviceObject
                = lgH.GetServiceObject();

            try
            {

                lgH.StopService(serviceObject);
                label1.Text = "服务已停止!";

            }
            catch (Exception ex)
            {

                label1.Text = "停止服务发生错误:" + ex.Message.ToString();
            };
        }