- SendWisperApi("cleared", e.DeviceNumber); ---call establish
- ------ api function
- static void SendWisperApi(string state, string agent_number)
- {
- try
- {
- string url = String.Format("/Home/CallMonitorApi");
- var client = new RestClient(System.Configuration.ConfigurationManager.AppSettings["iisserver"].ToString());
- var request = new RestRequest(url, Method.Post);
- request.AddParameter("state", state);
- request.AddParameter("agent_number", agent_number);
- RestResponse response = client.Execute(request);
- if (response.IsSuccessStatusCode)
- {
- // Request was successful
- string responseContent = response.Content;
- WriteLog(String.Format($"send wisper established ok agent number{agent_number}"));
- }
- else
- {
- // Request failed
- WriteLog("API request failed with status code: " + response.StatusCode);
- }
- }
- catch (Exception ex)
- {
- WriteLog("Failed and got error: " + ex.Message);
- }
- }
- --- loging function
- public static void WriteLog(string logMessage, bool addTimeStamp = true)
- {
- var path = AppDomain.CurrentDomain.BaseDirectory;
- if (!Directory.Exists(path))
- Directory.CreateDirectory(path);
- var filePath = String.Format("{0}\\callmonitor_log\\myservice_{1}.txt",
- path,
- DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.CurrentCulture)
- );
- if (addTimeStamp)
- logMessage = String.Format("[{0}] - {1}\r\n",
- DateTime.Now.ToString("HH:mm:ss", CultureInfo.CurrentCulture),
- logMessage);
- File.AppendAllText(filePath, logMessage);
- }
Recent Pastes