Exemplo n.º 1
0
        /// <summary>
        /// 获取N个没有中过奖的成员
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <CompanyMember> GetRandomMembers(LuckSetting luckSetting)
        {
            string full = string.Empty;
            List <CompanyMember> listMember = new List <CompanyMember>();

            for (int i = 0; i < luckSetting.count; i++)
            {
                CompanyMember member = GetRandomMember(luckSetting.level);
                if (member == null)
                {
                    continue;
                }
                member.isLuck   = true;
                member.luckName = luckSetting.name;
                full           += member.department + " " + member.name + "\r\n";
                listMember.Add(member);
            }

            //写出结果到本地
            if (Directory.Exists(@".\Result") == false)
            {
                Directory.CreateDirectory(@".\Result");
            }
            File.WriteAllText(@".\Result\" + luckSetting.name + "-" + DateTime.Now.Ticks + ".txt", full);


            return(listMember);
        }
Exemplo n.º 2
0
        public List <CompanyMember> GetRandomMembersForShow(LuckSetting luckSetting)
        {
            List <CompanyMember> listMember = new List <CompanyMember>();

            if (luckSetting.count > m_listMember.Count)
            {
                luckSetting.count = m_listMember.Count;
            }

            while (listMember.Count < luckSetting.count)
            {
                CompanyMember member = GetRandomMember(luckSetting.level);
                if (member == null)
                {
                    continue;
                }
                //member.isLuck = true;
                //member.luckName = luckSetting.name;

                if (listMember.Contains(member) == false)
                {
                    listMember.Add(member);
                }
            }


            return(listMember);
        }