Пример #1
0
        private bool GetUserTopicNameFromRequest(HttpRequest request, out GetTopicRequestDTO topicDTO)
        {
            string errorMessage = null;

            topicDTO = null;
            string        typeFullName = null;
            APIRequestDTO requestDTO;

            try
            {
                typeFullName = typeof(GetTopicRequestDTO).FullName;
                if (!Library.GetDTOFromRequest(request, out requestDTO, typeFullName, ref errorMessage))
                {
                    Global.Log.Error(errorMessage);
                    return(false);
                }
                topicDTO = (GetTopicRequestDTO)requestDTO;
                Global.Log.DebugFormat("User ID: [{0}] Topic: [{1}]", topicDTO.UserID, topicDTO.TopicName);
                return(true);
            }
            catch (Exception ex)
            {
                Global.Log.Error(ex.Message);
                return(false);
            }
        }
Пример #2
0
        internal bool GetSubscribedTasksByTopicName(out APIResponseDTO response)
        {
            response = new APIResponseDTO();
            List <CSTaskDTO>   subscribedTasks;
            GetTopicRequestDTO topicRequestDTO = null;
            string             errorMessage    = null;

            try
            {
                if (!GetUserTopicNameFromRequest(this.request, out topicRequestDTO))
                {
                    response.SetErrorResponse("Invalid Request!", APIResponseDTO.RESULT_TYPE.ERROR);
                    return(false);
                }
                subscribedTasks = this.serverMgr.RemoteTaskDistributor
                                  .GetSubscribedTasksByTopicName(topicRequestDTO.UserID
                                                                 , topicRequestDTO.TopicName
                                                                 , ref errorMessage);
                if (subscribedTasks == null)
                {
                    Global.Log.ErrorFormat(errorMessage);
                    response.SetErrorResponse(errorMessage, APIResponseDTO.RESULT_TYPE.ERROR);
                    return(false);
                }
                response.SetResponse(subscribedTasks, APIResponseDTO.RESULT_TYPE.SUCCESS);
                return(true);
            }
            catch (Exception ex)
            {
                Global.Log.Error(ex.Message);
                return(false);
            }
        }