Пример #1
0
        public void AddList(ListItemInfo list)
        {
            try
            {
                list.Name = list.Name.Trim();

                ObjectPersistence persistence = new ObjectPersistence(DbAccess);
                Criteria cri = new Criteria();
                cri.Add(Expression.Equal("Name", list.Name));
                if (!string.IsNullOrEmpty(list.Id))
                {
                    cri.Add(Expression.NotEqual("Id", list.Id));
                }
                IList<ListItemInfo> tmpList = persistence.GetList<ListItemInfo>(cri);
                if (tmpList.Count > 0)
                {
                    throw new FacadeException("列表名称已经存在,请重新输入!");
                }
                ListItemEntity entity = new ListItemEntity();
                entity.Name = list.Name;
                PageManager manager = new PageManager(DbAccess);
                manager.AddEntity<ListItemEntity>(entity);
                list.Id = entity.Id;
            }
            catch (Exception ex)
            {
                throw HandleException("Page", "AddList - " + list.Name, ex);
            }
        }
Пример #2
0
 public IList<MenuInfo> GetRootMenuList()
 {
     ObjectPersistence persistence = new ObjectPersistence(DbAccess);
     Criteria cri = new Criteria();
     cri.Add(Expression.IsNull("ParentId"));
     return persistence.GetList<MenuInfo>(cri, new SortInfo("Index"));
 }
Пример #3
0
 public IList<BonusDetailEntity> GetBonusDetailList(string gameName, string issueNumber)
 {
     Criteria cri = new Criteria();
     cri.Add(Expression.Equal("GameName", gameName));
     cri.Add(Expression.Equal("IssueNumber", issueNumber));
     return persistence.GetList<BonusDetailEntity>(cri, new SortInfo("TicketId"), new SortInfo("BonusLevel"));
 }
 public IList<PageBlockInfo> GetRowBlockList(int yIndex)
 {
     ObjectPersistence persistence = new ObjectPersistence(DbAccess);
     Criteria cri = new Criteria();
     cri.Add(Expression.Equal("YIndex", yIndex));
     return persistence.GetList<PageBlockInfo>(cri, new SortInfo("XIndex"));
 }
Пример #5
0
 public void LoadChildrenMenuList(MenuInfo menu, bool isEnforce)
 {
     if (menu.Children == null || isEnforce)
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         cri.Add(Expression.Equal("ParentId", menu.Id));
         menu.Children = persistence.GetList<MenuInfo>(cri, new SortInfo("Index"));
     }
 }
Пример #6
0
 public IList<NoticeInfo> GetCurrentNoticeList()
 {
     try
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         cri.Add(Expression.Equal("IsEnd", false));
         cri.Add(Expression.GreaterThanEqual("EndTime", DateTime.Now));
         cri.Add(Expression.LessThanEqual("StartTime", DateTime.Now));
         return persistence.GetList<NoticeInfo>(cri, new SortInfo("UpdateTime", SortDirection.Desc));
     }
     catch (Exception ex)
     {
         throw HandleException("Notice", "GetCurrentNoticeList", ex);
     }
 }
Пример #7
0
 public LoginEntity Authenticate(string userId, string password)
 {
     password = EncryptTool.MD5(password);
     Criteria cri = new Criteria();
     cri.Add(
         Expression.And(
             Expression.Equal("UserId", userId)
             , Expression.Equal("Password", password)
         ));
     IList<UserPassowrdEntity> users = persistence.GetList<UserPassowrdEntity>(cri);
     if (users.Count > 0)
     {
         if (users[0].IsCanLogin)
         {
             return users[0];
         }
         throw new LoginException(LoginErrorType.UserCannotLogin);
     }
     throw new LoginException(LoginErrorType.UserIdOrPasswordError);
 }
 private DbCommand GetDbCommand(Criteria criteria, params SortInfo[] orderBy)
 {
     TypeSchema entityInfo = ORMSchemaCache.GetTypeSchema(this.ObjectType);
     List<PropertyInfo> fieldPropertyList = new List<PropertyInfo>();
     string sqlFields = GetSelectStatement(entityInfo);
     List<DbParameter> parameters;
     string sqlWhere = criteria.GenerateExpression(this.ObjectType, out parameters, DbAccess);
     string sqlOrder = ToOrderByClause(this.ObjectType, orderBy);
     StringBuilder sqlBuilder = new StringBuilder();
     if (NeedPaged)
     {
         if (sqlOrder == "")
         {
             foreach (SchemaItem mfi in entityInfo.GetKeyFieldInfos())
             {
                 if (sqlOrder != "")
                 {
                     sqlOrder += ",";
                 }
                 else
                 {
                     sqlOrder += "ORDER BY ";
                 }
                 sqlOrder += GetQuotedName(mfi.MappingFieldAttribute.FieldName) + " ASC";
             }
         }
         sqlBuilder.AppendLine("WITH [TMP] AS(");
         sqlBuilder.AppendLine("SELECT *, ROW_NUMBER() OVER (" + sqlOrder + ") AS [ROW]");
         sqlBuilder.AppendLine("FROM(");
         sqlBuilder.AppendLine(string.Format("SELECT {0}", sqlFields));
         sqlBuilder.AppendLine(string.Format("WHERE 1=1 {0}", sqlWhere));
         sqlBuilder.AppendLine(") AS [A] )");
         sqlBuilder.AppendLine("SELECT * FROM [TMP]");
         sqlBuilder.AppendLine("INNER JOIN (SELECT COUNT([ROW]) AS [TotalCount] FROM [TMP]) AS [B] ON 1 = 1");
         sqlBuilder.AppendLine(string.Format(" AND ROW > {0} AND ROW <= {1}", PageSize * (PageIndex - 1), PageSize * PageIndex));
     }
     else
     {
         sqlBuilder.AppendLine(string.Format("SELECT {0}", sqlFields));
         sqlBuilder.AppendLine(string.Format("WHERE 1=1 {0}", sqlWhere));
         sqlBuilder.AppendLine(sqlOrder);
     }
     DbCommand dbCommand = GetDbCommandByEntity(fieldPropertyList, null);
     dbCommand.Parameters.AddRange(parameters.ToArray());
     dbCommand.CommandText = sqlBuilder.ToString();
     return dbCommand;
 }
