コード例 #1
0
        /// <summary>
        /// 获取评论用户信息
        /// </summary>
        /// <param name="userIdList">评论用户id列表</param>
        /// <returns></returns>
        public static List <User> getUserInfoList(List <string> userIdList)
        {
            string           userInfoStr = HttpWorker.HttpGet(Global.WorkerInfoUrl, "usrid=" + string.Join(",", userIdList));
            UserInfoResponse userInfo    = TranslationWorker.ConvertStringToEntity <UserInfoResponse>(userInfoStr);

            return(userInfo.ConvertToUsers());
        }
コード例 #2
0
 /// <summary>
 /// 一次性获取多个章节内容
 /// </summary>
 /// <param name="nodeIdList"></param>
 public static bool getNodeDetail(List <string> nodeIdList, bool downloadImage = false)
 {
     try
     {
         string             nodeDetails       = HttpWorker.HttpGet(Global.NodeDetailApi, "nodeIds=" + string.Join(",", nodeIdList));
         NodeDetailResponse nodeDtailResponse = TranslationWorker.ConvertStringToEntity <NodeDetailResponse>(nodeDetails);
         List <Node>        nodes             = nodeDtailResponse.ConvertToNodes();
         if (downloadImage)
         {
             foreach (Node node in nodes)//下载图片到本地,并生成离线内容
             {
                 List <string> urls = HtmlCleaner.GetImageUrl(node.content);
                 foreach (string url in urls)
                 {
                     HttpWorker.SaveImg(url, node.lawId);
                 }
                 node.offlineContent = HtmlCleaner.ChangeImageUrlToLocalPath(node.content, node.lawId);
             }
         }
         db.refreshNode(nodes, detailOnly: true);
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("操作超时");
         return(false);
     }
 }
コード例 #3
0
        /// <summary>
        /// 获取登陆用户信息
        /// </summary>
        public static void getUserInfo()
        {
            string           userInfoStr = HttpWorker.HttpGet(Global.WorkerInfoUrl, "usrid=" + Global.user.Id);
            UserInfoResponse userInfo    = TranslationWorker.ConvertStringToEntity <UserInfoResponse>(userInfoStr);

            userInfo.setUserInfo();
        }
コード例 #4
0
        /// <summary>
        /// 获取设置列表
        /// </summary>
        public static void getSetResponse()
        {
            string sets = HttpWorker.HttpGet(Global.SetListApi, "");

            if (sets == "error")
            {
                return;
            }
            SetListResponse setListResponse = TranslationWorker.ConvertStringToEntity <SetListResponse>(sets);

            db.refreshCode(setListResponse.ConvertToCodes());
        }
コード例 #5
0
        /// <summary>
        /// 获取修订列表内容
        /// </summary>
        /// <param name="bookId"></param>
        /// <returns></returns>
        public static string getHistory(string bookId)
        {
            string result        = string.Empty;
            string historyResult = HttpWorker.HttpGet(Global.HistoryApi, "bookId=" + bookId);

            if (historyResult == "error")
            {
                return(result);
            }
            HistoryResponse history = TranslationWorker.ConvertStringToEntity <HistoryResponse>(historyResult);

            result = string.Join(Environment.NewLine, history.data.list.Select(l => l.version));
            return(result);
        }
コード例 #6
0
        /// <summary>
        /// 获取全部法规列表
        /// </summary>
        public static int getLawResponse()
        {
            string laws = HttpWorker.HttpGet(Global.AllBooksApi, "beginTime=" + UTC.ConvertDateTimeInt(new DateTime(2010, 01, 01)).ToString() + "&pageSize=-1");

            if (laws == "error")
            {
                return(-1);
            }
            AllBooksResponse allBookResponse = TranslationWorker.ConvertStringToEntity <AllBooksResponse>(laws);
            int autoUpdateCount = 0;

            db.refreshLaw(allBookResponse.ConvertToLaws(), out autoUpdateCount);
            return(autoUpdateCount);
        }
コード例 #7
0
        /// <summary>
        /// 获取某一法规的整体目录
        /// </summary>
        /// <param name="bookId"></param>
        //public static Tuple<List<Node>, List<Node>> getBookContent(string bookId)
        //{
        //    string bookContents = HttpWorker.HttpGet(Global.BookContentApi, "bookId=" + bookId);
        //    BookContentResponse bookContentResponse = TranslationWorker.ConvertStringToEntity<BookContentResponse>(bookContents);
        //    List<Node> nodes = bookContentResponse.ConvertToNodes();
        //    db.refreshNode(nodes);
        //    List<Node> details = getNodeDetail(nodes.Select(n => n.Id).ToList());
        //    return new Tuple<List<Node>, List<Node>>(nodes, details);
        //}

        /// <summary>
        /// 获取某一法规的整体目录
        /// </summary>
        /// <param name="bookId"></param>
        public static List <Node> getBookContent(string bookId)
        {
            try
            {
                string bookContents = HttpWorker.HttpGet(Global.BookContentApi, "bookId=" + bookId);
                BookContentResponse bookContentResponse = TranslationWorker.ConvertStringToEntity <BookContentResponse>(bookContents);
                List <Node>         nodes = bookContentResponse.ConvertToNodes();
                db.refreshNode(nodes);
                return(nodes);
            }
            catch (Exception)
            {
                MessageBox.Show("操作超时");
                return(new List <Node>());
            }
        }
