/// <summary> /// 获取栏目集合前N条数据 /// </summary> /// <param name="ColumnID"></param> /// <param name="TopNum"></param> /// <returns></returns> public List <Article_S> GetTopArticleByColumnIDs(string ColumnIDs, string ColumnNums) { using (var factory = new BaseAccess()) { var listAll = new List <Article_S>(); for (int i = 0; i < ColumnIDs.Split(',').Length; i++) { var ColumnID = ColumnIDs.Split(',')[i]; var ColumnNum = ColumnNums.Split(',')[i].Convert <int>(0); var list = GetTopArticleByColumnID(ColumnID, ColumnNum); listAll.AddRange(list); } return(listAll); } }
/// <summary> /// 根据栏目编号获取栏目名称 /// </summary> /// <returns></returns> public string GetColumnNameByColumnId(string ColumnId) { using (var factory = new BaseAccess()) { try { var Column = factory.GetSingle <MenuEntity>(Specification <MenuEntity> .Create(c => c.MenuCode == ColumnId)); return(Column.MenuName); } catch (Exception) { return(""); } } }
/// <summary> /// 修改用户密码 /// </summary> /// <param name="UserID"></param> /// <param name="password"></param> /// <returns></returns> public bool ChangePwd(string UserID, string password) { using (var factory = new BaseAccess()) { var user = factory.GetSingle <UserEntity>(Specification <UserEntity> .Create(c => c.ID == UserID)); string newPassword = (user.UserLoginName + Define._PASSWORDSPLIT + password).ToMD5(); if (user != null) { user.UserPassword = newPassword; factory.Update <UserEntity>(user); return(true); } return(false); } }
/// <summary> /// 获取带明细的专题信息 /// </summary> /// <param name="EventID"></param> /// <returns></returns> public Event_S GetEventWithDetail(string EventID) { using (var factory = new BaseAccess()) { var entity = factory.GetSingle <EventEntity>(EventID); var model = entity.Adapter <Event_S>(new Event_S()); var spec = Specification <EventDetailEntity> .Create(c => c.N_EVENT_ID == EventID); var entitydetaillist = factory.GetAll <EventDetailEntity>(spec); model.listEventDetail = entitydetaillist.Adapter <EventDetailEntity, EventDetail_S>(new List <EventDetail_S>()); return(model); } }
/// <summary> /// 得到链接类型地址 /// 3国内档案网站 4省内档案网站 5热门网站 /// </summary> /// <param name="typeId"></param> /// <returns></returns> public List <Link_S> GetAllLinks(string typeId) { using (var factory = new BaseAccess()) { List <Orderby <LinkEntity> > orders = new List <Orderby <LinkEntity> >() { new Orderby <LinkEntity>(c => c.DT_OP_TIME, SortOrder.Descending) }; var spec = Specification <LinkEntity> .Create(c => c.C_LINK_TYPE == typeId); var list = factory.GetAll <LinkEntity>(spec, orders) .Adapter <LinkEntity, Link_S>(new List <Link_S>()); return(list); } }
/// <summary> /// 修改专题明细 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool EditArticleApply(ArticleApply_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <ArticleApplyEntity>(new ArticleApplyEntity()); factory.Update <ArticleApplyEntity>(entity); return(true); } catch { return(false); } } }
/// <summary> /// 获取用户有权限的菜单(根据菜单类型) /// </summary> /// <param name="UserID"></param> /// <returns></returns> public List <MenuInfo> GetMenusByUserID(string UserID, MenuType menuType) { using (var factory = new BaseAccess()) { var list = factory.DbContext.AsQueryable <MenuEntity>().Where(w => w.MenuType == (int)menuType && w.RecordStatus != (int)RecordStatus.UnEnable) .Join(factory.DbContext.AsQueryable <MenuRoleEntity>(), o => o.ID, i => i.MenuID, (o, i) => new { Menu = o, MenuRole = i }) .Join(factory.DbContext.AsQueryable <UserRoleEntity>(), o2 => o2.MenuRole.RoleID, i2 => i2.RoleID, (o2, i2) => new { Menu = o2.Menu, MenuRole = o2.MenuRole, UserRole = i2 }) .Join(factory.DbContext.AsQueryable <RoleEntity>(), o3 => o3.UserRole.RoleID, i3 => i3.ID, (o3, i3) => new { Menu = o3.Menu, MenuRole = o3.MenuRole, UserRole = o3.UserRole, Role = i3 }) .Where(w => w.UserRole.UserID == UserID && w.Role.RecordStatus != (int)RecordStatus.UnEnable).Select(s => s.Menu) .OrderBy(o => o.MenuLevel).ThenBy(t => t.MenuOrder).ToList() ?? new List <MenuEntity>(); return(list.Adapter <MenuEntity, MenuInfo>(new List <MenuInfo>())); } }
/// <summary> /// 获取所有站点 /// </summary> /// <param name="searchContent"></param> /// <returns></returns> public bool Add(EmailRecord_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <EmailRecordEntity>(new EmailRecordEntity()); factory.Insert <EmailRecordEntity>(entity); return(true); } catch { return(false); } } }
/// <summary> /// 新增文章 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddArticle(Article_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <ArticleEntity>(new ArticleEntity()); factory.Insert(entity); return(true); } catch { return(false); } } }
/// <summary> /// 修改专题 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool EditEvent(Event_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <EventEntity>(new EventEntity()); factory.Update <EventEntity>(entity); return(true); } catch { return(false); } } }
/// <summary> /// 修改专题明细 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool EditFloatWindow(FloatWindow_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <FloatWindowEntity>(new FloatWindowEntity()); factory.Update <FloatWindowEntity>(entity); return(true); } catch { return(false); } } }
/// <summary> /// 删除缓存托盘数据 /// </summary> /// <param name="access">数据库对象实例</param> private void DeleteCacheData(BaseAccess access, string delFlag) { string whereStr = string.Empty; if (delFlag == "1") { whereStr = string.Format(" WHERE [Flag]={0}", this.stackNumber); } else if (delFlag == "2") { whereStr = string.Format(" WHERE [InStack] = '2' AND [Flag]={0}", this.stackNumber); } string strSQL = "DELETE FROM [" + lineDevice.PrefixTable + "CacheStackTray]" + whereStr; int count = access.ExecuteNonQuery(strSQL); }
/// <summary> /// 新增专题明细 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddEventDetail(EventDetail_S model) { using (var factory = new BaseAccess()) { try { var entity = model.Adapter <EventDetailEntity>(new EventDetailEntity()); factory.Insert(entity); return(true); } catch { return(false); } } }
/// <summary> /// 根据用户登录帐号获取用户对象 /// </summary> /// <param name="LoginName"></param> /// <returns></returns> public UserInfo GetUserByLoginName(string LoginName) { using (var factory = new BaseAccess()) { var model = factory.Single <UserEntity>(Specification <UserEntity> .Create(c => c.UserLoginName == LoginName && c.RecordStatus != (int)RecordStatus.UnEnable && c.UserType == (int)UserType.Administrators)); if (model != null) { return(model.Adapter <UserInfo>(new UserInfo())); } else { return(new UserInfo()); } } }
/// <summary> /// 分页获取专题明细列表 /// </summary> /// <param name="model"></param> /// <param name="pi"></param> /// <returns></returns> public List <ArticleApply_S> GetArticleApplyListPaged(ArticleApply_S model, PageInfo pi) { using (var factory = new BaseAccess()) { List <Orderby <ArticleApplyEntity> > orders = new List <Orderby <ArticleApplyEntity> >() { new Orderby <ArticleApplyEntity>(c => c.DT_APPLY_TIME, SortOrder.Descending) }; var spec = Specification <ArticleApplyEntity> .Create(c => true); if (!string.IsNullOrWhiteSpace(model.VC_ARTICLE_NAME)) { var ArticleIDs = factory.GetAll <ArticleEntity>(Specification <ArticleEntity> .Create(c => c.VC_TITLE.Contains(model.VC_ARTICLE_NAME))).Select(c => c.ID).ToList().ToArray(); spec &= Specification <ArticleApplyEntity> .Create(c => ArticleIDs.Contains(c.ID)); } if (!string.IsNullOrWhiteSpace(model.C_CHECK_STATUS)) { spec &= Specification <ArticleApplyEntity> .Create(c => c.C_CHECK_STATUS == model.C_CHECK_STATUS); } if (!string.IsNullOrWhiteSpace(model.VC_APPLYER_NAME)) { spec &= Specification <ArticleApplyEntity> .Create(c => c.VC_APPLYER_NAME.Contains(model.VC_APPLYER_NAME)); } if (model.N_START_DATE != null) { spec &= (Specification <ArticleApplyEntity> .Create(c => c.DT_APPLY_TIME >= model.N_START_DATE)); } if (model.N_END_DATE != null) { spec &= (Specification <ArticleApplyEntity> .Create(c => c.DT_APPLY_TIME <= model.N_END_DATE)); } var list = factory.GetPage <ArticleApplyEntity>(pi, spec, orders) .Adapter <ArticleApplyEntity, ArticleApply_S>(new List <ArticleApply_S>()); foreach (var item in list) { // item.VC_ARTICLE_NAME = factory.GetSingle<ArticleEntity>(item.N_ARTICLE_ID).VC_TITLE; item.VC_ARTICLE_NAME = factory.GetSingle <ArticleEntity>(item.N_ARTICLE_ID) == null ? "未知" : factory.GetSingle <ArticleEntity>(item.N_ARTICLE_ID).VC_TITLE; if (!string.IsNullOrWhiteSpace(item.VC_CHECKER_ID)) { var checker = factory.GetSingle <SYS_UserEntity>(item.VC_CHECKER_ID); item.VC_CHECKER_NAME = checker == null ? "" : checker.UserDisplayName; } } return(list); } }
/// <summary> /// 查询托盘的Id /// </summary> /// <param name="trayCode">托盘条码</param> /// <param name="access">数据库对象实例</param> /// <returns>托盘在数据库中的Id</returns> private long SelectTraysId(string trayCode, BaseAccess access) { long traysId = -1; //BaseCondition condition = new Column(StackTrayFlow.BARCODE).Equal(trayCode); //BaseCondition condition2 = new Column(StackTrayFlow.USED).Equal(0); //OrderBy orderByDESC = new OrderBy(StackTrayFlow.ID, Order.DESC); //List<StackTrayFlow> traysIdList = access.Select<StackTrayFlow>(condition.And(condition2), orderByDESC); List <StackTrayFlow> traysIdList = access.ExecuteSelect <StackTrayFlow>(string.Format("SELECT * FROM {0} WHERE Barcode='{1}' AND Used=0 ORDER BY Id DESC", lineDevice.PrefixTable + "StackTrayFlow", trayCode)); if (traysIdList.Count > 0) { traysId = traysIdList[0].Id; } return(traysId); }
public static List <UserEventLog> SelectEventLog() { using (BaseAccess access = new BaseAccess()) { try { //BaseCondition condition = new Column(UserEventLog.EVENT_TIME).MoreThan(DateTime.Now.AddDays(-1)); List <UserEventLog> userEventLogList = access.ExecuteSelect <UserEventLog>(string.Format("SELECT * FROM {0} WHERE EventTime > '{1}'", tableName, DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"))); return(userEventLogList); } catch (System.Data.Common.DbException ex) { Log.Error(ex.StackTrace); return(null); } } }
private static void RecordUserLog(string message) { string unKnownUser = "******"; using (BaseAccess access = new BaseAccess()) { try { string strSQL = string.Format("INSERT INTO [{0}] ([Account],[HandleEvent]) VALUES('{1}','{2}')", tableName, unKnownUser, message); access.ExecuteNonQuery(strSQL); } catch (System.Data.Common.DbException ex) { Log.Error(ex.StackTrace); } } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> public void Add(Dictionary_I model) { using (var factory = new BaseAccess()) { if (string.IsNullOrEmpty(model.ID)) { model.ID = Guid.NewGuid().ToString(); } factory.Insert <Sys_DictionaryEntity>(model.Adapter <Sys_DictionaryEntity>(new Sys_DictionaryEntity())); //清理缓存 if ((model.IsCache ?? 0) == 1) { Manage.Open.CacheshipFactory.Instance.ClearDictionaryCache(model.DictType); } } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> public void Add(Menu_I model) { using (var factory = new BaseAccess()) { if (string.IsNullOrEmpty(model.ID)) { model.ID = Guid.NewGuid().ToString(); } factory.Insert <MenuEntity>(model.Adapter <MenuEntity>(new MenuEntity())); //清理缓存 if (model.MenuType == (int)MenuType.Function) { CacheshipFactory.Instance.ClearFunMenuCache(); } } }
/// <summary> /// 保存堆叠的托盘 /// </summary> /// <param name="trayCodeList">托盘条码集合</param> /// <param name="access">数据库对象实例</param> private void SaveStackTrays(List <CacheStackTray> trayCodeList, BaseAccess access, string flag) { // 按照允许叠盘数量依次增加,根据实际情况而定,其中1盘在最上面,就不需要翻转 // 翻转保存 // trayCodeList.Reverse(); long traysId = SelectTraysId(trayCodeList[trayCodeList.Count - int.Parse(flag)].Barcode, access); int trayIndex = 0; foreach (var item in trayCodeList) { if (flag == "2" && item.InStack == 1) { continue; } StackTrays tray = new StackTrays(); //tray.Id = Guid.NewGuid(); tray.TraysId = traysId; tray.Barcode = item.Barcode; tray.Batch = item.Batch; tray.TrayIndex = ++trayIndex; tray.UpdateTime = DateTime.Now; string insertSql = string.Format("INSERT INTO {0} (TraysId,Barcode,Batch,TrayIndex,UpdateTime) OUTPUT INSERTED.Id VALUES ('{1}','{2}','{3}','{4}','{5}')", lineDevice.PrefixTable + "StackTrays", tray.TraysId, tray.Barcode, tray.Batch, tray.TrayIndex, tray.UpdateTime); access.ExecuteNonQuery(insertSql); //int count = access.Insert(tray, StackTrays.TRAYS_ID, StackTrays.BARCODE, StackTrayFlow.BATCH, StackTrays.TRAY_INDEX, StackTrayFlow.UPDATE_TIME); ProductProcessDataEntity entity = new ProductProcessDataEntity() { TrayCode = item.Barcode, CreateTime = DateTime.Now, State = "叠盘完成", MaterialData = item.Batch }; //WriteProductDateBase(Writers["scanCodeFeedbackAddr"], entity); WriteProductDateBase(device, entity); } }
/// <summary> /// 获取所有分组,从数据库取 /// </summary> /// <returns></returns> public List <OrganizationInfo> GetAllOrgans(Organization_S model) { using (var factory = new BaseAccess()) { var spec = Specification <OrganizationEntity> .Create(c => c.RecordStatus != (int)RecordStatus.UnEnable); if (!string.IsNullOrWhiteSpace(model.OrganName)) { spec &= Specification <OrganizationEntity> .Create(c => c.OrganName.Contains(model.OrganName)); } if (!string.IsNullOrWhiteSpace(model.Extend4)) { spec &= Specification <OrganizationEntity> .Create(c => c.Extend4 == model.Extend4); } return(factory.GetAll <OrganizationEntity>(spec).Adapter <OrganizationEntity, OrganizationInfo>(new List <OrganizationInfo>())); } }
/// <summary> /// 获取所有菜单(除管理员菜单) /// </summary> /// <returns></returns> public List <Article_S> GetAllArticles(string ColumnId) { using (var factory = new BaseAccess()) { List <Orderby <ArticleEntity> > orders = new List <Orderby <ArticleEntity> >() { new Orderby <ArticleEntity>(c => c.DT_ADD_TIME, SortOrder.Descending) }; var Column = factory.GetSingle <MenuEntity>(Specification <MenuEntity> .Create(c => c.MenuCode == ColumnId)); var spec = Specification <ArticleEntity> .Create(c => c.N_COLUMN_ID == ColumnId); spec &= Specification <ArticleEntity> .Create(c => c.C_STATUS == "1"); var list = factory.GetAll <ArticleEntity>(spec, orders) .Adapter <ArticleEntity, Article_S>(new List <Article_S>()); return(list); } }
/// <summary> /// 得到网站访问量 /// </summary> /// <returns></returns> public int GetPageViewsCount() { using (var factory = new BaseAccess()) { try { var spec = Specification <HitRecordEntity> .Create(c => c.C_HIT_TYPE == "2");//网站访问量 int hitrecord = factory.GetCount <HitRecordEntity>(spec); return(hitrecord); } catch { return(0); } } }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> public void Edit(Menu_U model) { using (var factory = new BaseAccess()) { if (!string.IsNullOrEmpty(model.ID)) { var model_old = factory.GetSingle <MenuEntity>(model.ID); model_old = model.Adapter <MenuEntity>(model_old);//将页面对象的属性转换到数据库对象modle中 factory.Update <MenuEntity>(model_old); //清理缓存 if (model_old.MenuType == (int)MenuType.Function) { CacheshipFactory.Instance.ClearFunMenuCache(); } } } }
/// <summary> /// 根据标识获得导航 /// </summary> /// <returns></returns> public Navigation_S GetNavByKey(string key) { using (var factory = new BaseAccess()) { NavigationEntity Column = factory.GetSingle <NavigationEntity>(Specification <NavigationEntity> .Create(c => c.N_NAV_CODE == key)); if (Column != null) { Navigation_S ss = new Navigation_S(); Column.Adapter <Navigation_S>(ss); return(Column.Adapter <Navigation_S>(new Navigation_S())); } return(new Navigation_S()); } }
/// <summary> /// 删除历史托盘数据 /// </summary> /// <param name="trayId"></param> /// <returns></returns> public bool DeleteStackTray(int trayId) { using (BaseAccess access = new BaseAccess()) { try { string deleteSql = string.Format("DELETE FROM {0} WHERE Id='{1}'", lineDevice.PrefixTable + "StackTrays", trayId); access.ExecuteNonQuery(deleteSql); //BaseCondition condition = new Column(StackTrays.ID).Equal(trayId); //access.Delete<StackTrays>(condition); } catch (Exception ex) { PrintInfo.I(ex.Message); Console.WriteLine(ex.Message); } } return(true); }
/// <summary> /// 获取所有用户数据 /// </summary> /// <param name="user"></param> /// <param name="pi"></param> /// <returns></returns> public List <User_S> GetAllUsers(User_S user) { using (var factory = new BaseAccess(base._DBConfigPath)) { var spec = Specification <UserEntity> .Create(c => c.UserType != (int)UserType.Administrators); if (!string.IsNullOrEmpty(user.UserDisplayName)) { spec &= Specification <UserEntity> .Create(c => c.UserDisplayName.Contains(user.UserDisplayName)); } if (!string.IsNullOrEmpty(user.UserLoginName)) { spec &= Specification <UserEntity> .Create(c => c.UserLoginName.Contains(user.UserLoginName)); } var list = factory.GetAll <UserEntity>(spec, c => c.UserDisplayName, SortOrder.Ascending); return((list ?? new List <UserEntity>()).Adapter <UserEntity, User_S>(new List <User_S>())); } }
/// <summary> /// 获取用户分页数据 /// </summary> /// <param name="LoginNameOrDisplayName"></param> /// <param name="pi"></param> /// <returns></returns> public List <UserInfo> GetUserPaged(string LoginName, string DisplayName, PageInfo pi) { using (var factory = new BaseAccess(base._DBConfigPath)) { var spec = Specification <UserEntity> .Create(c => c.UserType != (int)UserType.Administrators); if (!string.IsNullOrEmpty(DisplayName)) { spec &= Specification <UserEntity> .Create(c => c.UserDisplayName.Contains(DisplayName)); } if (!string.IsNullOrEmpty(LoginName)) { spec &= Specification <UserEntity> .Create(c => c.UserLoginName.Contains(LoginName)); } var list = factory.GetPage <UserEntity>(pi, spec, c => c.UserDisplayName, SortOrder.Ascending); return((list ?? new List <UserEntity>()).Adapter <UserEntity, UserInfo>(new List <UserInfo>())); } }
/// <summary> /// 获取分页数据 /// </summary> /// <param name="Role"></param> /// <param name="pi"></param> /// <returns></returns> public List <AppRegister_S> GetRolePaged(AppRegister_S app, PageInfo pi) { using (var factory = new BaseAccess(base._DBConfigPath)) { var spec = Specification <SYS_AppRegisterEntity> .Create(c => true); if (!string.IsNullOrEmpty(app.AppName)) { spec &= Specification <SYS_AppRegisterEntity> .Create(c => c.AppName.Contains(app.AppName)); } if (!string.IsNullOrEmpty(app.AppRegisterID)) { spec &= Specification <SYS_AppRegisterEntity> .Create(c => c.AppRegisterID.Contains(app.AppRegisterID)); } var list = factory.GetPage <SYS_AppRegisterEntity>(pi, spec, c => c.OrderNum, SortOrder.Ascending); return((list ?? new List <SYS_AppRegisterEntity>()).Adapter <SYS_AppRegisterEntity, AppRegister_S>(new List <AppRegister_S>())); } }