コード例 #1
0
        private JTClass GetJtXXInfo(string jtKey)
        {
            JTClass jtInfo = new JTClass();

            WebHelper     web     = new WebHelper();
            StringBuilder postStr = new StringBuilder();

            postStr.Append("djtdabh=").Append(jtKey);

            //http://222.133.17.194:9080/sdcsm/home/homeshow.action?djtdabh=3714810102100441
            //查询请求执行
            string       returnString = web.PostHttp(baseUrl + "/home/homeshow.action", postStr.ToString(), "application/x-www-form-urlencoded", SysCookieContainer);
            HtmlDocument doc          = HtmlHelper.GetHtmlDocument(returnString);

            if (doc == null)
            {
                return(jtInfo);
            }

            var nodetrs = doc.DocumentNode.SelectNodes("//div[@id='jtcyxg']//table[@id='table1']//tr[position()>3]");

            List <PersonModel> lstpm = new List <PersonModel>();

            if (nodetrs != null)
            {
                var nodeJT = doc.DocumentNode.SelectSingleNode("//input[@name='jtcygs']");
                jtInfo.JTCount = nodeJT == null || !nodeJT.Attributes.Contains("value") ? 1 : Convert.ToInt32(nodeJT.Attributes["value"].Value);

                foreach (var jtP in nodetrs)
                {
                    var node  = jtP.SelectSingleNode("td[1]/input[1]");
                    var nodeR = jtP.SelectSingleNode("td[2]/select/option[@selected]");

                    PersonModel pm = new PersonModel();

                    pm.pid           = node == null || !node.Attributes.Contains("value") ? "" : node.Attributes["value"].Value;
                    pm.houseRelation = nodeR == null || !nodeR.Attributes.Contains("value") ? "" : nodeR.Attributes["value"].Value;

                    if (!string.IsNullOrEmpty(pm.pid))
                    {
                        lstpm.Add(pm);
                    }
                }

                jtInfo.JTKey     = jtKey;
                jtInfo.JTPeoples = lstpm;
            }

            return(jtInfo);
        }
コード例 #2
0
        private void TrySaveFamily(string idNumber, DataSet ds, int tryCount, Action <string> callback)
        {
            try
            {
                //家庭档案号
                string jtKey = GetJTKeyByID(idNumber);

                if (!string.IsNullOrEmpty(jtKey))
                {
                    // 修改家庭信息
                    EditJT(jtKey, ds);

                    DataTable dt = ds.Tables["memBer"];

                    foreach (DataRow row in dt.Rows)
                    {
                        string idcardno         = row["IDCardNo"].ToString();
                        string strHouseRelation = row["HouseRelation"].ToString();

                        // 户主时跳过
                        if (idcardno.ToUpper() == idNumber.ToUpper())
                        {
                            continue;
                        }

                        CommonBusiness.CommonBusiness cb = new CommonBusiness.CommonBusiness();

                        PersonModel person = cb.GetGrdaByIDCardNo(idcardno, loginKey, SysCookieContainer);

                        if (person == null)
                        {
                            continue;
                        }

                        string merberID = "";

                        // 没有家庭的,则直接增加
                        if (person.fid == "")
                        {
                            merberID = GetMemID(jtKey, person.pid);

                            if (!string.IsNullOrEmpty(merberID))
                            {
                                AddJTMem(merberID, strHouseRelation, jtKey);
                            }

                            continue;
                        }

                        // 若是已经存在,则不操作。(关系未修改)
                        if (person.fid.ToUpper() == jtKey.ToUpper())
                        {
                            continue;
                        }

                        JTClass jtclass = GetJtXXInfo(person.fid);

                        if (string.IsNullOrEmpty(jtclass.JTKey))
                        {
                            continue;
                        }

                        // 户主变更,删除当前家庭中人员
                        foreach (var p in jtclass.JTPeoples)
                        {
                            if (p.houseRelation == "1")
                            {
                                continue;
                            }

                            DelJTMem(p.pid, p.houseRelation, jtclass.JTKey, jtclass.JTCount);

                            jtclass.JTCount--;
                        }

                        // 删除户主
                        var tmpM = jtclass.JTPeoples.Where(m => m.houseRelation == "1").FirstOrDefault();

                        if (tmpM != null)
                        {
                            DelJTMem(tmpM.pid, tmpM.houseRelation, jtclass.JTKey, 1);
                        }

                        merberID = GetMemID(jtKey, person.pid);

                        if (!string.IsNullOrEmpty(merberID))
                        {
                            AddJTMem(merberID, strHouseRelation, jtKey);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("登录超时") > -1)
                {
                    callback("EX-“登录超时”、“该用户在别处登录”或者“当前用户信息被上级用户修改”导致用户无法操作,请您重新登录!");

                    throw;
                }

                CommonExtensions.WriteLog(ex.Message);
                CommonExtensions.WriteLog(ex.StackTrace);

                if (tryCount < MaxtryCount)
                {
                    callback("EX-家庭信息:身份证[" + idNumber + "]:上传家庭信息失败。重新尝试获取第" + tryCount + "次...");

                    System.Threading.Thread.Sleep(SleepMilliseconds);
                    tryCount++;
                    TrySaveFamily(idNumber, ds, tryCount, callback);
                }
                else
                {
                    callback("EX-家庭信息:身份证[" + idNumber + "]:上传家庭信息失败。请确保网路畅通。");
                }
            }
        }