Example #1
0
        /// <summary>
        /// 获取部门
        /// </summary>
        public void getDepartment()
        {
            ProxyBE p = new ProxyBE();

            SearchDepartmentArgs args = new SearchDepartmentArgs();
            //args.Areal = Request.QueryString["Area"];

            SearchResult sr    = p.Client.SearchDepartment(SenderUser, args);
            DataTable    dt    = sr.DataSet.Tables[0];;
            var          Areas = from d in dt.AsEnumerable() select new { DepartmentCode = d["DepartmentCode"], DepartmentName = d["DepartmentName"] };
            string       str   = "[";

            str += ("{\"text\":\"请选择\",");
            str += ("\"value\":\"请选择\"},");
            foreach (var p1 in Areas.Distinct())
            {
                str += "{\"DepartmentCode\":\"" + p1.DepartmentCode + "\",\"DepartmentName\":\"" + p1.DepartmentName + "\"},";
            }
            if (str.Length > 1)
            {
                str = str.Substring(0, str.LastIndexOf(","));
            }
            str += "]";
            Response.Write(str);
        }
Example #2
0
 /// <summary>
 /// 获取用户
 /// </summary>
 public void ListToUser()
 {
     try
     {
         using (ProxyBE p = new ProxyBE())
         {
             SearchDepartmentArgs sargs = new SearchDepartmentArgs();
             if (!string.IsNullOrEmpty(parm.DepartmentCode))
             {
                 List <string> DepartmentCode = new List <string>();
                 DepartmentCode.Add(parm.DepartmentCode);
                 sargs.DepartmentCodes = DepartmentCode;
             }
             if (!string.IsNullOrEmpty(parm.DepartmentName))
             {
                 List <string> DepartmentName = new List <string>();
                 DepartmentName.Add(parm.DepartmentName);
                 sargs.DepartmentNames = DepartmentName;
             }
             sargs.OrderBy       = pagingParm.SortOrder;
             sargs.RowNumberFrom = pagingParm.RowNumberFrom;
             sargs.RowNumberTo   = pagingParm.RowNumberTo;
             //Where
             SearchResult sr = p.Client.SearchDepartment(SenderUser, sargs);
             Response.Write(JSONHelper.Dataset2Json(sr.DataSet));
         }
     }
     catch (Exception ex)
     {
         WriteError(ex.Message, ex);
     }
 }
Example #3
0
 /// <summary>
 /// 获取部门信息
 /// </summary>
 public void DepartmentName()
 {
     using (ProxyBE p = new ProxyBE())
     {
         StringBuilder str = new StringBuilder();
         try
         {
             SearchDepartmentArgs args = new SearchDepartmentArgs();
             args.IsDisabled = false;
             var codeName = p.Client.SearchDepartment(SenderUser, args).DataSet.Tables[0];
             str.Append("[");
             str.Append("{\"text\":\"请选择\",");
             str.Append("\"value\":\"请选择\"},");
             if (codeName.Rows.Count > 0)
             {
                 for (int i = 0; i < codeName.Rows.Count; i++)
                 {
                     str.Append("{");
                     str.Append(string.Format("\"text\":\"{0}\",", codeName.Rows[i]["DepartmentName"]));
                     str.Append(string.Format("\"value\":\"{0}\"", codeName.Rows[i]["DepartmentID"]));
                     str.Append("},");
                 }
             }
             str.Append("]");
         }
         catch (Exception ex)
         {
             WriteError(ex.Message, ex);
         }
         string strm = str.ToString().Replace("},]", "}]");
         Response.Write(strm);
     }
 }
