public string CreateTemplate(string name, string content, string userId)
        {
            string id = Guid.NewGuid().ToString();
            TOP.Template.Domain.Template template = new TOP.Template.Domain.Template();
            template.Name = name;
            template.Content = content;
            template.CreateUserId = userId;
            template.LastUpdateUserId = userId;

            #region 执行SQL以创建对象

            TemplateManager manager = new TemplateManager();
            string sqlCreate = manager.GetCreateSql(template);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreate);
                    dbOperator.CommintTran();

                    return id;
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("创建模板发生异常 - ", ex);
                }
            }

            #endregion
        }
 public List<TemplateInfo> GetTemplateInfoListByUserId(string userId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(TemplateInfo));
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return TransferList<TemplateInfo>(dt);
     }
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string value = tvSchema.SelectedNode.Value;
            if (value != "table" && value != "view")
            {
                Type type = Type.GetType(value);
                string dbTypeId = ConfigurationManager.AppSettings["DbType"];
                TOP.Common.DbHelper.DbType dbType = (TOP.Common.DbHelper.DbType)short.Parse(dbTypeId);
                string connString = ConfigurationManager.AppSettings["ConnString"];

                string sqlDrop = string.Empty;
                string sqlCreate = string.Empty;

                string parent = tvSchema.SelectedNode.Parent.Value;
                if (parent.Equals("Table", StringComparison.OrdinalIgnoreCase))
                {
                    DbSqlCreater dbSqlCreater = DbSqlCreater.GetDbSqlCreater(dbType);
                    sqlDrop = dbSqlCreater.GenerateDropTableSql(type);
                    sqlCreate = dbSqlCreater.GenerateCreateTableSql(type);
                }
                else if (parent.Equals("View", StringComparison.OrdinalIgnoreCase))
                {
                    string baseDir = Server.MapPath("~");
                    baseDir += @"\..\..\Database\Scripts";
                    DbQuery dbQuery = DbQuery.GetDbQuery(dbType);
                    sqlDrop = dbQuery.GenerateDropViewSql(type, baseDir);
                    sqlCreate = dbQuery.GenerateCreateViewSql(type, baseDir);
                }
                else
                {
                    throw new ArgumentException("不能更新的类型 - " + parent + " - " + value);
                }

                using (DbOperator dbOperator = new DbOperator(connString))
                {
                    try
                    {
                        dbOperator.BeginTran();
                        dbOperator.ExecSql(sqlDrop);
                        dbOperator.ExecSql(sqlCreate);
                        dbOperator.CommintTran();

                        lblMessage.Text = "更新成功 - " + parent + " - " + value;
                    }
                    catch
                    {
                        dbOperator.RollbackTran();
                        throw new Exception("更新数据库对象错误 - " + parent + " - " + value);
                    }
                }
            }
            else
            {
                lblMessage.Text = "所选择对象无效,请选择要更新的数据库对象。";
            }
        }
 public void DeleteItemCategoryByParentId(string categoryId)
 {
     ItemCategory category = new ItemCategory();
     ItemCategoryManager manager = new ItemCategoryManager();
     string sqlDelete = manager.GetDeleteSql(category);
     sqlDelete += string.Format("WHERE [ParentId] = N'{0}'", categoryId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         dbOperator.ExecSql(sqlDelete);
     }
 }
        public string AddArea(string id, string areaId, string areaTypeId, string areaName, string parentId, string zip, string createUserId)
        {
            #region 构造要新增的对象

            if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
            {
                id = Guid.NewGuid().ToString();
            }

            Area area = new Area();
            area.Id = id;
            area.AreaId = areaId;
            area.AreaTypeId = areaTypeId;
            area.AreaName = areaName;
            area.ParentId = parentId;
            area.Zip = zip;
            area.CreateDate = DateTime.Now;
            area.CreateUserId = createUserId;
            area.LastUpdateDate = DateTime.Now;
            area.LastUpdateUserId = createUserId;

            #endregion

            #region 执行SQL以创建对象

            AreaManager manager = new AreaManager();
            string sqlCreate = manager.GetCreateSql(area);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreate);
                    dbOperator.CommintTran();

                    return id;
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("新增区域发生异常 - ", ex);
                }
            }

            #endregion
        }
 public TemplateContentInfo GetTemplateContentById(string templateId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(TemplateContentInfo));
     sqlSelect += string.Format(" WHERE [Id] = '{0}'", templateId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<TemplateContentInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
 public ItemCategoryInfo GetItemCategoryById(string categoryId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ItemCategoryInfo));
     sqlSelect += string.Format("WHERE [CategoryId] = N'{0}'", categoryId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<ItemCategoryInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
 /// <summary>
 /// 登录,并返回登录用户。如果登录失败,则返回null。
 /// </summary>
 /// <param name="loginName">登录名</param>
 /// <param name="password">加密后的密码</param>
 /// <returns></returns>
 public UserInfo Login(string loginName, string password)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(UserInfo));
     sqlSelect += string.Format("WHERE [LoginName] = N'{0}' AND [Password] = N'{1}'", loginName, password);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         if (dt.Rows.Count > 0)
         {
             return TransferInfo<UserInfo>(dt.Rows[0]);
         }
         else
         {
             return null;
         }
     }
 }
        public void AddImportGroup(string groupId, string operatorUserId, string operatorUserName, int totalCount
            , string fromNick, string fromTitle, string fromImageUrl, string toNick, string toTitle
            , ImportorEnumerations.ImportType importType, string userId)
        {
            ImportGroup groupEntity = new ImportGroup();
            groupEntity.Id = groupId;
            groupEntity.OperatorUserId = operatorUserId;
            groupEntity.OperatorUserName = operatorUserName;
            groupEntity.TotalCount = totalCount;
            groupEntity.SuccessCount = 0;
            groupEntity.FailCount = 0;
            groupEntity.ImportFormSellerNick = fromNick;
            groupEntity.ImportFormShopTitle = fromTitle;
            groupEntity.ImportFormShopImageUrl = fromImageUrl;
            groupEntity.ImportToSellerNick = toNick;
            groupEntity.ImportToShopTitle = toTitle;
            groupEntity.ImportType = importType;
            groupEntity.ImportState = ImportorEnumerations.ImportState.Waitting;
            groupEntity.ImportResult = ImportorEnumerations.ImportGroupResult.Pending;
            groupEntity.ListDateTime = DateTime.Now;
            groupEntity.StartDateTime = null;
            groupEntity.FinishDateTime = null;

            groupEntity.CreateDate = DateTime.Now;
            groupEntity.CreateUserId = userId;
            groupEntity.LastUpdateDate = DateTime.Now;
            groupEntity.LastUpdateUserId = userId;

            ImportGroupManager groupManager = new ImportGroupManager();
            string sqlCreateGroup = groupManager.GetCreateSql(groupEntity);

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreateGroup);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("添加导入组发生异常 - ", ex);
                }
            }
        }
        public string AddItemCategory(string id, string categoryId, string parentId, string name, bool isParent, string status, int sortOrder)
        {
            #region 构造要新增的对象

            if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
            {
                id = Guid.NewGuid().ToString();
            }

            ItemCategory category = new ItemCategory();
            category.Id = id;
            category.CategoryId = categoryId;
            category.ParentId = parentId;
            category.Name = name;
            category.IsParent = isParent;
            category.Status = status;
            category.SortOrder = sortOrder;

            #endregion

            #region 执行SQL以创建对象

            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreate);
                    dbOperator.CommintTran();

                    return id;
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("新增类目发生异常 - ", ex);
                }
            }

            #endregion
        }
 public void DbInitialize()
 {
     string sqlDropTable = dbSqlCreater.GenerateDropTableSql(typeof(Area));
     string sqlCreateTable = dbSqlCreater.GenerateCreateTableSql(typeof(Area));
     using (DbOperator dbOperator = new DbOperator(connString))
     {
         try
         {
             dbOperator.BeginTran();
             dbOperator.ExecSql(sqlDropTable);
             dbOperator.ExecSql(sqlCreateTable);
             dbOperator.CommintTran();
         }
         catch (Exception ex)
         {
             dbOperator.RollbackTran();
             Assert.Fail("初始化数据库错误 - " + ex.Message);
         }
     }
 }
        public void TestAddItemCategory_正确添加()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";

            #region 验证前置条件

            MSSql2005Query query = new MSSql2005Query();
            string sqlQuery = query.GenerateSelectViewSql(typeof(ItemCategoryInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            string idNew = facade.AddItemCategory(id, "50011665", "0", "网游装备/游戏币/帐号/代练", false, "normal", 0);

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("50011665", dt.Rows[0]["CategoryId"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("网游装备/游戏币/帐号/代练", dt.Rows[0]["Name"].ToString(), true);
                Assert.AreEqual("false", dt.Rows[0]["IsParent"].ToString(), true);
                Assert.AreEqual("normal", dt.Rows[0]["Status"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["SortOrder"].ToString(), true);
            }

            #endregion
        }
        public void TestAddArea_正确添加区域()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-037453d53919";

            #region 验证前置条件

            MSSql2005Query query = new MSSql2005Query();
            string sqlQuery = query.GenerateSelectViewSql(typeof(AreaInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            AreaFacade facade = new AreaFacade();
            string idNew = facade.AddArea(id, "401331", AreaType.Province, "重庆市", "", "401331");

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-037453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-037453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("401331", dt.Rows[0]["AreaId"].ToString(), true);
                Assert.AreEqual("2", dt.Rows[0]["AreaType"].ToString(), true);
                Assert.AreEqual("重庆市", dt.Rows[0]["AreaName"].ToString(), true);
                Assert.AreEqual("", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("401331", dt.Rows[0]["Zip"].ToString(), true);
            }

            #endregion
        }
Example #14
0
        /// <summary>
        /// 注册新用户。返回用户Id。
        /// </summary>
        /// <param name="id"></param>
        /// <param name="loginName">登录名</param>
        /// <param name="password">加密后的密码</param>
        /// <param name="userName">用户名</param>
        /// <returns></returns>
        public string Register(string id, string loginName, string password, string userName)
        {
            #region 构造要新增的对象

            if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString())
            {
                id = Guid.NewGuid().ToString();
            }

            User _user = new User();
            _user.Id = id;
            _user.LoginName = loginName;
            _user.Password = password;
            _user.UserName = userName;

            #endregion

            #region 执行SQL以创建对象

            UserManager manager = new UserManager();
            string sqlCreate = manager.GetCreateSql(_user);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreate);
                    dbOperator.CommintTran();

                    return id;
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("注册用户发生异常 - ", ex);
                }
            }

            #endregion
        }
        public void StartImport(string groupId, int version, string userId)
        {
            ImportGroup groupEntity = new ImportGroup();
            groupEntity.Id = groupId;
            groupEntity.ImportState = ImportorEnumerations.ImportState.Importing;

            groupEntity.LastUpdateDate = DateTime.Now;
            groupEntity.LastUpdateUserId = userId;
            groupEntity.CurrentVersion = version;

            #region 执行SQL以修改对象

            ImportGroupManager manager = new ImportGroupManager();
            string sqlUpdate = manager.GetUpdateSql(groupEntity, "ImportState");
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlUpdate);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("启动导入过程发生异常 - ", ex);
                }
            }

            #endregion
        }
        public void StartImportItem(string itemId, int version, string userId)
        {
            ImportItem itemEntity = new ImportItem();
            itemEntity.Id = itemId;
            itemEntity.ImportState = ImportorEnumerations.ImportState.Importing;
            itemEntity.StartDateTime = DateTime.Now;

            itemEntity.LastUpdateDate = DateTime.Now;
            itemEntity.LastUpdateUserId = userId;
            itemEntity.CurrentVersion = version;

            ImportItemManager manager = new ImportItemManager();
            string sqlUpdateItem = manager.GetUpdateSql(itemEntity, "ImportState", "StartDateTime");

            #region 执行SQL以修改对象

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlUpdateItem);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("启动导入宝贝发生异常 - ", ex);
                }
            }

            #endregion
        }
 public List<ItemCategoryInfo> GetItemCategoryListByParent(string parentId)
 {
     if (string.IsNullOrEmpty(parentId))
     {
         parentId = "0";
     }
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ItemCategoryInfo));
     sqlSelect += string.Format("WHERE [ParentId] = N'{0}' ", parentId);
     sqlSelect += "ORDER BY [SortOrder] ASC";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         List<ItemCategoryInfo> list = new List<ItemCategoryInfo>();
         DataTable dt = dbOperator.GetTable(sqlSelect);
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<ItemCategoryInfo>(row));
         }
         return list;
     }
 }
        public void TestGetItemCategoryListByParent_有一条根数据()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            category.Name = "测试类目";
            category.ParentId = "0";
            category.IsParent = true;
            category.SortOrder = 1;
            category.Status = "normal";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            List<ItemCategoryInfo> list = facade.GetItemCategoryListByParent(string.Empty);

            #region 验证后置条件

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", list[0].Id);
            Assert.AreEqual("50011665", list[0].CategoryId);
            Assert.AreEqual("测试类目", list[0].Name);
            Assert.AreEqual("0", list[0].ParentId);
            Assert.AreEqual(true, list[0].IsParent);
            Assert.AreEqual(1, list[0].SortOrder);
            Assert.AreEqual("normal", list[0].Status);

            #endregion
        }
        public void AddImportItem(string itemId, string groupId, string operatorUserId, string operatorUserName
            , string fromItemIid, string fromItemTitle, string fromItemPrice, string fromSellerNick, string fromShopTitle, string userId)
        {
            ImportItem itemEntity = new ImportItem();
            itemEntity.Id = itemId;
            itemEntity.OperatorUserId = operatorUserId;
            itemEntity.OperatorUserName = operatorUserName;
            itemEntity.ItsImportGroupId = groupId;
            itemEntity.ImportFormItemIid = fromItemIid;
            itemEntity.ImportFormItemTitle = fromItemTitle;
            itemEntity.ImportFormItemPrice = fromItemPrice;
            itemEntity.ImportFormSellerNick = fromSellerNick;
            itemEntity.ImportFormShopTitle = fromShopTitle;
            itemEntity.ImportState = ImportorEnumerations.ImportState.Waitting;
            itemEntity.ImportResult = ImportorEnumerations.ImportItemResult.Pending;
            itemEntity.ListDateTime = DateTime.Now;
            itemEntity.StartDateTime = null;
            itemEntity.FinishDateTime = null;

            itemEntity.CreateDate = DateTime.Now;
            itemEntity.CreateUserId = userId;
            itemEntity.LastUpdateDate = DateTime.Now;
            itemEntity.LastUpdateUserId = userId;

            ImportItemManager itemManager = new ImportItemManager();
            string sqlCreateItem = itemManager.GetCreateSql(itemEntity);

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreateItem);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("添加导入项发生异常 - ", ex);
                }
            }
        }
