/// <summary>
 /// 获得某一个xpath的详细信息
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Xpath getInfo(Guid id)
 {
     Xpath path = new Xpath();
     DatabaseAccess database = new DatabaseAccess();
     String sql = "select * from xpath where id='" + id + "'";
     try {
         SqlDataReader data = database.executeQuery(sql);
         if (data.Read()) {
             path.Id = data.GetGuid(0);
             path.Websitename = data.GetString(1);
             path.Weblanguage = data.GetString(2);
             path.Baseurl = data.GetString(3);
             path.Cntitle = data.GetString(4);
             path.Entitle = data.GetString(5);
             path.Unit = data.GetString(6);
             path.Types = data.GetString(7);
             path.Author = data.GetString(8);
             path.Articletype = data.GetString(9);
             path.Source = data.GetString(10);
             path.Language = data.GetString(11);
             path.Journalname = data.GetString(12);
             path.Publishtime = data.GetString(13);
             path.Levels = data.GetString(14);
             path.Recordtype = data.GetString(15);
             path.Forbid = (int)data["forbid"];
         }
     } catch (Exception e) {
         throw new Exception(e.Message);
     } finally {
         database.close();
     }
     return path;
 }
示例#2
0
            public override int GetHashCode()
            {
                var hashCode = (Name != null ? Name.GetHashCode() : 0);

                hashCode = (hashCode * 397) ^ (Code != null ? Code.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Base != null ? Base.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Xpath != null ? Xpath.GetHashCode() : 0);
                return(hashCode);
            }
示例#3
0
        public TaoMoiVuAnPopUp()
        {
            x = new Xpath();
            #region Controls initialize
            quyetĐinhKhoiToVuAnSo   = new TextBox("quyết định khởi tố vụ án số", x.D["inputQuyetDinhKhoiToVuAnSo"], "");
            ngayQuyetDinhKhoiToVuAn = new DateTimePicker("chọn ngày", x.D["buttonNgayQuyetDinhKhoiToVuAn"], "");
            ngayQdMot                        = new Other("ngày 1", x.D["ngayMot"], "");
            ngayQd                           = new Other("chọn ngày", x.D["Ngay15QuyetDinhKhoiToVuAn"], "");
            coQuanRaQuyetDinh                = new ComboBox("cơ quan ra QĐ", x.D["dropdownCoQuanRaQuyetDinh"], "");
            coQuanCongAn                     = new Other("cơ quan công an", x.D["coQuanCongAn"], "");
            dieuLuatVu                       = new TextBox("điều luật vụ", x.D["inputDieuLuatVu"], "");
            toiVuKhong                       = new Other("tội vu khống", x.D["toiVuKhong"], "");
            donViRaQuyetDinh                 = new TextBox("đơn vị ra QĐ", x.D["inputDonViRaQuyetDinh"], "");
            tenVuAn                          = new TextBox("tên vụ án", x.D["inputTenVuAn"], "");
            maVuCuaToaAn                     = new TextBox("mã vụ của tòa án", x.D["inputMaVuCuaToaAn"], "");
            clickLoaiToiPham                 = new CheckBox("loại tội phạm check", x.D["clickLoaiToiPham"], "");
            btnLoaiToiPhamChuaXD             = new Button("chưa xác định", x.D["btnLoaiToiPhamChuaXD"], "");
            chonLoaiToiPham                  = new Button("chọn loại tội phạm", x.D["chonLoaiToiPham"], "");
            btnLoaiToiPhamItNghiemTrong      = new Button("ít nghiêm trọng", x.D["btnLoaiToiPhamItNghiemTrong"], "");
            btnLoaiToiPhamNghiemTrong        = new Button("nghiêm trọng", x.D["btnLoaiToiPhamNghiemTrong"], "");
            btnLoaiToiPhamRatNghiemTrong     = new Button("rất nghiêm trọng", x.D["btnLoaiToiPhamRatNghiemTrong"], "");
            btnLoaiToiPhamDacBietNghiemTrong = new Button("đặc biệt nghiêm trọng", x.D["btnLoaiToiPhamDacBietNghiemTrong"], "");
            txtNgayXayRa                     = new TextBox("ngày xảy ra", x.D["txtNgayXayRa"], "");
            ngayXayRa                        = new DateTimePicker("ngày xảy ra", x.D["inputThang"], "");
            thang           = new TextBox("tháng", x.D["inputThang"], "");
            nam             = new TextBox("năm", x.D["inputNam"], "");
            gio             = new TextBox("giờ", x.D["inputGio"], "");
            noiXayRa        = new TextBox("nơi xảy ra", x.D["inputNoiXayRa"], "");
            chiTietNoiXayRa = new TextBox("chi tiết nơi xảy ra", x.D["inputChiTietNoiXayRa"], "");
            ghiChu          = new TextBox("ghi chú", x.D["inputGhiChu"], "");

            ghiAmGhiHinhBiMat        = new CheckBox();
            ngheDienThoaiBiMat       = new CheckBox();
            thuThapBiMatDuLieuDienTu = new CheckBox();

            ghiLai  = new Button("buttonGhiLai", x.D["buttonGhiLai"], "");
            quayLai = new Button("buttonQuayLai", x.D["buttonQuayLai"], "");
            ngayQDKhoiToTuNgayText  = new TextBox("txt ngày quyết định khởi tố", x.D["ngayQDKhoiToTuNgayText"], "");
            ngayQDKhoiToDenNgayText = new TextBox("txt ngày quyết định khởi tố", x.D["ngayQDKhoiToDenNgayText"], "");
            txtNgayQDKhoiToVuAn     = new TextBox("text ngày quyết định khởi tố vụ án", x.D["txtNgayQDKhoiToVuAn"], "");
            o = new Other();


            #endregion
            //x = new Xpath();
            //this.driver = driver;
        }
