Пример #1
0
 private void BindAllUser()
 {
     UsersManage umg = new UsersManage();
     allusers.DataSource = umg.GetAlluserTeacher("学生");
     allusers.DataTextField = "TrueName";
     allusers.DataValueField = "UserName";
     allusers.DataBind();
 }
Пример #2
0
 private void LoadPersonInfo(string username)
 {
     Users u = new Users();
     UsersManage umg = new UsersManage();
     u = umg.Getuser(username);
     if (u.TrueName.ToString() != "")
     {
         truename.Text = u.TrueName;
     }
     if (u.UserType.ToString() != "")
     {
         Role.Text = u.UserType;
     }
 }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string username = Request.QueryString["username"].ToString().Trim();
        UsersManage UsersManage1 = new UsersManage();
        string LastLoginIP = "";
        //if (HttpContext.Current.Request.UserHostAddress != null)
        //{
        //    LastLoginIP = HttpContext.Current.Request.UserHostAddress;
        //}
        //else
        //{
        //    LastLoginIP = "";
        //}

        //Response.Write(LastLoginIP);
        if (UsersManage1.CheckUserIsOnline(username))
        {
            Session["username"] = username;
            Response.Redirect("admin/index.aspx");
        }
        else
        {
            Response.Write("<script>alert('非法用户,本页即将关闭');window.close();</script>");

        }
        //string user_IP = "";
        //string ip = Page.Request.UserHostAddress.ToString().Trim();
        ////if (context.Request.ServerVariables["HTTP_VIA"] != null) //判定是否有代理
        ////{
        ////    user_IP = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
        ////}
        ////else
        ////{
        ////    user_IP = context.Request.ServerVariables["REMOTE_ADDR"].ToString();
        ////}

        //string username = Request.QueryString["username"].ToString().Trim();
        //SqlConnection conn = DBHelper.getConnection();

        //SqlCommand cmd = new SqlCommand("usp_CheckUserOnline", conn);
        //cmd.CommandType = CommandType.StoredProcedure;
        //SqlParameter username1 = cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50);
        //SqlParameter ipaddress = cmd.Parameters.Add("@IPAddress", SqlDbType.VarChar, 50);
        //SqlParameter result = cmd.Parameters.Add("@ReturnBit", SqlDbType.Bit, 2);
        //username1.Direction = ParameterDirection.Input;
        //ipaddress.Direction = ParameterDirection.Input;
        //result.Direction = ParameterDirection.Output;
        //username1.Value = username;
        //ipaddress.Value = ip;
        //conn.Open();
        //try
        //{

        //    cmd.ExecuteNonQuery();
        //    Response.Write(result.Value.ToString());
        //    Response.Write(username);
        //    Response.Write(ip);
        //    //if (Convert.ToBoolean(result.Value))
        //    //{
        //    //    Response.Redirect("admin/main.aspx");
        //    //}
        //    //else
        //    //{
        //    //    Response.Write("<script>alert('非法用户,本页即将关闭');window.close();</script>");
        //    //}
        //    //conn.Close();
        //}
        //catch (Exception ex)
        //{
        //    conn.Close();
        //    throw ex;

        //}
    }
