Example #1
0
 private string InsertCarTrafficViolation(ViolationModel model)
 {
     SqlHelper helper = new SqlHelper();
     int isSucc = helper.ExecuteNonQuery("P_TrafficViolation_I", model.CarNumber, model.ViolationAddress, model.ViolationDateTime, model.ViolationAmount, model.ViolationScore, model.ViolationContent, model.ViolationStatus);
     return isSucc.ToString();
 }
Example #2
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位不匹配" });
            }
        }