Exemplo n.º 1
0
        /// <summary>
        /// 根据操作员取组织树(是否需要权限 WeChatId判断)
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public List <OrganizeModel> GetOrgTree(long UserId)
        {
            List <OrganizeModel> trees = new List <OrganizeModel>();

            List <Int64> PHIDs1 = new List <Int64>();//存有权限的组织phid

            Dictionary <string, object> dic_userorg = new Dictionary <string, object>();

            new CreateCriteria(dic_userorg)
            .Add(ORMRestrictions <Int64> .Eq("UserId", UserId));
            //IList<UserOrganize2Model> userOrganize2s = UserOrgRule.Find(dic_userorg);
            List <long> PHIDs2 = UserOrgRule.Find(dic_userorg).ToList().Select(x => x.OrgId).Distinct().ToList();

            Dictionary <string, object> dic_sb = new Dictionary <string, object>();

            new CreateCriteria(dic_sb).
            Add(ORMRestrictions <string> .Eq("Dylx", "SB"));
            List <Int64> PHIDs3 = CorrespondenceSettings2Rule.Find(dic_sb).ToList().Select(x => long.Parse(x.DefStr2)).Distinct().ToList();

            /*if (PHIDs1.Count > 0)
             * {
             *  for (var i = 0; i < PHIDs1.Count; i++)
             *  {
             *      if (!PHIDs2.Contains(PHIDs1[i]))
             *      {
             *          PHIDs1.Remove(PHIDs1[i]);
             *      }
             *  }
             * }*/
            PHIDs1 = PHIDs3.Intersect(PHIDs2).ToList();



            Dictionary <string, object> dic = new Dictionary <string, object>();

            new CreateCriteria(dic)
            .Add(ORMRestrictions <String> .Eq("RelatId", "lg"))
            .Add(ORMRestrictions <Int64> .Eq("ParentOrgId", 0));
            IList <OrgRelatitem2Model> orgRelatitems = OrgRelatitem2Rule.Find(dic, new string[] { "RelId Asc" });

            if (orgRelatitems.Count > 0)
            {
                for (var i = 0; i < orgRelatitems.Count; i++)
                {
                    OrganizeModel tree = OrganizationRule.Find(orgRelatitems[i].OrgId);
                    if (tree.IfCorp == "Y" && tree.IsActive == "1") //筛选组织
                    {
                        if (!PHIDs1.Contains(tree.PhId))
                        {
                            tree.WeChatId = "false";//用于判断是否没有权限
                        }
                        GetChild(tree, PHIDs1);

                        trees.Add(tree);
                    }
                }
            }
            return(trees);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据操作员取申报单位
        /// </summary>
        /// <param name="USERID"></param>
        /// <returns></returns>
        public IList <OrganizeModel> GetSBUnit(long USERID)
        {
            //SELECT DISTINCT fg3_userorg.ORGID FROM fg3_userorg WHERE USERID=488181024000001
            List <Int64> PHIDs1 = new List <Int64>();
            List <Int64> PHIDs2 = new List <Int64>();
            Dictionary <string, object> dic_userorg = new Dictionary <string, object>();

            new CreateCriteria(dic_userorg)
            .Add(ORMRestrictions <Int64> .Eq("UserId", USERID));
            IList <UserOrganize2Model> userOrganize2s = UserOrgRule.Find(dic_userorg);

            if (userOrganize2s.Count > 0)
            {
                for (var i = 0; i < userOrganize2s.Count; i++)
                {
                    if (!PHIDs1.Contains(userOrganize2s[i].OrgId))
                    {
                        PHIDs1.Add(userOrganize2s[i].OrgId);
                    }
                }
            }

            Dictionary <string, object> dic_Corr2 = new Dictionary <string, object>();

            new CreateCriteria(dic_Corr2)
            .Add(ORMRestrictions <String> .Eq("Dylx", "SB"));
            IList <CorrespondenceSettings2Model> correspondenceSettings2 = CorrespondenceSettings2Rule.Find(dic_Corr2);

            if (correspondenceSettings2.Count > 0)
            {
                for (var i = 0; i < correspondenceSettings2.Count; i++)
                {
                    if (!PHIDs2.Contains(long.Parse(correspondenceSettings2[i].DefStr2)))
                    {
                        PHIDs2.Add(long.Parse(correspondenceSettings2[i].DefStr2));
                    }
                }
            }
            List <Int64> phid3 = PHIDs1.Intersect(PHIDs2).ToList();
            Dictionary <string, object> dic_org = new Dictionary <string, object>();

            new CreateCriteria(dic_org)
            .Add(ORMRestrictions <String> .Eq("IfCorp", "Y"))
            .Add(ORMRestrictions <String> .Eq("IsActive", "1"))
            .Add(ORMRestrictions <List <Int64> > .In("PhId", phid3));
            IList <OrganizeModel> organizes = OrganizationRule.Find(dic_org, new string[] { "OCode" });

            return(organizes);
        }