public async Task <IActionResult> Create(StationViewModel stationViewModel) { if (ModelState.IsValid) { string path = string.Empty; if (stationViewModel.LogoFile != null) { path = await _imageHelper.UploadImageAsync(stationViewModel.LogoFile, "Stations"); } StationEntity team = _converterHelper.ToStationEntity(stationViewModel, path, true); _context.Add(team); try { await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { if (ex.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, "Already there is a record with the same name."); } else { ModelState.AddModelError(string.Empty, ex.InnerException.Message); } } } return(View(stationViewModel)); }
private void InitItems(string pPlanCode,string pStationCode) { StationEntity ent1 = StationFactory.GetByKey(pStationCode); WorkunitCode = ""; txtWorkUnit.Text = ent1.STATION_NAME; PlanEntity ent2 = PlanFactory.GetByKey(pPlanCode); OrderCode = ent2.ORDER_CODE; List<PlanStandardBOMEntity> lstBom = PlanStandardBOMFactory.GetByOrderCode(OrderCode); List<PlanStandardBOMEntity> lstBom1 = (from p in lstBom where p.VIRTUAL_ITEM_CODE == "X" && p.WORKUNIT_CODE == WorkunitCode select p).ToList<PlanStandardBOMEntity>(); if (lstBom1.Count == 0) { cmbVItemCode.SelectedIndex = -1; cmbVItemCode.Enabled = false; } else { cmbVItemCode.Items.Clear(); cmbVItemCode.Items.Add("总装件"); for (int i = 0; i < lstBom1.Count; i++) { cmbVItemCode.Items.Add(lstBom1[i].ITEM_CODE + "-" + lstBom1[i].ITEM_NAME); } cmbVItemCode.Enabled = true; } }
/// <summary> /// 根据字符串加载成实体 /// </summary> /// <param name="stationStr"></param> /// <returns></returns> private static StationEntity[] GetStationNames(string stationStr) { var ss = stationStr.Split('@'); var result = new StationEntity[ss.Length - 1]; for (var i = 1; i < ss.Length; ++i) { var name = ss[i]; var names = name.Split('|'); result[i - 1] = new StationEntity() { OP = names[0], FN = names[1], SC = names[2], FP = names[3], JP = names[4] }; //result[i - 1] = new StationEntity() //{ // StationData = new string[4] // { names[0], names[1], names[2], names[3] } //}; } return(result); }
//private void Init() //{ // List<AndonAlertEntity> andon = AndonFactory.GetByTime(); // for (int i = 0; i < andon.Count; i++) // { // if (GridAndon.Rows.Count < andon.Count) // GridAndon.Rows.Add(); // StationEntity Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE); // LocationEntity location = LocationFactory.GetByMasterKey(Stationen.RMES_ID); // GridAndon.Rows[i].Cells[0].Value = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm"); // GridAndon.Rows[i].Cells[1].Value = Stationen.STATION_NAME; // // GridAndon.Rows[i].Cells[2].Value = location.LOCATION_NAME; // GridAndon.Rows[i].Cells[3].Value = andon[i].ANDON_ALERT_CONTENT.Substring(3, 4); // } //} private void Init() { //textBox.Text = "123"; List <AndonAlertEntity> andon = AndonFactory.GetByTime(); string string1 = "";//, string2, string3; string string2 = ""; string string3 = ""; string string4 = ""; string str1 = ""; string[] str = new string[] { "", "", "" }; for (int i = 0; i < andon.Count; i++) { StationEntity Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE); LocationEntity location = LocationFactory.GetByMasterKey(Stationen.RMES_ID); TeamEntity team = TeamFactory.GetByTeamCode(andon[i].TEAM_CODE); string1 = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm"); string2 = Stationen.STATION_NAME; string3 = team.TEAM_NAME; string4 = andon[i].ANDON_ALERT_CONTENT.ToString(); str[i] = string1 + " ," + string2 + string3 + string4; str1 = str1 + str[i] + "\r\n"; textBox.Text = str1; } }
private async Task <StationEntity> CheckStationAsync( string Name, string LegalCertificate, string namelegal, string addrres) { StationEntity station = await _context.Stations.FirstOrDefaultAsync(s => s.LegalCertificate == LegalCertificate); if (station == null) { station = new StationEntity { Name = Name, LegalCertificate = LegalCertificate, LegalName = namelegal, Address = addrres, LogoPath = "~/images/Stations/San Gerardo.png" }; await _context.AddAsync(station); await _context.SaveChangesAsync(); } return(station); }
protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { ASPxTextBox uCode = ASPxGridView1.FindEditFormTemplateControl("txtStationCode") as ASPxTextBox; ASPxTextBox uName = ASPxGridView1.FindEditFormTemplateControl("txtStationName") as ASPxTextBox; ASPxComboBox uTcode = ASPxGridView1.FindEditFormTemplateControl("dropStaionType") as ASPxComboBox; ASPxComboBox uPcode = ASPxGridView1.FindEditFormTemplateControl("dropPlineCode") as ASPxComboBox; ASPxTextBox uScode = ASPxGridView1.FindEditFormTemplateControl("dropStaionArea") as ASPxTextBox; string id = e.NewValues["RMES_ID"] as string; StationEntity s = new StationEntity() { RMES_ID = id, COMPANY_CODE = theCompanyCode, PLINE_CODE = uPcode.Value.ToString(), STATION_CODE = uCode.Text.Trim(), STATION_NAME = uName.Text.Trim(), STATION_TYPE_CODE = uTcode.Value as string, STATION_AREA_CODE = uScode.Value as string, WORKUNIT_CODE = e.NewValues["WORKUNIT_CODE"] as string }; db.Update("CODE_STATION", "RMES_ID", s); e.Cancel = true; ASPxGridView1.CancelEdit(); setCondition(); }
public StationEntity GetStation(string stationID) { IRAPError error = new IRAPError(); StationEntity e = _stations.Table.FirstOrDefault(r => r.StationID == stationID); return(e); }
protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxTextBox uCode = ASPxGridView1.FindEditFormTemplateControl("txtStationCode") as ASPxTextBox; ASPxTextBox uName = ASPxGridView1.FindEditFormTemplateControl("txtStationName") as ASPxTextBox; ASPxComboBox uTcode = ASPxGridView1.FindEditFormTemplateControl("dropStaionType") as ASPxComboBox; ASPxComboBox uPcode = ASPxGridView1.FindEditFormTemplateControl("dropPlineCode") as ASPxComboBox; ASPxTextBox uScode = ASPxGridView1.FindEditFormTemplateControl("dropStaionArea") as ASPxTextBox; StationEntity s = new StationEntity() { COMPANY_CODE = theCompanyCode, PLINE_CODE = uPcode.Value.ToString(), STATION_CODE = uCode.Text.Trim(), STATION_NAME = uName.Text.Trim(), STATION_TYPE_CODE = uTcode.Value as string, STATION_AREA_CODE = uScode.Value as string, WORKUNIT_CODE = e.NewValues["WORKUNIT_CODE"] as string }; s.RMES_ID = s.STATION_CODE; StationFactory.Insert(s); //string Sql = "INSERT INTO CODE_STATION (COMPANY_CODE,STATION_CODE,STATION_NAME,STATION_TYPE_CODE,PLINE_CODE,STATION_AREA_CODE) " // + "VALUES('" + theCompanyCode + "','" + uCode.Text.Trim() + "','" + uName.Text.Trim() + "','" + uTcode.Value.ToString() + "','" + uPcode.Value.ToString() + "','" + uScode.Value.ToString() + "')"; //dc.ExeSql(Sql); e.Cancel = true; ASPxGridView1.CancelEdit(); setCondition(); }
public async Task <IActionResult> Edit(int id, StationViewModel stationViewModel) { if (ModelState.IsValid) { string path = stationViewModel.LogoPath; if (stationViewModel.LogoFile != null) { path = await _imageHelper.UploadImageAsync(stationViewModel.LogoFile, "Stations"); } StationEntity stationEntity = _converterHelper.ToStationEntity(stationViewModel, path, false); _context.Update(stationEntity); try { await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { if (ex.Message.Contains("updating")) { ModelState.AddModelError(string.Empty, $"Already exists a Station {stationEntity.Name}. "); } else { ModelState.AddModelError(string.Empty, ex.Message); } } } return(View(stationViewModel)); }
public void GetStationByStationNameAndLineId() { StationEntity peopleSquare = MetroWebEntity.Instance.StationList["人民广场", "1号线"]; // station id Assert.AreEqual(113, peopleSquare.StationId); // station name Assert.AreEqual("人民广场", peopleSquare.StationName); // line list Assert.AreEqual(7, peopleSquare.LineList.Count); List <int> lineIdList = peopleSquare.LineList.Select(line => line.LineId).ToList(); List <int> expectedLineIdList = new List <int>(new[] { 101, 102, 103, 201, 202, 801, 802 }); lineIdList.Sort(); for (int i = 0; i < lineIdList.Count; i++) { Assert.AreEqual(expectedLineIdList[i], lineIdList[i]); } // station line list Assert.AreEqual(7, peopleSquare.StationLineList.Count); List <int> stationLineIdList = peopleSquare.StationLineList.Select(stationLine => stationLine.StationLineId).ToList(); List <int> expectedStationLineIdList = new List <int>(new[] { 10116, 10213, 10309, 20111, 20212, 80116, 80215 }); stationLineIdList.Sort(); for (int i = 0; i < lineIdList.Count; i++) { Assert.AreEqual(expectedStationLineIdList[i], stationLineIdList[i]); } }
public ActionResult DeleteConfirmed(int id) { StationEntity stationEntity = _iStationEntityRepos.FindById(id); _iStationEntityRepos.Delete(stationEntity); _iStationEntityRepos.SaveChanges(); return(RedirectToAction("Index")); }
public Tuple <List <StationLineEntity>, TimeSpan> GetTheNearestRouteBetween(StationEntity fromStation, StationEntity toStation) { List <StationLineEntityExtender> stationLineListCache = new List <StationLineEntityExtender>(); List <StationLineEntityExtender> toStationlineList = StationLineEntityExtender.Convert(toStation, stationLineListCache); // Quick find a route so that the full find will not reach the time limit bool finalFound = false; TimeSpan arrivedTimeLimit = new TimeSpan(); foreach (StationLineEntityExtender toStationline in toStationlineList) { stationLineListCache.ForEach(stationLine => stationLine.Initialize()); bool found = toStationline.QuickGetRoute(fromStation, stationLineListCache); if (found) { arrivedTimeLimit = toStationline.MinimumTime; finalFound = true; break; } } if (!finalFound) { throw new Exception("Quick get route not found!"); } // Fully find a route so that finalFound = false; TimeSpan arrivedTime = new TimeSpan(TimeSpan.MaxValue.Ticks / 2); List <StationLineEntity> route = new List <StationLineEntity>(); foreach (StationLineEntityExtender toStationline in toStationlineList) { stationLineListCache.ForEach(stationLine => stationLine.Initialize()); bool found = toStationline.FullyGetRoute(fromStation, stationLineListCache, arrivedTimeLimit, new Stack <StationLineEntityExtender>()); if (found) { if (toStationline.MinimumTime < arrivedTime) { arrivedTime = toStationline.MinimumTime; route = toStationline.MinimumRoute; } finalFound = true; } } if (!finalFound) { throw new Exception("Full get route not found!"); } Tuple <List <StationLineEntity>, TimeSpan> result = new Tuple <List <StationLineEntity>, TimeSpan>(route, arrivedTime); return(result); }
public ActionResult Create(StationEntity stationEntity) { if (ModelState.IsValid) { stationEntity.TeamEntities = _iTeamEntityRepos.FindById(stationEntity.TeamEntities.TeamEntityId); _iStationEntityRepos.AddorUpdate(stationEntity); _iStationEntityRepos.SaveChanges(); return(RedirectToAction("Index")); } return(View(stationEntity)); }
public bool Insert(StationEntity s) { try { db.Insert("CODE_STATION", "RMES_ID", false, s); return(true); } catch (Exception ex) { return(false); } }
public StationViewModel ToStationViewModel(StationEntity stationEntity) { return(new StationViewModel { Id = stationEntity.Id, LogoPath = stationEntity.LogoPath, Name = stationEntity.Name, Address = stationEntity.Address, LegalCertificate = stationEntity.LegalCertificate, LegalName = stationEntity.LegalName }); }
private void setTestStationEntities() { List<StationEntity> list = new List<StationEntity>(); StationEntity se = new StationEntity("TEST"); StationField f = new StationField("field-one"); f.Type = (Field.TextType); se.AddField(f); StationField f2 = new StationField("field-two"); f2.Type = (Field.TextType); se.AddField(f2); list.Add(se); this.Entities = (list); }
/// <summary> /// 取得站點資料 /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public static StationEntity Get(int no) { StationEntity entity = null; using (var openData = new Station()) { var table = openData.GetById(no); entity = table.ToList <StationEntity>().FirstOrDefault(); } return(entity); }
public static List <PlanEntity> GetWorkStationPlans(string StationRmesID) { StationEntity station = StationFactory.GetByPrimaryKey(StationRmesID); if (station == null) { Rmes.Public.ErrorHandle.EH.LASTMSG = "传入的StationRmesID不正确,没有找到相应Station"; return(null); } List <PlanEntity> plans = new PlanDal().FindBySql <PlanEntity>("where RUN_FLAG<>'N' and PLINE_CODE=@0 and sysdate between BEGIN_DATE and END_DATE order by PLAN_SEQUENCE,PLAN_CODE", station.PLINE_CODE); return(plans); }
public void SameStations() { StationEntity fromStation = MetroWebEntity.Instance.StationList["宜山路", "4号线"]; StationEntity toStation = MetroWebEntity.Instance.StationList["宝山路", "3号线"]; finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result1 = finder.GetTheNearestRouteBetween(fromStation, toStation); Assert.AreEqual(10, result1.Item1.Count); Tuple <List <StationLineEntity>, TimeSpan> result2 = finder.GetTheNearestRouteBetween(toStation, fromStation); Assert.AreEqual(10, result2.Item1.Count); }
// GET: StationEntities/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StationEntity stationEntity = _iStationEntityRepos.FindById((int)id); if (stationEntity == null) { return(HttpNotFound()); } return(View(stationEntity)); }
public BaseDTU(DTUEntity dtu, Dictionary <string, BaseStation> baseStationDic) : this(dtu, IntPtr.Zero, null) { this.baseStationDic = baseStationDic; /// this.trList = trList; StationEntity se = new StationEntity(); se.DTU_ID = dtu.DTU_ID; se.Address = dtu.Address; selfStation = new BaseStation(se); InitTimedRule(); InitBaseStationDic(); InitSendCmd(); }
public void GetByPlanStatonZJTS(string CompanyCode, string PlanCode, string PlineCode, string StationCode, string Sn, string fdjxl, string so, string stationcode1) { try { //大线生成计划对应的站点bom是根据当前登录的站点StationCode,返修点是根据选择的站点,这两个变量统一,但生成snbomtemp时,返修点要根据返修站点当前登录站点生成 //调用存储过程 获取替换后的站点BOM 插入data_sn_bom_temp和rstbomqd、rstbomts StationEntity ent_st = StationFactory.GetBySTATIONCODE(StationCode); string station_name = ent_st.STATION_NAME; ProductDataFactory.PL_QUERY_ZJTS(so, StationCode, PlineCode, fdjxl, PlanCode, Sn); } catch (Exception e1) { return; } }
public void TwoStationNeedTransfer() { StationEntity fromStation = MetroWebEntity.Instance.StationList["杨高中路", "9号线"]; StationEntity toStation = MetroWebEntity.Instance.StationList["东昌路", "2号线"]; finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result1 = finder.GetTheNearestRouteBetween(fromStation, toStation); Assert.AreEqual(3, result1.Item1.Count); finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result2 = finder.GetTheNearestRouteBetween(toStation, fromStation); Assert.AreEqual(3, result2.Item1.Count); }
public void GetTwoStationsALittleFar() { StationEntity fromStation = MetroWebEntity.Instance.StationList["临港大道", "16号线"]; StationEntity toStation = MetroWebEntity.Instance.StationList["惠南东", "16号线"]; finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result1 = finder.GetTheNearestRouteBetween(fromStation, toStation); Assert.AreEqual(3, result1.Item1.Count); finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result2 = finder.GetTheNearestRouteBetween(toStation, fromStation); Assert.AreEqual(3, result2.Item1.Count); }
public void ComplexTransfer() { StationEntity fromStation = MetroWebEntity.Instance.StationList["东川路", "5号线"]; StationEntity toStation = MetroWebEntity.Instance.StationList["北洋泾路", "6号线"]; finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result1 = finder.GetTheNearestRouteBetween(fromStation, toStation); Assert.AreEqual(26, result1.Item1.Count); finder = new RouteFinder(); Tuple <List <StationLineEntity>, TimeSpan> result2 = finder.GetTheNearestRouteBetween(toStation, fromStation); Assert.AreEqual(25, result2.Item1.Count); }
/// <summary> /// 得到一个对象实体 /// </summary> public StationEntity DataRowToModel(DataRow row) { StationEntity model = new StationEntity(); if (row != null) { if (row["DTU_ID"] != null) { model.DTU_ID = row["DTU_ID"].ToString(); } if (row["Address"] != null && row["Address"].ToString() != "") { model.Address = row["Address"].ToString().ToString(); } if (row["Md_ID"] != null) { model.Md_ID = row["Md_ID"].ToString(); } if (row["Mp_ID"] != null) { model.Mp_ID = row["Mp_ID"].ToString(); } if (row["Md_Protocol"] != null) { model.Md_Protocol = row["Md_Protocol"].ToString(); } if (row["Md_Baud"] != null) { model.Md_Baud = row["Md_Baud"].ToString(); } if (row["Md_0dd_even_check"] != null && row["Md_0dd_even_check"].ToString() != "") { if ((row["Md_0dd_even_check"].ToString() == "1") || (row["Md_0dd_even_check"].ToString().ToLower() == "true")) { model.Md_0dd_even_check = true; } else { model.Md_0dd_even_check = false; } } if (row["Md_Stopbit"] != null && row["Md_Stopbit"].ToString() != "") { model.Md_Stopbit = int.Parse(row["Md_Stopbit"].ToString()); } } return(model); }
public StationEDA9017(StationEntity stationEntity) : base(stationEntity) { portList.Add(new Port(0, "IIN0")); portList.Add(new Port(1, "IIN1")); portList.Add(new Port(2, "IIN2")); portList.Add(new Port(3, "IIN3")); portList.Add(new Port(4, "IIN4")); portList.Add(new Port(5, "IIN5")); portList.Add(new Port(6, "IIN6")); portList.Add(new Port(7, "IIN7")); portList.Add(new Port(8, "IIN8")); portList.Add(new Port(9, "IIN9")); portList.Add(new Port(10, "IIN10")); portList.Add(new Port(11, "IIN11")); }
// GET: Stations/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } StationEntity stationEntity = await _context.Stations.FindAsync(id); if (stationEntity == null) { return(NotFound()); } StationViewModel stationViewModel = _converterHelper.ToStationViewModel(stationEntity); return(View(stationViewModel)); }
//判断某个mac地址是否存在! public IRAPError HasStation(string stationID) { IRAPError error = new IRAPError(); StationEntity e = _stations.Table.FirstOrDefault(r => r.StationID == stationID); if (e == null) { error.ErrCode = 91; error.ErrText = $"此站点:{stationID} 不存在!"; } else { error.ErrCode = 0; error.ErrText = $"站点存在!站点名:{e.HostName}"; } return(error); }
public IEnumerable <SelectListItem> GetTrucksStation(StationEntity station) { List <SelectListItem> list = _context.Trucks.Where(d => d.Station == station).Select(t => new SelectListItem { Text = t.Name, Value = $"{t.Id}" }) .OrderBy(t => t.Text) .ToList(); list.Insert(0, new SelectListItem { Text = "[Select a Truck...]", Value = "0" }); return(list); }
// GET: Stations/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } StationEntity station = await _context.Stations.Include(s => s.Dispensers) .ThenInclude(d => d.Hoses) .FirstOrDefaultAsync(d => d.Id == id); if (station == null) { return(NotFound()); } return(View(station)); }
public void getFieldTest() { string name = "TEST_STATION_ENTITY"; StationEntity se = new StationEntity(name); StationField sf1 = new StationField("Title"); sf1.Level = (1); StationField sf2 = new StationField("CreateDate"); sf2.Level = (1); StationField sf3 = new StationField("Detail"); sf3.Level = (2); StationField sf4 = new StationField("UniqueId"); se.AddField(sf1); se.AddField(sf2); se.AddField(sf3); se.AddField(sf4); // getField(String fieldName) Assert.AreEqual(2, se.GetField("Detail").Level); // getSummaryFields // level 1 List<StationField> sflist = se.SummaryFields; Assert.AreEqual(2, sflist.Count); Assert.AreEqual("Title", sflist[0].Name); // getFields / Add / setFields then verify sflist = se.Fields; Assert.AreEqual(4, sflist.Count); sflist.Add(new StationField("Name")); se.Fields = (sflist); sflist = se.Fields; Assert.AreEqual(5, sflist.Count); Assert.AreEqual("Title", sflist[0].Name); Assert.AreEqual("Name", sflist[4].Name); sflist = se.SummaryFields; Assert.AreEqual(2, sflist.Count); Assert.AreEqual("Title", sflist[0].Name); Assert.AreEqual(1, sflist[1].Level); }