public void parseXml(Stream stream) { DateTime now = DateTime.Now; houses = new List <HouseName>(); plants = new List <PlantName>(); dates = new Dictionary <int, DateTemp>(); stream.Position = 0; XDocument xml = XDocument.Load(stream); foreach (XElement el in xml.Root.Element("houses").Elements("house")) { var house = new HouseName { name = el.Attribute("Name").Value }; houses.Add(house); foreach (XElement element in el.Elements()) { DateTemp dateTemp = new DateTemp { dateTime = getDate(element), temperature = getDouble(element, "Weather") }; TimeSpan span = (dateTemp.dateTime - DateTemp.zeroCountDateTime); dateTemp.daysNumber = span.Days; HouseDetail houseDetail = new HouseDetail { localDateTemp = now, userName = getUserName(), daysNumber = dateTemp.daysNumber, consumptionHouse = getDouble(element, "Consumption") }; if (!dates.ContainsKey(span.Days)) { dates.Add(span.Days, dateTemp); } house.listHouseDetails.Add(houseDetail); } } foreach (XElement el in xml.Root.Elements("plants").Elements()) { PlantName plant = new PlantName { name = el.Attribute("Name").Value }; plants.Add(plant); foreach (XElement element in el.Elements()) { TimeSpan span = getDate(element) - DateTemp.zeroCountDateTime; PlantDetail plantDetail = new PlantDetail { localDateTemp = now, userName = getUserName(), daysNumber = span.Days, price = getDouble(element, "Price"), consumptionPlant = getDouble(element, "Consumption") }; plant.listPlantDetails.Add(plantDetail); } } saveToDb(); }
/// <summary> /// 房屋评估来源信息集合 /// </summary> /// <param name="estimateSource"></param> /// <param name="houseDetailId"></param> public IEnumerable <EstimateSource> SaveEstimateSource(HouseDetail oldmodel, HouseDetail newmodel) { var estList = new List <EstimateSource>(); foreach (var model in oldmodel.EstimateSources) { var entity = new EstimateSource { ID = Guid.NewGuid().ToString(), HouseDetailID = newmodel.ID, ContactNumber = model.ContactNumber, EstimateInstitutions = model.EstimateInstitutions, HouseDetail = model.HouseDetail, InformationProvider = model.InformationProvider, RushEstimate = model.RushEstimate, Sequence = model.Sequence, CertificateFile = model.CertificateFile }; entity.CertificateFile = SaveFiles(model.CertificateFile, entity.ID, newmodel.ID); estList.Add(entity); } newmodel.EstimateSources = estList; estimateSourceDAL.AddRange(estList); return(estList); }
public HouseDetailViewModel CastModel(HouseDetail model) { var house = new HouseDetailViewModel(); var dicdal = new DictionaryDAL(); Com.HSJF.Infrastructure.ExtendTools.ObjectExtend.CopyTo(model, house); house.HouseTypeText = dicdal.GetText(model.HouseType); return(house); }
//库区级联 public static List <HouseDetail> GetHouse(int index) { string sqlstr = string.Format("select * from t_StoreHouseDetail where HouseID={0}", index); DataTable dt = DBHelper.GetDataTable(sqlstr); List <HouseDetail> list = new List <HouseDetail>(); foreach (DataRow item in dt.Rows) { HouseDetail ho = new HouseDetail(); ho.ID = Convert.ToInt32(item["ID"].ToString()); ho.SubareaName = item["SubareaName"].ToString(); list.Add(ho); } return(list); }
/// <summary> /// 保存房屋明细信息集合 /// </summary> /// <param name="houseDetail"></param> /// <param name="auditId"></param> public void SaveHouseDetail(BaseAudit baseAudit, BaseAudit newAudit, CollateralAudit oldColl, CollateralAudit newColl) { var houseList = new List <HouseDetail>(); var house = baseAudit.HouseDetails.Where(t => t.CollateralID == oldColl.ID); if (!house.Any()) { return; } foreach (var model in house) { var entity = new HouseDetail { ID = Guid.NewGuid().ToString(), BaseAuditID = newAudit.ID, Accout = model.Accout, AssessedValue = model.AssessedValue, CompletionDate = model.CompletionDate, Description = model.Description, EstimateSources = model.EstimateSources, HouseType = model.HouseType, LimitInfo = model.LimitInfo, LandType = model.LandType, RepairSituation = model.RepairSituation, ServiceCondition = model.ServiceCondition, TotalHeight = model.TotalHeight, Collateral = model.Collateral, CollateralID = newColl.ID, Sequence = model.Sequence, RealHigh = model.RealHigh, IsDamage = model.IsDamage, RealResident = model.RealResident, WaterPaymentCheck = model.WaterPaymentCheck, TaxPaymentCheck = model.TaxPaymentCheck, Man2Wei1 = model.Man2Wei1, SpecialResident = model.SpecialResident, OtherDescription = model.OtherDescription, SchoolInfo = model.SchoolInfo, HospitalInfo = model.HospitalInfo, TrafficInfo = model.TrafficInfo, Supermarket = model.Supermarket, Recreation = model.Recreation, NegativeSite = model.NegativeSite }; // Com.HSJF.Infrastructure.ExtendTools.ObjectExtend.CopyTo(model, entity); entity.VillagePhotoFile = SaveFiles(model.VillagePhotoFile, entity.ID, newAudit.ID); entity.MainGatePhotoFile = SaveFiles(model.MainGatePhotoFile, entity.ID, newAudit.ID); entity.ParlourPhotoFile = SaveFiles(model.ParlourPhotoFile, entity.ID, newAudit.ID); entity.BedroomPhotoFile = SaveFiles(model.BedroomPhotoFile, entity.ID, newAudit.ID); entity.KitchenRoomPhotoFile = SaveFiles(model.KitchenRoomPhotoFile, entity.ID, newAudit.ID); entity.ToiletPhotoFile = SaveFiles(model.ToiletPhotoFile, entity.ID, newAudit.ID); entity.HousePhotoFile = SaveFiles(model.HousePhotoFile, entity.ID, newAudit.ID); entity.HouseReportFile = SaveFiles(model.HouseReportFile, entity.ID, newAudit.ID); houseList.Add(entity); SaveEstimateSource(model, entity); } houseDetailDAL.AddRange(houseList); }