public long GetEquipmentByName(string equipmentName) { var filter = new GridRequestOptions() { Filter = new[] { "Name", "contains", equipmentName } }; var url = "/api/dpaEnterpriseStrusture/getEquipments/"; var postParams = JsonConvert.SerializeObject(filter); var result = client.Post(url, postParams); if (string.IsNullOrEmpty(result)) { throw Examples.NotFoundException("Equipment", equipmentName); } var resultObject = JsonConvert.DeserializeObject <IdNameContainer[]>(result); if (resultObject.Length == 0) { throw Examples.NotFoundException("Equipment", equipmentName); } return(resultObject[0].Id); }
public long GetIndicatorByName(string equipmentName, string indicatorName) { var resultObject = GetIndicatorList(equipmentName); var indicator = resultObject.FirstOrDefault(ind => ind.Name == indicatorName); if (indicator == null) { throw Examples.NotFoundException("Indicator", indicatorName); } return(indicator.Id); }
public void AddAwaitingForTransportTicket(string equipmentName) { var equipmentId = GetEquipmentByName(equipmentName); if (!TryGetTicketByName(AWAITING_FOR_TRANSPORT_TICKET_NAME_RUS, out long ticketId)) { if (!TryGetTicketByName(AWAITING_FOR_TRANSPORT_TICKET_NAME_ENG, out ticketId)) { throw Examples.NotFoundException("Ticket", AWAITING_FOR_TRANSPORT_TICKET_NAME_RUS); } } AddTicket(equipmentId, ticketId); }