Ejemplo n.º 1
0
        /// <summary>
        /// 批量删除 批量启用 批量禁用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <Int32>  list  = new List <Int32>();
            List <String> links = new List <String>();

            foreach (RepeaterItem item in Repeater1.Items)
            {
                CheckBox    chkbox   = item.FindControl("id") as CheckBox;
                HiddenField linkname = item.FindControl("linkname") as HiddenField;
                if (chkbox.Checked)
                {
                    list.Add(Convert.ToInt32(chkbox.Text));
                    links.Add(linkname.Value);
                }
            }

            if (list.Count > 0)
            {
                String id  = String.Join(",", list.ToArray());
                Int32  arg = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);
                if (arg == -1)
                {
                    db.ExecuteCommand(String.Format("DELETE FROM [t_links] WHERE id in ({0})", id));
                    T_LogsHelper.Append("批量删除友情连接:" + String.Join(",", links.ToArray()), Admin.ID);
                }
            }

            BindData();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 会员登录
        /// </summary>
        /// <param name="membername"></param>
        /// <param name="password"></param>
        public static String Login(String membername, String password)
        {
            IJsonResult msg = new IJsonResult {
                Status = false, Text = "用户名或密码输入错误!"
            };

            ExecuteObject obj = new ExecuteObject();

            obj.tableName = "T_Members";
            obj.cmdtype   = CmdType.SELECT;
            obj.terms.Add("MemberName", membername);
            obj.terms.Add("PassWord", EncryptHelper.MD5Upper32(password));

            T_MembersEntity data = db.ExecuteObject <T_MembersEntity>(obj);

            if (!String.IsNullOrEmpty(data.MemberName))
            {
                if (!data.Status)
                {
                    msg.Text = "当前账号无法登录,请与管理员联系!";
                    T_LogsHelper.Append("会员:" + data.MemberName + "尝试登录会员中心,登录失败!", data.ID);
                }
                else
                {
                    msg.Text   = null;
                    msg.Status = true;

                    data.LastSignTime = DateTime.Now;
                    db.ExecuteCommand <T_MembersEntity>(data, CmdType.UPDATE);
                    T_LogsHelper.Append("会员:" + data.MemberName + "成功登录会员中心!", data.ID);
                    Member = data;
                }
            }
            return(JsonConvert.SerializeObject(msg));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 批量删除 批量启用 批量禁用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 arg = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);

            if (arg == -2)
            {
                db.ExecuteCommand("DELETE FROM [t_logs]");
                T_LogsHelper.Append("清空操作日志.", Admin.ID);
            }
            else if (arg == -1)
            {
                List <Int32> list = new List <Int32>();
                foreach (RepeaterItem item in Repeater1.Items)
                {
                    CheckBox chkbox = item.FindControl("id") as CheckBox;
                    if (chkbox.Checked)
                    {
                        list.Add(Convert.ToInt32(chkbox.Text));
                    }
                }

                if (list.Count > 0)
                {
                    String id = String.Join(",", list.ToArray());
                    db.ExecuteCommand(String.Format("DELETE FROM [t_logs] WHERE id in ({0})", id));
                    T_LogsHelper.Append("批量操作日志.", Admin.ID);
                }
            }
            BindData();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 列表事件
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            String      ID       = ((CheckBox)e.Item.FindControl("ID")).Text;
            HiddenField linkname = e.Item.FindControl("linkname") as HiddenField;

            if (e.CommandName == "del")
            {
                db.ExecuteCommand(String.Format("DELETE FROM [t_links] WHERE id in ({0})", ID));
                T_LogsHelper.Append("删除友情连接:" + linkname.Value, Admin.ID);
            }
            BindData();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 列表事件
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            String ID = ((CheckBox)e.Item.FindControl("ID")).Text;

            if (e.CommandName == "del")
            {
                db.ExecuteCommand(String.Format("DELETE FROM [T_Logs] WHERE id in ({0})", ID));
                T_LogsHelper.Append("删除操作日志.", Admin.ID);
            }

            BindData();
        }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            IJsonResult result = new IJsonResult {
                Text = "备份失败!", Ico = MessageICO.Failure
            };
            String   basedir  = AppDomain.CurrentDomain.BaseDirectory;
            FileInfo backfile = new FileInfo(Server.MapPath("/Developer/BackUp/data.bak"));
            if (backfile.Exists)
            {
                backfile.Delete();
            }

            try
            {
                String sql = String.Format("BACKUP DATABASE data TO DISK = N'{0}' WITH INIT,NOUNLOAD,NAME = N'数据备份',NOSKIP,STATS = 10,NOFORMAT", backfile.FullName);
                db.ExecuteReader(sql);

                ProcessStartInfo p = new ProcessStartInfo();
                p.FileName         = Server.MapPath("/App_Data/Plugins/Rar.exe");
                p.Arguments        = String.Format(" a {0}.rar -ep {1}", DateTime.Now.ToString("yyyy年MM月dd日"), backfile.FullName);
                p.WindowStyle      = ProcessWindowStyle.Hidden;
                p.WorkingDirectory = Server.MapPath("/Developer/BackUp");
                Process process = new Process();
                process.StartInfo = p;
                process.Start();
                process.WaitForExit();
                process.Close();

                backfile = new FileInfo(Server.MapPath("/Developer/BackUp/data.bak"));
                if (backfile.Exists)
                {
                    backfile.Delete();
                }

                result.Status = true;
                result.Text   = "备份成功!";
                result.Ico    = MessageICO.Success;

                T_LogsHelper.Append("备份数据库:" + DateTime.Now.ToString("yyyy年MM月dd日") + ".rar", LogsAction.BackUp, Admin.UserData);
            }
            catch (Exception ex)
            {
                result.Text = ex.Message;
            }

            String json = JsonConvert.SerializeObject(result);
            Response.Write(json);
        }
    }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            IJsonResult result = new IJsonResult {
                Text = "打包失败!", Ico = MessageICO.Failure
            };
            try
            {
                int    i        = 0;
                String backfile = "/网站打包[" + DateTime.Now.ToString("yyyy-MM-dd") + "].rar";
                while (File.Exists(Server.MapPath(backfile)))
                {
                    i++;
                    backfile = "/网站打包[" + DateTime.Now.ToString("yyyy-MM-dd") + "]-" + i.ToString("00") + ".rar";
                }
                String rarfile = Server.MapPath(backfile);

                ProcessStartInfo p = new ProcessStartInfo();
                p.FileName         = Server.MapPath("/App_Data/Plugins/Rar.exe");
                p.Arguments        = String.Format(" a {0} -r -m5", rarfile);
                p.WindowStyle      = ProcessWindowStyle.Hidden;
                p.WorkingDirectory = Server.MapPath("/");
                Process process = new Process();
                process.StartInfo = p;
                process.Start();
                process.WaitForExit();
                process.Close();

                Thread.Sleep(300);
                result.Text   = "打包成功,文件已存放在网站根目录下!";
                result.Ico    = MessageICO.Success;
                result.Status = true;
                result.Data   = backfile;

                T_LogsHelper.Append("打包网站:" + backfile, LogsAction.Delete, Admin.UserData);
            }
            catch (Exception ex)
            {
                result.Text = ex.Message;
            }

            Response.Write(JsonConvert.SerializeObject(result));
        }
    }
