/// <summary> /// 获取线路区域实体 /// </summary> /// <param name="Id">主键编号</param> /// <returns></returns> public EyouSoft.Model.CompanyStructure.Area GetModel(int Id) { EyouSoft.Model.CompanyStructure.Area areaModel = null; DbCommand cmd = this._db.GetStoredProcCommand("proc_Area_GetAreaInfo"); this._db.AddInParameter(cmd, "Id", DbType.Int32, Id); using (IDataReader rdr = EyouSoft.Toolkit.DAL.DbHelper.ExecuteReader(cmd, this._db)) { if (rdr.Read()) { #region 线路区域信息 areaModel = new EyouSoft.Model.CompanyStructure.Area(); areaModel.Id = rdr.GetInt32(rdr.GetOrdinal("Id")); areaModel.AreaName = rdr.GetString(rdr.GetOrdinal("AreaName")); areaModel.CompanyId = rdr.GetInt32(rdr.GetOrdinal("CompanyId")); areaModel.OperatorId = rdr.GetInt32(rdr.GetOrdinal("OperatorId")); areaModel.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); areaModel.IsDelete = Convert.ToBoolean(rdr.GetOrdinal("IsDelete")); areaModel.SortId = rdr.GetInt32(rdr.GetOrdinal("SortId")); #endregion #region 计调员信息 rdr.NextResult(); IList <EyouSoft.Model.CompanyStructure.UserArea> lsUserArea = new List <EyouSoft.Model.CompanyStructure.UserArea>(); while (rdr.Read()) { EyouSoft.Model.CompanyStructure.UserArea userAreaModel = new EyouSoft.Model.CompanyStructure.UserArea(); userAreaModel.AreaId = rdr.GetInt32(rdr.GetOrdinal("AreaId")); userAreaModel.UserId = rdr.GetInt32(rdr.GetOrdinal("UserId")); userAreaModel.ContactName = rdr.IsDBNull(rdr.GetOrdinal("ContactName")) ? "" : rdr.GetString(rdr.GetOrdinal("ContactName")); lsUserArea.Add(userAreaModel); userAreaModel = null; } #endregion areaModel.AreaUserList = lsUserArea; } } return(areaModel); }
/// <summary> /// 转XML格式 /// </summary> /// <param name="ContactXML"></param> /// <returns></returns> private IList <EyouSoft.Model.CompanyStructure.UserArea> GetUserAreaList(string userAreaXML) { if (string.IsNullOrEmpty(userAreaXML)) { return(null); } IList <EyouSoft.Model.CompanyStructure.UserArea> ResultList = new List <EyouSoft.Model.CompanyStructure.UserArea>(); XElement root = XElement.Parse(userAreaXML); var xRow = root.Elements("row"); foreach (var tmp in xRow) { EyouSoft.Model.CompanyStructure.UserArea model = new EyouSoft.Model.CompanyStructure.UserArea() { UserId = Convert.ToInt32(tmp.Attribute("UserId").Value), AreaId = Convert.ToInt32(tmp.Attribute("AreaId").Value), ContactName = tmp.Attribute("ContactName") == null ? "" : tmp.Attribute("ContactName").Value }; ResultList.Add(model); model = null; } return(ResultList); }