public JsonResult CreateChatRoom(ChatRoomCreationModel model) { int userId = -1; int messageId = -1; int chatRoomId = -1; int count = 0; bool EmailAvailable = false; //<-- indica si el envio de emails esta disponible bool userIsAlreadyUsed = false; //<-- indica si el usuario ya tiene un chatroom activo bool isSurveyAvailable = false; //<-- indica si las encuestas estan disponibles string surveyText = null; string surveyUrl = null; try { count = EpironChatDAC.OnlineUsers_Count(model.ChatConfigId); ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(model.ChatConfigId); isSurveyAvailable = chatConfigBE.ChatSurveyConfigId != null; surveyText = chatConfigBE.ChatSurveyConfigText; surveyUrl = chatConfigBE.ChatSurveyConfigURL; if (count == 0) { EpironChatBC.CreateChatRoom_NoOperators(model.Phone, null, string.Empty, model.InitialMessage); return(Json(new { Result = "NO-OPERATORS", EmailAvailable = chatConfigBE.EmailAvailable })); } EpironChatBC.CreateChatRoom(model, out chatRoomId, out userId, out messageId, out userIsAlreadyUsed, out EmailAvailable); if (userIsAlreadyUsed) { return(Json(new { Result = "USER-SIGNED" })); } return(Json(new { Result = "OK", userId = userId, roomId = chatRoomId, messageId = messageId, EmailAvailable = EmailAvailable, surveyText = surveyText, isSurveyAvailable = isSurveyAvailable, surveyUrl = surveyUrl })); } catch (Exception ex) { Helper.Log(ex.Message); return(Json(new { Result = "ERROR", Message = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex) })); } }
/// <summary> /// Raliza la creación de un chatRoom para un No Operators /// </summary> /// <param name="phone"></param> /// <param name="url"></param> /// <param name="@case"></param> internal static void CreateChatRoom_NoOperators(string phone, string url, string @case, string menssage) { //Busca el cliente relacionado al telefono Este debe existir int userId = EpironChatBC.CheckPhoneId(phone, String.Empty, String.Empty); ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); int roomId = ChatRoomDAC.CreateChatRoom(chatConfigBE.ChatConfigId, (int)Common.Enumerations.ChatRoomStatus.ClosedLoggedOutRep, @case, url); //[08:55:38 a.m.]yulygasp: se lo concatenemos al mensaje es que no podemos pasarlo en otro campo //porque el etl no esta preparado para recibirlo //model.InitialMessage = String.Concat(model.InitialMessage, "|", model.ClientName); int messageId = EpironChatBC.InsertMessage(roomId, userId, menssage, null); }
static Common() { //SI NO HAY WRAPPERS CARGA DIRECTAMENTE EpironChatLogs_CnnString = System.Configuration.ConfigurationManager.ConnectionStrings[EpironChatLogs_CnnStringName].ConnectionString; EpironChat_CnnString = System.Configuration.ConfigurationManager.ConnectionStrings[EpironChat_CnnStringName].ConnectionString; //CnnString_Entities = System.Configuration.ConfigurationManager.ConnectionStrings["HealthEntities"].ConnectionString; //Fwk.Security.Cryptography.FwkSymetricAlg s = new FwkSymetricAlg(SEED_K); //ISymetriCypher = s;// SymetricCypherFactory.Cypher();// SymetricCypherFactory.Get<RijndaelManaged>(SEED_K); try { //CONFIGURACIONES DE APPLICATIONSETTINGS [EPIMOVI-1377] List <ApplicationSettingBE> wAppSettingsList = ChatConfigDAC.SearchApplicationSettings(); //RetriveMessage_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.RetriveMessage_Timer)).Value) /1000; //GetRecord_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_Timer)).Value) / 1000; //VersionWeb = wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.VersionWeb)).Value; //GetRecordIdTries = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecordIdTries)).Value); //ClientInactivityTimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.ClientInactivityTimeOut)).Value)/1000; MaxLength_Message = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.MaxLength_Message)).Value); var varHostRefer = wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.Host_Referer)); if (varHostRefer == null || varHostRefer.Value == string.Empty) { Host_Referer = null; } else { Host_Referer = varHostRefer.Value; } } catch (Exception ex) { Helper.Log(ex.Message); } //if (!String.IsNullOrEmpty(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "RetriveMessage_Timer") )) // RetriveMessage_Timer = Convert.ToInt32(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "RetriveMessage_Timer")); //if (!String.IsNullOrEmpty(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "CheckOperators_Timer"))) // CheckOperators_Timer = Convert.ToInt32(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "CheckOperators_Timer")); //if (!String.IsNullOrEmpty(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "GetRecord_Timer"))) // CheckOperators_Timer = Convert.ToInt32(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "GetRecord_Timer")); ////VERSION DE LA WEB //if (!String.IsNullOrEmpty(Fwk.Configuration.ConfigurationManager.GetProperty("Config", "VersionWeb"))) // VersionWeb = Fwk.Configuration.ConfigurationManager.GetProperty("Config", "VersionWeb"); }
//[HttpGet] //public ActionResult Default(string tel, string url, string @case, Boolean? isAjaxCall) //{ // try // { // if (WebChat.Common.Common.Host_Referer != null) // { // if (HttpContext.Request.ServerVariables["HTTP_REFERER"].Contains(WebChat.Common.Common.Host_Referer)) // { // return View(); // } // else // { // Helper.Log("Ruta de acceso incorrecta, HTTP_REFERER distinto de" + WebChat.Common.Common.Host_Referer); //Registro que se ingreso por un lugar que no correspondería // ChatRoomFromUrlModel mChatRoomFromUrlModel = new ChatRoomFromUrlModel(); // mChatRoomFromUrlModel.HaveException = true; // return View("Chat", mChatRoomFromUrlModel); //abro el chat pero con excepcion, para detener todo. // } // } // else // { // return View(); // } // } // catch (Exception ex) // { // Helper.Log(ex.Message); // ChatRoomFromUrlModel mChatRoomFromUrlModel = new ChatRoomFromUrlModel(); // mChatRoomFromUrlModel.HaveException = true; // return View("Chat", mChatRoomFromUrlModel); //abro el chat pero con excepcion, para detener todo. // } //} /// <summary> /// /// </summary> /// <returns></returns> public ActionResult Index() { ChatRoomGridModel wModel = new ChatRoomGridModel(); try { //Busco las configuraciones (salas) que llenan los combos var chatConfigList = ChatConfigDAC.RetriveAll(); List <SelectListItem> li = new List <SelectListItem>(); foreach (var chatConfig in chatConfigList) { li.Add(new SelectListItem { Text = chatConfig.ChatConfigName, Value = chatConfig.ChatConfigGuid.ToString() }); } if (li.Count > 0) { wModel.IsConfigavailable = true; } ViewData["ChatConfigList"] = li; //<-- las configuraciones se envian a través del ViewData // Busco las appSettings List <ApplicationSettingBE> wAppSettingsList = ApplicationSettingBC.SearchApplicationSetting(); wModel.RetriveMessage_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.RetriveMessage_Timer)).Value); wModel.GetRecord_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_Timer)).Value); wModel.VersionWeb = wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.VersionWeb)).Value; wModel.GetRecordIdTries = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecordIdTries)).Value); wModel.ClientInactivityTimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.ClientInactivityTimeOut)).Value) / 1000; wModel.GetRecord_TimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_TimeOut)).Value) / 1000; wModel.GetRecord_TimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_TimeOut)).Value) / 1000; wModel.MaxLength_Message = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.MaxLength_Message)).Value); } catch (Exception ex) { Helper.Log(ex.Message); wModel.HaveException = true; return(View(wModel)); } return(View(wModel)); }
/// <summary> /// REaliza la creacion de chatroom nuevo. Adicionalmente verifica si existen chatrooms activos por el usuario y los cierra /// </summary> /// <param name="model"></param> /// <param name="roomId"></param> /// <param name="userId"></param> internal static void CreateChatRoom(ChatRoomCreationModel model, out int roomId, out int userId, out int messageId, out bool userIsAlreadyUsed, out bool EmailAvailable) { roomId = -1; messageId = -1; //Busca el cliente relacionado al telefono userId = EpironChatBC.CheckPhoneId(model.Phone, model.ClientName, model.ClientEmail); ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(model.ChatConfigId); userIsAlreadyUsed = GetChatRoom_IfNotExpired(userId, chatConfigBE); EmailAvailable = chatConfigBE.EmailAvailable; if (userIsAlreadyUsed) { return; } roomId = ChatRoomDAC.CreateChatRoom(chatConfigBE.ChatConfigId, (int)Common.Enumerations.ChatRoomStatus.Waiting, String.Empty, null); //[08:55:38 a.m.]yulygasp: se lo concatenemos al mensaje es que no podemos pasarlo en otro campo //porque el etl no esta preparado para recibirlo //model.InitialMessage = String.Concat(model.InitialMessage, "|", model.ClientName); messageId = EpironChatBC.InsertMessage(roomId, userId, model.InitialMessage, null); }
/// <summary> /// REaliza la creacion de chatroom nuevo. Adicionalmente verifica si existen chatrooms activos por el usuario y los cierra /// </summary> /// <param name="model"></param> /// <param name="roomId"></param> /// <param name="userId"></param> internal static void CreateChatRoom_FromUrl(string phone, string url, string @case, out int roomId, out int userId, out int messageId, out bool userIsAlreadyUsed) { roomId = -1; //Busca el cliente relacionado al telefono Este debe existir userId = EpironChatBC.CheckPhoneId(phone, String.Empty, String.Empty); ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); userIsAlreadyUsed = GetChatRoom_IfNotExpired(userId, chatConfigBE); if (userIsAlreadyUsed) { messageId = 0; return; } roomId = ChatRoomDAC.CreateChatRoom(chatConfigBE.ChatConfigId, (int)Common.Enumerations.ChatRoomStatus.Waiting, @case, url); //[08:55:38 a.m.]yulygasp: se lo concatenemos al mensaje es que no podemos pasarlo en otro campo //porque el etl no esta preparado para recibirlo //model.InitialMessage = String.Concat(model.InitialMessage, "|", model.ClientName); messageId = EpironChatBC.InsertMessage(roomId, userId, string.Empty, null); }
/// <summary> /// Este se usa para casos donde el cliente (ej TP) tienbe su propio formulario de carga de dato y genera la URL . /// /// </summary> /// <param name="model"></param> /// <param name="phone"></param> /// <param name="initialMessage"></param> /// <param name="roomId"></param> /// <param name="userId"></param> /// <author>moviedo</author> internal static void CreateChatRoom(ChatRoomFromUrlModel model, String phone, String initialMessage, out int roomId, out int userId, out int messageId, out bool userIsAlreadyUsed, out bool EmailAvailable) { roomId = -1; messageId = -1; //Busca el cliente relacionado al telefono userId = EpironChatBC.CheckPhoneId(phone, model.ClientName, model.ClientEmail); ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(model.ChatConfigId); userIsAlreadyUsed = GetChatRoom_IfNotExpired(userId, chatConfigBE); EmailAvailable = chatConfigBE.EmailAvailable; if (userIsAlreadyUsed) { return; } roomId = ChatRoomDAC.CreateChatRoom(chatConfigBE.ChatConfigId, (int)Common.Enumerations.ChatRoomStatus.Waiting, String.Empty, null); messageId = EpironChatBC.InsertMessage(roomId, userId, initialMessage, null); }
public ActionResult Chatfrm(string tel, string clientName, string email, string query) { bool anyIsNull = string.IsNullOrEmpty(Request.QueryString["tel"]) || string.IsNullOrEmpty(Request.QueryString["clientName"]) || string.IsNullOrEmpty(Request.QueryString["email"]) || string.IsNullOrEmpty(Request.QueryString["query"]); if (anyIsNull) { return(RedirectToAction("Index")); } ChatRoomFromUrlModel model = new ChatRoomFromUrlModel(); int chatRoomId = -1; int userId = -1; int messageId = -1; bool userIsAlreadyUsed = false; //<-- indica si el usuario ya tiene un chatroom activo //model.Phone = tel; model.ClientName = clientName; model.ClientEmail = email; //model.InitialMessage = query; bool emailAvailable = false; //<-- indica si el envio de emails esta disponible try { if (WebChat.Common.Common.Host_Referer != null)//<--pregunto si el parametro esta configurado { if (HttpContext.Request.ServerVariables["HTTP_REFERER"] == null || !HttpContext.Request.ServerVariables["HTTP_REFERER"].Contains(WebChat.Common.Common.Host_Referer)) { Helper.Log("Ruta de acceso incorrecta, HTTP_REFERER distinto de" + WebChat.Common.Common.Host_Referer); //Registro que se ingreso por un lugar que no correspondería ChatRoomFromUrlModel mChatRoomFromUrlModel = new ChatRoomFromUrlModel(); mChatRoomFromUrlModel.HaveException = true; return(View("Chat", mChatRoomFromUrlModel)); //abro el chat pero con excepcion, para detener todo. } } ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); if (chatConfigBE == null) { model.IsConfigavailable = false; //<--No hay configuraciones, en el cliente se mostrara un mensaje return(View("chat", model)); } model.OperatrCount = EpironChatDAC.OnlineUsers_Count(chatConfigBE.ChatConfigGuid); if (model.OperatrCount > 0) { EpironChatBC.CreateChatRoom(model, tel, query, out chatRoomId, out userId, out messageId, out userIsAlreadyUsed, out emailAvailable); } else { EpironChatBC.CreateChatRoom_NoOperators(tel, null, string.Empty, query); } model.ChatConfigId = chatConfigBE.ChatConfigGuid; model.UserId = userId; model.RoomId = chatRoomId; model.MessageId = messageId; model.userAlreadySigned = userIsAlreadyUsed; model.IsConfigavailable = true; model.EmailAvailable = chatConfigBE.EmailAvailable; //Survey model.SurveyAvailable = chatConfigBE.ChatSurveyConfigId != null; model.ChatSurveyConfigText = chatConfigBE.ChatSurveyConfigText; model.ChatSurveyConfigURL = chatConfigBE.ChatSurveyConfigURL; model.ChatSurveyConfigId = chatConfigBE.ChatSurveyConfigId; // Busco las appSettings List <ApplicationSettingBE> wAppSettingsList = ApplicationSettingBC.SearchApplicationSetting(); model.RetriveMessage_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.RetriveMessage_Timer)).Value); model.GetRecord_Timer = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_Timer)).Value); model.VersionWeb = wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.VersionWeb)).Value; model.GetRecordIdTries = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecordIdTries)).Value); model.ClientInactivityTimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.ClientInactivityTimeOut)).Value) / 1000; model.GetRecord_TimeOut = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.GetRecord_TimeOut)).Value) / 1000; model.MaxLength_Message = int.Parse(wAppSettingsList.Find(x => x.SettingId.Equals((int)Enumerations.ApplicationSettingId.MaxLength_Message)).Value); //if (isAjaxCall.HasValue) // return Json(new { Result = "OK", userId = userId, roomId = chatRoomId, count = model.OperatrCount, messageId = model.MessageId }, JsonRequestBehavior.AllowGet); return(View("chat", model)); } catch (Exception ex) { Helper.Log(ex.Message); //if (isAjaxCall.HasValue) //{ // return Json(new { Result = "ERROR", Message = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex) }); //} //else //{ model.HaveException = true; return(View("chat", model)); //} } }
public ActionResult SendEmail(string cellPhone, string email, string emailBody, bool toTheClientFlag, string pGuid, int pRoomId, int pIsNoOperator) { try { ChatMailSenderBE wChatMailSenderBE = null; if (pGuid == "0") { ChatConfigBE chatConfigBE = ChatConfigDAC.GetByParam(null); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(chatConfigBE.ChatConfigGuid); } else { Guid wGuid = new Guid(pGuid); wChatMailSenderBE = EpironChatEmailBC.GetChatMailSenderByCongGuid(wGuid); } ChatUserBE wChatUserBE = new ChatUserBE(); wChatUserBE.ChatUserEmail = email; //<--usaremos el email que el usuario nos provee, aunque este tenga uno previo, no lo modificaremos en la base if (toTheClientFlag) { string css = @" <style>.bubbleOwn { position: relative; width: 60%; /*height: 35px;*/ padding: 5px; background-color: #71C837; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; left: 1px; clear: both; margin:6px 0px 1px 8px; border: 1px solid #CCC; /*min-height: 35px;*/ } .bubbleThey { position: relative; width: 60%; /*height: 35px;*/ padding: 2px; background: white; border: 1px solid #CCC; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; float: right; margin-right: 1px; clear: both; margin:6px 8px 1px 0px; /*min-height: 35px;*/ } ._time { float: right; font-size: 10px; } </style>"; emailBody = css + emailBody; } bool isSent = EmailHelper.SentEmail(emailBody, toTheClientFlag, wChatMailSenderBE, wChatUserBE); if (isSent) { //se registra en la base que se ha enviado un email ChatEmailMessageBE wChatEmailMessageBE = new ChatEmailMessageBE(); // pIsNoOperator <-- Indica si este email se envia tras no encontrar operadores disponibles wChatEmailMessageBE.ChatDescription = pIsNoOperator == 1 ? "SIN-OPERADORES" : null; wChatEmailMessageBE.EmailFrom = wChatMailSenderBE.Email; if (pRoomId != 0) { wChatEmailMessageBE.ChatRoomId = pRoomId; } else { wChatEmailMessageBE.ChatRoomId = null; } wChatEmailMessageBE.Body = emailBody; if (toTheClientFlag) { wChatEmailMessageBE.Subject = "-Subject-"; wChatEmailMessageBE.DeliveredTo = wChatUserBE.ChatUserEmail; } else { wChatEmailMessageBE.Subject = wChatMailSenderBE.TagStartWith + wChatUserBE.ChatUserEmail + wChatMailSenderBE.TagEndWith; wChatEmailMessageBE.DeliveredTo = wChatMailSenderBE.Email; } bool saved = EpironChatEmailBC.InsertChatEmailMessage(wChatEmailMessageBE); if (saved) { return(Json(new { Result = "OK", Message = "Correo enviado correctamente" })); } else { return(Json(new { Result = "OK", Message = "Error al Guardar el Email" })); //<-- Revisar si se debe o no avisar al cliente } } else { return(Json(new { Result = "OK", Message = "Error al Enviar Correo" })); //<-- Revisar si se debe o no avisar al cliente } } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex) })); } }
public static List <ApplicationSettingBE> SearchApplicationSetting() { return(ChatConfigDAC.SearchApplicationSettings()); }