public static bool ApplyMigration(Context context, bool initDatabase = false) { BaseDal dal = new BaseDal(); Action migration = null; if (initDatabase) { migration = new Action(DatabaseMigrator.InitDatabase); } else { migration = new Action(DatabaseMigrator.Migration); } var result = dal.RunTransaction(migration); if (result) { var appInfo = dal.ReadAll <AppInfo>().First(); var currentVersion = context.PackageManager.GetPackageInfo(context.PackageName, 0).VersionCode; appInfo.Version = currentVersion; dal.Update <AppInfo>(appInfo); } return(result); }
public ActionResult SaveRolePer(long Rid, string Pids) { BaseDal <rolepermission> rmDal = new BaseDal <rolepermission>(); rolepermission rmModel = new rolepermission(); try { rmDal.ExecSqlCommand(string.Format("delete from {0} WHERE rid = {1}", "rolepermission", Rid)); Pids.Split(',').ToList().ForEach( q => { rmModel = new rolepermission() { Rid = Rid, Pid = Convert.ToInt64(q) }; rmDal.Add(rmModel); } ); return(Success()); } catch (Exception e) { return(Error(e)); } }
public virtual ActionResult Upload() { string[] type = { ".bmp", ".jpg", ".jpeg", ".png", ".gif", ".exe" }; List <long> list = new List <long>(); try { BaseDal <image> idal = new BaseDal <image>(); image en = new image(); HttpFileCollectionBase collection = HttpContext.Request.Files; for (int i = 0; i < collection.Count; i++) { HttpPostedFileBase singel = collection[i]; byte[] buff = new byte[singel.ContentLength]; singel.InputStream.Read(buff, 0, singel.ContentLength); en.Name = singel.FileName; en.Img = buff; en.ContentType = Path.GetExtension(singel.FileName); if (type.Any(h => h == en.ContentType.ToLower())) { en = idal.Add(en); list.Add(en.ID); } else { return(Error(new Exception("文件格式不支持"))); } } return(Json(new { Message = Tip.Success, Ids = string.Join(",", list) })); } catch (Exception e) { return(Error(e)); } }
/// <summary> /// 添加登录日志 /// 添加人:周 鹏 /// 添加时间:2015-08-11 /// </summary> /// <history> /// 修改描述:时间+作者+描述 /// </history> /// <param name="source">登录来源(Web、PDA)</param> /// <param name="ip">登录IP</param> /// <param name="status">登录状态(成功、失败)</param> /// <param name="note">登录情况说明</param> /// <param name="account">登录账号</param> /// <param name="userName">登录人员姓名</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool AddLog(int source, string ip, int status, string note, string account, string userName) { try { var entity = new ComLoginLogEntity() { Id = LogHelper.Id, Source = source, Ip = ip, Status = status, Note = note, CreatorId = account, CreateBy = userName, CreateOn = DateTime.Now }; BaseDal.Add(entity); if (status != 3) { LogHelper.Dispose(); } return(true); } catch { return(false); } }
public UserDetailsController() { BaseDal _dal = new BaseDal(DBContextFactory.CreateDbContext()); dal = _dal; runtimeModel = _dal.GetRuntimeModelType(GetJsonDatas.GetJson(), 0); }
public override object GetData() { int i = -1; string id = ""; try { id = (string)optdatas["id"]; } catch { id = ""; } JsonData js = new JsonData(); try { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("dm", "1"); BaseDal.UpdateTables("danci_t", dic, "id=" + id + ""); i = 1; } catch (Exception ex) { JngsDal.RecordError("isshoucang", ex.Message); } AddJsonProperty("id", ref js); js["id"] = i; return(js); }
/// <summary> /// 学生查询本专业的所有论文课题 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize">页面显示的数据的条数</param> /// <returns></returns> public ActionResult GetAllTheme(int pageIndex = 1, int pageSize = 2) { ThemeService themeservice = new ThemeService(); BaseDal <Theme> based = new BaseDal <Theme>(); Student s = (Student)Session["student"]; //session中的数据 if (s == null) { return(RedirectToAction("Login", "Login")); } int proid = (int)s.Profession.Pro_Id; IList <Theme> list = themeservice.GetThemesByPro(proid); int total = list.Count(); if (Request["action"] == "gettotal") { ViewData["total"] = total; int[] arr = { pageIndex, pageSize, total }; string str = js.Serialize(arr); Response.Write(str); } if (Request["action"] == "gettheme") { int pgindex = Convert.ToInt32(Request["pgindex"]); IQueryable <Theme> iq = based.GetPageEntities <int?>(pageSize, pgindex, out total, u => u.Profession.Pro_Id == proid, u => u.Theme_Id, true); string str = js.Serialize(iq); Response.Write(str); } Response.End(); return(View()); }
public ActionResult Test(int pageIndex, int pageSize) { BaseDal <Student> based = new BaseDal <Student>(); pageIndex = Convert.ToInt32(Request["pageIndex"]); pageSize = Convert.ToInt32(Request["pageSize"]); int total = based.GetEntities(u => u.Stu_Id > 0).Count(); ViewData["total"] = total; IQueryable <Student> iq = based.GetPageEntities <string>(pageSize, pageIndex, out total, u => u.Stu_Id > 0, u => u.Stu_Num, true); Student[] sts = new Student[iq.Count()]; foreach (var item in iq) { int i = 0; sts[i] = item; i++; } string[] starr = new string[] { "HELLO1", "hello2" }; JavaScriptSerializer js = new JavaScriptSerializer(); string s = js.Serialize(sts); Response.Write(s); Response.End(); // Response.Write("helloworld"); return(View()); }
// // GET: /OrderInfo/ public ActionResult Index() { BaseDal <OrderInfo> based = new BaseDal <OrderInfo>(); ViewData.Model = based.GetEntities(u => u.OrderId < 40); return(View()); }
protected BaseBll() { var assembly = "Guoli.Fs.Dal"; var fullName = $"Guoli.Fs.Dal.{typeof(T).Name}Dal"; Dal = ReflectorHelper.GetInstance(assembly, fullName) as BaseDal <T>; }
/* * var _menus = { * "menus": [ * { * "menuid": "1", "icon": "icon-sys", "menuname": "下载管理", * "menus": [{ "menuname": "软件下载", "icon": "icon-set", "url": "/Back/Download/Index" } * ] * }, { * "menuid": "2", "icon": "icon-sys", "menuname": "内容管理", * "menus": [ * { "menuname": "经典案例类别", "icon": "icon-set", "url": "/Back/AnLiType/Index" }, * { "menuname": "经典案例列表", "icon": "icon-set", "url": "/Back/AnLi/Index" }, * { "menuname": "常见问题", "icon": "icon-set", "url": "/Back/Question/Index" }, * { "menuname": "问题反馈", "icon": "icon-set", "url": "/Back/FanKui/Index" } * ] * }, { * "menuid": "3", "icon": "icon-sys", "menuname": "首页管理", * "menus": [ * { "menuname": "导航列表", "icon": "icon-set", "url": "/Back/DaoHang/Index" }, * { "menuname": "首页说明列表", "icon": "icon-set", "url": "/Back/HomeInfo/Index" } * ] * }, { * "menuid": "3", "icon": "icon-sys", "menuname": "产品介绍管理", * "menus": [ * { "menuname": "产品介绍列表", "icon": "icon-set", "url": "/Back/Product/Index" }, * ] * }, { * "menuid": "4", "icon": "icon-sys", "menuname": "系统管理", * "menus": [ * { "menuname": "用户管理", "icon": "icon-set", "url": "/Back/User/Index" }, * { "menuname": "菜单权限管理", "icon": "icon-set", "url": "/Back/Menue/Index" }, * { "menuname": "系统日志", "icon": "icon-set", "url": "/Back/UserLog/Index" } * ] * }, * ] * };*/ public ActionResult GetTree(long Rid) { //取得角色下的所有菜单 BaseDal <rolemenue> rmDal = new BaseDal <rolemenue>(); var list = rmDal.GetListTopN(q => q.Rid == Rid, "Id", true, 0).Select(q => q.Mid); BaseDal <menue> mdal = new BaseDal <menue>(); List <HomeTree> trees = new List <HomeTree>(); List <menue> all = mdal.GetListTopN(q => true, "Id", true, 0).ToList(); //根节点 menue root = all.Where(q => q.ParentId == 0).FirstOrDefault(); all = all.Where(q => list.Contains(q.Id)).ToList(); //一级子几点 List <menue> _menus = all.Where(q => q.ParentId == root.Id).ToList(); //菜单表转成 HomeTree 格式 添加集合 foreach (var menue in _menus) { trees.Add(GetDiGuiTree(menue, all)); } // 权限设置 BaseDal <rolepermission> rpDal = new BaseDal <rolepermission>(); var vrlist = rpDal.GetListTopN(q => q.Rid == Rid, "Id", true, 0).Select(q => q.Pid).ToList(); BaseDal <permission> pDal = new BaseDal <permission>(); var listpermission = pDal.GetListTopN(q => true, "Id", true, 0).ToList(); var btnquanxian = listpermission.Where(q => vrlist.Contains(q.Id)).Select(q => q.SmallName).ToList(); CacheHelper.SetCache(base.UserId, btnquanxian, 60 * 24); return(Json(trees)); }
public async Task <int> SaveRolePermissions(int roleId, List <RolePermissionEntity> rolePermissions) { try { int count = 0; _unitOfWork.BeginTran(); var deleteRes = await BaseDal.Delete(c => c.RoleId == roleId); foreach (var item in rolePermissions) { RolePermissionEntity ep = new RolePermissionEntity(); ep.RoleId = roleId; ep.PermissionId = item.PermissionId; ep.CreationTime = item.CreationTime; await _rolePermissionRepository.Add(ep); count++; } _unitOfWork.CommitTran(); return(count); } catch (Exception ex) { _unitOfWork.RollbackTran(); throw ex; } }
/// <summary> /// 添加日志 /// </summary> /// <param name="logType">日志类型</param> /// <param name="controller">控制器名称</param> /// <param name="modelName">模块名称</param> /// <param name="action">方法</param> /// <param name="handleType">操作类型</param> /// <param name="note">文本</param> /// <param name="userId">操作用户编号</param> /// <param name="userName">操作用户名称</param> /// <returns></returns> public bool AddLog(LogType logType, string controller, string modelName, string action, HandleType handleType, string note, string userId, string userName) { try { ComOperationLogEntity entity = new ComOperationLogEntity() { Id = LogHelper.Id, LogType = (int)logType, Controller = controller, ModelName = modelName, Action = action, HandleTypeId = ((int)handleType).ToString(), Note = note, Ip = LogHelper.GetUserIp, CreatorId = userId, CreateBy = userName, CreateOn = DateTime.Now }; BaseDal.Add(entity); return(true); } catch { return(false); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="repository">注入数据访问接口</param> protected BaseLogic(BaseDal <T> repository) { if (repository == null) { throw new ArgumentNullException("BaseDal", "BaseDal cannot be null"); } this.repository = repository; }
private async Task LoadFilterData() { using (var BDal = new BaseDal()) { Branches = new ObservableCollection <TAWDBBRANCH>(await Task.Run(() => BDal.TAWDBBRANCHDal.GetTAWDBBRANCHs())); Regions = new ObservableCollection <TAWDBREGION>(await Task.Run(() => BDal.TAWDBREGIONDal.GetTAWDBREGIONs())); Cities = new ObservableCollection <TAWDBCITY>(await Task.Run(() => BDal.TAWDBCITYDal.GetTAWDBCITYs())); } }
public override object GetData() { int i = 0; string account = ""; try { account = (string)optdatas["account"]; } catch { account = ""; } string pwd = ""; try { pwd = (string)optdatas["pwd"]; } catch { pwd = ""; } string message = ""; string token = ""; try { token = (string)optdatas["token"]; } catch { token = ""; } JsonData js = new JsonData(); try { pwd = "666666"; AddJsonProperty("userinfo", ref js); var dt = tdal.public_user_login(account, BaseDal.MD5Encrype(pwd)); if (dt.Rows.Count > 0) { if (dt.Rows[0]["DeleteMark"].ToString() == "1") { i = -2; message = "此号被冻结"; js["userinfo"] = DataTableToJson(dt); } else { i = 1; message = "成功"; js["userinfo"] = DataTableToJson(dt); } } else { i = -1; message = "账号或密码错误"; js["userinfo"] = DataTableToJson(dt); } } catch (Exception ex) { JngsDal.RecordError("get_code", ex.Message); } AddJsonProperty("id", ref js); AddJsonProperty("message", ref js); js["id"] = i; js["message"] = message; return(js); }
public IActionResult Index() { //Console.Write(value); //CallContext.SetData("DB",null); BaseDal <book> bookbll = new BaseDal <book>(db); var a = bookbll.GetList((x) => true).ToList(); var b = db.book.ToList(); return(View(b)); }
/* * /// <summary> * /// 分页获取数据列表 * /// </summary> * public DataSet GetList(int PageSize,int PageIndex,string strWhere) * { * SqlParameter[] parameters = { * new SqlParameter("@tblName", SqlDbType.VarChar, 255), * new SqlParameter("@fldName", SqlDbType.VarChar, 255), * new SqlParameter("@PageSize", SqlDbType.Int), * new SqlParameter("@PageIndex", SqlDbType.Int), * new SqlParameter("@IsReCount", SqlDbType.Bit), * new SqlParameter("@OrderType", SqlDbType.Bit), * new SqlParameter("@strWhere", SqlDbType.VarChar,1000), * }; * parameters[0].Value = "Sys_ItemsDetail"; * parameters[1].Value = "F_Id"; * parameters[2].Value = PageSize; * parameters[3].Value = PageIndex; * parameters[4].Value = 0; * parameters[5].Value = 0; * parameters[6].Value = strWhere; * return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds"); * }*/ #endregion BasicMethod #region ExtensionMethod public List <MyTest.Model.Sys_ItemsDetailModel> GetItemList(string enCode) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT d.* FROM Sys_ItemsDetail d INNER JOIN Sys_Items i ON i.F_Id = d.F_ItemId WHERE 1 = 1 AND i.F_EnCode = '" + enCode + "' AND d.F_EnabledMark = 1 AND d.F_DeleteMark = 0 ORDER BY d.F_SortCode ASC"); return(BaseDal.ExecuteReaderReturnListT <MyTest.Model.Sys_ItemsDetailModel>(strSql.ToString())); }
public void SetLink() { var dal = new BaseDal <Domain>(); var domains = dal.Get(); foreach (var domain in domains) { Dal.SetLinkWith(_admin, domain); } }
/// <summary> /// 笔记分页 /// </summary> /// <param name="where"></param> /// <param name="page"></param> /// <returns></returns> public DataTable get_mydanci(string where, string page) { Dictionary <string, string> dic = new Dictionary <string, string> (); DataTable dt = new DataTable(); string sql = "select a.*,b.UserName,b.UserAccount from danci_t a join BaseUser b on a.userid=b.UserId where 1=1"; sql += where; dt = BaseDal.QueryDataTableByPage("10", sql, dic, page, "id", "desc"); return(dt); }
public List <Employee> FindAppUsers(string username, string firstName, string lastName, string jobDescription, string roleName, bool?active) { OracleConnection con = new OracleConnection(_connectionString); OracleCommand com = con.CreateCommand(SchemaOwner + PackageName + "find_employees"); com.Parameters.Add("i_app_name", OracleDbType.Varchar2, ApplicationName, ParameterDirection.Input); com.Parameters.Add("i_employee_number", OracleDbType.Varchar2, string.IsNullOrEmpty(username) ? null : username.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_first_name", OracleDbType.Varchar2, string.IsNullOrEmpty(firstName) ? null : firstName.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_last_name", OracleDbType.Varchar2, string.IsNullOrEmpty(lastName) ? null : lastName.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_job_descr", OracleDbType.Varchar2, string.IsNullOrEmpty(jobDescription) ? null : jobDescription.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_role_name", OracleDbType.Varchar2, string.IsNullOrEmpty(roleName) ? null : roleName, ParameterDirection.Input); if (active != null) { com.Parameters.Add("i_employee_status", OracleDbType.Int32, active.Value ? 1 : 0, ParameterDirection.Input); } com.Parameters.Add("o_data", OracleDbType.RefCursor, ParameterDirection.Output); OracleDataReader dr = null; List <Employee> items = new List <Employee>(); try { con.Open(); dr = com.ExecuteReader(); while (dr.Read()) { Employee employee = new Employee(); PopulateEmployee(employee, dr); items.Add(employee); } con.Close(); } finally { BaseDal.Cleanup(con, com, dr); con = null; com = null; dr = null; } return(items); }
public void UpdateAppUser(string username, string bscEmployeeNumber, string lastName, string firstName, string middleName, string suffix, bool active, DateTime statusValidity, IEnumerable <string> roleName, string auditUser) { OracleConnection con = new OracleConnection(_connectionString); OracleCommand com = con.CreateCommand(SchemaOwner + PackageName + "update_user"); com.Parameters.Add("i_app_name", OracleDbType.Varchar2, ApplicationName, ParameterDirection.Input); com.Parameters.Add("i_employee_number", OracleDbType.Varchar2, username.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_bsc_employee_number", OracleDbType.Varchar2, bscEmployeeNumber.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_last_name", OracleDbType.Varchar2, lastName.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_first_name", OracleDbType.Varchar2, firstName.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_middle_name", OracleDbType.Varchar2, middleName.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_suffix", OracleDbType.Varchar2, suffix.Trim().ToUpper(), ParameterDirection.Input); com.Parameters.Add("i_employee_status", OracleDbType.Int32, (active ? 1 : 0), ParameterDirection.Input); com.Parameters.Add("i_status_eff_end_date", OracleDbType.Date, statusValidity, ParameterDirection.Input); com.Parameters.Add("i_role_list", OracleDbType.Varchar2, string.Join(",", roleName), ParameterDirection.Input); com.Parameters.Add("i_audit_user", OracleDbType.Varchar2, auditUser, ParameterDirection.Input); try { con.Open(); com.ExecuteNonQuery(); con.Close(); } catch (OracleException oex) { // check if its a custom oracle exception if (oex.Number >= 20000 && oex.Number <= 20999) { // throw a custom exception throw new DalException(BaseDal.ExtractOracleMessage(oex.Message), oex); } else { throw; } } finally { BaseDal.Cleanup(con, com); con = null; com = null; } }
/// <summary> /// 根据父类获取子类集合 /// </summary> /// <typeparam name="TP">父类类型</typeparam> /// <typeparam name="TC">子类类型</typeparam> /// <param name="parent"></param> /// <returns></returns> public List <TC> GetChildren <TP, TC>(TP parent) where TP : BaseModel, new() where TC : BaseModel, new() { if (parent == null) { return(null); } var dal = new BaseDal <TP>(); return(dal.GetChildren <TC>(parent)); }
public async Task GetAsyncWithCompositeKeysExampe() { var cityDal = new BaseDal <City>(CreateDapperConnection()); var city = await cityDal.QueryByEntityKeysAsync(new City { CityName = "Alfred", StateProvinceID = 35 }); city.Should().NotBeNull("QueryByEntityKeysAsync doesn't behave correctly"); }
public override object GetData() { int i = 0; string nicheng = ""; try { nicheng = (string)optdatas["nicheng"]; } catch { nicheng = ""; } string shuoming = ""; try { shuoming = (string)optdatas["shuoming"]; } catch { shuoming = ""; } string userid = ""; try { userid = (string)optdatas["userid"]; } catch { userid = ""; } string baseimg = ""; try { baseimg = (string)optdatas["baseimg"]; } catch { baseimg = ""; } JsonData js = new JsonData(); try { Dictionary <string, string> dic = new Dictionary <string, string>(); if (baseimg != "") { string ss = baseimg; byte[] bt = Convert.FromBase64String(ss); System.IO.MemoryStream stream = new System.IO.MemoryStream(bt); Bitmap bitmap = new Bitmap(stream); string filesname = DateTime.Now.ToFileTime() + ".jpg"; bitmap.Save(@"C:\Web\笔记系统\fileimg\" + filesname + "", System.Drawing.Imaging.ImageFormat.Jpeg); dic.Add("picurl", "../fileimg/" + filesname); } dic.Add("UserName", nicheng); dic.Add("jieshao", shuoming); i = 1; BaseDal.UpdateTables("baseuser", dic, "userid='" + userid + "'"); } catch (Exception ex) { JngsDal.RecordError("xiugai_ziliao", ex.Message); } AddJsonProperty("id", ref js); js["id"] = i; return(js); }
/// <summary> /// 保存通用文章 /// 添加人:张西琼 /// 时间:2014-11-13 /// <history> /// 修改描述:时间+作者+描述 /// </history> /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public ComArticleEntity SaveArticle(ComArticleEntity entity) { try { return(BaseDal.Add(entity)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public IQueryable <UserInfo> GetAllUsers(Func <UserInfo, bool> wherelambda) { BaseDal <UserInfo> based = new BaseDal <UserInfo>(); IQueryable <UserInfo> iq = based.GetEntities(wherelambda); //IList<UserInfo> ls=new List<UserInfo>(); //foreach (var item in iq) //{ // ls.Add(item); //} return(iq); }
/// <summary> /// 先删除依赖关系,再删除实体 /// </summary> /// <param name="child"></param> /// <param name="parent"></param> /// <returns></returns> public bool DeleteModel <TP, TC, TLink>(TC child, TP parent = null) where TP : BaseModel, new() where TLink : BaseLink, new() where TC : BaseModel, new() { var dal = new BaseDal <TC>(); var res = true; if (parent != null) { res = dal.DeleteLinkWith <TP, TC, TLink>(parent, child); } return(res && dal.Delete(child)); }
public UserInfo Get(int id) { UserInfo user = new UserInfo(); BaseDal <UserInfo> based = new BaseDal <UserInfo>(); IQueryable <UserInfo> iq = based.GetEntities(u => u.UserId == id); foreach (var item in iq) { user = item; } return(user); }
public void SaveOTDetail(string _emno, string _ottype, DateTime _otdt, DateTime _sttm, DateTime _endtime, double _othr, double _othrr, double _othm) { List <ColumnInfo> parameters = new List <ColumnInfo>() { new ColumnInfo() { ColumnName = "emno", ColumnValue = _emno }, new ColumnInfo() { ColumnName = "otdt", ColumnValue = UtilDatetime.FormatDate1(_otdt), ColumnType = "datetime" }, new ColumnInfo() { ColumnName = "sttm", ColumnValue = UtilDatetime.FormateDateTime1(_sttm), ColumnType = "datetime" }, }; List <totdetail> list = new BaseDal().GetSelectedRecords <totdetail>(parameters); if (list.Count <= 0) { totdetail otdetail = new totdetail(); otdetail.emno = _emno; otdetail.edtm = _endtime; otdetail.otdt = _otdt; otdetail.oths = _othr; otdetail.othm = _othm; otdetail.othr = _othrr; otdetail.otcd = _ottype; otdetail.sttm = _sttm; otdetail.lmtm = DateTime.Now; otdetail.lmur = Function.GetCurrentUser(); gDB.totdetails.InsertOnSubmit(otdetail); } else { totdetail otdetail = list.First(); otdetail.edtm = _endtime; otdetail.otcd = _ottype; otdetail.othr = _othr; otdetail.othr = _othrr; otdetail.lmtm = DateTime.Now; otdetail.lmur = Function.GetCurrentUser(); } gDB.SubmitChanges(); }