示例#1
0
        /// <summary>
        /// 1 - actualiza la BD BotCreatedDateObtained
        /// 2 - Envia al moderardor
        /// 3 - update_delivery
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task Bot_update_sendStatus(EnqueueCommentBotReq req)
        {
            string msgError = "";

            try
            {
                int count = EpironDAC.MessageBot_u_BotCreatedDateObtained(req);
                if (count == 0)
                {
                    msgError = " No se encontro CaseCommentGUID  " + req.CaseCommentGUID;
                    throw new Exception(msgError);
                }

                var res = await sendMessaged_async(req);

                if (res.StatusCode == HttpStatusCode.OK)
                {
                    //TODO: desserializar y leer el resultado
                    //Podria venir internamente un error
                    var content = res.Content.ReadAsStringAsync().Result;
                    EpironDAC.Bot_update_delivery(req.CaseCommentGUID, req.CaseId);
                }
                else
                {
                    if (res.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        msgError = "No tiene autorización para acceder a " + apiAppSettings.serverSettings.apiConfig.api_bootApiHoock;
                    }
                    else
                    {
                        msgError = res.ReasonPhrase;
                    }
                    //var msg = await res.RequestMessage.Content.ReadAsStringAsync();

                    //EpironDAC.MessageBot_u_BotCreatedDateObtained(req);
                    //EpironDAC.Bot_update_sendStatus(req.CaseCommentGUID, "Error", msg);
                }
            }
            catch (Exception ex)
            {
                msgError = ex.Message;

                //   EpironDAC.Bot_update_sendStatus(req.CaseCommentGUID, "Error", ex.Message);
            }

            if (!string.IsNullOrEmpty(msgError))
            {
                throw new Exception(msgError);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="domain"></param>
        /// <returns></returns>
        public String Authenticate(string username, string password, string domain)
        {
            FunctionalException fe = null;

            try
            {
                var emmpleadoBE = EpironDAC.VirifyUser(username);

                //Emp_Id, legajo correspondiente al usuario reseteador, si devuelve NULL mostrar el mensaje “Usuario no registrado en Epiron” y cerrar aplicación.
                //o Cue_Id, cuenta correspondiente al usuario reseteador, si devuelve NULL y el campo CAIS es 0, mostrar el mensaje “Usuario no habilitado”

                if (emmpleadoBE == null)
                {
                    fe         = new FunctionalException("Usuario no registrado en Epiron ");
                    fe.ErrorId = HttpStatusCode.Unauthorized.ToString();
                    throw fe;
                    //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no registrado en Epiron "));
                }

                if (string.IsNullOrEmpty(emmpleadoBE.Cuenta) && emmpleadoBE.CAIS == false)
                {
                    fe         = new FunctionalException("Usuario no habilitado ");
                    fe.ErrorId = HttpStatusCode.Unauthorized.ToString();
                    throw fe;
                    //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no habilitado"));
                }
                emmpleadoBE.Dominio = domain;


                var jwtTokenString = TokenGenerator.GenerateTokenEpiron(emmpleadoBE);
                return(jwtTokenString);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="req"></param>
        public void Proc(BotCommentModeratedReq req)
        {
            var actionId = (int)Enum.Parse(typeof(Common.HookResponsesEnum), req.Action);

            //Actualizo
            EpironDAC.Bot_update_response(req.CaseCommentGUID, req.CaseId, actionId, req.Text);



            if (actionId == (int)Common.HookResponsesEnum.Responder)
            {
                AccountOutputChannelTypeBE selectedAccountOutputChannelType = null;

                #region Obtener tipo de elemento de salida:

                List <AccountOutputChannelTypeBE> etOutputList = EpironDAC.ElementTypeOutput(req.CaseCommentGUID, req.CaseId);

                if (etOutputList.Count == 0)
                {
                    throw new Exception("No hay datos al obtener tipo de elemento de salida para el caso ");
                }

                // sp devuelve solo un registro se debe tomar el valor del campo ElementTypeOutputId
                if (etOutputList.Count == 1)
                {
                    selectedAccountOutputChannelType = etOutputList[0];
                }
                //Si el sp devuelve más de un registro Se debe tomar el valor del campo ElementTypeOutputId donde InputPublic = OutputPublic
                if (etOutputList.Count > 1)
                {
                    selectedAccountOutputChannelType = etOutputList.Where(p => p.OutputPublic == p.InputPublic).FirstOrDefault();
                }


                #endregion


                #region Obtención de datos para publicar
                var caseComment = EpironDAC.CaseComment(req.CaseCommentGUID);
                int?accountId   = caseComment.AccountId;
                #endregion


                #region Obtención de usuario bot
                //Identificador del registro correspondiente al usuario Bot – API Epiron (valor = 216)
                var settings = EpironDAC.ApplicationSettings(216, accountId);
                #endregion

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
                                                                     new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    #region Insertar en la Comentario saliente y publicación:

                    //Identificador del registro correspondiente al usuario Bot – API Epiron (valor = 216)
                    CaseCommentCreationBE caseComment_to_create = new CaseCommentCreationBE();

                    //identificador del caso al cual se le está dando una respuesta.
                    caseComment_to_create.CaseId = req.CaseId;

                    //Se pasa el valor del parámetro @CaseCommentTextToPublication.

                    if (selectedAccountOutputChannelType.PChannelType == (int)PChannelTypeEnum.Mail)
                    {
                        StringBuilder str = new StringBuilder();
                        str.AppendLine(req.Text);
                        str.AppendLine(caseComment.AccountEmailBodyTemplate);
                        str.AppendLine("--------------------------------------------------------------------");

                        str.AppendLine(caseComment.CaseCommentText);
                        caseComment_to_create.CaseCommentText = str.ToString();
                    }

                    if (selectedAccountOutputChannelType.PChannelType == (int)PChannelTypeEnum.Twitter)
                    {
                        caseComment_to_create.CaseCommentText = "@" + caseComment.UCUserName + " " + req.Text;
                    }

                    else
                    {
                        caseComment_to_create.CaseCommentText = req.Text;
                    }
                    //Identificador del usuario al cual se envía el mensaje. Valor del campo UserChannelId
                    caseComment_to_create.AccountDetailId = caseComment.AccountDetailIdOutput;
                    caseComment_to_create.UserChannelId   = caseComment.UserChannelId;
                    //@ElementTypeId: Tipo de elemento de salida. Valor del campo ElementTypeOutputId obtenido
                    caseComment_to_create.ElementTypeId = selectedAccountOutputChannelType.ElementTypeOutputId;
                    //identificador utilizado para publicar en respuesta a un comentario el
                    //cual contendrá valor si el canal es público (OutputPublic = 1).
                    if (selectedAccountOutputChannelType.OutputPublic)
                    {
                        caseComment_to_create.CaseCommentPublicationTo = caseComment.CaseCommentPublicationTo;
                    } //Si (OutputPublic = 0) se coloca NULL. nada en este caso . se lo deja ''

                    //identificador del usuario que envía el mensaje.Valor del campo Value obtenido de[Api].[ApplicationSettings_s_BySettingId]
                    if (!String.IsNullOrEmpty(settings.Value))
                    {
                        caseComment_to_create.CaseCommentModifiedByUserId = Convert.ToInt32(settings.Value);
                    }

                    //Identificador del estado de validación. Se pasa NULL.
                    caseComment_to_create.StateValidationId = null;


                    caseComment_to_create.AttentionQueueId = caseComment.AttentionQueueId;

                    //Identificador del comentario al cual se envía una respuesta. Se pasa NULL.
                    caseComment_to_create.ReplyToCaseCommentId = null;


                    EpironDAC.Insert_CaseComment(caseComment_to_create);

                    if (selectedAccountOutputChannelType.PChannelType == (int)PChannelTypeEnum.Mail)
                    {
                        DetailCaseCommentBE detailCaseComment = new DetailCaseCommentBE();

                        detailCaseComment.CaseCommentId    = caseComment_to_create.CaseCommentId;
                        detailCaseComment.CaseCommentGUID  = caseComment_to_create.CaseCommentGUID;
                        detailCaseComment.DCCSubject       = caseComment.Subject;
                        detailCaseComment.DCCTextEmailBody = caseComment.CaseCommentText;
                        //Url que indica la ubicación en la redsocial del posteo raíz (root) del cual proviene el comentario. (para los cometarios salientes este campo se guarda como NULL)
                        detailCaseComment.DCCPermlinkRoot = null;
                        //descripción relacionada a un comentario. (para los cometarios salientes este campo se guarda como NULL)
                        detailCaseComment.DCCDescription = null;
                        EpironDAC.Insert_DetailCaseComment(detailCaseComment);
                    }
                    #endregion

                    #region Insert Publicacion
                    var publicacion = new PublicationBE();
                    publicacion.CaseCommentGUID = caseComment_to_create.CaseCommentGUID;

                    publicacion.PComment = caseComment_to_create.CaseCommentText;

                    if (selectedAccountOutputChannelType.OutputPublic)
                    {
                        publicacion.PublicationTo = caseComment.CaseCommentPublicationTo;
                    }
                    else
                    {
                        //si es privado(OutputPublic = 0), se pasa el valor del campo UCPublicationTo.
                        publicacion.PublicationTo = caseComment.UCPublicationTo;
                    }

                    //GUID de la cuenta de salida.
                    publicacion.AccountDetailUnique = caseComment.AccountDetailUniqueOutput;
                    publicacion.PChannelType        = selectedAccountOutputChannelType.PChannelType;
                    //TODO : identificador del usuario que envía el mensaje. @PModifiedByUserId: identificador del usuario que envía el mensaje. Valor del campo Value obtenido de [Api].[ApplicationSettings_s_BySettingId]
                    if (!String.IsNullOrEmpty(settings.Value))
                    {
                        publicacion.PModifiedByUserId = Convert.ToInt32(settings.Value);
                    }


                    EpironDAC.Insert_Publication(publicacion);


                    if (selectedAccountOutputChannelType.PChannelType == (int)PChannelTypeEnum.Mail)
                    {
                        PublicationDetailBE publicationDetail = new PublicationDetailBE();

                        publicationDetail.PublicationId = publicacion.PublicationId;
                        publicationDetail.PDCommentAux1 = caseComment.Subject;

                        EpironDAC.Insert_PublicationDetail(publicationDetail);
                    }
                    #endregion

                    scope.Complete();
                }
            }

            if (actionId == (int)Common.HookResponsesEnum.Liberar)
            {
                EpironDAC.Realease_CaseComment(req.CaseId);
            }
            if (actionId == (int)Common.HookResponsesEnum.Cerrar)
            {
                EpironDAC.Close_CaseComment(req.CaseId);
            }
        }