コード例 #8
0
        /// <summary>
        /// 获取意见列表
        /// </summary>
        /// <param name="bookId"></param>
        public static void getOpinionList(string bookId)
        {
            string opinions = HttpWorker.HttpGet(Global.OpinionListApi, "bookId=" + bookId);

            if (opinions == "error")
            {
                return;
            }
            OpinionResponse opinionResponse = TranslationWorker.ConvertStringToEntity <OpinionResponse>(opinions);

            db.refreshComment(opinionResponse.ConverToComments());
            //获取评论后获取评论人的信息
            List <User> userList = getUserInfoList(opinionResponse.data.list.Select(d => d.readerId).ToList());

            foreach (User user in userList)
            {
                db.saveUser(user);
            }
        }
コード例 #9
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        public static bool getloginResponse(string username, string password)
        {
            string responseStr = HttpWorker.HttpGet(Global.LoginUrl, "yhm=" + username + "&mm=" + password);

            if (responseStr == "error")
            {
                return(false);
            }
            LoginResponse response = TranslationWorker.ConvertStringToEntity <LoginResponse>(responseStr);

            response.SetUserId();
            if (response.code == "1")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
        /// <summary>
        /// 获取预下载法规id
        /// </summary>
        /// <returns></returns>
        public static List <string> getPreloadLaw()
        {
            string result = HttpWorker.HttpGet(Global.WorkerRulesUrl, "usrid=" + Global.user.Id);

            if (result == "error")
            {
                return(new List <string>());
            }
            WorkerRulesResponse response  = TranslationWorker.ConvertStringToEntity <WorkerRulesResponse>(result);
            List <string>       lawIdList = new List <string>();

            if (response != null)
            {
                if (response.status == "200")
                {
                    lawIdList = response.data.Select(l => l.jcyjid).ToList();
                }
            }
            return(lawIdList);
        }
コード例 #11
0
        /// <summary>
        /// 获取搜索结果
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public static List <string> getSearch(string keyword)
        {
            string result = string.Empty;

            result = HttpWorker.HttpGet(Global.SearchApi, "key1=" + keyword);
            if (result == "error")
            {
                return(new List <string>());
            }
            SearchResponse response  = TranslationWorker.ConvertStringToEntity <SearchResponse>(result);
            List <string>  lawIdList = new List <string>();

            if (response != null)
            {
                if (response.status == "200")
                {
                    lawIdList = response.data.list.Select(l => l.bookId).ToList();
                }
            }
            return(lawIdList);
        }
コード例 #12
0
        /// <summary>
        /// 获取一个章节的内容
        /// </summary>
        /// <param name="nodeId"></param>
        public static void getNodeDetail(string nodeId)
        {
            string nodeDetails = HttpWorker.HttpGet(Global.NodeDetailApi, "nodeIds=" + nodeId);

            if (nodeDetails == "error")
            {
                return;
            }
            NodeDetailResponse nodeDtailResponse = TranslationWorker.ConvertStringToEntity <NodeDetailResponse>(nodeDetails);
            List <Node>        nodes             = nodeDtailResponse.ConvertToNodes();

            foreach (Node node in nodes)//下载图片到本地,并生成离线内容
            {
                List <string> urls = HtmlCleaner.GetImageUrl(node.content);
                foreach (string url in urls)
                {
                    HttpWorker.SaveImg(url, node.lawId);
                }
                node.offlineContent = HtmlCleaner.ChangeImageUrlToLocalPath(node.content, node.lawId);
            }
            db.refreshNode(nodes, detailOnly: true);
        }
コード例 #13
0
        public static bool getTokenResponse(string username, string password)
        {
            string responseStr = HttpWorker.HttpGet(Global.TokenUrl, "appId=client&username="******"&password="******"获取Token失败,错误信息:" + response.errmsg);
                    return(false);
                }
                Global.token           = response;
                Global.token.tokenTime = DateTime.Now;
                return(true);
            }
            catch (Exception)
            {
                TokenResponse response = null;
                Global.token = response;
                return(false);
            }
        }