private void UpdateAreas(out int total, out int added, out int updated) { added = 0; updated = 0; TOP.Management.Facade.AreaFacade areaFacade = new TOP.Management.Facade.AreaFacade(); TOP.Core.Facade.AreaFacade topFacade = new TOP.Core.Facade.AreaFacade(varHelper.TOP_AppKey, varHelper.TOP_AppSecret); TOPDataList <Area> list = topFacade.GetAllAreas(); total = list.Count; foreach (Area area in list) { if (areaFacade.IsAreaExist(area.AreaId)) { areaFacade.UpdateArea(area.AreaId, area.AreaType, area.AreaName, area.ParentId, area.Zip); updated++; } else { areaFacade.AddArea(string.Empty, area.AreaId, area.AreaType, area.AreaName, area.ParentId, area.Zip); added++; } } }
private void InitRootArea() { TOP.Management.Facade.AreaFacade areaFacade = new TOP.Management.Facade.AreaFacade(); List <AreaInfo> list = areaFacade.GetAllRootAreaList(); foreach (AreaInfo area in list) { TreeViewNode node = GetNodeByArea(area); tvArea.Nodes.Add(node); } }
private void InitTreeNode(TreeViewNode node) { TOP.Management.Facade.AreaFacade areaFacade = new TOP.Management.Facade.AreaFacade(); List <AreaInfo> list = areaFacade.GetAreaListByParentId(node.Value); node.Nodes.Clear(); foreach (AreaInfo item in list) { TreeViewNode sub = GetNodeByArea(item); node.Nodes.Add(sub); } node.AutoPostBackOnExpand = false; }
private TreeViewNode GetNodeByArea(string name, string areaId) { TreeViewNode node = new TreeViewNode(); node.Text = name; node.Value = areaId; TOP.Management.Facade.AreaFacade areaFacade = new TOP.Management.Facade.AreaFacade(); if (areaFacade.IsHasChildren(areaId)) { node.ImageUrl = "folder.gif"; node.ExpandedImageUrl = "folder_open.gif"; AddLoadingNode(node); } else { node.ImageUrl = "config.gif"; } return(node); }
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 }