Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            ConsultRequest consultRequest = new ConsultRequest();

            consultRequest.ConvertFromSuggests(list);
            string         reslut   = RemoteWorker.postCommit(consultRequest);
            CommonResponse response = TranslationWorker.ConvertStringToEntity <CommonResponse>(reslut);

            if (response != null)
            {
                if (response.status != null)
                {
                    if (response.status.ToString() == "200")
                    {
                        if (MessageBox.Show("提交征询意见成功") == DialogResult.OK)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("提交征询意见失败。原因:" + response.errmsg);
                    }
                }
                else
                {
                    MessageBox.Show("提交征询意见失败。原因:" + response.errmsg);
                }
            }
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            Comment newComment = new Comment();

            newComment.lawId           = lawId;
            newComment.nodeId          = nodeId;
            newComment.comment_content = rtb_content.Text.Trim();
            newComment.comment_date    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            newComment.userId          = Global.user.Id;

            OpinionCommitRequest opinionRequest = new OpinionCommitRequest();

            opinionRequest.ConvertFromComment(newComment);
            //RemoteWorker
            CommonResponse response = TranslationWorker.ConvertStringToEntity <CommonResponse>(RemoteWorker.postOpinion(opinionRequest));

            if (response != null)
            {
                if (response.status.ToString() == "200")
                {
                    //如果提交成功,在法规正文界面刷新评论
                    RemoteWorker.getOpinionList(lawView.law.lawId);
                    if (Global.online)// && string.IsNullOrEmpty(law.isLocal))
                    {
                        ((LawView)lawView).loadComment(reload: true);
                    }
                    if (MessageBox.Show("提交评论成功") == DialogResult.OK)
                    {
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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>());
            }
        }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
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);
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
 protected override Task Given()
 {
     return(TranslationWorker.StartAsync(_translationRequest));
 }