Example #4
0
 public SearchResult SearchDepartment(Sender sender, SearchDepartmentArgs args)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             return(op.SearchDepartment(args));
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Example #5
0
        /// <summary>
        /// List
        /// </summary>
        public void List()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    SearchDepartmentArgs sargs = new SearchDepartmentArgs();

                    if (!string.IsNullOrEmpty(parm.DepartmentCode))
                    {
                        List <string> DepartmentCode = new List <string>();
                        DepartmentCode.Add(parm.DepartmentCode);
                        sargs.DepartmentCodes = DepartmentCode;
                    }
                    if (!string.IsNullOrEmpty(parm.DepartmentName) && parm.DepartmentName != "请选择")
                    {
                        List <string> DepartmentName = new List <string>();
                        DepartmentName.Add(parm.DepartmentName);
                        sargs.DepartmentNames = DepartmentName;
                    }


                    //if (!string.IsNullOrEmpty(Request["Closed"]))
                    //{
                    //    sargs.ClosedFrom = DateTime.Today;

                    //}


                    if (!string.IsNullOrEmpty(Request["IsDisabled"]))
                    {
                        sargs.IsDisabled = Convert.ToBoolean(Request["IsDisabled"]);
                    }
                    sargs.OrderBy       = string.IsNullOrEmpty(pagingParm.SortOrder.Trim()) ? "DepartmentID" : pagingParm.SortOrder;
                    sargs.RowNumberFrom = pagingParm.RowNumberFrom;
                    sargs.RowNumberTo   = pagingParm.RowNumberTo;
                    //Where

                    SearchResult sr = p.Client.SearchDepartment(SenderUser, sargs);
                    Response.Write(JSONHelper.Dataset2Json(sr.DataSet));
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Example #6
0
 public SearchResult SearchDepartment(bool IsDisabled, string Category)
 {
     try
     {
         using (ProxyAE ae = new ProxyAE())
         {
             SearchDepartmentArgs args = new SearchDepartmentArgs();
             args.IsDisabled = IsDisabled;
             args.Category = Category;
             SearchResult sr  = ae.Client.SearchDepartment(sender, args);
             return sr;
         }
     }
     catch (System.Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
Example #7
0
        /// <summary>
        /// 按部门分类加载用户
        /// </summary>
        public void UserTree()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    string RoleID = Request["UserRoleID"];

                    List <User2Role> listUser2Role = new List <User2Role>();
                    if (!string.IsNullOrEmpty(RoleID))
                    {
                        listUser2Role = p.Client.GetUser2RoleByRoleID(SenderUser, new Guid(RoleID));
                    }
                    StringBuilder jsonBuilder = new StringBuilder();
                    jsonBuilder.Append("[{");
                    jsonBuilder.Append("\"id\":\"0\"");
                    jsonBuilder.Append(",\"text\":\"用户设置\"");
                    jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"0\"}");
                    #region 部门类型

                    SearchDepartmentArgs ugargs = new SearchDepartmentArgs();
                    ugargs.IsDisabled = false;
                    SearchResult sr = p.Client.SearchDepartment(SenderUser, ugargs);
                    if (sr.Total > 0)
                    {
                        jsonBuilder.AppendFormat(",\"children\":");
                        jsonBuilder.Append("[");
                        for (int j = 0; j < sr.DataSet.Tables[0].Rows.Count; j++)
                        {
                            DataRow drow = sr.DataSet.Tables[0].Rows[j];
                            jsonBuilder.Append("{");
                            jsonBuilder.AppendFormat("\"id\":\"{0}\"", drow["DepartmentID"]);
                            jsonBuilder.AppendFormat(",\"text\":\"{0}\"", drow["DepartmentName"]);
                            jsonBuilder.AppendFormat(",\"iconCls\":\"{0}\"", "group");
                            jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"2\",\"ParentID\":\"" + drow["DepartmentID"] + "\"}");
                            jsonBuilder.AppendFormat(",\"children\":");
                            jsonBuilder.Append("[");
                            #region 用户
                            List <User> listuser = p.Client.GetUsersByDepartmentID(SenderUser, new Guid((drow["DepartmentID"].ToString())));
                            if (listuser != null)
                            {
                                for (int n = 0; n < listuser.Count; n++)
                                {
                                    User item = listuser[n];
                                    if (item.IsDisabled)
                                    {
                                        continue;
                                    }
                                    jsonBuilder.Append("{");
                                    jsonBuilder.AppendFormat("\"id\":\"{0}\"", item.UserID);
                                    jsonBuilder.AppendFormat(",\"text\":\"{0}\"", item.UserName);
                                    jsonBuilder.AppendFormat(",\"iconCls\":\"{0}\"", "user");
                                    if (listUser2Role.Find(pl => pl.UserID == item.UserID) != null)
                                    {
                                        jsonBuilder.AppendFormat(",\"checked\":\"{0}\"", true);
                                    }
                                    jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"3\",\"ParentID\":\"" + drow["DepartmentID"].ToString() + "\"}");
                                    jsonBuilder.Append("}");
                                    if (n < listuser.Count - 1)
                                    {
                                        jsonBuilder.Append(",");
                                    }
                                }
                            }
                            #endregion
                            jsonBuilder.Append("]");
                            jsonBuilder.Append("}");
                            if (j < sr.DataSet.Tables[0].Rows.Count - 1)
                            {
                                jsonBuilder.Append(",");
                            }
                        }
                        jsonBuilder.Append("]");
                    }

                    #endregion
                    jsonBuilder.Append("}]");
                    Response.Write(jsonBuilder.ToString());
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }