Exemplo n.º 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     lblResultU.Text = "";
     lblResultC.Text = "";
     SCParams scParams = new SCParams() { CarNumber = txtCarNumber.Text.Trim(), CarFrame = txtCarFrame.Text.Trim() };
     SCDA da = new SCDA();
     List<ViolationModel> listU = da.GetUnProcessedWebShow(scParams);
     List<ViolationModel> listC = da.GetCompletedWebShow(scParams);
     string stringU = "<font color=\"red\">未处理:</font><br />";
     string stringC = "<br /><font color=\"red\">已处理:</font><br />";
     int i = 1;
     int j = 1;
     foreach (ViolationModel u in listU)
     {
         stringU += i.ToString() + "<br />" + string.Format(strFormat, u.ViolationAddress, u.ViolationDateTime, u.ViolationContent, u.ViolationAmount, u.ViolationScore) + "<br /><br />";
         i++;
     }
     foreach (ViolationModel c in listC)
     {
         stringC += j.ToString() + "<br />" + string.Format(strFormat, c.ViolationAddress, c.ViolationDateTime, c.ViolationContent, c.ViolationAmount, c.ViolationScore) + "<br /><br />";
         j++;
     }
     if (stringU == "<font color=\"red\">未处理:</font><br />")
         lblResultU.Text = stringU + "恭喜,木有违章<br />";
     else
         lblResultU.Text = stringU;
     if (stringC == "<br /><font color=\"red\">已处理:</font><br />")
         lblResultC.Text = stringC + "恭喜,木有违章";
     else
         lblResultC.Text = stringC;
 }
Exemplo n.º 2
0
 public List<SCModel> GetUnProcessed(SCParams scParams)
 {
     List<ViolationModel> listUnprocessed = new List<ViolationModel>();
     List<SCModel> retListUnprocessed = new List<SCModel>();
     try
     {
         string serverErrorMsg = "";
         CarInfoModel isExistCarInfoModel = GetCarInfoDetail(scParams.CarNumber, scParams.CarFrame);
         if (isExistCarInfoModel == null)
         {
             isExistCarInfoModel = new CarInfoModel();
             isExistCarInfoModel.CarFrame = scParams.CarFrame;
             isExistCarInfoModel.CarNumber = scParams.CarNumber;
             InsertCarInfo(isExistCarInfoModel);
         }
         else
         {
             scParams.CarFrame = isExistCarInfoModel.CarFrame;
         }
         bool isRefresh = NeedRefresh(scParams.CarNumber, scParams.CarFrame, "U");
         if (isRefresh)
         {
             GetAllUnProcessed(scParams, ref listUnprocessed);
             if (listUnprocessed.Count > 0 && listUnprocessed[0].ViolationAddress == "车架号后6位不匹配")
             {
                 serverErrorMsg = "车架号后6位不匹配";
             }
             else
             {
                 foreach (ViolationModel currentModel in listUnprocessed)
                 {
                     InsertCarTrafficViolation(currentModel);
                 }
                 UpdateRefreshDate(scParams.CarNumber, "U");
             }
         }
         if (string.IsNullOrEmpty(serverErrorMsg))
         {
             List<ViolationModel> dbListViolationModel = GetViolation(scParams.CarNumber, scParams.CarFrame, "U");
             foreach (ViolationModel currentModel in dbListViolationModel)
             {
                 retListUnprocessed.Add(new SCModel()
                 {
                     ViolationAddress = currentModel.ViolationAddress,
                     ViolationDateTime = currentModel.ViolationDateTime,
                     ViolationAmount = currentModel.ViolationAmount.ToString(),
                     ViolationScore = currentModel.ViolationScore.ToString()
                 });
             }
         }
         else
         {
             retListUnprocessed.Add(new SCModel { ViolationAddress = "[ERROR]" + serverErrorMsg });
         }
     }
     catch (Exception ex)
     {
         retListUnprocessed.Add(new SCModel { ViolationAddress = "[ERROR]" + ex.Message });
     }
     return retListUnprocessed;
 }
Exemplo n.º 3
0
 public List<ViolationModel> GetUnProcessedWebShow(SCParams scParams)
 {
     List<ViolationModel> listUnprocessed = new List<ViolationModel>();
     if (scParams.CarFrame == "123123")
     {
         CarInfoModel isExistCarInfoModel = GetCarInfoDetailForiHeart(scParams.CarNumber);
         if (isExistCarInfoModel != null)
             scParams.CarFrame = isExistCarInfoModel.CarFrame;
     }
     try
     {
         string serverErrorMsg = "";
         CarInfoModel isExistCarInfoModel = GetCarInfoDetail(scParams.CarNumber, scParams.CarFrame);
         if (isExistCarInfoModel == null)
         {
             isExistCarInfoModel = new CarInfoModel();
             isExistCarInfoModel.CarFrame = scParams.CarFrame;
             isExistCarInfoModel.CarNumber = scParams.CarNumber;
             InsertCarInfo(isExistCarInfoModel);
         }
         else
         {
             scParams.CarFrame = isExistCarInfoModel.CarFrame;
         }
         bool isRefresh = NeedRefresh(scParams.CarNumber, scParams.CarFrame, "U");
         if (isRefresh)
         {
             GetAllUnProcessed(scParams, ref listUnprocessed);
             if (listUnprocessed.Count > 0 && listUnprocessed[0].ViolationAddress == "车架号后6位不匹配")
             {
                 serverErrorMsg = "车架号后6位不匹配";
             }
             else
             {
                 foreach (ViolationModel currentModel in listUnprocessed)
                 {
                     InsertCarTrafficViolation(currentModel);
                 }
                 UpdateRefreshDate(scParams.CarNumber, "U");
             }
         }
         if (string.IsNullOrEmpty(serverErrorMsg))
         {
             listUnprocessed = GetViolation(scParams.CarNumber, scParams.CarFrame, "U");
         }
         else
         {
             listUnprocessed.Clear();
             listUnprocessed.Add(new ViolationModel { ViolationAddress = "[ERROR]" + serverErrorMsg });
         }
     }
     catch (Exception ex)
     {
         listUnprocessed.Clear();
         listUnprocessed.Add(new ViolationModel { ViolationAddress = "[ERROR]" + ex.Message });
     }
     return listUnprocessed;
 }
Exemplo n.º 4
0
        public void GetAllCompleted(SCParams scParams, ref List<ViolationModel> listCompleted)
        {
            HTTPHelper httpHelper = new HTTPHelper();
            ViolationModel model = new ViolationModel();
            string currentCarP = HttpUtility.UrlEncode(scParams.CarNumber).ToUpper();
            string urlCompleted = string.Format(CompletedAddress, currentCarP, scParams.CarFrame);
            string pageContentCompleted = httpHelper.GetPage(urlCompleted);

            if (!pageContentCompleted.Contains("车架号后6位不匹配"))
            {
                #region if there is only one page
                int numberCompleted = int.Parse(pageContentCompleted.Substring(pageContentCompleted.IndexOf(" 的 小型汽车 共有  <font color=\"#d42e2f\">") + 34, 1));
                if (numberCompleted != 0)
                {
                    string[] completeds = pageContentCompleted.Split(new string[] { "<div class=\"result_r\"><h2>", "</h2><p>", "<font color=\"#d42e2f\">", "</font>元", "</font>分", "于 ", ",在" }, StringSplitOptions.None);
                    int j = 1;
                    if (completeds.Length > 0)
                    {
                        for (int i = 0; i < completeds.Length; i++)
                        {
                            if (!completeds[i].Contains("<")
                                && !completeds[i].Contains("/>")
                                && !completeds[i].Contains("罚款,记")
                                && !completeds[i].Contains("小型汽车")
                                )
                            {
                                switch (j)
                                {
                                    case 1:
                                        model.ViolationAddress = completeds[i];
                                        break;
                                    case 2:
                                        model.ViolationDateTime = completeds[i];
                                        break;
                                    case 3:
                                        model.ViolationContent = completeds[i];
                                        break;
                                    case 4:
                                        model.ViolationAmount = int.Parse(completeds[i]);
                                        break;
                                    case 5:
                                        model.ViolationScore = int.Parse(completeds[i]);
                                        break;
                                    default: break;
                                }
                                j++;
                                if (j > 5)
                                {
                                    model.CarNumber = scParams.CarNumber;
                                    model.ViolationStatus = "C";
                                    listCompleted.Add(model);
                                    model = new ViolationModel();
                                    j = 1;
                                }
                            }
                        }
                    }
                }
                #endregion

                #region if there are some pages
                if (pageContentCompleted.Contains("条记录")
                        && pageContentCompleted.Contains("下一页"))
                {
                    int totalPage = int.Parse(pageContentCompleted.Substring(pageContentCompleted.IndexOf("条记录 "), 8).Substring(6, 2).Trim());
                    for (int pageNumber = 2; pageNumber <= totalPage; pageNumber++)
                    {
                        urlCompleted = string.Format(CompletedAddress + "&p=" + pageNumber.ToString(), currentCarP, scParams.CarFrame);
                        pageContentCompleted = httpHelper.GetPage(urlCompleted);
                        numberCompleted = int.Parse(pageContentCompleted.Substring(pageContentCompleted.IndexOf(" 的 小型汽车 共有  <font color=\"#d42e2f\">") + 34, 1));
                        if (numberCompleted != 0)
                        {
                            string[] completeds = pageContentCompleted.Split(new string[] { "<div class=\"result_r\"><h2>", "</h2><p>", "<font color=\"#d42e2f\">", "</font>元", "</font>分", "于 ", ",在" }, StringSplitOptions.None);
                            int j = 1;
                            if (completeds.Length > 0)
                            {
                                for (int i = 0; i < completeds.Length; i++)
                                {
                                    if (!completeds[i].Contains("<")
                                        && !completeds[i].Contains("/>")
                                        && !completeds[i].Contains("罚款,记")
                                        && !completeds[i].Contains("小型汽车")
                                        )
                                    {
                                        switch (j)
                                        {
                                            case 1:
                                                model.ViolationAddress = completeds[i];
                                                break;
                                            case 2:
                                                model.ViolationDateTime = completeds[i];
                                                break;
                                            case 3:
                                                model.ViolationContent = completeds[i];
                                                break;
                                            case 4:
                                                model.ViolationAmount = int.Parse(completeds[i]);
                                                break;
                                            case 5:
                                                model.ViolationScore = int.Parse(completeds[i]);
                                                break;
                                            default: break;
                                        }
                                        j++;
                                        if (j > 5)
                                        {
                                            model.CarNumber = scParams.CarNumber;
                                            model.ViolationStatus = "C";
                                            listCompleted.Add(model);
                                            model = new ViolationModel();
                                            j = 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                listCompleted.Add(new ViolationModel() { ViolationAddress = "车架号后6位不匹配" });
            }
        }