Пример #1
0
        /// <summary>
        /// Obtiene la lista de mensajes pendientes a ser enviados para el usuario que realiza la peticion
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario</param>
        /// <returns>Un objeto <c>GetNotiwayMessageListResponse</c> que contiene la lista de mensajes pendientes</returns>
        private GetNotiwayNewsListResponse _getNotiwayNewsList(GetNotiwayNewsListRequest request)
        {
            bool notiwayEnabled = true;

            try
            {
                notiwayEnabled = Boolean.Parse(ConfigurationManager.AppSettings["NotiwayEnabled"]);
            }
            catch (Exception) { }

            GetNotiwayNewsListResponse response = new GetNotiwayNewsListResponse();

            if (notiwayEnabled)
            {
                response = (new NotiwayProvider()).GetNotiwayNewsList(request);
            }
            else
            {
                response.ResponseCode    = 9999;
                response.ResponseMessage = "Notiway disabled";
            }

            return(response);
        }
Пример #2
0
 /// <summary>
 /// Obtiene la lista de mensajes pendientes a ser enviados para el usuario que realiza la peticion
 /// </summary>
 /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario</param>
 /// <returns>Un objeto <c>GetNotiwayMessageListResponse</c> que contiene la lista de mensajes pendientes</returns>
 GetNotiwayNewsListResponse INotiwayApiRest.GetNotiwayNewsListRest(GetNotiwayNewsListRequest request)
 {
     return(_getNotiwayNewsList(request));
 }
Пример #3
0
        /// <summary>
        /// Obtiene la lista de mensajes pendientes a ser enviados para el usuario que realiza la peticion
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario</param>
        /// <returns>Un objeto <c>GetNotiwayMessageListResponse</c> que contiene la lista de mensajes pendientes</returns>
        public GetNotiwayNewsListResponse GetNotiwayNewsList(GetNotiwayNewsListRequest request)
        {
            String _methodName = String.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            LogRequest(request);

            GetNotiwayNewsListResponse response = new GetNotiwayNewsListResponse();
            var sessionId = GetSessionId(request, response, out errorMessage);

            if (errorMessage != ErrorMessagesMnemonics.None)
            {
                return(response);
            }

            var countryId  = Convert.ToInt32(ConfigurationManager.AppSettings["CountryId"]);
            var platformId = Convert.ToInt32(String.IsNullOrEmpty(request.Platform) ? ConfigurationManager.AppSettings["DefaultPlatform"] : request.Platform);

            if (countryId == 14 && platformId == 1)
            {
                countryId  = 1;
                platformId = 4;
            }

            using (var db = new Movilway.API.Data.Notiway.NotiwayEntities())
            {
                ProviderLogger.InfoLow(() => TagValue.New()
                                       .MethodName(_methodName)
                                       .Message("[" + sessionId + "] " + "Obteniendo lista de mensajes ...")
                                       );

                var list = db.Database.SqlQuery <NotiwayQuerySelectItem>(
                    QUERY_SELECT,
                    new SqlParameter("@CountryP", countryId),
                    new SqlParameter("@PlatformP", platformId),
                    new SqlParameter("@LoginP", request.AuthenticationData.Username),
                    new SqlParameter("@DeviceTypeP", request.DeviceType),
                    new SqlParameter("@OnlyUnreadP", request.OnlyUnread ? "1" : "0")
                    );

                foreach (var item in list)
                {
                    NotiwayNews aux = new NotiwayNews()
                    {
                        NewsId = item.MessageId
                        ,
                        ScheduleId = item.MessageScheduleId
                        ,
                        ExpirationDate = item.ExpirationDate.ToString("yyyy-MM-dd")
                        ,
                        Title = item.Title
                        ,
                        Abstract = item.Abstract
                        ,
                        Type = item.MessageTypeId
                        ,
                        FirstDeliveryDate = item.FirstDeliveryDate.ToString("yyyy-MM-dd")
                        ,
                        LastReadDate = ((item.LastReadDate != null && item.LastReadDate.HasValue) ? (item.LastReadDate.Value.ToString("yyyy-MM-dd")) : "")
                    };

                    if (request.DeviceType == PosWebDeviceTypeId)
                    {
                        // POS WEB
                        aux.Detail   = String.IsNullOrEmpty(item.Detail) ? "" : item.Detail;
                        aux.ImageURL = String.IsNullOrEmpty(item.ImageURL) ? "" : item.ImageURL;
                    }
                    response.NewsList.Add(aux);
                }

                ProviderLogger.InfoLow(() => TagValue.New()
                                       .MethodName(_methodName)
                                       .Message("[" + sessionId + "] " + "Total mensajes a ser enviados: " + response.NewsList.Count)
                                       );

                try
                {
                    ThreadPool.QueueUserWorkItem(unused => writeAudit(sessionId, countryId, platformId, request.AuthenticationData.Username, request.DeviceType, request.MarkAsReaded, response.NewsList));
                }
                catch (Exception e)
                {
                    ProviderLogger.ExceptionLow(() => TagValue.New()
                                                .MethodName(_methodName)
                                                .Message("Error iniciando hilo de escritura mensajes de auditoria")
                                                .Exception(e)
                                                );
                }
            }

            response.ResponseCode    = 0;
            response.ResponseMessage = "Exito";
            response.Quantity        = response.NewsList.Count;

            LogResponse(response);
            return(response);
        }