示例#4
0
        public Page()
        {
            //actionCount = 0;
            xpath = new Xpath();

            maVuAn         = new TextBox("mã vụ án", xpath.D["maVuAn"], "");
            tenVuAn        = new TextBox("tên vụ án", xpath.D["tenVuAn"], "");
            tenBiCan       = new TextBox("tên bị can", xpath.D["inputTenBiCan"], "");
            toiDanh        = new TextBox("tội danh", xpath.D["inputToiDanh"], "");
            QDKhoiToVuAnSo = new TextBox("tội danh", xpath.D["inputToiDanh"], "");
            noiDKHKTT      = new TextBox("nơi đk hộ khẩu thường trú", xpath.D["noiDkhktt"], "");
            noiOHienTai    = new TextBox("ct nơi ở hiện tại", xpath.D["chiTietNoiOHienTai"], "");
            tenKSVien      = new TextBox("tên KSV", xpath.D["tenKsVien"], "");
            thuLySo        = new TextBox("thụ lý số", xpath.D["thuLySo"], "");

            timKiem     = new Button("tìm kiếm", xpath.D["timKiem"], "");
            doiGiaoDien = new Button();
        }
 /// <summary>
 /// 插入一条数据到数据库
 /// </summary>
 /// <param name="path">Xpath的对象</param>
 /// <returns></returns>
 public Boolean insert(Xpath path)
 {
     Boolean insert = false;
     DatabaseAccess database = new DatabaseAccess();
     String sql = "insert into xpath(id,websitename,weblanguage,baseurl,cntitle,entitle,unit,types,author,articletype,source,language,journalname,publishtime,levels,recordtype,forbid) values(NewId(),'"
         + path.Websitename + "','" + path.Weblanguage + "','" + path.Baseurl + "','" + path.Cntitle + "','" + path.Entitle + "','" + path.Unit + "','" + path.Types + "','" + path.Author + "','" + path.Articletype + "','" + path.Source + "','" + path.Language + "','" + path.Journalname + "','" + path.Publishtime + "','" + path.Levels + "','" + path.Recordtype + "',0)";
     try {
         insert = database.executeUpdate(sql);
     } catch (Exception e) {
         throw new Exception(e.Message);
     } finally {
         database.close();
     }
     return insert;
 }
 /// <summary>
 /// 获得所有已经添加到数据库的论文网站
 /// </summary>
 /// <returns></returns>
 public List<Xpath> webSiteList()
 {
     List<Xpath> webList = new List<Xpath>();
     DatabaseAccess database = new DatabaseAccess();
     String sql = "select id,websitename,baseurl from xpath where forbid=1";
     try {
         SqlDataReader result = database.executeQuery(sql);
         while (result.Read()) {
             Xpath path = new Xpath();
             path.Id = result.GetGuid(0);
             path.Baseurl = result.GetString(2);
             path.Websitename = result.GetString(1) + "(" + path.Baseurl + ")";
             webList.Add(path);
         }
     } catch (Exception e) {
         throw new Exception(e.Message);
     } finally {
         database.close();
     }
     return webList;
 }
 /// <summary>
 /// 更新整个数据的内容
 /// </summary>
 /// <param name="path">xpath的实例</param>
 /// <returns></returns>
 public Boolean update(Xpath path)
 {
     Boolean update = false;
     DatabaseAccess database = new DatabaseAccess();
     string sql = "update xpath set websitename='" + path.Websitename + "',weblanguage='" + path.Weblanguage + "',baseurl='" + path.Baseurl + "',cntitle='" + path.Cntitle + "',entitle='" + path.Entitle + "',unit='" + path.Unit + "',author='" + path.Author + "',types='" + path.Types + "',articletype='" + path.Articletype + "',source='" + path.Source + "',language='" + path.Language + "',journalname='" + path.Journalname + "',publishtime='" + path.Publishtime + "',levels='" + path.Levels + "',recordtype='" + path.Recordtype + "',forbid=" + path.Forbid + " where id='" + path.Id+"'";
     try {
         update = database.executeUpdate(sql);
     } catch (Exception e) {
         throw new Exception(e.Message);
     }
     return update;
 }
 /// <summary>
 /// 获得抓取规则的所有数据
 /// </summary>
 /// <param name="page">第几页</param>
 /// <param name="size">每页显示的数据</param>
 /// <returns></returns>
 public List<Xpath> pathList(int page,int size)
 {
     List<Xpath> pathList = new List<Xpath>();
     DatabaseAccess database = new DatabaseAccess();
     String sql = "select top(" +  size + ") * from xpath where id not in(select top( " + (page - 1) * size + ") id from xpath)";
     try {
         SqlDataReader result = database.executeQuery(sql);
         while (result.Read()) {
             Xpath path = new Xpath();
             path.Id = (Guid)result["id"];
             path.Baseurl = result["baseurl"].ToString();
             path.Websitename = result["websitename"].ToString();
             path.Weblanguage = result["weblanguage"].ToString();
             path.Cntitle = result["cntitle"].ToString();
             path.Entitle = result["entitle"].ToString();
             path.Unit = result["unit"].ToString();
             path.Types = result["types"].ToString();
             path.Author = result["author"].ToString();
             path.Articletype = result["articletype"].ToString();
             path.Source = result["source"].ToString();
             path.Language = result["language"].ToString();
             path.Journalname = result["journalname"].ToString();
             path.Publishtime = result["publishtime"].ToString();
             path.Levels = result["levels"].ToString();
             path.Recordtype = result["recordtype"].ToString();
             path.Forbid = (int)result["forbid"];
             pathList.Add(path);
         }
     } catch (Exception e) {
         throw new Exception(e.Message);
     } finally {
         database.close();
     }
     return pathList;
 }
