码迷,mamicode.com
首页 > 其他好文 > 详细

优化部门人员加载缓慢

时间:2017-03-21 12:41:06      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:out   uid   ssi   nal   tar   lap   cti   insert   cep   

1.SMSInfo_Add页面初始化部门人员并缓存起来

技术分享
1 $(function () {
2             createInternalUsers("");
3             createExternalUsers();
4             $.post("Action.ashx?t=GetUserTree", function () { })//预加载部门人员,缓存后直接调用
5         });
View Code

2.Internalusers页面调用初始化的部门人员

技术分享
 1 //部门人员树形节点
 2         function createTree() {
 3             $.ajax({
 4                 url: ‘Action.ashx?t=GetUserTree‘,
 5                 data: { id: "100" },
 6                 type: ‘POST‘,
 7                 dataType: "json",
 8                 success: function (result) {
 9                     if (result.success) {
10                         $("#dtload").hide();
11                         zNodes = result.data;
12                         zTree = $.fn.zTree.init($("#treeUser"), setting, zNodes);
13                         zTree.addNodes(null, 0, { id: ‘00F157EB-1D3A-45FD-AF42-5B142C8D5EHX‘, pId: ‘companyall‘, isParent: false, name: "公司全员" });
14                         var guId = "<%=ReceiveDeptGUID2 %>"; //$("#hid").val();
15                         guId = guId.substring(1, guId.length - 1);
16                         var idStr = guId.split(‘,‘);
17                         for (var i = 0; i < idStr.length; i++) {
18                             //alert(idStr[i]);
19                             zTree.checkNode(zTree.getNodeByParam("id", $.trim(idStr[i])), true, true);
20                             GetNodes();
21                         }
22                     } else {
23                         $("#dtload").hide();
24                         $("#treeUser").html("<li class=‘red‘>服务器异常:获取用户失败</li>");
25                     }
26                 }
27             });
28         }
View Code

3.部门人员方法

技术分享
 1 public string GetUserTree(HttpContext context)
 2         {
 3             string json = "";
 4             try
 5             {
 6                 if (context.Cache["usertree"] == null)
 7                 {
 8                     SYSUser sysUser = context.Session["SYSUser"] as SYSUser;
 9                     DepartmentInfo[] dept = port.GetAllDept();
10                     GetNodeDeptUser(dept, sysUser.CPInnerID);
11                     context.Cache.Insert("usertree", nlist, null, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration);
12                 }
13                 else {
14                     nlist = (List<zTreeNode>)context.Cache["usertree"];
15                 }
16                 var obj = new { success = true, data = nlist, msg = "" };
17                 json = HX.Common.JsonHelper.SerializeObject(obj);
18             }
19             catch (Exception ex)
20             {
21                 var obj = new { success = false, msg = ex.Message };
22                 json = HX.Common.JsonHelper.SerializeObject(obj);
23             }
24             return json;
25         }
View Code

 

优化部门人员加载缓慢

标签:out   uid   ssi   nal   tar   lap   cti   insert   cep   

原文地址:http://www.cnblogs.com/yidengbone/p/6593496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!