Esempio n. 1
0
        public virtual void Update(DDTreeUpdateInfo updateInfo)
        {
            var path = HostingEnvironment.MapPath(updateInfo.Path);

            _doc = new HtmlDocument();
            _doc.OptionOutputOriginalCase = true;
            _doc.Load(path);

            _updateInfo = updateInfo;

            var scripts         = new List <string>();
            var scriptresources = _doc.DocumentNode.SelectSingleNode("//scriptresources");

            if (scriptresources != null)
            {
                foreach (var node in scriptresources.ChildNodes)
                {
                    if (node.Attributes.Contains("src"))
                    {
                        scripts.Add(node.Attributes["src"].Value.ToLower());
                    }
                }
            }
            var scriptNodes = _doc.DocumentNode.SelectNodes("//script");

            if (scriptNodes != null)
            {
                foreach (var node in scriptNodes)
                {
                    if (node.Attributes.Contains("src"))
                    {
                        scripts.Add(node.Attributes["src"].Value.ToLower());
                    }
                }
            }

            bool existsJquery = false;
            bool existsDDTree = false;

            foreach (var script in scripts)
            {
                if (script.Contains("jquery"))
                {
                    existsJquery = true;
                }
                if (script.Contains("ddtree.js"))
                {
                    existsDDTree = true;
                }
            }
            if (existsDDTree)
            {
                _updateInfo.HasUpdated = true;
                _updateInfo.Error      = "页面已经添加过公司控件";
                return;
            }

            if (!AddDom())
            {
                return;
            }
            if (!existsJquery)
            {
                AddJs("/Expand/js/jquery-1.8.3.js");
            }
            AddJs("/Expand/ajax.aspx?type=Mysoft.Expand.DDTreeService");
            AddJs("/Expand/js/DDTree/DDTree.js");
            AddTreeJs();
            Save();
            _updateInfo.Error      = "已生成文件";
            _updateInfo.HasUpdated = true;
            return;
        }
Esempio n. 2
0
        public virtual void Update(DDTreeUpdateInfo updateInfo)
        {
            var path = HostingEnvironment.MapPath(updateInfo.Path);
              _doc = new HtmlDocument();
              _doc.OptionOutputOriginalCase = true;
              _doc.Load(path);

              _updateInfo = updateInfo;

             var scripts = new List<string>();
             var scriptresources = _doc.DocumentNode.SelectSingleNode("//scriptresources");
             if (scriptresources != null)
             {
                 foreach (var node in scriptresources.ChildNodes)
                 {
                     if (node.Attributes.Contains("src"))
                         scripts.Add(node.Attributes["src"].Value.ToLower());
                 }
             }
             var scriptNodes = _doc.DocumentNode.SelectNodes("//script");
             if (scriptNodes != null)
             {
                 foreach (var node in scriptNodes)
                 {
                     if (node.Attributes.Contains("src"))
                         scripts.Add(node.Attributes["src"].Value.ToLower());
                 }
             }

             bool existsJquery = false;
             bool existsDDTree = false;
             foreach (var script in scripts)
             {
                 if (script.Contains("jquery"))
                     existsJquery = true;
                 if (script.Contains("ddtree.js"))
                     existsDDTree = true;
             }
             if (existsDDTree)
             {
                 _updateInfo.HasUpdated = true;
                 _updateInfo.Error = "ҳ���Ѿ���ӹ���˾�ؼ�";
                 return;
             }

             if (!AddDom())
                 return;
             if (!existsJquery)
                 AddJs("/Expand/js/jquery-1.8.3.js");
             AddJs("/Expand/ajax.aspx?type=Mysoft.Expand.DDTreeService");
             AddJs("/Expand/js/DDTree/DDTree.js");
             AddTreeJs();
             Save();
             _updateInfo.Error = "�������ļ�";
             _updateInfo.HasUpdated = true;
             return;
        }