Ejemplo n.º 8
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">登录密码</param>
        /// <returns></returns>
        public static void LoginUser(String username, String password, ref IJsonResult result)
        {
            ExecuteObject obj = new ExecuteObject();

            obj.tableName = "T_User";
            obj.cmdtype   = CmdType.SELECT;
            obj.terms.Add("UserName", username);
            obj.terms.Add("UserPass", password);

            T_UserEntity data = db.ExecuteObject <T_UserEntity>(obj);

            if (data.ID > 0)
            {
                if (data.IsLock)
                {
                    result.Text = "当前账号无法登录,请与管理员联系!";
                    T_LogsHelper.Append("尝试登录管理系统.", LogsAction.Login, data);
                }
                else
                {
                    result.Status     = true;
                    data.LastSignTime = DateTime.Now;
                    db.ExecuteCommand <T_UserEntity>(data, CmdType.UPDATE);
                    T_LogsHelper.Append("成功登录管理系统.", LogsAction.Login, data);
                    SetUserData(data);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "root", DateTime.Now, DateTime.Now.AddMinutes(60), false, data.ID.ToString());
                    String authticket = FormsAuthentication.Encrypt(ticket);

                    CookieHelper.AddCookie(FormsAuthentication.FormsCookieName, authticket);

                    //HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, authticket);
                    //cookie.Expires = DateTime.Now.AddMinutes(60);
                    //cookie.HttpOnly = false;
                    //cookie.Path = FormsAuthentication.FormsCookiePath;
                    //cookie.Secure = FormsAuthentication.RequireSSL;
                    //cookie.Domain = FormsAuthentication.CookieDomain;
                    //HttpContext.Current.Response.Cookies.Set(cookie);
                    //HttpContext.Current.Response.Redirect("/Developer", true);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            T_LinksEntity data = (T_LinksEntity)ViewState["data"];

            data = this.GetFormValue <T_LinksEntity>(data);
            CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT;

            if (db.ExecuteCommand <T_LinksEntity>(data, cmd))
            {
                if (!IsEdit)
                {
                    this.ClearFromValue();
                    T_LogsHelper.Append("添加友情连接:" + data.LinkName, Admin.ID);
                }
                else
                {
                    T_LogsHelper.Append("编辑友情连接:" + data.LinkName, Admin.ID);
                }
                Alert(Label1, "保存成功!", "line1px_3");
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 批量删除 批量启用 批量禁用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <Int32>  list   = new List <Int32>();
            List <String> titles = new List <String>();

            foreach (RepeaterItem item in Repeater1.Items)
            {
                CheckBox    chk   = item.FindControl("id") as CheckBox;
                HiddenField title = item.FindControl("title") as HiddenField;
                if (chk.Checked)
                {
                    list.Add(Convert.ToInt32(chk.Text));
                    titles.Add(title.Value);
                }
            }

            if (list.Count > 0)
            {
                String id        = String.Join(",", list.ToArray());
                Int32  arguments = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);
                switch (arguments)
                {
                case 0:    //批量未审核
                    db.ExecuteCommand(String.Format("UPDATE [t_comment] SET audit = 0 WHERE id IN({0})", id));
                    T_LogsHelper.Append("批量未通过审核:" + String.Join(",", titles.ToArray()), Admin.ID);
                    break;

                case -1:    //删除
                    db.ExecuteCommand(String.Format("DELETE FROM [t_comment] WHERE id in ({0})", id));
                    T_LogsHelper.Append("批量删除评论:" + String.Join(",", titles.ToArray()), Admin.ID);
                    break;

                case 1:    //批量通过审核
                    db.ExecuteCommand(String.Format("UPDATE [t_comment] SET audit = 1 WHERE id IN({0})", id));
                    T_LogsHelper.Append("批量通过审核:" + String.Join(",", titles.ToArray()), Admin.ID);
                    break;
                }
            }
            BindData();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 批量删除 批量启用 批量禁用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <Int32>  list    = new List <Int32>();
            List <String> members = new List <String>();

            foreach (RepeaterItem item in Repeater1.Items)
            {
                CheckBox    chk    = item.FindControl("id") as CheckBox;
                HiddenField member = item.FindControl("membername") as HiddenField;
                if (chk.Checked)
                {
                    list.Add(Convert.ToInt32(chk.Text));
                    members.Add(member.Value);
                }
            }

            if (list.Count > 0)
            {
                String id        = String.Join(",", list.ToArray());
                Int32  arguments = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);
                switch (arguments)
                {
                case 0:    //禁用
                    db.ExecuteCommand(String.Format("UPDATE [t_members] SET status = 0 WHERE id IN({0})", id));
                    T_LogsHelper.Append("批量禁用会员:" + String.Join(",", members.ToArray()), Admin.ID);
                    break;

                case -1:    //删除
                    db.ExecuteCommand(String.Format("DELETE FROM [t_members] WHERE id in ({0})", id));
                    T_LogsHelper.Append("批量删除会员:" + String.Join(",", members.ToArray()), Admin.ID);
                    break;

                case 1:    //启用
                    db.ExecuteCommand(String.Format("UPDATE [t_members] SET status = 1 WHERE id IN({0})", id));
                    T_LogsHelper.Append("批量启用会员:" + String.Join(",", members.ToArray()), Admin.ID);
                    break;
                }
            }
            BindData();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 列表事件
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            String      ID    = ((CheckBox)e.Item.FindControl("ID")).Text;
            HiddenField title = e.Item.FindControl("title") as HiddenField;

            switch (e.CommandName)
            {
            case "del":
                db.ExecuteCommand(String.Format("DELETE FROM [t_comment] WHERE id in ({0})", ID));
                T_LogsHelper.Append("删除评论:" + title.Value, Admin.ID);
                break;

            case "audit":
                ExecuteObject obj = new ExecuteObject();
                obj.cmdtype   = CmdType.UPDATE;
                obj.tableName = "t_comment";
                obj.terms.Add("id", ID);
                obj.cells.Add(e.CommandName, !Convert.ToBoolean(e.CommandArgument));
                db.ExecuteCommand(obj);
                T_LogsHelper.Append("修改评论审核:" + title.Value, Admin.ID);
                break;
            }
            BindData();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 记录日志
 /// </summary>
 /// <param name="text"></param>
 /// <param name="action"></param>
 protected void AppendLogs(String text, LogsAction action)
 {
     T_LogsHelper.Append(text, action, Admin.UserData);
 }