Example #1
0
        // 当时间发生的时候需要进行的逻辑处理等
        //     在这里仅仅是一种方式,可以实现这样的方式很多.
        private static void TimeEvent(object source, ElapsedEventArgs e)
        {
            // 得到 hour minute second   如果等于某个值就开始执行某个程序。
            DateTime datetime  = e.SignalTime;
            int      intHour   = e.SignalTime.Hour;
            int      intMinute = e.SignalTime.Minute;
            int      intSecond = e.SignalTime.Second;

            try
            {
                for (int i = 0; i < keywords.Rows.Count; i++)
                {
                    //keywords.Rows[i]["KNUM"] = int.Parse(keywords.Rows[i]["KNAME"].ToString()) + 1;
                    string _kname = keywords.Rows[i]["KNAME"].ToString();
                    string _upsql = " update pno_keyword set knum =" + int.Parse(keywords.Rows[i]["KNUM"].ToString())
                                    + "  where kname = '" + _kname + "'";
                    int n = DBHelpSql.ExecuteSql(_upsql);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("更新字典库出现错误");

                // throw;
            }
        }
Example #2
0
        public string implementNew()
        {
            string datetimes = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            string fg        = " select count(1) as num from IpMsg where ip = @dz   ";
            object oo        = DBHelpSql.ExecuteScalar(fg, new SqlParameter("@dz", label6.Text + "#" + label3.Text));

            if ((int)oo > 0)
            {
                return("外网IP已存在");
            }
            else
            {
                string         sql   = " insert into IpMsg values(@ipguid,@ip,@cjdate,@qy);  select @@IDENTITY  ";
                SqlParameter[] param =
                {
                    new SqlParameter("@ipguid", Guid.NewGuid()),
                    new SqlParameter("@ip",     label6.Text + "#" + label3.Text),
                    new SqlParameter("@cjdate", datetimes),
                    new SqlParameter("@qy",     "1")
                };
                //将用户发送的消息存储到数据库中
                object obj = DBHelpSql.ExecuteScalar(sql, param);
                if (obj != null)
                {
                    return("添加成功");
                }
                else
                {
                    return("添加失败");
                }
            }
        }
Example #3
0
        /// <summary>
        /// websocket客户端登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.Trim();
            string userpwd  = textBox2.Text.Trim();

            if (username != "" && userpwd != "")
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@username", username),
                    new SqlParameter("@userpwd",  userpwd)
                };
                string sql = " select name from users where username=@username and userpwd=@userpwd and userzt='1' ";
                object obj = DBHelpSql.ExecuteScalar(sql, param);
                if (obj != null)
                {
                    // 登录后获取当前登录用户名称
                    string    name = obj.ToString();
                    frmClient frm  = new frmClient();
                    frm.clientName = name;
                    frm.username   = username;
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码输入有误");
                }
            }
            else
            {
                MessageBox.Show("请输入用户名或密码");
            }
        }
Example #4
0
        private static Dictionary <string, List <string> > msgDictionary = new Dictionary <string, List <string> >(); //消息历史
        #endregion

        public static void initKeyWords()
        {
            try
            {
                string sqlCmd = " select * from pno_keyword ";
                keywords = DBHelpSql.Query(sqlCmd).Tables[0];
            }
            catch (Exception) { }
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string userName = textBox1.Text.ToString().Trim();
            string userPwd  = textBox2.Text.ToString().Trim();

            if (userName != "")
            {
                if (userPwd != "")
                {
                    //string sql = " select * from Userright where uname=@uname and upwd=@upwd ";
                    SqlParameter[] param =
                    {
                        new SqlParameter("@uname", userName),
                        new SqlParameter("@wpwd",  userPwd),
                    };
                    DataSet users = DBHelpSql.RunProcedureGetDS("pro_selUser", param);


                    //object nnn = DBHelpSql.GetSingle("select * from Userright ");
                    if (users.Tables[0].Rows.Count > 0)
                    {
                        cz.User = new Userright(
                            (int)users.Tables[0].Rows[0]["uid"],
                            users.Tables[0].Rows[0]["uguid"].ToString(),
                            users.Tables[0].Rows[0]["uname"].ToString(),
                            users.Tables[0].Rows[0]["upwd"].ToString(),
                            users.Tables[0].Rows[0]["upower"].ToString(),
                            users.Tables[0].Rows[0]["ustatic"].ToString()
                            );
                        Main form = new Main();
                        form.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码不正确");
                    }
                }
                else
                {
                    MessageBox.Show("密码不能为空");
                }
            }
            else
            {
                MessageBox.Show("用户名不能为空");
            }
        }
