Exemplo n.º 1
0
 private void SetData()
 {
     if (txtToDate.Text.Length > 0 && txtFromDate.Text.Length > 0)
     {
         string        json             = File.ReadAllText(HttpContext.Current.Server.MapPath(@"result.json"));
         URLCollection resultCollection = JsonConvert.DeserializeObject <URLCollection>(json);
         finalCollection = resultCollection.urls.Where <URL>(i => i.expiration >= Convert.ToDateTime(txtFromDate.Text).Date&&
                                                             i.expiration <= Convert.ToDateTime(txtToDate.Text).Date).ToList <URL>();
     }
 }
Exemplo n.º 2
0
        private void Init()
        {
            System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
            _document.Load(Xy.Tools.IO.File.foundConfigurationFile("UrlControl", Xy.AppSetting.FILE_EXT));
            System.Xml.XmlNodeList default_xnl = _document.SelectNodes("UrlRewrite/Item");

            _defaultUrlControl = new URLCollection(string.Empty, string.Empty, string.Empty, string.Empty);
            foreach (System.Xml.XmlNode _xn in default_xnl) {
                _defaultUrlControl.Add(new URLItem(_xn));
            }

            _defaultUrlControl.Add(new URLItem(null, null, @".*\.js$", "application/x-javascript", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.css$", "text/css", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.gif$", "image/gif", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.jpg$", "image/jpeg", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.png$", "image/png", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.bmp$", "image/bmp", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.swf$", "application/x-shockwave-flash", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @".*\.ico$", "image/x-icon", false, false, "ResourceFile", URLItem.DEFAULTAGE));
            _defaultUrlControl.Add(new URLItem(null, null, @"^/Xy_(App|Data|Log)/.*", "text/html", false, false, "Prohibit", 0));
            _defaultUrlControl.Add(new URLItem(null, null, @"^/Xy_Theme/[^/]+/Xy_(Cache|Include|Page|Xslt)/.*", "text/html", false, false, "Prohibit", 0));
            _defaultUrlControl.Add(new URLItem(null, "Xy.Web,Xy.Web.Page.ErrorPage", @"^/error\.aspx", "text/html", true, false, "MainContent", 0));

            _urlControl = new List<URLCollection>();
            foreach (System.Xml.XmlElement _xe in _document.SelectNodes("UrlRewrite/UrlCollection")) {
                URLCollection _urlItemCollection = new URLCollection(_xe);
                if (_urlItemCollection.SiteUrlReg == null && string.IsNullOrEmpty(_urlItemCollection.Name)) continue;

                foreach (System.Xml.XmlNode _xn in _xe.SelectNodes("Item")) {
                    _urlItemCollection.Add(new URLItem(_xn));
                }
                URLCollection _parent = null;
                if (!string.IsNullOrEmpty(_urlItemCollection.Inherit)) {
                    _parent = GetUrlItemCollection(_urlItemCollection.Inherit);
                }
                if (_parent == null) _parent = _defaultUrlControl;
                _urlItemCollection.AddRange(_parent.ToArray());
                _urlControl.Add(_urlItemCollection);
            }
        }
Exemplo n.º 3
0
        public IActionResult Create(URLCollection uRLCollection)
        {
            try
            {
                var urlRep = _unitOfWork.Repository <URLCollection>();

                urlRep.Insert(uRLCollection);
                _unitOfWork.Commit();
                return(Json(new ResultModel
                {
                    IsSuccess = true,
                    Message = "添加成功"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ResultModel
                {
                    IsSuccess = false,
                    Message = $"添加失败,原因为:{ex.Message}"
                }));
            }
        }
Exemplo n.º 4
0
 public void AddUrl(string url)
 {
     URLCollection.Add(url);
 }