public JsonResult GetSessionIDAndToken(string therapistId, string patientId) { try { if (!string.IsNullOrEmpty(therapistId) && !string.IsNullOrEmpty(patientId)) { Patient lpatient = IPatient.GetPatientByPatientLoginId(patientId); if (lpatient != null) { Vtransact _result = lVTransactRepository.getVTransactbyTherapistAndPatientId(therapistId, patientId); return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", VTransact = _result, PatientName = lpatient.PatientName.Replace(' ', '_'), TimeZone = DateTime.UtcNow.ToString("s") })); } else { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "failed", TimeZone = DateTime.UtcNow.ToString("s") })); } } else { return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", TimeZone = DateTime.UtcNow.ToString("s") })); } } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "failed", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public JsonResult CreateSessionIDAndToken(string therapistId) { try { int ApiKey = ConfigVars.NewInstance.OpenTokAPIKey; //46201082 string ApiSecret = ConfigVars.NewInstance.OpenTokAPISecretKey; // "fbef52398143449c9b269e1357d797c64ae945be"; var OpenTok = new OpenTok(ApiKey, ApiSecret); var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED); //var session=OpenTok.CreateSession(); // Store this sessionId in the database for later use: string sessionId = session.Id; //string token = OpenTok.GenerateToken(sessionId); double inOneMonth = (DateTime.UtcNow.Add(TimeSpan.FromDays(30)).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string token = session.GenerateToken(role: Role.MODERATOR, expireTime: inOneMonth); Vtransact ltranact = new Vtransact(); ltranact.SessionId = sessionId; ltranact.TherapistId = therapistId; ltranact.Status = 0; ltranact.Token = token; Vtransact _result = lVTransactRepository.insertVTransact(ltranact); return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", VTransact = _result, TimeZone = DateTime.UtcNow.ToString("s") })); } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "failed", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public Vtransact insertVTransact(Vtransact ltransact) { context.Vtransact.Add(ltransact); if (context.SaveChanges() > 0) { return(ltransact); } else { return(null); } }
public Vtransact getVTransactbyTherapistAndPatientId(string therapistId, string patientId) { Vtransact ltransact = (from p in context.Vtransact where p.TherapistId == therapistId && p.Status == 0 select p).FirstOrDefault(); if (ltransact != null) { ltransact.PatientId = patientId; context.Entry(ltransact).State = Microsoft.EntityFrameworkCore.EntityState.Modified; if (context.SaveChanges() > 0) { return(ltransact); } } return(null); }
public IActionResult VideoCallTherapist(string patientId) { try { if (!string.IsNullOrEmpty(HttpContext.Session.GetString("UserId")) && !string.IsNullOrEmpty(patientId)) { Vtransact lgetOpenSession = lVTransactRepository.getVTransactDetails(HttpContext.Session.GetString("UserId"), patientId); if (lgetOpenSession != null) { HttpContext.Session.SetString("VideoSessionId", lgetOpenSession.SessionId); HttpContext.Session.SetString("Token", lgetOpenSession.Token); } else { int ApiKey = ConfigVars.NewInstance.OpenTokAPIKey; //46201082 string ApiSecret = ConfigVars.NewInstance.OpenTokAPISecretKey; // "fbef52398143449c9b269e1357d797c64ae945be"; var OpenTok = new OpenTok(ApiKey, ApiSecret); var session = OpenTok.CreateSession(mediaMode: MediaMode.ROUTED); //var session = OpenTok.CreateSession(); // Store this sessionId in the database for later use: string sessionId = session.Id; //string token = OpenTok.GenerateToken(sessionId); double inOneMonth = (DateTime.UtcNow.Add(TimeSpan.FromDays(30)).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string token = session.GenerateToken(role: Role.MODERATOR, expireTime: inOneMonth); Vtransact ltranact = new Vtransact(); ltranact.SessionId = sessionId; ltranact.TherapistId = HttpContext.Session.GetString("UserId"); ltranact.Status = 0; ltranact.Token = token; Vtransact _result = lVTransactRepository.insertVTransact(ltranact); if (_result != null) { HttpContext.Session.SetString("VideoSessionId", _result.SessionId); HttpContext.Session.SetString("Token", _result.Token); } } } } catch (Exception ex) { } return(View()); }
public JsonResult UpdateStatus([FromBody] Vtransact ptranact) { try { if (ptranact != null) { Vtransact ltransact = lVTransactRepository.getVTransact(ptranact.SessionId, ptranact.Token); if (ltransact != null) { ltransact.PatientId = ptranact.PatientId; ltransact.Status = ptranact.Status; ltransact.Duration = ptranact.Duration; lVTransactRepository.updateStatus(ltransact); } } return(Json(new { Status = (int)HttpStatusCode.OK, result = "success", TimeZone = DateTime.UtcNow.ToString("s") })); } catch (Exception ex) { return(Json(new { Status = (int)HttpStatusCode.InternalServerError, result = "failed", TimeZone = DateTime.UtcNow.ToString("s") })); } }
public void updateStatus(Vtransact ltransact) { context.Entry(ltransact).State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); }