Beispiel #1
0
 public SearchResult SearchPartnerUserGroup(Sender sender, SearchPartnerUserGroupArgs args)
 {
     try
     {
         using (ObjectProxy op = new ObjectProxy())
         {
             return(op.SearchPartnerUserGroup(args));
         }
     }
     catch (Exception ex)
     {
         PLogger.LogError(ex);
         throw ex;
     }
 }
        /// <summary>
        /// 树(经销商)
        /// </summary>
        public void PartnerTree()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    string      PartnerID   = Request["PartnerID"].ToString();
                    PartnerRole partnerRole = null;
                    if (!string.IsNullOrEmpty(PartnerID))
                    {
                        SearchPartnerUserGroupArgs UserGroupArgs = new SearchPartnerUserGroupArgs();
                        UserGroupArgs.PartnerID = new Guid(PartnerID);
                        UserGroupArgs.GroupName = "默认组";
                        Guid         GroupID = Guid.Empty;
                        SearchResult sr      = p.Client.SearchPartnerUserGroup(SenderUser, UserGroupArgs);
                        if (sr.Total > 0)
                        {
                            foreach (DataRow item in sr.DataSet.Tables[0].Rows)
                            {
                                GroupID = Guid.Parse(item["GroupID"].ToString());
                            }
                        }
                        if (GroupID != Guid.Empty)
                        {
                            partnerRole = p.Client.GetPartnerRoleByName(SenderUser, GroupID, "root");
                        }
                    }
                    var PrivilegeItems = new List <PrivilegeItem>();
                    if (partnerRole != null)
                    {
                        PrivilegeItems = p.Client.GetPrivilegeItemByPartnerRoleID(SenderUser, partnerRole.RoleID);
                    }

                    StringBuilder jsonBuilder = GetTreeBuilder(p, PrivilegeItems);
                    Response.Write(jsonBuilder.ToString());
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// (树)经销商权限
        /// </summary>
        public void RoleTree()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    string UserID = Request["UserID"];
                    List <PartnerUser2Role> partnerUser2Role = new List <PartnerUser2Role>();
                    if (!string.IsNullOrEmpty(UserID))
                    {
                        partnerUser2Role = p.Client.GetPartnerUser2RoleByUserID(SenderUser, new Guid(UserID));
                    }
                    StringBuilder jsonBuilder = new StringBuilder();
                    jsonBuilder.Append("[{");
                    jsonBuilder.Append("\"id\":\"0\"");
                    jsonBuilder.Append(",\"text\":\"角色设置\"");
                    jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"0\"}");
                    #region 用户组
                    //用户组
                    SearchPartnerUserGroupArgs pargs = new SearchPartnerUserGroupArgs();
                    if (CurrentUser.PartnerID != Guid.Empty)
                    {
                        pargs.PartnerID = CurrentUser.PartnerID;
                    }
                    pargs.IsSystem = false;
                    SearchResult sr = p.Client.SearchPartnerUserGroup(SenderUser, pargs);
                    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["GroupID"]);
                            jsonBuilder.AppendFormat(",\"text\":\"{0}\"", drow["GroupName"]);
                            jsonBuilder.AppendFormat(",\"iconCls\":\"{0}\"", "group");
                            jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"2\",\"ParentID\":\"" + drow["GroupID"] + "\"}");
                            jsonBuilder.AppendFormat(",\"children\":");
                            jsonBuilder.Append("[");
                            #region 角色
                            //角色
                            List <PartnerRole> pRole = p.Client.GetPartnerRolesByGroupID(SenderUser, new Guid((drow["GroupID"].ToString())));
                            if (pRole != null)
                            {
                                for (int n = 0; n < pRole.Count; n++)
                                {
                                    PartnerRole itemRole = pRole[n];
                                    if (itemRole.IsSystem)
                                    {
                                        continue;
                                    }
                                    jsonBuilder.Append("{");
                                    jsonBuilder.AppendFormat("\"id\":\"{0}\"", itemRole.RoleID);
                                    jsonBuilder.AppendFormat(",\"text\":\"{0}\"", itemRole.RoleName);
                                    jsonBuilder.AppendFormat(",\"iconCls\":\"{0}\"", "user");

                                    if (partnerUser2Role.Find(pl => pl.RoleID == itemRole.RoleID) != null)
                                    {
                                        jsonBuilder.AppendFormat(",\"checked\":\"{0}\"", true);
                                    }
                                    jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"3\",\"ParentID\":\"" + drow["GroupID"].ToString() + "\"}");
                                    jsonBuilder.Append("}");
                                    if (n < pRole.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);
            }
        }
