- public void device_CallEstablished(object sender, CallEstablishedEventArgs e)
- {
- SendCallInformationApi(ani,nationalcode,devicenumber);
- // Update the Call Events list view, if CallEstablished is enabled
- if (menuEventsCallEstablished.Checked)
- {
- CallEventsListViewEventArgs args = new CallEventsListViewEventArgs(
- sender as Device, EVENT_NAME_CALL_ESTABLISHED,
- e.EventTime, string.Empty, e.DeviceNumber,
- string.Empty, string.Empty, string.Empty);
- UpdateCallEventsListViewWrapper(sender as Device, args);
- dbContext dal = new dbContext();
- DeviceNumberModel model = new DeviceNumberModel();
- model.DeviceNumber = e.ConnectedDevice.DeviceNumber;
- dal.GetDeviceNumber(model);
- }
- }
- public static void SendCallInformationApi(string ani, string nationalCode, string deviceNumber, string state)
- {
- try
- {
- string baseUrl = "http://192.168.0.133:8080/items/"; // Replace with the actual FastAPI server endpoint
- var client = new RestClient(baseUrl);
- var request = new RestRequest(); // FastAPI expects a GET request in your provided code
- request.Method = Method.Get;
- // Add query parameters to the request
- request.AddParameter("Ani", ani);
- request.AddParameter("NationalCode", nationalCode);
- request.AddParameter("DeviceNumber", deviceNumber);
- // Execute the API request synchronously
- RestResponse response = client.Execute(request);
- // If the response is not successful, handle it silently if no logging is required
- if (!response.IsSuccessStatusCode)
- {
- // Optionally throw an error or handle failure silently
- throw new Exception($"API call failed with status: {response.StatusCode}");
- }
- }
- catch (Exception)
- {
- // Silently catch errors or rethrow if needed
- // Example: throw;
- }
Recent Pastes