Exemple #1
0
        public Response <FtpConfig> AddFtpConfig(FtpConfig ftpConfig, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <FtpConfig> requestValue = new TokenRequest <FtpConfig>()
                {
                    RequestData = ftpConfig,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/ftpconfig/AddFtpConfig";
                HttpResponseMessage responseMessage = HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <FtpConfig> >(requestUri, requestValue).Result;

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(responseMessage.Content.ReadAsAsync <Response <FtpConfig> >().Result);
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "FtpConfigManager", "AddFtpConfig", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #2
0
        public Response <NoteApprovedRecord> ApproveNote(ApproveNoteRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <ApproveNoteRequest> requestValue = new TokenRequest <ApproveNoteRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/noteapprovedrecord/ApproveNote";
                HttpResponseMessage responseMessage = HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <ApproveNoteRequest> >(requestUri, requestValue).Result;

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(responseMessage.Content.ReadAsAsync <Response <NoteApprovedRecord> >().Result);
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "NoteApprovedRecordManager", "ApproveNote", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #3
0
        public Response <SysInfo> GetSysInfoByName(GetSysInfoByNameRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <GetSysInfoByNameRequest> requestValue = new TokenRequest <GetSysInfoByNameRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/sysinfo/GetSysInfoByName";
                HttpResponseMessage responseMessage = HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <GetSysInfoByNameRequest> >(requestUri, requestValue).Result;

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(responseMessage.Content.ReadAsAsync <Response <SysInfo> >().Result);
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "SysInfoManager", "GetSysInfoByName", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #4
0
        public async Task <Response <SysInfo> > AddSysInfoAsync(SysInfo sysInfo, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <SysInfo> requestValue = new TokenRequest <SysInfo>()
                {
                    RequestData = sysInfo,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/sysinfo/AddSysInfo";
                HttpResponseMessage responseMessage = await HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <SysInfo> >(requestUri, requestValue);

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(await responseMessage.Content.ReadAsAsync <Response <SysInfo> >());
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "SysInfoManager", "AddSysInfoAsync", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #5
0
        public Response <User> GetUserByToken(GetUserByTokenRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                string requestUri = this.baseAddr + @"api/noteuser/GetUserByToken";

                HttpResponseMessage httpResponse = HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <GetUserByTokenRequest> >(requestUri, new TokenRequest <GetUserByTokenRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                }).Result;

                if (httpResponse.IsSuccessStatusCode)
                {
                    return(httpResponse.Content.ReadAsAsync <Response <User> >().Result);
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "UserManager", "GetUserByToken", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #6
0
        public async Task <Response <List <NoteCommentContent> > > GetNoteCommentContentsByCommentIdAsync(GetNoteCommentContentsByCommentIdRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <GetNoteCommentContentsByCommentIdRequest> requestValue = new TokenRequest <GetNoteCommentContentsByCommentIdRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/notecommentcontent/GetNoteCommentContentsByCommentId";
                HttpResponseMessage responseMessage = await HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <GetNoteCommentContentsByCommentIdRequest> >(requestUri, requestValue);

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(await responseMessage.Content.ReadAsAsync <Response <List <NoteCommentContent> > >());
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "NoteCommentContentManager", "GetNoteCommentContentsByCommentIdAsync", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #7
0
        public async Task <Response <SearchNotesResponse> > SearchNotesByTimeSpanAsync(SearchNotesByTimeSpanRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <SearchNotesByTimeSpanRequest> requestValue = new TokenRequest <SearchNotesByTimeSpanRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/note/SearchNotesByTimeSpan";
                HttpResponseMessage responseMessage = await HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <SearchNotesByTimeSpanRequest> >(requestUri, requestValue);

                if (responseMessage.IsSuccessStatusCode)
                {
                    return(await responseMessage.Content.ReadAsAsync <Response <SearchNotesResponse> >());
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "NoteManager", "SearchNotesByTimeSpan", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }
Exemple #8
0
        public async Task <Response <User> > GetUserByIdAsync(GetUserByIdRequest request, TokenCheckInfo tokenCheckInfo)
        {
            try
            {
                TokenRequest <GetUserByIdRequest> requestValue = new TokenRequest <GetUserByIdRequest>()
                {
                    RequestData = request,
                    Token       = tokenCheckInfo.Token,
                    UserId      = tokenCheckInfo.UserId,
                    Version     = tokenCheckInfo.Version
                };

                string requestUri = this.baseAddr + @"api/noteuser/GetUserById";
                //string json = JsonHelper.Serialized(requestValue);
                HttpResponseMessage httpResponse = await HttpClientHelper.Client.PostAsJsonAsync <TokenRequest <GetUserByIdRequest> >(requestUri, requestValue);

                if (httpResponse.IsSuccessStatusCode)
                {
                    return(await httpResponse.Content.ReadAsAsync <Response <User> >());
                }
                else
                {
                    LogHelper.WriteLog(LogType.Error, "UserManager", "GetUserByIdAsync", "HTTP响应失败:" + requestUri);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                return(null);
            }
        }