示例#1
0
        private static void UpgradeDatabaseToVersion(MySqlConnection conn, int version)
        {
            string filePath;

            if (version == 0)
            {
                if (_verbose)
                {
                    Logger.WriteLine("\tCleaning database...");
                }
                filePath = "sql/clean.sql";
            }
            else
            {
                if (_verbose)
                {
                    Logger.WriteLine("\tUpgrading to v{0}...", version);
                }
                filePath = $"sql/v{version}.sql";
            }

            List <string> startTables = ListTables(conn);

            MySqlTransaction transaction = conn.BeginTransaction();

            try
            {
                ImportSql(conn, filePath, transaction);
                transaction.Commit();
            }
            catch (MySqlException)
            {
                transaction.Rollback();
                throw;
            }

            if (version > 0)
            {
                ExecSql(conn, "UPDATE db_info SET update_date = CURRENT_TIMESTAMP(), version = @version WHERE 1",
                        ("@version", version));
            }

            List <string> endTables = ListTables(conn);

            if (_verbose)
            {
                foreach (string table in startTables.Where(t => !endTables.Contains(t)))
                {
                    Logger.WriteLine("\t\t(-) table {0}", table);
                }
                foreach (string table in endTables.Where(t => !startTables.Contains(t)))
                {
                    Logger.WriteLine("\t\t(+) table {0}", table);
                }
            }
        }
示例#2
0
    private void checkUserAvailable()
    {
        int        times = 0;
        HttpCookie co    = System.Web.HttpContext.Current.Request.Cookies["ccUserTimes"];

        if (co != null)
        {
            times = CFun.ParseInt(co.Value);
            times++;
            if (times > 10)
            {
                times = 0;
            }
        }
        else
        {
            co = new HttpCookie("ccUserTimes");
        }

        co.Value = times.ToString();
        System.Web.HttpContext.Current.Response.Cookies.Add(co);
        if (times == 0)
        {
            if (ExecSql.GetDataSet("select ld from AdmUser where Ld=" + CurrentUId + " and CheckCode<>" + CurrentCheckCode).Tables[0].Rows.Count > 0)
            {
                new BllAdmUser().LogOut();
                return;
            }
        }
    }
        public void SaveLog(int uId, int actId, int dataId, string remark)
        {
            SqlParameter[] pam = new SqlParameter[4];
            pam[0] = new SqlParameter("@uId", uId);
            pam[1] = new SqlParameter("@actId", actId);
            pam[2] = new SqlParameter("@dataId", dataId);
            pam[3] = new SqlParameter("@remark", remark);

            ExecSql.SqlExecNoquery("insert into admacthistory(admuid,actclass,dataid,remark,createdate) values(@uId,@actId,@dataId,@remark,getdate())", pam);
        }
示例#4
0
        /// <summary>
        /// 新增或修改一条信息
        /// </summary>
        /// <param name="_UserModule">实体类</param>
        /// <param name="Expired">返回是否过期</param>
        /// <returns></returns>
        public bool InsertOrUpdate(T _UserModule, out bool Expired)
        {
            Expired = false;
            string       idStr = "";
            PropertyInfo p     = typeof(T).GetProperty("LastDate");

            if (p != null)
            {
                try
                {
                    object obj = p.GetValue(_UserModule, null);
                    if (obj != null)
                    {
                        DateTime lastDate = (DateTime)obj;
                        if (lastDate != null)
                        {
                            PropertyInfo p1 = typeof(T).GetProperty("Ld");
                            if (p1 != null)
                            {
                                object obj1 = p1.GetValue(_UserModule, null);
                                if (obj1 != null)
                                {
                                    idStr = ((Int32)obj1).ToString();
                                    string dataLastDate = ExecSql.GetDataSet("select LastDate from " + tableName + " where Ld=" + idStr).Tables[0].Rows[0][0].ToString();
                                    if (dataLastDate != "")
                                    {
                                        DateTime nDate = Convert.ToDateTime(dataLastDate);
                                        if (nDate > lastDate)
                                        {
                                            Expired = true;
                                            return(false);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }
            }

            return(ExecSqlConn.InsertOrUpdateData <T>(_UserModule, sqlConn));
        }
示例#5
0
        public int CheckUser(string UserName, string UserPassword, string CurrentIp, out DataTable dtUser)
        {
            UserName = CFun.VerifySQL(UserName);
            int    loginRate  = 0;
            int    loginState = 0;
            string SqlStr     = "";

            SqlParameter[] pam = new SqlParameter[3];
            pam[0] = new SqlParameter("@userName", UserName);
            pam[1] = new SqlParameter("@userPassword", UserPassword);
            pam[2] = new SqlParameter("@logninIP", CurrentIp);

            DataSet dst = ExecSql.GetDataSetByStoredProcedure("[AdmUserLogin]", pam);

            loginRate  = Convert.ToInt32(dst.Tables[0].Rows[0][0].ToString());
            loginState = Convert.ToInt32(dst.Tables[1].Rows[0][0].ToString());
            dtUser     = dst.Tables[2];
            if (loginRate <= 0)
            {
                loginState = -4;
            }
            return(loginState);
        }