示例#1
0
        public PM_ALT_NOTI getAgentByAlertID()
        {
            try
            {
                IList <PM_ALT_NOTI> list = new List <PM_ALT_NOTI>();

                list = pm_ALT_NOTIBO.GetEntityByAlertID(alertID);
                if (list.Count > 0)
                {
                    return(list[0]);
                }
                // Guid guid= (Guid)list[0].AgentGuid;
                return(null);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// 拼装树结构
        /// </summary>
        /// <param name="nodelist">组</param>
        /// <param name="userList">人</param>
        /// <returns></returns>
        public IList <CV_DEPARTMENT_ROOT_QuaryParam> GetTree(IList <CV_PM_WECHAT_DEPARTMENT> deptlist, Guid alertID)
        {
            //所有部门
            allDepts = DepToQuaryParam2(deptlist); //转换一下

            //user被选中项
            if (listNoti == null || listNoti.Count == 0)
            {
                listNoti = pm_ALT_NOTIBO.GetEntityByAlertID(alertID);
                foreach (PM_ALT_NOTI noti in listNoti)
                {
                    if (string.IsNullOrEmpty(strNotiGuids))
                    {
                        strNotiGuids = noti.UserGuid.ToString();
                    }
                    else
                    {
                        strNotiGuids = strNotiGuids + "," + noti.UserGuid.ToString();
                    }
                }
            }

            //所有用户
            if (allUsers == null || allUsers.Count == 0)
            {
                //allUsers = cv_PM_WECHAT_USER_DEPARTMENTBO.GetEntities();

                string strUser = @"SELECT usrDept.UserGuid,usrDept.UserID,usrDept.Name,usrDept.EnglishName,DepartmentGuid,DepartmentID,DepartmentName,
                CASE WHEN ISNULL(noti.UserID,'')='' THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END AS IsLeader --借用此字段【是否选中】
                FROM CV_PM_WECHAT_USER_DEPARTMENT usrDept 
                LEFT JOIN CV_PM_ALT_NOTI noti ON usrDept.UserGuid=noti.UserGuid AND  noti.AlertID = '{0}'
                WHERE 1=1 ";
                strUser = string.Format(strUser, alertID);
                DataTable dt = alt_BSC_BO.GetDataTableBySql(strUser);
                ModelHandler <CV_PM_WECHAT_USER_DEPARTMENT> model = new ModelHandler <CV_PM_WECHAT_USER_DEPARTMENT>();
                allUsers = model.FillModel(dt);

                allUserQPList = UserToQuaryParam(allUsers);
            }

            IList <CV_DEPARTMENT_ROOT_QuaryParam> rootList  = new List <CV_DEPARTMENT_ROOT_QuaryParam>();
            IList <CV_DEPARTMENT_QuaryParam>      childList = new List <CV_DEPARTMENT_QuaryParam>();

            //IList<CV_USER_DEPARTMENT_QuaryParam> userListByDepid = new List<CV_USER_DEPARTMENT_QuaryParam>();
            //IList<CV_DEPARTMENT_QuaryParam> userlistbyid = new List<CV_DEPARTMENT_QuaryParam>();
            for (int i = 0; i < allDepts.Count; i++)
            {
                if (allDepts[i].ParentID == "0") //根节点,Holley
                //if (allDepts[i].Name == "家电事业部") //根节点,Aux
                {
                    //根节点(组)
                    //rootList.Add(nodeList2[i]);
                    //string ID = nodeList2[i].ID.ToString();

                    CV_DEPARTMENT_ROOT_QuaryParam root = allDepts[i];
                    root.expand = true;
                    rootList.Add(root);

                    //子节点(组)
                    childList = GetChildList(rootList[0], alertID);
                    break;
                }
            }

            return(rootList);
        }