示例#9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //LogEntry le;
        if (PreviousPage != null && PreviousPage.IsValid)
        {
            var tb = (TextBox)PreviousPage.FindControl("tbXmlUri");
            if (tb == null || string.IsNullOrEmpty(tb.Text))
            {
                string         error = "<h2>Unable to read XML URL</h2>";
                LiteralControl lc    = new LiteralControl(error);
                phAnchors.Controls.Add(lc);
                return;
            }
            string xmlUrl = tb.Text;

            string[] permittedProtocols = new string[] { "http", "https" };
            if (!Util.UrlHasPermittedProtocol(xmlUrl, permittedProtocols))
            {
                //le = new LogEntry();
                //le.Categories.Add(LogCategory.GENERAL);
                //le.Title = "Invalid protocol in XML URL";
                //le.Message = xmlUrl;
                //le.Severity = TraceEventType.Error;
                //le.ExtendedProperties.Add(new KeyValuePair<string, object>("Client IP", Request.UserHostAddress));
                //Logger.Write(le);

                string         error = "<h2>Invalid protocol in URL.</h2>";
                LiteralControl lc    = new LiteralControl(error);
                phAnchors.Controls.Add(lc);

                return;
            }

            if (Util.IsUrlReferencingThisMachine(xmlUrl,
                                                 Request.ServerVariables["SERVER_NAME"],
                                                 Request.ServerVariables["HTTP_HOST"],
                                                 permittedProtocols))
            {
                //le = new LogEntry();
                //le.Categories.Add(LogCategory.GENERAL);
                //le.Title = "Invalid XML URL";
                //le.Message = string.Format("{0} references hosting machine", xmlUrl);
                //le.Severity = TraceEventType.Error;
                //le.ExtendedProperties.Add(new KeyValuePair<string, object>("Client IP", Request.UserHostAddress));
                //Logger.Write(le);

                string         error = "<h2>Invalid URL.</h2>";
                LiteralControl lc    = new LiteralControl(error);
                phAnchors.Controls.Add(lc);
                return;
            }

            XmlDocument xdoc = new XmlDocument();
            try {
                /*
                 * A bunch of exceptions can potentially occur here -
                 * 1) can't resolve hostname
                 * 2) unable to connect to remote server
                 * 3) file not found (404)
                 * 4) xml parse error
                 */
                xdoc.Load(xmlUrl);
            }
            catch (Exception ex) {
                string error = "<h2>Error loading XML</h2>";
                error += string.Format("<h3>{0}</h3>", ex.Message);
                LiteralControl lce = new LiteralControl(error);
                phAnchors.Controls.Add(lce);

                //LogEntry leEx = new LogEntry();
                //leEx.Categories.Add(LogCategory.GENERAL);
                //leEx.Title = "XmlDocument.Load() failed";
                //leEx.Message = ex.Message;
                //leEx.Severity = TraceEventType.Error;
                //leEx.ExtendedProperties.Add(new KeyValuePair<string, object>("Xml URL", xmlUrl));
                //leEx.ExtendedProperties.Add(new KeyValuePair<string, object>("Client IP", Request.UserHostAddress));
                //Logger.Write(leEx);

                return;
            }

            /*
             * Make a copy of Application["lstXpathExpressionInfo"] for this request
             * so that parallel requests don't overwrite XpathExpressionInfo.NumRequests
             */
            List <XpathExpressionInfo> lstXei  = Application["lstXpathExpressionInfo"] as List <XpathExpressionInfo>;
            List <XpathExpressionInfo> lstXei2 = new List <XpathExpressionInfo>(lstXei.Count);
            foreach (var xei in lstXei)
            {
                lstXei2.Add(XpathExpressionInfo.Duplicate(xei));
            }

            var    matcher = new Xpath();
            string matches = string.Empty;
            try {
                matches = matcher.Match(xdoc, lstXei2);
            }
            catch (Exception ex) {
                string error = "<h2>Error analyzing XML</h2>";
                error += string.Format("<h3>{0}</h3>", ex.Message);
                LiteralControl lce = new LiteralControl(error);
                phAnchors.Controls.Add(lce);

                //LogEntry leEx = new LogEntry();
                //leEx.Categories.Add(LogCategory.GENERAL);
                //leEx.Title = "Xpath.Match() failed";
                //leEx.Message = ex.Message;
                //leEx.Severity = TraceEventType.Error;
                //leEx.ExtendedProperties.Add(new KeyValuePair<string, object>("Xml URL", xmlUrl));
                //leEx.ExtendedProperties.Add(new KeyValuePair<string, object>("Client IP", Request.UserHostAddress));
                //for (int i = 0; i < lstXei.Count; i++) {
                //    var xei = lstXei[i];
                //    string name = "XPath" + (i + 1);
                //    leEx.ExtendedProperties.Add(new KeyValuePair<string, object>(name, xei.XpathExpression));
                //}
                //Logger.Write(leEx);

                return;
            }

            LiteralControl lcMatches = new LiteralControl(matches);
            phResult.Controls.Add(lcMatches);

            //le = new LogEntry();
            ////le.Categories.Add(LogCategory.REQUESTS);
            //le.Title = "Request Successful";
            //le.Message = xmlUrl;
            //le.Severity = TraceEventType.Information;
            //le.ExtendedProperties.Add(new KeyValuePair<string, object>("Client IP", Request.UserHostAddress));
            //Logger.Write(le);
        }
    }