Beispiel #4
0
        public void SavePartnerManagerUser()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    #region  PartnerUser
                    PartnerUser partnerUser = p.Client.GetPartnerUser(SenderUser, parm.UserID);
                    if (partnerUser != null)
                    {
                        partnerUser.UserCode = parm.UserCode.Trim();
                        bool flag = p.Client.PartnerUserIsDuplicated(SenderUser, partnerUser);
                        if (flag)
                        {
                            throw new Exception("该账号已经存在,请重新输入。");
                        }
                        partnerUser.PartnerID       = parm.PartnerID;
                        partnerUser.UserName        = parm.UserName.Trim();
                        partnerUser.Sex             = "";
                        partnerUser.Position        = "";
                        partnerUser.IsSystem        = true;
                        partnerUser.Email           = "";
                        partnerUser.Description     = parm.Description.Trim();
                        partnerUser.Mobile          = parm.Mobile.Trim();
                        partnerUser.LoginErrorCount = 0;
                        partnerUser.IsDisabled      = Convert.ToBoolean(parm.IsDisabled);
                        partnerUser.IsLocked        = parm.IsLocked;
                        partnerUser.IsAxamine       = true;
                        partnerUser.IsFinishInfo    = true;
                        partnerUser.MemberClass     = parm.MemberClass;
                        string strDate = Request["EndDate"];
                        partnerUser.EndDate = Convert.ToDateTime(Request["EndDate"]);
                    }
                    SavePartnerUserArgs args = new SavePartnerUserArgs();
                    args.PartnerUser = partnerUser;
                    p.Client.SavePartnerUser(SenderUser, args);
                    #endregion

                    #region  PartnerUserGroup
                    PartnerUserGroup           UserGroup     = null;
                    SearchPartnerUserGroupArgs UserGroupArgs = new SearchPartnerUserGroupArgs();
                    UserGroupArgs.PartnerID = partnerUser.PartnerID;
                    UserGroupArgs.GroupName = "默认组";
                    Guid         GroupID = Guid.Empty;
                    SearchResult sr      = p.Client.SearchPartnerUserGroup(SenderUser, UserGroupArgs);
                    if (sr.Total > 0)
                    {
                        foreach (DataRow item in sr.DataSet.Tables[0].Rows)
                        {
                            GroupID = Guid.Parse(item["GroupID"].ToString());
                        }
                        UserGroup = p.Client.GetPartnerUserGroup(SenderUser, GroupID);
                    }
                    if (GroupID == Guid.Empty)
                    {
                        UserGroup           = new PartnerUserGroup();
                        UserGroup.GroupID   = Guid.NewGuid();
                        UserGroup.GroupName = "默认组";
                        UserGroup.IsSystem  = true;
                        UserGroup.PartnerID = partnerUser.PartnerID;
                        SavePartnerUserGroupArgs GroupArgs = new SavePartnerUserGroupArgs();
                        GroupArgs.PartnerUserGroup = UserGroup;
                        p.Client.SavePartnerUserGroup(SenderUser, GroupArgs);
                    }
                    #endregion

                    #region  PartnerRole
                    string      PrivilegeItemS   = Request["PrivilegeItemS"];
                    List <Guid> PrivilegeItemIDS = new List <Guid>();
                    if (!string.IsNullOrEmpty(PrivilegeItemS))
                    {
                        string[] ItemS = PrivilegeItemS.Split(',');
                        foreach (var item in ItemS)
                        {
                            PrivilegeItemIDS.Add(new Guid(item));
                        }
                    }
                    PartnerRole partnerRole = p.Client.GetPartnerRoleByName(SenderUser, UserGroup.GroupID, "root");
                    if (partnerRole == null)
                    {
                        partnerRole          = new PartnerRole();
                        partnerRole.GroupID  = UserGroup.GroupID;
                        partnerRole.IsSystem = true;
                        partnerRole.RoleID   = Guid.NewGuid();
                        partnerRole.RoleName = "root";
                    }
                    SavePartnerRoleArgs roleArgs = new SavePartnerRoleArgs();
                    roleArgs.PartnerRole      = partnerRole;
                    roleArgs.PrivilegeItemIDs = PrivilegeItemIDS;
                    p.Client.SavePartnerRole(SenderUser, roleArgs);
                    #endregion

                    #region PartnerUser2Role
                    PartnerUser2Role PartnerUser2Role = new PartnerUser2Role();
                    PartnerUser2Role.UserID = partnerUser.UserID;
                    PartnerUser2Role.RoleID = partnerRole.RoleID;

                    SavePartnerUser2RoleArgs sargs = new SavePartnerUser2RoleArgs();
                    sargs.PartnerUser2Role = PartnerUser2Role;
                    p.Client.SavePartnerUser2Role(SenderUser, sargs);
                    #endregion

                    WriteSuccess();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 树(经销商)
        /// </summary>
        public void PartnerTree()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    string      PartnerID   = Request["PartnerID"].ToString();
                    PartnerRole partnerRole = null;
                    if (!string.IsNullOrEmpty(PartnerID))
                    {
                        SearchPartnerUserGroupArgs UserGroupArgs = new SearchPartnerUserGroupArgs();
                        UserGroupArgs.PartnerID = new Guid(PartnerID);
                        UserGroupArgs.GroupName = "默认组";
                        Guid         GroupID = Guid.Empty;
                        SearchResult sr      = p.Client.SearchPartnerUserGroup(SenderUser, UserGroupArgs);
                        if (sr.Total > 0)
                        {
                            foreach (DataRow item in sr.DataSet.Tables[0].Rows)
                            {
                                GroupID = Guid.Parse(item["GroupID"].ToString());
                            }
                        }
                        if (GroupID != Guid.Empty)
                        {
                            partnerRole = p.Client.GetPartnerRoleByName(SenderUser, GroupID, "root");
                        }
                    }
                    if (partnerRole != null)
                    {
                        #region 第二次
                        var PrivilegeItems = p.Client.GetPrivilegeItemByPartnerRoleID(SenderUser, partnerRole.RoleID);
                        PrivilegeItems = PrivilegeItems ?? new List <PrivilegeItem>();
                        StringBuilder jsonBuilder = new StringBuilder();
                        jsonBuilder.Append("[{");
                        jsonBuilder.Append("\"id\":\"0\"");
                        jsonBuilder.Append(",\"text\":\"权限菜单\"");
                        jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");

                        jsonBuilder.AppendFormat(",\"children\":");
                        PrivilegeCategory item = p.Client.GetPrivilegeCategory(SenderUser, new Guid(CategoryID));
                        //获取当前应用系统下的所有菜单项
                        jsonBuilder.Append("[");
                        if (item != null)
                        {
                            jsonBuilder.Append("{");
                            jsonBuilder.AppendFormat("\"id\":\"{0}\"", item.CategoryID);
                            jsonBuilder.AppendFormat(",\"text\":\"{0}\"", item.CategoryName);
                            jsonBuilder.Append(",\"state\":\"closed\"");
                            jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");
                            jsonBuilder.AppendFormat(",\"children\":");
                            jsonBuilder.Append("[");
                            #region 权限菜单

                            List <Privilege> Privileges = p.Client.GetPrivilegesByCategoryID(SenderUser, item.CategoryID).Where(t => !t.IsDisabled).ToList();

                            for (int i = 0; i < Privileges.Count; i++)
                            {
                                Privilege itemPrivilege = Privileges[i];
                                //if (itemPrivilege.IsDisabled)
                                //{
                                //    continue;
                                //}
                                jsonBuilder.Append("{");
                                jsonBuilder.AppendFormat("\"id\":\"{0}\"", itemPrivilege.PrivilegeID);
                                jsonBuilder.AppendFormat(",\"text\":\"{0}\"", itemPrivilege.PrivilegeName);
                                jsonBuilder.Append(",\"state\":\"closed\"");
                                jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");
                                #region 权限项
                                //是否权限项
                                List <PrivilegeItem> listPrivilegeItem = p.Client.GetPrivilegeItemByPrivilegeID(SenderUser, itemPrivilege.PrivilegeID);
                                if (listPrivilegeItem != null)
                                {
                                    jsonBuilder.AppendFormat(",\"children\":");
                                    jsonBuilder.Append("[");
                                    for (int j = 0; j < listPrivilegeItem.Count; j++)
                                    {
                                        PrivilegeItem itemPrivilegeItem = listPrivilegeItem[j];
                                        jsonBuilder.Append("{");
                                        jsonBuilder.AppendFormat("\"id\":\"{0}\"", itemPrivilegeItem.PrivilegeItemID);
                                        jsonBuilder.AppendFormat(",\"text\":\"{0}\"", itemPrivilegeItem.PrivilegeItemName);
                                        if (PrivilegeItems.Find(pl => pl.PrivilegeItemID == itemPrivilegeItem.PrivilegeItemID) != null)
                                        {
                                            jsonBuilder.AppendFormat(",\"checked\":\"{0}\"", true);
                                        }
                                        jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"0\"}");
                                        jsonBuilder.Append("}");
                                        if (j < listPrivilegeItem.Count - 1)
                                        {
                                            jsonBuilder.Append(",");
                                        }
                                    }
                                    jsonBuilder.Append("]");
                                }

                                #endregion
                                jsonBuilder.Append("}");
                                if (i < Privileges.Count - 1)
                                {
                                    jsonBuilder.Append(",");
                                }
                            }
                            #endregion
                            jsonBuilder.Append("]");
                            jsonBuilder.Append("}");
                        }
                        jsonBuilder.Append("]");
                        jsonBuilder.Append("}]");
                        Response.Write(jsonBuilder.ToString());
                        #endregion
                    }
                    else
                    {
                        #region 初始化
                        var           PrivilegeItems = new List <PrivilegeItem>();
                        StringBuilder jsonBuilder    = new StringBuilder();
                        jsonBuilder.Append("[{");
                        jsonBuilder.Append("\"id\":\"0\"");
                        jsonBuilder.Append(",\"text\":\"权限菜单\"");
                        jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");

                        jsonBuilder.AppendFormat(",\"children\":");
                        PrivilegeCategory item = p.Client.GetPrivilegeCategory(SenderUser, new Guid(CategoryID));
                        //获取当前应用系统下的所有菜单项
                        jsonBuilder.Append("[");
                        if (item != null)
                        {
                            jsonBuilder.Append("{");
                            jsonBuilder.AppendFormat("\"id\":\"{0}\"", item.CategoryID);
                            jsonBuilder.AppendFormat(",\"text\":\"{0}\"", item.CategoryName);
                            jsonBuilder.Append(",\"state\":\"closed\"");
                            jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");
                            jsonBuilder.AppendFormat(",\"children\":");
                            jsonBuilder.Append("[");
                            #region 权限菜单

                            List <Privilege> Privileges = p.Client.GetPrivilegesByCategoryID(SenderUser, item.CategoryID).Where(t => !t.IsDisabled).ToList();

                            for (int i = 0; i < Privileges.Count; i++)
                            {
                                Privilege itemPrivilege = Privileges[i];
                                //if (itemPrivilege.IsDisabled)
                                //{
                                //    continue;
                                //}
                                jsonBuilder.Append("{");
                                jsonBuilder.AppendFormat("\"id\":\"{0}\"", itemPrivilege.PrivilegeID);
                                jsonBuilder.AppendFormat(",\"text\":\"{0}\"", itemPrivilege.PrivilegeName);
                                jsonBuilder.Append(",\"state\":\"closed\"");
                                jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"1\"}");
                                #region 权限项
                                //是否权限项
                                List <PrivilegeItem> listPrivilegeItem = p.Client.GetPrivilegeItemByPrivilegeID(SenderUser, itemPrivilege.PrivilegeID);
                                if (listPrivilegeItem != null)
                                {
                                    jsonBuilder.AppendFormat(",\"children\":");
                                    jsonBuilder.Append("[");
                                    for (int j = 0; j < listPrivilegeItem.Count; j++)
                                    {
                                        PrivilegeItem itemPrivilegeItem = listPrivilegeItem[j];
                                        jsonBuilder.Append("{");
                                        jsonBuilder.AppendFormat("\"id\":\"{0}\"", itemPrivilegeItem.PrivilegeItemID);
                                        jsonBuilder.AppendFormat(",\"text\":\"{0}\"", itemPrivilegeItem.PrivilegeItemName);
                                        if (PrivilegeItems.Find(pl => pl.PrivilegeItemID == itemPrivilegeItem.PrivilegeItemID) != null)
                                        {
                                            jsonBuilder.AppendFormat(",\"checked\":\"{0}\"", true);
                                        }
                                        jsonBuilder.Append(",\"attributes\":{\"IsMenu\":\"0\"}");
                                        jsonBuilder.Append("}");
                                        if (j < listPrivilegeItem.Count - 1)
                                        {
                                            jsonBuilder.Append(",");
                                        }
                                    }
                                    jsonBuilder.Append("]");
                                }

                                #endregion
                                jsonBuilder.Append("}");
                                if (i < Privileges.Count - 1)
                                {
                                    jsonBuilder.Append(",");
                                }
                            }
                            #endregion
                            jsonBuilder.Append("]");
                            jsonBuilder.Append("}");
                        }
                        jsonBuilder.Append("]");
                        jsonBuilder.Append("}]");
                        Response.Write(jsonBuilder.ToString());
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }