public ActionResult DeleteConfirmed(int id) { Outdoor outdoor = db.Outdoors.Find(id); db.Outdoors.Remove(outdoor); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "OutdoorID,HouseholdID,Garden,Car,WaterGarden,WashCar,UpdateDate")] Outdoor outdoor) { if (ModelState.IsValid) { db.Entry(outdoor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.HouseholdID = new SelectList(db.Households, "HouseholdID", "WPnumber", outdoor.HouseholdID); return(View(outdoor)); }
static void AddDataToDB() { using (var db = new EFContext()) { if (db.Outdoors.Any()) { //Console.Write("Db already exists!"); return; } } List <Indoor> indoorList = new List <Indoor>(); List <Outdoor> outdoorList = new List <Outdoor>(); using (var reader = new StreamReader("Data\\TemperaturData.csv")) { var provider = new CultureInfo("en-US"); while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); if (values[1] == "Inne") { var indoorData = new Indoor(); indoorData.Date = DateTime.Parse(values[0]); indoorData.Temperature = double.Parse(values[2], provider); indoorData.Humidity = int.Parse(values[3]); indoorList.Add(indoorData); } else { var outdoorData = new Outdoor(); outdoorData.Date = DateTime.Parse(values[0]); outdoorData.Temperature = double.Parse(values[2], provider); outdoorData.Humidity = int.Parse(values[3]); outdoorList.Add(outdoorData); } } } using (var db = new EFContext()) { Console.Write("Working..."); db.Indoors.AddRange(indoorList); db.Outdoors.AddRange(outdoorList); db.SaveChanges(); Console.WriteLine("Finished."); } }
public ActionResult Create([Bind(Include = "OutdoorID,HouseholdID,Garden,Car,WaterGarden,WashCar,UpdateDate")] Outdoor outdoor, string returnUrl) { ViewBag.returnUrl = returnUrl; if (ModelState.IsValid) { db.Outdoors.Add(outdoor); db.SaveChanges(); return(Redirect(returnUrl)); } ViewBag.HouseholdID = new SelectList(db.Households, "HouseholdID", "WPnumber", outdoor.HouseholdID); return(View(outdoor)); }
// GET: Outdoors/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Outdoor outdoor = db.Outdoors.Find(id); if (outdoor == null) { return(HttpNotFound()); } return(View(outdoor)); }
// GET: Outdoors/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Outdoor outdoor = db.Outdoors.Find(id); if (outdoor == null) { return(HttpNotFound()); } ViewBag.HouseholdID = new SelectList(db.Households, "HouseholdID", "WPnumber", outdoor.HouseholdID); return(View(outdoor)); }
protected void UpdateSelectedOutdoorValues(object sender, Object ControlName) { if (this.SelectedNode != null) { if (ControlName != null) { if (this.projectLegacy.CanvasODUList != null && this.projectLegacy.CanvasODUList.Count > 0) { var itemIndex = this.projectLegacy.CanvasODUList.FindIndex(x => x.NO == this.SelectedNode.NodeNo); if (itemIndex >= 0) { var item = this.projectLegacy.CanvasODUList.ElementAt(itemIndex); this.projectLegacy.CanvasODUList.RemoveAt(itemIndex); if ((string)ControlName == "Type") { item.SelOutdoorType = OduEquipmentPropertiesViewModel.SelectedType; if (item.OutdoorItem != null) { item.OutdoorItem.Type = OduEquipmentPropertiesViewModel.SelectedType; } } else if ((string)ControlName == "Power") { item.Power = OduEquipmentPropertiesViewModel.SelectedPower; } else if ((string)ControlName == "Outdoor") { if (item.OutdoorItem != null) { item.OutdoorItem.ModelFull = OduEquipmentPropertiesViewModel.SelectedOutdoor; //item.OutdoorItem.FullModuleName = OduEquipmentPropertiesViewModel.SelectedOutdoor; } else { Outdoor OTD = new Outdoor(); OTD.Series = item.Series; OTD.ModelFull = OduEquipmentPropertiesViewModel.SelectedOutdoor; //OTD.FullModuleName = OduEquipmentPropertiesViewModel.SelectedOutdoor; item.OutdoorItem = OTD; } } else if ((string)ControlName == "Equipment") { item.Name = OduEquipmentPropertiesViewModel.OduName; } else if ((string)ControlName == "AutoManual") { item.IsAuto = OduEquipmentPropertiesViewModel.IsAuto; if (OduEquipmentPropertiesViewModel.IsAuto == true) { //item.DBCooling = SystemSetting.UserSetting.defaultSetting.outdoorCoolingDB; //item.DBHeating = SystemSetting.UserSetting.defaultSetting.outdoorHeatingDB; //item.WBHeating = SystemSetting.UserSetting.defaultSetting.outdoorHeatingWB; //item.RHHeating = SystemSetting.UserSetting.defaultSetting.outdoorHeatingRH; //item.PipeEquivalentLength = SystemSetting.UserSetting.pipingSetting.pipingEqLength; //item.PipeEquivalentLengthbuff = SystemSetting.UserSetting.pipingSetting.pipingEqLength; //item.FirstPipeLength = SystemSetting.UserSetting.pipingSetting.firstBranchLength; //item.FirstPipeLengthbuff = SystemSetting.UserSetting.pipingSetting.firstBranchLength; //item.HeightDiff = SystemSetting.UserSetting.pipingSetting.pipingHighDifference; //item.PipingLengthFactor = SystemSetting.UserSetting.pipingSetting.pipingCorrectionFactor; //item.PipingPositionType = SystemSetting.UserSetting.pipingSetting.pipingPositionType; //item.IWCooling = SystemSetting.UserSetting.defaultSetting.outdoorCoolingIW; //item.IWHeating = SystemSetting.UserSetting.defaultSetting.outdoorHeatingIW; } } else if ((string)ControlName == "IndoreFreshAir") { if (OduEquipmentPropertiesViewModel.IsBothIndoreFreshAir == true) { item.SysType = SystemType.CompositeMode; } else { item.SysType = SystemType.OnlyIndoor; } } else if ((string)ControlName == "MaxRatio") { if (OduEquipmentPropertiesViewModel.SelectedMaxRatio > 0) { //if (item.SysType == SystemType.OnlyFreshAir) // return; //if (OduEquipmentPropertiesViewModel.SelectedMaxRatio == Convert.ToInt32(item.MaxRatio * 100)) // return; //item.MaxRatio = Convert.ToDouble(OduEquipmentPropertiesViewModel.SelectedMaxRatio) / 100; item.MaxRatio = Math.Round( (Convert.ToDouble(OduEquipmentPropertiesViewModel.SelectedMaxRatio) / 100), 2); } } this.projectLegacy.CanvasODUList.Insert(itemIndex, item); } } } } }
//public double CalOutdoorEstCapacityNextGen(Outdoor outItem, double maxRatio, double OutTemperature, double InTemperature, bool isHeating, JCHVRF.Model.NextGen.SystemVRF sysItem) //{ // return _dal.CalOutdoorEstCapacitynew(outItem, maxRatio, OutTemperature, InTemperature, isHeating, sysItem); //} public double CalOutdoorEstCapacitynextgen(Outdoor outItem, double maxRatio, double OutTemperature, double InTemperature, bool isHeating, JCHVRF.Model.NextGen.SystemVRF sysItem) { return(_dal.CalOutdoorEstCapacitynew(outItem, maxRatio, OutTemperature, InTemperature, isHeating, sysItem)); }
/// <summary> /// 计算室外机估算容量值,查容量表计算 /// 增加SystemVRF参数,可以处理水机流速 20170216 by Yunxiao Lin /// </summary> /// <param name="type"></param> /// <param name="shortModel"></param> /// <param name="maxRatio"></param> /// <param name="OutTemperature"></param> /// <param name="InTemperature"></param> /// <param name="isHeating"></param> /// <returns></returns> public double CalOutdoorEstCapacity(Outdoor outItem, double maxRatio, double OutTemperature, double InTemperature, bool isHeating, SystemVRF sysItem) { return(_dal.CalOutdoorEstCapacity(outItem, maxRatio, OutTemperature, InTemperature, isHeating, sysItem)); }
/// <summary> /// Startar en ny transaktion där datat läggs in i databasen, beroende på vilken typ T är /// /// </summary> /// <typeparam name="T"></typeparam> public static void ImportToDB <T>() { //format "2016 - 05 - 31 13:58:30,Inne,24.8,42"; string[] temperatureFileRows; Type t = typeof(T); if (t == typeof(Outdoor)) { temperatureFileRows = File.ReadAllLines(Directory.GetCurrentDirectory() + @"\TemperaturData.csv") .Where(line => line.Contains($",Ute,")) .ToArray(); } else { temperatureFileRows = File.ReadAllLines(Directory.GetCurrentDirectory() + @"\TemperaturData.csv") .Where(line => line.Contains($",Inne,")) .ToArray(); } int i = 1; using (var context = new TemperatureDBContext()) { using (var transaction = context.Database.BeginTransaction()) { try { foreach (string row in temperatureFileRows) { string consoleOutput = ""; string[] rowData = row.Split(','); DateTime dateFromFile = DateTime.Parse(rowData[0]); double temperatureFromFile = double.Parse(rowData[2].Replace('.', ',')); //ersätter . med , för att kunda köra parse int humidityFromFile = int.Parse(rowData[3]); if (t == typeof(Indoor)) { Indoor temperatureIndoor = new Indoor() { Date = dateFromFile, Temperature = temperatureFromFile, Humidity = humidityFromFile }; context.Indoors.Add(temperatureIndoor); consoleOutput = $"#{i}. Added indoor date: {temperatureIndoor.Date}," + $"\n\t Deg: {temperatureIndoor.Temperature} Hum: {temperatureIndoor.Humidity}"; } else { Outdoor temperatureOutdoor = new Outdoor() { Date = dateFromFile, Temperature = temperatureFromFile, Humidity = humidityFromFile }; context.Outdoors.Add(temperatureOutdoor); consoleOutput = $"#{i}. Added outdoor date: {temperatureOutdoor.Date}," + $"\n\t Deg: {temperatureOutdoor.Temperature} Hum: {temperatureOutdoor.Humidity}"; } Console.WriteLine(consoleOutput); i++; } Console.WriteLine("Saving changes please wait..."); context.SaveChanges(); Console.WriteLine("Done! press any key to continue"); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message + "\n\t" + e.InnerException); transaction.Rollback(); } finally { Console.WriteLine("Comitting please wait..."); transaction.Commit(); } } } }
/// 从另一个System中复制属性到当前System Add on 20161126 by Yunxiao Lin /// <summary> /// 从另一个System中复制属性到当前System /// </summary> /// <param name="sys"></param> public void Copy(SystemVRF sys) { this._addRefrigeration = sys._addRefrigeration; this._allowExceedRatio = sys._allowExceedRatio; this._controlGroupID = sys._controlGroupID; this._coolingCapacity = sys._coolingCapacity; this._dbCooling = sys._dbCooling; this._dbHeating = sys._dbHeating; this._rhHeatling = sys._rhHeatling; this._diversityFactor = sys._diversityFactor; this._firstPipeLength = sys._firstPipeLength; this._firstPipeLengthbuff = sys._firstPipeLengthbuff; this._heatingCapacity = sys._heatingCapacity; this._heightDiff = sys._heightDiff; this._isExportToReport = sys._isExportToReport; this._isPipingOK = sys._isPipingOK; this._isUpdated = sys._isUpdated; this._iwCooling = sys._iwCooling; this._iwHeating = sys._iwHeating; this._MaxDiffIndoorHeight = sys._MaxDiffIndoorHeight; this._MaxDiffIndoorLength = sys._MaxDiffIndoorLength; this._MaxEqPipeLength = sys._MaxEqPipeLength; this._MaxIndoorLength = sys._MaxIndoorLength; this._MaxOutdoorAboveHeight = sys._MaxOutdoorAboveHeight; this._MaxOutdoorBelowHeight = sys._MaxOutdoorBelowHeight; this._MaxPipeLength = sys._MaxPipeLength; this._MaxPipeLengthwithFA = sys._MaxPipeLengthwithFA; this._maxRatio = sys._maxRatio; this.Name = sys.Name; this._no = sys._no; this._optionItem = sys._optionItem; this._pipeActualLength = sys._pipeActualLength; this._pipeEquivalentLength = sys._pipeEquivalentLength; this._pipeEquivalentLengthbuff = sys._pipeEquivalentLengthbuff; this._pipingLengthFactor = sys._pipingLengthFactor; this._pipingPositionType = sys._pipingPositionType; this._ratio = sys._ratio; this._ratioFA = sys._ratioFA; this._selOutdoorType = sys._selOutdoorType; this._sysType = sys._sysType; this._wbHeating = sys._wbHeating; this.OutdoorItem = sys.OutdoorItem; this._IDUFirst = sys._IDUFirst; this._isAuto = sys._isAuto; this._coolingFlowRate = sys._coolingFlowRate; this._heatingFlowRate = sys._heatingFlowRate; this._flowRateLevel = sys._flowRateLevel; //添加新的属性 add by Shen Junjie on 2018/02/01 this.MaxTotalPipeLength = sys.MaxTotalPipeLength; //this.MaxTotalPipeLength_MaxIU = sys.MaxTotalPipeLength_MaxIU; this.MaxMKIndoorPipeLength = sys.MaxMKIndoorPipeLength; //this.MaxMKIndoorPipeLength_MaxIU = sys.MaxMKIndoorPipeLength_MaxIU; //添加新的属性 add by xyj on 2018/06/25 this.MaxSameCHBoxHighDiffLength = sys.MaxSameCHBoxHighDiffLength; this.MaxCHBoxHighDiffLength = sys.MaxCHBoxHighDiffLength; this.MaxCHBox_IndoorHighDiffLength = sys.MaxCHBox_IndoorHighDiffLength; this.MaxIndoorHeightDifferenceLength = sys.MaxIndoorHeightDifferenceLength; this.MaxLowerHeightDifferenceLength = sys.MaxLowerHeightDifferenceLength; this.MaxUpperHeightDifferenceLength = sys.MaxUpperHeightDifferenceLength; this.NormalCHBoxHighDiffLength = sys.NormalCHBoxHighDiffLength; this.NormalCHBox_IndoorHighDiffLength = sys.NormalCHBox_IndoorHighDiffLength; this.NormalSameCHBoxHighDiffLength = sys.NormalSameCHBoxHighDiffLength; }