public void MovePhysicianStatuses() { try { // create log _logger.AddLogEntry(_serviceName, "INPROGRESS", _serviceName + " Started", ""); var now = DateTime.Now.ToEST(); List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter("@DateEST", now)); DataSet dataSet = DBHelper.ExecuteSqlDataSet("usp_job_status_mover", param.ToArray()); var snoozePoupUsersIds = new List <PhysicianStatusSnoozeViewModel>(); List <string> movedUserIds = new List <string>(); foreach (DataRow item in dataSet.Tables[0].Rows) { snoozePoupUsersIds.Add(new PhysicianStatusSnoozeViewModel { phs_key = (Int32)item["status_key"], UserId = item["UserId"].ToString() }); } foreach (DataRow item in dataSet.Tables[1].Rows) { movedUserIds.Add(item["UserId"].ToString()); } if (snoozePoupUsersIds.Count() > 0) { RunSnoozePopupCode(snoozePoupUsersIds); snoozePoupUsersIds.Clear(); } if (movedUserIds.Count() > 0) { // sending request to signal r controller to update the status of online physician string url = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(movedUserIds); scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json); } } catch (Exception exception) { _logger.AddLogEntry(_serviceName, "ERROR", exception.ToString(), ""); } finally { _logger.AddLogEntry(_serviceName, "COMPLETED", "", ""); } }
public void StatusAvailableProcess() { try { // create log _logger.AddLogEntry(_serviceName, "INPROGRESS", _serviceName + " Started", ""); var now = DateTime.Now.ToEST(); List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter("@DateEST", now)); DataTable dataTable = DBHelper.ExecuteSqlDataAdapter("usp_job_status_available", param.ToArray()); if (dataTable.Rows.Count > 0) { var physicianUserIds = dataTable.AsEnumerable().Select(x => x["UserId"].ToString()).ToList(); string url = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(physicianUserIds); scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json); } } catch (Exception exception) { _logger.AddLogEntry(_serviceName, "ERROR", exception.ToString(), ""); } finally { _logger.AddLogEntry(_serviceName, "COMPLETED", "", ""); } }
public void CallJSMethod(List <string> recievers, SocketResponseModel model) { recievers = recievers.Distinct().ToList(); var allUsers = _chatClients.Select(x => ((WebSocketEventHandler)x)).ToList(); var users = allUsers.Where(m => string.IsNullOrEmpty(m.ServerUrl)) .Where(x => recievers.Contains(x.UserId)).ToList(); users.ForEach(client => { var data = Functions.EncodeTo64UTF8(Newtonsoft.Json.JsonConvert.SerializeObject(model)); client.Send(data); }); var otherServerUsers = allUsers.Where(m => recievers.Contains(m.UserId)) .Where(m => !string.IsNullOrEmpty(m.ServerUrl)) .Select(m => new { m.ServerUrl }) .Distinct() .ToList(); try { otherServerUsers.ForEach(s => { var sendRequest = new SocketSendRequestModel { Recievers = recievers, ResponseModel = model }; var postData = Newtonsoft.Json.JsonConvert.SerializeObject(sendRequest); var url = s.ServerUrl + "/RpcHandler/CallJsMethod?SignalRAuthKey=" + Settings.SignalRAuthKey; var response = scrapper.GetData(url, "POST", postData, ContentTypes.Json); }); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } }
public void MovePhysicianStatuses() { try { // create log _logger.AddLogEntry(_serviceName, "INPROGRESS", _serviceName + " Started", ""); var snoozePoupUsersIds = new List <PhysicianStatusSnoozeViewModel>(); var movedUserIds = new List <string>(); using (var objService = new PhysicianService()) { objService.GetPhysicianStatusDashboard() .Where(m => m.physician.physician_status.phs_move_status_key != null && m.physician.status_key != m.physician.physician_status.phs_move_status_key) .ToList() .ForEach(item => { var status_key = item.physician.status_key; var isSendSnoozeNotification = false; var snoozeTime = item.physician.physician_status_snooze.Where(m => m.pss_processed_date == null && m.pss_phs_key == status_key ); double snoozeMinutes = 0; if (snoozeTime.Count() > 0) { snoozeMinutes = snoozeTime.Sum(m => m.pss_snooze_time.TotalMinutes); } if (item.physician.physician_status.phs_move_threshhold_time.HasValue && item.physician.physician_status.phs_enable_snooze) { // this condition will be rechecked after the task is completed. little bit doubt on it var elapsedTime = DateTime.Now.ToEST() - item.physician.status_change_date_forAll.Value.AddMinutes(snoozeMinutes); var difference = item.physician.physician_status.phs_move_threshhold_time.Value.TotalMinutes - elapsedTime.TotalMinutes; var currentSnooze = item.physician.physician_status_snooze.Where(m => m.pss_processed_date == null && m.pss_phs_key == status_key && m.pss_is_latest_snooze ) .FirstOrDefault(); if (difference <= 2.1 && difference >= 1.5 && currentSnooze == null) { isSendSnoozeNotification = true; } } if (isSendSnoozeNotification && snoozeTime.Count() < item.physician.physician_status.phs_max_snooze_count.Value) { snoozePoupUsersIds.Add(new PhysicianStatusSnoozeViewModel { phs_key = item.physician.status_key.Value, UserId = item.physician.Id }); } else { if (RunStatusUpdateCode(item, snoozeMinutes)) { snoozeTime.ToList().ForEach(m => { m.pss_processed_date = DateTime.Now.ToEST(); m.pss_is_latest_snooze = false; m.pss_modified_by = "physician status move service"; m.pss_modified_by_name = "physician status move service"; m.pss_modified_date = DateTime.Now.ToEST(); }); movedUserIds.Add(item.physician.Id); } } }); objService.SaveChanges(); } if (snoozePoupUsersIds.Count() > 0) { RunSnoozePopupCode(snoozePoupUsersIds); snoozePoupUsersIds.Clear(); } if (movedUserIds.Count() > 0) { // sending request to signal r controller to update the status of online physician string url = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey; string postData = Newtonsoft.Json.JsonConvert.SerializeObject(movedUserIds); scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json); } } catch (Exception exception) { _logger.AddLogEntry(_serviceName, "ERROR", exception, ""); } finally { _logger.AddLogEntry(_serviceName, "COMPLETED", "", ""); } }
/// <summary> /// Send call to five9 /// </summary> /// <param name="data"></param> /// <param name="f9Number"></param> /// <param name="f9Domain"></param> /// <returns>get eAlert processed data to update in database</returns> public eAlertUpdateViewModel SendCallRequestToFive9(eAlertViewModel data, string f9Number, string f9Domain) { var eAlertUpdateModel = new eAlertUpdateViewModel(); eAlertUpdateModel.reprocessed_date = DateTime.Now.ToEST(); eAlertUpdateModel.wcl_request_retry_count = data.wcl_request_retry_count; eAlertUpdateModel.case_key = data.case_key; try { //fin9 complete url to process request var five9ApiUrl = five9URL + f9Domain + "&F9list=" + five9List; five9ApiUrl += "&F9key=case_number&F9updateCRM=1&case_number=" + data.case_number; five9ApiUrl += "&number1=" + f9Number; five9ApiUrl += "&case_type=" + data.case_type + "&Facility Name=" + data.facility_name + "&cart=" + data.cart + "&callback_number=" + data.callback_number; five9ApiUrl += "&callback_extension=" + data.callback_extension + "&F9CallASAP=0&F9retResults=1"; _logger.AddLogEntry(_serviceName, "INPROGRESS", five9ApiUrl, "SendCallRequestToFive9"); //send call to five9 string result = scrapper.GetData(five9ApiUrl, "POST", null); if (!string.IsNullOrEmpty(result)) { //pars response returned from five9 var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(result); var htmlNodes = htmlDoc.DocumentNode.SelectNodes("//td/input"); //responbile to create json object StringBuilder json = new StringBuilder(); json.Append("{"); for (int i = 0; i < htmlNodes.Count; i++) { string id = htmlNodes[i].Attributes["id"].Value; string value = htmlNodes[i].Attributes["value"].Value; if (id == "F9errCode" && value == "0") { eAlertUpdateModel.error_code = value; } else if (id == "F9errCode" && value != "0") { eAlertUpdateModel.error_code = "TC-Error"; } else if (id == "F9errDesc") { eAlertUpdateModel.error_description = value; } json.Append(string.Format(" \"{0}\":\"{1}\",", id, value)); } // remove ',' at the end of the string if (htmlNodes.Count > 0) { json.Remove(json.Length - 1, 1); } json.Append("}"); eAlertUpdateModel.raw_result = json.ToString(); } _logger.AddLogEntry(_serviceName, "COMPLETED", five9ApiUrl, "SendCallRequestToFive9"); } catch (Exception exception) { _logger.AddLogEntry(_serviceName, "ERROR", exception.ToString(), "SendCallRequestToFive9"); } return(eAlertUpdateModel); }