Example #6
0
        // 当时间发生的时候需要进行的逻辑处理等
        //     在这里仅仅是一种方式,可以实现这样的方式很多.
        private static void TimeEvent(object source, ElapsedEventArgs e)
        {
            // 得到 hour minute second   如果等于某个值就开始执行某个程序。
            DateTime datetime  = e.SignalTime;
            int      intHour   = e.SignalTime.Hour;
            int      intMinute = e.SignalTime.Minute;
            int      intSecond = e.SignalTime.Second;

            for (int i = 0; i < keywords.Rows.Count; i++)
            {
                string _kname = keywords.Rows[i]["KNAME"].ToString();
                string _upsql = " update pno_keyword set knum =" + int.Parse(keywords.Rows[i]["KNAME"].ToString()) + 1
                                + "  where kname = '" + _kname + "'";
                int n = DBHelpSql.ExecuteSql(_upsql);
            }
        }
Example #7
0
        public string implement()
        {
            string output = ExecuteCom("net user xjadmin root123 /add", 2);

            if (output.Contains("命令成功完成。"))
            {
                string aaa = ExecuteCom("net user xjadmin /del", 2);
                if (aaa.Contains("命令成功完成。"))
                {
                    string bbb = ExecuteCom("net user admin /active:yes", 2);
                    if (bbb.Contains("命令成功完成。"))
                    {
                        string datetimes = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

                        string fg = " select count(1) as num from IpMsg where ip = @dz   ";

                        object oo = DBHelpSql.ExecuteScalar(fg, new SqlParameter("@dz", label1.Text));
                        if ((int)oo > 0)
                        {
                            return("新建用户已存在IP");
                        }
                        else
                        {
                            string         sql   = " insert into IpMsg values(@ipguid,@ip,@cjdate,@qy);  select @@IDENTITY  ";
                            SqlParameter[] param =
                            {
                                new SqlParameter("@ipguid", Guid.NewGuid()),
                                new SqlParameter("@ip",     label1.Text),
                                new SqlParameter("@cjdate", datetimes),
                                new SqlParameter("@qy",     "1")
                            };
                            //将用户发送的消息存储到数据库中
                            object obj = DBHelpSql.ExecuteScalar(sql, param);
                            if (obj != null)
                            {
                                return("新建用户并添加成功");
                            }
                            else
                            {
                                return("新建用户但添加数据库失败");
                            }
                        }
                    }
                }
            }
            return("添加失败");
        }
Example #8
0
        /// <summary>
        /// 发送消息按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            DateTime dt        = DateTime.Now.ToLocalTime();
            string   dtime     = dt.ToString("HH:mm:ss");
            string   datetimes = dt.ToString("yyyy-MM-dd HH:mm:ss");

            //判断客户端是否连接上了服务器
            if (websocket.State == WebSocketState.Open)
            {
                var msg = textBox3.Text.Trim();
                if (msg == "")
                {
                    MessageBox.Show("不能发送空消息");
                    return;
                }
                //本方返显消息
                websocket.Send(string.Format("{0}:{1}", clientName, msg));
                this.listBox1.Items.Add(string.Format("{0}", dtime + ":" + msg));

                this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight) + 2;
                string         sql   = " insert into chatMessage values(@name,@message,@datetimes) ;  select @@IDENTITY  ";
                SqlParameter[] param =
                {
                    new SqlParameter("@name",      username),
                    new SqlParameter("@message",   msg),
                    new SqlParameter("@datetimes", datetimes)
                };
                //将用户发送的消息存储到数据库中
                object obj = DBHelpSql.ExecuteScalar(sql, param);
                if (obj != null)
                {
                    textBox3.Text = "";
                }
            }
            else if (websocket.State == WebSocketState.Connecting)
            {
                MessageBox.Show("正在连接,请稍后!");
            }
            else
            {
                MessageBox.Show("没有连接到服务器!");
            }
        }