public IHttpActionResult PutPark(int id, ParkInfo park) { try { SqlConnection conn = new SqlConnection(str_connectionDB); conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "update Parks set name=@name, description=@description, numberOfSpots=@numberOfSpots, operatingHours=@operatingHours, numberOfSpecialSpots=@numberOfSpecialSpots, geoLocationFile=@geoLocationFile where id=@id"; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@name", park.Name); cmd.Parameters.AddWithValue("@description", park.Description); cmd.Parameters.AddWithValue("@numberOfSpots", park.NumberOfSpots); cmd.Parameters.AddWithValue("@operatingHours", park.OperatingHours); cmd.Parameters.AddWithValue("@numberOfSpecialSpots", park.NumberOfSpecialSpots); cmd.Parameters.AddWithValue("@geoLocationFile", park.GeoLocationFile); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = conn; int nRet = cmd.ExecuteNonQuery(); conn.Close(); if (nRet > 0) { return(Ok(park)); } else { return(BadRequest()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
private void HandleWallet(LR280Item item, LR280Response w) { EntranceInfo entrance = item.EntranceID.HasValue ? ParkBuffer.Current.GetEntrance(item.EntranceID.Value) : null; OpenCardEventArgs args = new OpenCardEventArgs() { CardID = w.卡号, CardType = LR280Setting.CardTyte, Entrance = entrance, Balance = (decimal)w.金额 / 100, }; if (args.CardType == LR280Setting.CardTyte) { ParkInfo p = ParkBuffer.Current.GetPark(entrance.ParkID); CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardByID(w.卡号).QueryObject; if (card != null && card.CardType.Name == LR280Setting.CardTyte && (entrance == null || (!p.IsNested && entrance.IsExitDevice))) ////中央收费处和非嵌套车场的出口,则进行收费处理 { HandlePayment(item, w, args); } else { if (this.OnReadCard != null) { this.OnReadCard(this, args); } } } }
public NETPark(ParkInfo park, ParkBase parent) : base(park, parent) { foreach (EntranceInfo en in park.Entrances) //初始化主控制器 { if (en.IsMaster && _Master == null) { AddEntrance(en); } } foreach (EntranceInfo en in park.Entrances) //初始化所有其它的控制器,都设置成非主控,且其主控IP设置为_Master的IP { if (GetEntrance(en.EntranceID) == null) { AddEntrance(en); } } if (park.SubParks != null && park.SubParks.Count > 0) { foreach (ParkInfo subPark in park.SubParks) { NETPark sub = new NETPark(subPark, this); AddSubPark(sub); } } BeginBackGroudWork(); }
private void parkCombobox1_SelectedIndexChanged(object sender, EventArgs e) { this.entranceGrid.Rows.Clear(); ParkBuffer.Current.InValid(); if (parkCombobox1.SelectedParkID > 0) { ParkInfo park = ParkBuffer.Current.GetPark(parkCombobox1.SelectedParkID); if (park != null) { foreach (EntranceInfo entrance in park.Entrances) { int row = entranceGrid.Rows.Add(); entranceGrid.Rows[row].Tag = entrance; entranceGrid.Rows[row].Cells["colEntranceName"].Value = entrance.EntranceName; entranceGrid.Rows[row].Cells["colEntranceType"].Value = entrance.IsExitDevice ? Resource1.Entrance_Out : Resource1.Entrance_In; DataGridViewComboBoxCell comboCell = entranceGrid.Rows[row].Cells["colCarType"] as DataGridViewComboBoxCell; comboCell.Items.Add(Resource1.CarType_Car); comboCell.Items.Add(Resource1.CarType_Motor); comboCell.Value = Resource1.CarType_Car; } } ParkOutDoorLedManager settings = ParkOutDoorLedSettingsStorage.Get(park.ParkID); if (settings == null) { settings = new ParkOutDoorLedManager(); settings.ParkID = park.ParkID; ShowParkOutDoorSetting(settings); } else { ShowParkOutDoorSetting(settings); } } }
private ParkFullLed _DixiaKongjian; //地下空间用 #endregion #region 私有方法 private void InitLED() { try { //满位显示屏 if (AppSettings.CurrentSetting.ParkFullLedCOMPort > 0) { _ParkFullLed = new ZhongKuangLed(AppSettings.CurrentSetting.ParkFullLedCOMPort); _ParkFullLed.Open(); if (ParkBuffer.Current.Parks.Count == 1) //显示车位余数 { ParkInfo park = ParkBuffer.Current.Parks[0]; _ParkFullLed.DisplayMsg(string.Format("{0}{1}", park.VacantText, park.Vacant), int.MaxValue); } } } catch (Exception ex) { ExceptionPolicy.HandleException(ex); } try { string filePath = System.IO.Path.Combine(Application.StartupPath, "ParkFullLed.xml"); if (System.IO.File.Exists(filePath)) //显示在地下空间满位显示屏上 { _DixiaKongjian = ParkFullLed.Create(filePath); _DixiaKongjian.Open(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex); } }
private void UpdateParkAdapterUri(ParkInfo park) { string select = string.Empty; //选择登录验证的数据库 string another = string.Empty; //另外一个数据库 if (AppSettings.CurrentSetting.SelectedPark == DataBaseType.Master) { select = AppSettings.CurrentSetting.MasterParkConnect; another = AppSettings.CurrentSetting.StandbyParkConnect; } else { select = AppSettings.CurrentSetting.StandbyParkConnect; another = AppSettings.CurrentSetting.MasterParkConnect; } //先更新选择登录验证的数据库,因为登录验证的数据库是可连接的 UpdatePark(select, park); //再更新另外一个数据库 if (!string.IsNullOrEmpty(another)) { Action action = delegate() { UpdatePark(another, park); }; Thread t = new Thread(new ThreadStart(action)); t.Start();//由于不知道另外一个数据库是否能连接,所以这里使用单独线程去更新 } }
protected override void ItemShowing() { ParkInfo info = (ParkInfo)UpdatingItem; this.Text = info.ParkName; this.txtParkName.Text = info.ParkName; this.txtMaxPortCount.IntergerValue = info.TotalPosition; this.txtParkFullText.Text = info.ParkFullText; this.txtVacant.IntergerValue = info.Vacant; this.txtVacantText.Text = info.VacantText; this.comWorkStation.StationID = info.HostWorkstation; this.comPort.ComPort = info.CommPort; this.comDeviceType.SelectedIndex = (int)info.DeviceType; if (info.DeviceType == EntranceDeviceType.CANEntrance) { this.comWorkMode.SelectedIndex = 1; this.comWorkMode.Enabled = false; } else { this.comWorkMode.SelectedIndex = (int)info.WorkMode; this.comWorkMode.Enabled = info.HostWorkstation == WorkStationInfo.CurrentStation.StationID && AppSettings.CurrentSetting.AllowChangeParkWorkMode; this.comPort.Enabled = false; } if (!info.IsRootPark) { this.comWorkStation.Enabled = false; this.comPort.Enabled = false; this.comDeviceType.Enabled = false; this.comWorkMode.Enabled = false; } this.chkIsNested.Checked = info.IsNested; }
private void ParkVacantRender(ParkInfo park) { try { if (AppSettings.CurrentSetting.ParkVacantLed == 0) { _ParkFullLed = new ZhongKuangLed(AppSettings.CurrentSetting.ParkFullLedCOMPort); } else if (AppSettings.CurrentSetting.ParkVacantLed == 1) { _ParkFullLed = new KeyTopVacantLed(AppSettings.CurrentSetting.ParkFullLedCOMPort); } if (_ParkFullLed != null) { _ParkFullLed.Open(); if (_ParkFullLed is KeyTopVacantLed) { _ParkFullLed.DisplayMsg(park.Vacant.ToString("D3"), int.MaxValue); } else { _ParkFullLed.DisplayMsg(string.Format("{0}{1}", park.VacantText, park.Vacant), int.MaxValue); } _ParkFullLed.Close(); } } catch (Exception ex) { ExceptionPolicy.HandleException(ex); } }
/// <summary> /// 更新停车场的车位数 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult UpdateVacant(int parkID, short vacant) { ParkInfo original = GetParkInfoByID(parkID).QueryObject; ParkInfo oldVal = original.Clone(); original.Vacant = vacant; return(provider.Update(original, oldVal)); }
protected override CommandResult UpdateItem(object updatingItem) { EntranceInfo entrance = updatingItem as EntranceInfo; ParkInfo park = ParkBuffer.Current.GetPark(entrance.ParkID); if (entrance.IsMaster && park.MastEntrance != null && park.MastEntrance.EntranceID != entrance.EntranceID) { return(new CommandResult(ResultCode.Fail, Resources.Resource1.FrmNetEntrance_MastExists)); } return(bll.Update((EntranceInfo)updatingItem)); }
/// <summary> /// 获取通道控制器信息 /// </summary> /// <param name="parkID">停车场ID</param> /// <param name="entranceID">控制器ID</param> /// <returns></returns> public EntranceInfo GetEntrance(int parkID, int entranceID) { EntranceInfo entrance = null; ParkInfo park = _Parks.SingleOrDefault(p => p.ParkID == parkID); if (park != null) { entrance = park.Entrances.SingleOrDefault(en => en.EntranceID == entranceID); } return(entrance); }
private void ProcessReport(ParkVacantReport report) { ParkInfo park = ParkBuffer.Current.GetPark(report.ParkID); if (park != null) { park.Vacant = report.ParkVacant; TreeNode parkNode = GetParkNode(park.ParkID); RenderPark(parkNode, park); } }
/// <summary> /// 获取停车场节点 /// </summary> /// <param name="parkID"></param> /// <returns></returns> public TreeNode GetParkNode(int parkID) { foreach (TreeNode node in allParkNodes) { ParkInfo park = node.Tag as ParkInfo; if (park != null && park.ParkID == parkID) { return(node); } } return(null); }
/// <summary> /// 更新停车场的车位数 /// </summary> /// <param name="parkID">停车场ID</param> /// <param name="vacant">车位数</param> /// <returns></returns> public CommandResult UpdateVacant(int parkID, short vacant) { ParkInfo original = GetParkInfoByID(parkID).QueryObject; if (original != null) { ParkInfo newVal = original.Clone(); newVal.Vacant = vacant; return(provider.Update(newVal, original)); } return(new CommandResult(ResultCode.Fail, string.Empty)); }
private void AddPark(ParkInfo park) { PictureBox pic = new PictureBox(); pic.Tag = park; pic.Image = global::Ralid.OpenCard.UI.Properties.Resources.serverFail; pic.MouseEnter += new EventHandler(pic_MouseEnter); pic.Dock = DockStyle.Left; pic.SizeMode = PictureBoxSizeMode.Zoom; pic.BorderStyle = BorderStyle.FixedSingle; this.pnlPark.Controls.Add(pic); }
/// <summary> /// 更新停车场命令服务器地址 /// </summary> /// <param name="parkID"></param> /// <param name="parkAdapterUri"></param> /// <returns></returns> public CommandResult UpdateParkAdapterUri(int parkID, string parkAdapterUri) { ParkInfo original = GetParkInfoByID(parkID).QueryObject; if (original != null) { ParkInfo newVal = original.Clone(); newVal.ParkAdapterUri = parkAdapterUri; return(provider.Update(newVal, original)); } return(new CommandResult(ResultCode.Fail)); }
[Route("{name:minlength(16):regex(^Campus_[1-5]_[A-Z]_Park[1-9]$)?}")] //6. public IHttpActionResult GetAllParks(string name = null) { try { SqlConnection connection = new SqlConnection(str_connectionDB); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select * from Parks"; if (name != null) { cmd.CommandText += " where name = @name"; cmd.Parameters.AddWithValue("@name", name); } cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = connection; connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); ParkInfo park; List <ParkInfo> parks = new List <ParkInfo>(); while (reader.Read()) { park = new ParkInfo(); park.Id = (int)reader["Id"]; park.Name = (string)reader["Name"]; park.Description = (string)reader["Description"]; park.NumberOfSpots = (int)reader["NumberOfSpots"]; park.OperatingHours = (string)reader["OperatingHours"]; park.NumberOfSpecialSpots = (int)reader["NumberOfSpecialSpots"]; park.GeoLocationFile = (string)reader["GeoLocationFile"]; parks.Add(park); } reader.Close(); connection.Close(); if (parks.Count == 0) { return(BadRequest()); } return(Ok(parks)); } catch (Exception ex) { return(InternalServerError(ex)); } }
/// <summary> /// 获取树中所有选中的停车场 /// </summary> /// <returns></returns> public List <ParkInfo> GetSelectedParks() { List <ParkInfo> park = new List <ParkInfo>(); foreach (TreeNode node in allParkNodes) { if (node.Checked) { ParkInfo info = node.Tag as ParkInfo; park.Add(info); } } return(park); }
/// <summary> /// 显示PARK节点 /// </summary> /// <param name="node"></param> /// <param name="park"></param> public void RenderPark(TreeNode node, ParkInfo park) { if (park.IsRootPark) { node.Text = string.Format("{0}[{1}/{2}][{3}]", park.ParkName, park.Vacant, park.TotalPosition, ParkWorkModeDescription.GetDescription(park.WorkMode)); } else { node.Text = string.Format("{0}[{1}/{2}]", park.ParkName, park.Vacant, park.TotalPosition); } node.Tag = park; node.ForeColor = (park.Status == EntranceStatus.Ok) ? Color.Black : Color.Red; node.ImageIndex = (park.Status == EntranceStatus.Ok) ? 1 : 4; node.SelectedImageIndex = (park.Status == EntranceStatus.Ok) ? 1 : 4; }
private void ShowSetting(ParkInfo park) { ParkOutDoorLedManager settings = ParkOutDoorLedSettingsStorage.Get(park.ParkID); if (settings == null) { settings = new ParkOutDoorLedManager(); settings.ParkID = park.ParkID; ShowParkOutDoorSetting(settings); } else { ShowParkOutDoorSetting(settings); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ParkInfo = await _context.ParkInfo.SingleOrDefaultAsync(m => m.Id == id); if (ParkInfo == null) { return(NotFound()); } return(Page()); }
public void Init(string emptyPark) { ParkBll bll = new ParkBll(AppSettings.CurrentSetting.ParkConnect); this.Items.Clear(); List <ParkInfo> parks = bll.GetAllParks().QueryObjects; ParkInfo info = new ParkInfo(); info.ParkName = emptyPark; // Resources.Resource1.HardwareTree_Root; parks.Insert(0, info); SetDataSource(parks); this.DropDownStyle = ComboBoxStyle.DropDownList; }
private void btn_ParkPUT_Click(object sender, EventArgs e) { string name = text_ParkName.Text.Trim(); if (!Regex.IsMatch(name, "^Campus_[1-5]_[A-Z]_Park[1-9]$")) { MessageBox.Show("Field 'name' format invalid! Example pattern: 'Campus_[1-5]_[A-Z]_Park[1-9]'"); return; } #region Create ParkInfo Data Contact ParkInfo park = new ParkInfo(); park.Name = name; park.Description = text_ParkDescription.Text.Trim(); park.NumberOfSpots = Convert.ToInt32(numericUpDown_ParkNumberOfSpots.Text); park.OperatingHours = text_ParkOperatingHours.Text.Trim(); park.NumberOfSpecialSpots = Convert.ToInt32(numericUpDown_ParkNumberOfSpecialSpots.Text); park.GeoLocationFile = text_ParkGeoLocationFile.Text.Trim(); #endregion #region PUT Park On Database JavaScriptSerializer serializer = new JavaScriptSerializer(); string content = serializer.Serialize(park); string id = text_ParkID.Text.Trim(); if (id == null) { MessageBox.Show($"Error: Please define the id of the Park that you want to update!"); return; } var client = new RestClient($"{baseURI}/parks/{id}"); var request = new RestRequest(); request.Method = Method.PUT; request.AddHeader("accept", "application/json"); request.AddParameter("application/json; charset=utf-8", content, ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; var response = client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { MessageBox.Show($"Success: Park Updated Id: {id}"); } else { MessageBox.Show($"Error: Park not updated! {response.StatusDescription}"); } #endregion }
private void ShowServerSwitchRecordOnRow(DataGridViewRow row, ServerSwitchRecord item) { row.Tag = item; ParkInfo park = ParkBuffer.Current.GetPark(item.ParkID); row.Cells["colPark"].Value = park == null ? string.Empty : park.ParkName; row.Cells["colSwitchDateTime"].Value = item.SwitchDateTime.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells["colSwitchServerIP"].Value = item.SwitchServerIP; row.Cells["colSwitchStatus"].Value = HostStandbyStatusDescription.GetDescription(item.SwitchStatus); row.Cells["colOperator"].Value = item.Operator; row.Cells["colLastDateTime"].Value = item.LastDateTime == null ? string.Empty : item.LastDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells["colLastIP"].Value = item.LastIP; row.Cells["colLastStatus"].Value = HostStandbyStatusDescription.GetDescription(item.LastStatus); row.Cells["colSMSStatus"].Value = SMSSendStatusDescription.GetDescription(item.SMSStatus); row.Cells["colMemo"].Value = item.Memo; }
public IHttpActionResult PostPark(ParkInfo park) { try { SqlConnection connection = new SqlConnection(str_connectionDB); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "insert into Parks (" + "name, " + "description, " + "numberOfSpots, " + "operatingHours, " + "numberOfSpecialSpots, " + "geoLocationFile) " + "values (" + "@name, " + "@description, " + "@numberOfSpots, " + "@operatingHours, " + "@numberOfSpecialSpots, " + "@geoLocationFile);" + "SELECT CAST(scope_identity() AS int);"; cmd.Parameters.AddWithValue("@name", park.Name); cmd.Parameters.AddWithValue("@description", park.Description); cmd.Parameters.AddWithValue("@numberOfSpots", park.NumberOfSpots); cmd.Parameters.AddWithValue("@operatingHours", park.OperatingHours); cmd.Parameters.AddWithValue("@numberOfSpecialSpots", park.NumberOfSpecialSpots); cmd.Parameters.AddWithValue("@geoLocationFile", park.GeoLocationFile); cmd.CommandType = System.Data.CommandType.Text; cmd.Connection = connection; connection.Open(); Int32 id = (Int32)cmd.ExecuteScalar(); connection.Close(); if (id != 0) { park.Id = id; return(Ok(park)); } else { return(BadRequest()); } } catch (Exception ex) { return(InternalServerError(ex)); } }
private void HandleWallet(YCTItem item, YCTWallet w) { EntranceInfo entrance = item.EntranceID.HasValue ? ParkBuffer.Current.GetEntrance(item.EntranceID.Value) : null; OpenCardEventArgs args = new OpenCardEventArgs() { CardID = w.LogicCardID, CardType = w.WalletType == 0 ? string.Empty : YCTSetting.CardTyte, Entrance = entrance, Balance = (decimal)w.Balance / 100, }; if (args.CardType == YCTSetting.CardTyte) { ParkInfo p = ParkBuffer.Current.GetPark(entrance.ParkID); CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardByID(w.LogicCardID).QueryObject; if (card != null && (entrance == null || (!p.IsNested && entrance.IsExitDevice))) { //add by Jan 2016-04-27 增加未完整交易记录判断 YCTPaymentRecord record = GetUnFinishedPayment(card); if (record != null) { if (HandleUnFinishedPayment(item, w, record, args) == false) //处理未完整交易记录 { return; //如果处理未完整交易记录失败了,就不需要继续了 } } //end add by Jan 2016-04-27 HandlePayment(item, w, args);//中央收费处和非嵌套车场的出口,并且是羊城通卡,则进行收费处理 } else { if (this.OnReadCard != null) { this.OnReadCard(this, args); } } } else { if (this.OnReadCard != null) { this.OnReadCard(this, args); } } }
public void ProcessReport(ReportBase report) { if (report is ParkVacantReport) { ParkVacantReport r = report as ParkVacantReport; ParkInfo park = ParkBuffer.Current.GetPark(r.ParkID); if (park != null) { List <ParkInfo> parks = ParkBuffer.Current.Parks; if (parks != null && parks.Count == 1) //满位屏只适用于一个系统中只有一个车场的情况 { ParkVacantRender(parks[0]); } DixiakongjianRender(park); } } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ParkInfo = await _context.ParkInfo.FindAsync(id); if (ParkInfo != null) { _context.ParkInfo.Remove(ParkInfo); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void pad_ParkAdapterConnectFail(object sender, EventArgs e) { this.Invoke((Action)(() => { foreach (Control c in pnlPark.Controls) { if (c is PictureBox) { ParkInfo park = c.Tag as ParkInfo; if (park != null && park.ParkID == (sender as ParkingAdapter).ParkID) { (c as PictureBox).Image = global::Ralid.OpenCard.UI.Properties.Resources.serverFail; } } } })); }
/// <summary> /// 更新停车场,如没有该停车场,插入一个停车场 /// </summary> /// <param name="info"></param> /// <param name="withPrimaryKey">是否插入主键值</param> /// <returns></returns> public CommandResult UpdateOrInsert(ParkInfo info, bool withPrimaryKey) { ParkInfo original = GetParkInfoByID(info.ParkID).QueryObject; if (original != null) { return(provider.Update(info, original)); } else if (withPrimaryKey) { return(provider.InsertWithPrimaryKey(info)); } else { return(provider.Insert(info)); } }