Пример #9
0
        public void ModifyListName(string listId, string newName)
        {
            try
            {
                newName = newName.Trim();

                ObjectPersistence persistence = new ObjectPersistence(DbAccess);
                Criteria cri = new Criteria();
                cri.Add(Expression.Equal("Name", newName));
                cri.Add(Expression.NotEqual("Id", listId));
                IList<ListItemInfo> tmpList = persistence.GetList<ListItemInfo>(cri);
                if (tmpList.Count > 0)
                {
                    throw new FacadeException("列表名称已经存在,请重新输入!");
                }
                ListItemEntity entity = new ListItemEntity();
                entity.Id = listId;
                entity.Name = newName;
                PageManager manager = new PageManager(DbAccess);
                manager.ModifyEntity<ListItemEntity>(entity);
            }
            catch (Exception ex)
            {
                throw HandleException("Page", "ModifyListName - " + listId + " : " + newName, ex);
            }
        }
Пример #10
0
 public IList<MenuItemInfo> GetTopMenuList()
 {
     try
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         cri.Add(Expression.Or(
             Expression.IsNull("ParentId"),
             Expression.Equal("ParentId", "")));
         return persistence.GetList<MenuItemInfo>(cri, new SortInfo("Index"));
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "GetTopMenuList", ex);
     }
 }
Пример #11
0
 public IList<HtmlItemInfo> GetHtmlItemsByParent(string listId)
 {
     try
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         if (string.IsNullOrEmpty(listId) || listId == Guid.Empty.ToString("N"))
         {
             cri.Add(Expression.Or(
                 Expression.IsNull("ItsListId"),
                 Expression.Equal("ItsListId", "")));
         }
         else
         {
             cri.Add(Expression.Equal("ItsListId", listId));
         }
         return persistence.GetList<HtmlItemInfo>(cri, new SortInfo("LastUpdateTime", SortDirection.Desc));
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "GetHtmlItemsByParent - " + listId, ex);
     }
 }
Пример #12
0
 public IList<MenuItemInfo> GetChildrenMenuList(string parentId)
 {
     try
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         cri.Add(Expression.Equal("ParentId", parentId));
         return persistence.GetList<MenuItemInfo>(cri, new SortInfo("Index"));
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "GetChildrenMenuList - " + parentId, ex);
     }
 }
Пример #13
0
 public void DeleteList(string listId)
 {
     ObjectPersistence persistence = new ObjectPersistence(DbAccess);
     Criteria cri = new Criteria();
     cri.Add(Expression.Equal("ItsListId", listId));
     IList<HtmlItemInfo> list = persistence.GetList<HtmlItemInfo>(cri);
     if (list.Count > 0)
     {
         throw new FacadeException("此列表包含有子页面,请先删除列表下的全部子页面。");
     }
     try
     {
         ListItemEntity entity = new ListItemEntity();
         entity.Id = listId;
         PageManager manager = new PageManager(DbAccess);
         manager.DeleteEntity<ListItemEntity>(entity);
     }
     catch (Exception ex)
     {
         throw HandleException("Page", "DeleteList - " + listId, ex);
     }
 }
Пример #14
0
 public IList<RequestGetMoneyInfo> GetRequestMoneyList(string userId)
 {
     try
     {
         ObjectPersistence persistence = new ObjectPersistence(DbAccess);
         Criteria cri = new Criteria();
         cri.Add(Expression.Equal("UserId", userId));
         return persistence.GetList<RequestGetMoneyInfo>(cri, new SortInfo("Status"), new SortInfo("RequestTime", SortDirection.Desc));
     }
     catch (Exception ex)
     {
         string errMsg = "获取用户请求提款失败!";
         throw HandleException(LogCategory.Money, errMsg, ex);
     }
 }