Example #20
0
 public List<AreaInfo> GetAllProvinceAreaList()
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(AreaInfo));
     sqlSelect += string.Format("WHERE [AreaType] = N'{0}'", (int)AreaType.Province);
     sqlSelect += " ORDER BY [AreaId]";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         List<AreaInfo> list = new List<AreaInfo>();
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<AreaInfo>(row));
         }
         return list;
     }
 }
        public void TestGetItemCategory_已经存在的情况()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            category.Name = "测试类目";
            category.ParentId = "0";
            category.IsParent = true;
            category.SortOrder = 1;
            category.Status = "normal";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            ItemCategoryInfo categoryInfo = facade.GetItemCategoryById("50011665");

            #region 验证后置条件

            Assert.IsNotNull(categoryInfo);
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", categoryInfo.Id);
            Assert.AreEqual("50011665", categoryInfo.CategoryId);
            Assert.AreEqual("测试类目", categoryInfo.Name);
            Assert.AreEqual("0", categoryInfo.ParentId);
            Assert.AreEqual(true, categoryInfo.IsParent);
            Assert.AreEqual(1, categoryInfo.SortOrder);
            Assert.AreEqual("normal", categoryInfo.Status);

            #endregion
        }
Example #22
0
        public void UpdateArea(string areaId, string areaTypeId, string areaName, string parentId, string zip, string updateUserId)
        {
            #region 构造要修改的对象

            Area area = new Area();
            area.AreaTypeId = areaTypeId;
            area.AreaName = areaName;
            area.ParentId = parentId;
            area.Zip = zip;
            area.LastUpdateDate = DateTime.Now;
            area.LastUpdateUserId = updateUserId;

            #endregion

            #region 执行SQL以修改对象

            AreaManager manager = new AreaManager();
            string sqlUpdate = manager.GetUpdateSql(area);
            sqlUpdate += string.Format("WHERE [AreaId] = N'{0}'", areaTypeId);
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlUpdate);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("修改区域发生异常 - ", ex);
                }
            }

            #endregion
        }
        public void TestGetItemCategoryListByParent_父子数据情况()
        {
            #region 验证前置条件

            ItemCategory category1 = new ItemCategory();
            category1.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category1.CategoryId = "50011665";
            category1.Name = "测试类目1";
            category1.ParentId = "0";
            category1.IsParent = true;
            category1.SortOrder = 1;
            category1.Status = "normal";

            ItemCategory category2 = new ItemCategory();
            category2.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53929";
            category2.CategoryId = "50011667";
            category2.Name = "测试类目2";
            category2.ParentId = "50011665";
            category2.IsParent = true;
            category2.SortOrder = 0;
            category2.Status = "deleted";

            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate1 = manager.GetCreateSql(category1);
            string sqlCreate2 = manager.GetCreateSql(category2);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate1);
                dbOperator.ExecSql(sqlCreate2);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();

            #region 验证后置条件

            List<ItemCategoryInfo> list1 = facade.GetItemCategoryListByParent(string.Empty);

            Assert.AreEqual(1, list1.Count);
            ItemCategoryInfo categoryInfo1 = list1[0];
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", categoryInfo1.Id);
            Assert.AreEqual("50011665", categoryInfo1.CategoryId);
            Assert.AreEqual("测试类目1", categoryInfo1.Name);
            Assert.AreEqual("0", categoryInfo1.ParentId);
            Assert.AreEqual(true, categoryInfo1.IsParent);
            Assert.AreEqual(1, categoryInfo1.SortOrder);
            Assert.AreEqual("normal", categoryInfo1.Status);

            List<ItemCategoryInfo> list2 = facade.GetItemCategoryListByParent("50011665");

            ItemCategoryInfo categoryInfo2 = list2[0];
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53929", categoryInfo2.Id);
            Assert.AreEqual("50011667", categoryInfo2.CategoryId);
            Assert.AreEqual("测试类目2", categoryInfo2.Name);
            Assert.AreEqual("50011665", categoryInfo2.ParentId);
            Assert.AreEqual(true, categoryInfo2.IsParent);
            Assert.AreEqual(0, categoryInfo2.SortOrder);
            Assert.AreEqual("deleted", categoryInfo2.Status);

            #endregion
        }
