Example #1
0
        /// <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);
        }
Example #2
0
        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) });
            }
        }