示例#10
0
        public void GenerateXpath_Click(object sender, EventArgs e)
        {
            string Tvalue = TvalueTxtBox.Text;
            string Target = TargetTxtBox.Text;

            if (!string.IsNullOrEmpty(txtLindex.Text))
            {
                JSupport.Index = txtLindex.Text;
            }
            string Option = SelectOptions.Text;

            if (string.IsNullOrEmpty(Option))
            {
                MessageBox.Show("控件选择为必填项");
            }
            else
            {
                XpathDateView.Rows.Clear();
                try
                {
                    switch (Option)
                    {
                    case "普通按钮":
                        Xpath = JXpath.Button(Tvalue, Target);
                        break;

                    case "勾选按钮":
                        Xpath = JXpath.Radio(Tvalue, Target);
                        break;

                    case "树节点按钮":
                        Xpath = JXpath.TreeNode(Tvalue, Target);
                        break;

                    case "图标按钮":
                        Xpath = JXpath.IConButton(Tvalue, Target);
                        break;

                    case "普通文本框":
                        Xpath = JXpath.Input(Target, Tvalue);
                        break;

                    case "文件文本框":
                        Xpath = JXpath.FileInput(Target, Tvalue);
                        break;

                    case "普通下拉框":
                        Xpath = JXpath.Select(Target, Tvalue);
                        break;
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show(string.Format("{0}:请重试", error));
                }
                //Print xpath and control format
                var Collection = Xpath.Split('|');
                foreach (string item in Collection)
                {
                    XpathDateView.Rows.Add(item.Trim());
                }
            }
        }