麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

以一個(gè)權(quán)限系統(tǒng)來(lái)告別WebForm —(一)項(xiàng)目整休架構(gòu)設(shè)計(jì)與數(shù)據(jù)庫(kù)設(shè)計(jì)

2019-11-17 02:09:15
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

以一個(gè)權(quán)限系統(tǒng)來(lái)告別WebForm —(一)項(xiàng)目整休架構(gòu)設(shè)計(jì)與數(shù)據(jù)庫(kù)設(shè)計(jì)

在本節(jié)我想與大家與分享一下,我所將要做的權(quán)限系統(tǒng)的架構(gòu)和數(shù)據(jù)庫(kù)的表的設(shè)計(jì)。請(qǐng)各位大神們對(duì)我項(xiàng)目中設(shè)計(jì)的不足之處進(jìn)行指導(dǎo),讓我得以更好的寫(xiě)完它,留給需要它的人。

我的項(xiàng)目架構(gòu)如下圖所示:

如上圖所示,在數(shù)據(jù)訪問(wèn)層,我采用了抽象工廠的方式,來(lái)對(duì)數(shù)據(jù)訪問(wèn)層和業(yè)務(wù)邏輯層解耦,當(dāng)然如果你想更高大上一些,可以用第三方的框架,比如SPRing.Net ,Autofac來(lái)實(shí)現(xiàn)。解耦的好處在于可以方便的切換數(shù)據(jù)庫(kù),當(dāng)數(shù)據(jù)庫(kù)變更時(shí),只需換一下對(duì)應(yīng)的數(shù)據(jù)訪問(wèn)DAL就行,本系列中,我所采用的是SQLServer。寫(xiě)到這我想在如下這個(gè)大數(shù)據(jù)時(shí)代,MongoDB其實(shí)也是不錯(cuò)的。后面有機(jī)會(huì),可以開(kāi)一個(gè)MongoDB的專題和大家一起來(lái)使用一下MongoDB學(xué)習(xí)一下它。對(duì)于抽象工廠來(lái)實(shí)現(xiàn)業(yè)務(wù)邏輯層與數(shù)據(jù)訪問(wèn)層的解耦實(shí)現(xiàn)代碼如下,主要用到了反射,面向接口編程。

配置:

<appSettings>  <add key="DAL" value="MCFramework.SQLDAL"/>    <!--頁(yè)容量-->  <add key="PageSize" value="20"/></appSettings>
View Code

抽象工廠:

