/// <summary> /// 用户向导部分插入四个表 /// </summary> /// <param name="user"></param> /// <param name="list"></param> /// <returns></returns> public bool InsertUserWizard(UserInfo user, Policy policy, List <string> right, List <Dictionary <string, object> > list) { MeaningsBLL bll = new MeaningsBLL(); using (System.Data.SQLite.SQLiteConnection conn = SQLiteHelper.SQLiteHelper.CreateConn()) { if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } System.Data.Common.DbTransaction tran = conn.BeginTransaction(); try { /*插入userinfo*/ this.InsertUser(user, tran); /*修改策略*/ processor.Update <Policy>(policy, tran); /*修改权限*/ if (right != null) { Dictionary <string, List <string> > r = new Dictionary <string, List <string> >(); r.Add(user.UserName, right); new UserRightBLL().SummitUserRight(r, tran); } /*修改meaning*/ if (list != null && list.Count > 0) { bll.InsertMeanRel(user.UserName, list, tran); } tran.Commit(); } catch { tran.Rollback(); conn.Close(); return(false); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(true); }
/// <summary> /// 用户向导部分插入四个表 /// </summary> /// <param name="user"></param> /// <param name="list"></param> /// <returns></returns> public bool InsertUserWizard(UserInfo user, List <Dictionary <string, object> > list) { MeaningsBLL bll = new MeaningsBLL(); using (System.Data.SQLite.SQLiteConnection conn = SQLiteHelper.SQLiteHelper.CreateConn()) { if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } System.Data.Common.DbTransaction tran = conn.BeginTransaction(); try { /*插入userinfo*/ this.InsertUser(user, tran); //先获取当前meaning及relation的最大id int mId = bll.GetMeaningPKValue(); int rId = bll.GetRelationPKValue(); Dictionary <string, object> rDic, mDic; foreach (Dictionary <string, object> dic in list) { rDic = new Dictionary <string, object>(dic); mDic = new Dictionary <string, object>(dic); mDic.Add("ID", ++mId); rDic.Add("ID", ++rId); bll.InsertOrUpdateMeaning(mDic, tran); bll.InsertMeanRel(user.UserName, rDic, tran); } tran.Commit(); } catch { tran.Rollback(); conn.Close(); return(false); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(true); }