示例#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);
            }
        }