namespace MCFramework.RepositoryFactory{    public class RepositoryFactory    {        public RepositoryFactory()        { }        private static readonly string AssemblyPath =ConfigurationSettings.AppSettings["DAL"];        #region CreateObject        //不使用緩存        private static object CreateObjectNoCache(string AssemblyPath, string classNamespace)        {            try            {                object objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);                return objType;            }            catch(System.Exception ex)            {                string str=ex.StackTrace;// 記錄錯(cuò)誤日志                return null;            }        }        //使用緩存        //private static object CreateObject(string AssemblyPath, string classNamespace)        //{        //    object objType = DataCache.GetCache(classNamespace);        //    if (objType == null)        //    {        //        try        //        {        //            objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);        //            DataCache.SetCache(classNamespace, objType);// 寫(xiě)入緩存        //        }        //        catch//(System.Exception ex)        //        {        //            //string str=ex.Message;// 記錄錯(cuò)誤日志        //        }        //    }        //    return objType;        //}        #endregion        /// <summary>        /// 用戶倉(cāng)儲(chǔ)        /// </summary>        public static ISystem_EmployeeRepository System_EmployeeRepository { get { return (ISystem_EmployeeRepository)CreateObjectNoCache(AssemblyPath, AssemblyPath + ".System_EmployeeRepository"); } }        /// <summary>        ///菜單倉(cāng)儲(chǔ)        /// </summary>        public static ISystem_MenuRepository  System_MenuRepository { get { return (ISystem_MenuRepository)CreateObjectNoCache(AssemblyPath, AssemblyPath + ".System_MenuRepository"); } }        /// <summary>        ///角色倉(cāng)儲(chǔ)        /// </summary>        public static ISystem_RoleRepository System_RoleRepository { get { return (ISystem_RoleRepository)CreateObjectNoCache(AssemblyPath, AssemblyPath + ".System_RoleRepository"); } }        /// <summary>        ///按鈕倉(cāng)儲(chǔ)        /// </summary>        public static ISystem_ButtonRepository System_ButtonRepository { get { return (ISystem_ButtonRepository)CreateObjectNoCache(AssemblyPath, AssemblyPath + ".System_ButtonRepository"); } }    }}
View Code

所有的訪問(wèn)數(shù)據(jù)庫(kù)的操作都用接口來(lái)約束:

namespace MCFramework.IDAL{    public interface IBaseRepository<T> where T:class    {        int Add(T model);        int UpdateDel(string ids, bool isDel);        int Del(string ids);        int Update(T model);        DataSet GetListByProc(string procName, System.Data.SqlClient.SqlParameter[] paras);        DataSet GetModel(string Id);        DataSet GetList(string strWhere);    }}
View Code
namespace MCFramework.IDAL{   public interface ISystem_ButtonRepository:IBaseRepository<System_ButtonModel>    {        bool IsExit(string ButtonCode);    }}
View Code

接口的實(shí)現(xiàn):

namespace MCFramework.SQLDAL{    /// <summary>    /// Author: MaChun    /// Description: DALTier -- the DAL class of System_Button.    /// Datetime:2015/6/8 13:00:35    /// </summary>    public class  BaseSystem_ButtonRepository: IBaseRepository<System_ButtonModel>    {            //創(chuàng)建企業(yè)庫(kù)連接     public  SqlDataaccess db = SqlDataAccess.CreateDataAccess();            #region 新增一條記錄 Add(System_ButtonModel model)        /// <summary>        /// 新增一條記錄        /// </summary>        public int Add(System_ButtonModel  model)        {            int result = 0;            try            {                StringBuilder strSql = new StringBuilder();                strSql.Append("insert into System_Button(");                strSql.Append("SBT_Guid,SBT_ButtonCode,SBT_ButtonName,SBT_IconUrl,SBT_IconCSS,SBT_CreateBy,SBT_CreatedDate)");                strSql.Append(" values (");                strSql.Append("@SBT_Guid,@SBT_ButtonCode,@SBT_ButtonName,@SBT_IconUrl,@SBT_IconCss,@SBT_CreateBy,@SBT_CreatedDate)");                strSql.Append(";select @@IDENTITY");                SqlParameter[] parameters = {                    new SqlParameter("@SBT_Guid", SqlDbType.VarChar,36),                    new SqlParameter("@SBT_ButtonCode", SqlDbType.VarChar,200),                    new SqlParameter("@SBT_ButtonName", SqlDbType.VarChar,100),                    new SqlParameter("@SBT_IconUrl", SqlDbType.VarChar,100),                    new SqlParameter("@SBT_IconCss", SqlDbType.VarChar,100),                    new SqlParameter("@SBT_CreateBy", SqlDbType.VarChar,100),                    new SqlParameter("@SBT_CreatedDate", SqlDbType.DateTime,8)};                                parameters[0].Value = model.SBTGuid;                parameters[1].Value = model.SBTButtonCode;                parameters[2].Value = model.SBTButtonName;                parameters[3].Value = model.SBTIconUrl;                parameters[4].Value = model.SBTIconCss;                parameters[5].Value = model.SBTCreateBy;                parameters[6].Value = model.SBTCreatedDate;                                result =   db.ExecuteNonQuery(strSql.ToString(), parameters);            }            catch (Exception ex)            {                throw ex;            }            return result;        }        #endregion         #region 邏輯刪除 UpdateDel(
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 欧日韩在线 | 欧美成人理论片乱 | 思思久而久而蕉人 | 国产精品一 | 欧美日韩一区,二区,三区,久久精品 | 国产亚洲精品久久久久久久久久 | 黄色网址在线播放 | 色综合久久99 | 日本最新免费二区三区 | 好吊色欧美一区二区三区四区 | 免费黄色大片在线观看 | 成人午夜视频网站 | 欧日一级片 | 九九黄色 | cosplay裸体福利写真 | 欧美一级免费在线观看 | 欧美精品成人一区二区在线观看 | 色阁阁69婷婷 | 欧美人的天堂一区二区三区 | japanesexxxx24videofree | 成年人黄色免费电影 | 成人黄视频在线观看 | 欧美亚洲国产成人 | 国产91免费看 | 一区二区三区四区视频在线观看 | 久久精品国产99久久6动漫亮点 | 亚洲国产精品高潮呻吟久久 | 爱福利视频| 视频一区二区三区在线播放 | 久久精品亚洲一区二区三区观看模式 | 美国黄色毛片女人性生活片 | 国产色妞影院wwwxxx | 亚洲一区在线观看视频 | 国产宾馆3p国语对白 | 久久久久久久久久亚洲 | 日韩欧美精品电影 | 国产一级淫片在线观看 | 日本一级黄色大片 | 久久精热 | 亚洲成人涩涩 | 久久新网址 |