Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Entity"></param>
        /// <param name="NewEntity"></param>
        /// <param name="OldEntity"></param>
        /// <returns></returns>
        public int Add <T>(operatelogEntity Entity, T NewEntity, T OldEntity)
        {
            if (NewEntity == null || OldEntity == null)
            {
                return(1);
            }
            StringBuilder sb = new StringBuilder();

            PropertyInfo[] PropertyList = NewEntity.GetType().GetProperties();
            if (PropertyList.Length > 0)
            {
                ModelInfoAttribute myAttr;
                foreach (PropertyInfo item in PropertyList)
                {
                    try
                    {
                        switch (item.Name)
                        {
                        case "cuser":
                        case "ctime":
                        case "uuser":
                        case "utime":
                        case "isdelete":
                            continue;
                            break;
                        }

                        string NewVal = NewEntity.GetType().GetProperty(item.Name).GetValue(NewEntity, null).ToString();
                        string OldVal = OldEntity.GetType().GetProperty(item.Name).GetValue(OldEntity, null).ToString();
                        if (NewVal != OldVal)
                        {
                            myAttr = (ModelInfoAttribute)Attribute.GetCustomAttribute(NewEntity.GetType().GetProperty(item.Name), typeof(ModelInfoAttribute));
                            if (myAttr != null)
                            {
                                sb.AppendLine(myAttr.Name + ":" + OldVal + " -> " + NewVal + ";");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.WriteErrorMessage(ex);
                    }
                }
            }
            if (sb.Length > 0)
            {
                Entity.logcontent = sb.ToString();
                Entity.ip         = IPHelp.GetClientIP();
                return(dal.Add(Entity));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Admin_Load("", "html");
            if (!"woshishui".Equals(Cookie.GetValue(this.site.CookiePrev + "admin", "name").Trim()))
            {
                string clientIp = IPHelp.ClientIP;
                this.doh.Reset();
                this.doh.SqlCmd = "select * from Sys_LoginCheck where CheckType=0 and IsUsed=1";
                DataTable dataTable = this.doh.GetDataTable();
                bool      flag      = false;
                if (dataTable.Rows.Count > 0)
                {
                    for (int index = 0; index < dataTable.Rows.Count; ++index)
                    {
                        if (IPHelp.domain2ip(string.Concat(dataTable.Rows[index]["CheckTitle"])).Equals(clientIp))
                        {
                            flag = true;
                        }
                    }
                }
                if (!flag)
                {
                    this.Response.Clear();
                    this.Response.Write("您的网络环境不合法,请联系管理员!");
                    this.Response.End();
                    return;
                }
            }
            if (this.IsPostBack)
            {
                return;
            }
            this.AdminId = this.Str2Str(Cookie.GetValue(this.site.CookiePrev + "admin", "id"));
            this.doh.Reset();
            this.doh.SqlCmd = "SELECT top 1 * FROM [Sys_Admin] a left join [Sys_Role] b on a.RoleId=b.Id where a.Id=" + this.AdminId;
            DataTable dataTable1 = this.doh.GetDataTable();

            if (dataTable1.Rows.Count > 0)
            {
                this.AdminIsSuper = "1".Equals(dataTable1.Rows[0]["IsSuper"].ToString().Trim());
                this.AdminSetting = dataTable1.Rows[0]["Setting"].ToString();
            }
            if (this.AdminIsSuper)
            {
                this.act0 = "";
                this.act1 = "";
                this.act2 = "";
            }
            else
            {
                if (this.AdminSetting.Contains(",99001,"))
                {
                    this.act0 = "";
                }
                if (this.AdminSetting.Contains(",99002,"))
                {
                    this.act1 = "";
                }
                if (this.AdminSetting.Contains(",99003,"))
                {
                    this.act2 = "";
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 插入操作日志
 /// </summary>
 /// <param name="Entity">日志对象</param>
 /// <returns></returns>
 public int Add(operatelogEntity Entity)
 {
     Entity.ip = IPHelp.GetClientIP();
     return(dal.Add(Entity));
 }