Пример #4
0
        private void BeginListen()
        {
            IPEndPoint iep = new IPEndPoint(IPAddress.Parse(servertip), listenport);
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            byte[] byteMessage = new byte[4068];

            //this.label1.Text = iep.ToString();
            try
            {
                socket.Bind(iep);
            }
            catch (SocketException ex)
            {
                MessageBox.Show("Socket�����������ʧ�ܣ�����ϵͳ��IP�����Ƿ���ȷ��", "����", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //listBox1.Items.Add(ex.Message.ToString());
                //throw ex;
            }
            while (true)
            {

                try
                {

                    socket.Listen(100);

                    Socket newSocket = socket.Accept();
                    Encryption ecry = new Encryption();
                    UsersManage umg = new UsersManage();
                    newSocket.Receive(byteMessage);
                    //IPAddress remoteclientip = IPAddress.Parse(((IPEndPoint)newSocket.RemoteEndPoint).Address.ToString());
                    IFormatter formatter = new BinaryFormatter();
                    MemoryStream stram = new MemoryStream(byteMessage);
                    Users u = (Users)formatter.Deserialize(stram);
                    string username = u.UserName;
                    string password = Function.PasswordMD5(ecry.Decrypto(u.Password));
                    //listBox1.Items.Add(username);
                    //listBox1.Items.Add(password);
                    int count = umg.CheckExist(username, password);
                    ////newSocket.Connect(remoteclientip,listenport);
                    if (count > 0)
                    {
                        newSocket.Send(Encoding.ASCII.GetBytes(Connectionstring + "|" + url + "|"));

                    }
                    else
                    {
                        newSocket.Send(Encoding.ASCII.GetBytes("faild|"));
                    }

                    newSocket.Shutdown(SocketShutdown.Both);
                    newSocket.Close();
                    //listBox1.Items.Add(Encoding.Default.GetString(byteMessage));
                    //MessageBox.Show(password, "dddddf");
                }

                catch (SocketException ex)
                {

                    ////this.label1.Text += ex.ToString();
                    //throw ex;
                    //throw ex;
                    //listBox1.Items.Add(ex.Message.ToString());

                }

            }
        }
Пример #5
0
 private void BindUser()
 {
     UsersManage umg=new UsersManage();
     AllUser.DataSource = umg.getalluser();
     AllUser.DataTextField = "TrueName";
     AllUser.DataValueField = "UserName";
     AllUser.DataBind();
     AllUser.Items.Insert(0, new ListItem("==选择用户==", ""));
 }
Пример #6
0
 /// <summary>
 /// 绑定用户在网络中心的时间段
 /// </summary>
 /// <param name="username"></param>
 private void BinUserTimeDuring(string username)
 {
     UsersManage umg = new UsersManage();
     int starttime = Convert.ToInt32(umg.GetUserAddTime(username));
     int endtime = Convert.ToInt32(DateTime.Now.Year.ToString());
     for (int i = starttime; i <= endtime; i++)
     {
         ListItem li = new ListItem();
         li.Text = i.ToString() + "年";
         li.Value = i.ToString();
         yearuntab4.Items.Add(li);
     }
     yearuntab4.Items.Insert(0, new ListItem("==选择年份==", ""));
 }
Пример #7
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (Session["username"] == null)
        {
            Function.CheckIstimeout();
        }
        else
        {
            UsersManage umg = new UsersManage();
            int sucess = 0;
            int faild = 0;
            SMS sms = new SMS();
            SendSMS ssm = GetSMSConf();
            sms.Number = "";
            string recivers = "";
            string recivername = "";
            if (phonebooklist.SelectedValue.ToString() != "")
            {
                DataTable dt = umg.getalluser(Convert.ToInt32(phonebooklist.SelectedValue));
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows.Count == 1)
                    {
                        sms.Number = dt.Rows[0]["phone"].ToString();
                        recivers = dt.Rows[0]["TrueName"].ToString().Trim();
                        recivername += dt.Rows[0]["UserName"].ToString().Trim();
                    }
                    else
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sms.Number += dt.Rows[i]["phone"].ToString().Trim() + "|";
                            recivers += dt.Rows[i]["TrueName"].ToString().Trim() + "、";
                            recivername += dt.Rows[i]["UserName"].ToString().Trim() + "+";
                        }
                    }
                }

            }
            else
            {
                if (CheckBoxList1.Items.Count == 1)
                {
                    sms.Number = umg.Getuser(CheckBoxList1.Items[0].Value.ToString().Trim()).Phone;
                }
                else
                {
                    for (int i = 0; i < CheckBoxList1.Items.Count; i++)
                    {

                        if (CheckBoxList1.Items[i].Selected)
                        {
                            sms.Number += umg.Getuser(CheckBoxList1.Items[i].Value.ToString().Trim()).Phone + "|";
                            recivers += CheckBoxList1.Items[i].Text.ToString().Trim() + "、";
                            recivername += CheckBoxList1.Items[i].Value.ToString().Trim() + "+";
                        }
                    }
                }
            }
            if (sms.Number.ToString().Trim() != "")
            {
                sms.Scon = SMSContent.Text.ToString();
                Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint Ipe = new IPEndPoint(IPAddress.Parse(ssm.Ip), int.Parse(ssm.Port));
                try
                {
                    socket.Connect(Ipe);
                    if (socket.Connected)
                    {
                        MemoryStream stream = new MemoryStream();
                        IFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(stream, sms);
                        stream.Flush();
                        byte[] smsbyte = stream.ToArray();
                        socket.Send(smsbyte);
                        byte[] reciver = new byte[128];
                        socket.Receive(reciver);
                        string reciverstring = Encoding.Default.GetString(reciver).ToString().Trim();
                        if (Convert.ToBoolean(reciverstring))
                        {
                            sucess++;
                        }
                        else
                        {
                            faild++;
                        }
                    }
                    if (sucess > 0)
                    {

                        NoticesManager nmg = new NoticesManager();
                        nmg.AddNotices("", Session["username"].ToString(), recivers.Substring(0, recivers.Length - 1), SMSContent.Text.ToString(), DateTime.Now, "短信", 0, recivername.Substring(0, recivername.Length - 1));
                        ScriptManager.RegisterClientScriptBlock(this.UpdatePanel2, UpdatePanel2.GetType(), "", "alert('短信接发送成功')", true);
                        SMSContent.Text = "";
                        for (int i = 0; i < CheckBoxList1.Items.Count; i++)
                        {
                            CheckBoxList1.Items[i].Selected = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this.UpdatePanel2, UpdatePanel2.GetType(), "", "alert('短信接收者为空')", true);
            }
        }
    }
Пример #8
0
 private void BindUser()
 {
     UsersManage umg = new UsersManage();
     CheckBoxList1.DataSource = umg.getalluser();
     CheckBoxList1.DataTextField = "TrueName";
     CheckBoxList1.DataValueField = "UserName";
     CheckBoxList1.DataBind();
 }
Пример #9
0
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (UserType.SelectedValue.ToString().Trim() == "")
     {
         usertypelist.Visible = false;
     }
     else
     {
         UsersManage umg=new UsersManage();
         usertypelist.Visible = true;
         NoticeObj.DataSource = umg.GetAllUserByType( UserType.SelectedValue.ToString().Trim());
         NoticeObj.DataTextField = "TrueName";
         NoticeObj.DataValueField = "UserName";
         NoticeObj.DataBind();
     }
 }