Example #24
0
 public bool IsHasChildren(string parentId)
 {
     string sqlSelect = sqlHelper.GenerateCountViewSql(typeof(AreaInfo));
     sqlSelect += string.Format("WHERE [ParentId] = N'{0}'", parentId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return (int)dt.Rows[0]["RowCount"] > 0;
     }
 }
Example #25
0
 public bool IsAreaExist(string areaId)
 {
     string sqlCheck = sqlHelper.GenerateCountViewSql(typeof(AreaInfo));
     sqlCheck += string.Format("WHERE [AreaId] = N'{0}'", areaId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlCheck);
         return (int)dt.Rows[0]["RowCount"] > 0;
     }
 }
 public List<ImportItemInfo> GetImportItemList(string groupId)
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ImportItemInfo));
     sqlSelect += string.Format("WHERE [ItsImportGroupId] = N'{0}'", groupId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         return TransferList<ImportItemInfo>(dt);
     }
 }
        public List<ImportItemInfo> GetImportItemList(string groupId, int pageIndex, int pageSize)
        {
            int start = pageIndex * pageSize + 1;
            int end = start + pageSize - 1;
            string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(ImportItemInfo));
            sqlSelect += string.Format("WHERE [ItsImportGroupId] = N'{0}'", groupId);
            sqlSelect = "SELECT * FROM (SELECT *, ROW_NUMBER() OVER(ORDER BY [LastUpdateDate] DESC) AS [RowNum] FROM ("
                + sqlSelect
                + string.Format(") AS [MyTable]) AS [T1] WHERE [T1].[RowNum] BETWEEN {0} AND {1}", start, end);

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                DataTable dt = dbOperator.GetTable(sqlSelect);
                return TransferList<ImportItemInfo>(dt);
            }
        }
 public bool IsItemCategoryExist(string categoryId)
 {
     string sqlCheck = sqlHelper.GenerateCountViewSql(typeof(ItemCategoryInfo));
     sqlCheck += string.Format("WHERE [CategoryId] = N'{0}'", categoryId);
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlCheck);
         int i = (int)dt.Rows[0][0];
         return i > 0;
     }
 }
Example #29
0
 public List<AreaInfo> GetAllRootAreaList()
 {
     string sqlSelect = sqlHelper.GenerateSelectViewSql(typeof(AreaInfo));
     sqlSelect += "WHERE [ParentId] = N'0'";
     sqlSelect += " ORDER BY [AreaId]";
     using (DbOperator dbOperator = new DbOperator(ConnString))
     {
         DataTable dt = dbOperator.GetTable(sqlSelect);
         List<AreaInfo> list = new List<AreaInfo>();
         foreach (DataRow row in dt.Rows)
         {
             list.Add(TransferInfo<AreaInfo>(row));
         }
         return list;
     }
 }
        public void TestIsItemCategoryExist_已经存在的情况()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            bool isExist = facade.IsItemCategoryExist("50011665");

            Assert.AreEqual(true, isExist);
        }