示例#1
0
        /// <summary>
        /// 创建参会人员
        /// </summary>
        /// <param name="createDelegate"></param>
        /// <returns></returns>
        public Status create(CreateDelegate createDelegate)
        {
            //初始化会议操作
            meeting_initOperator(createDelegate.meetingID);

            bool isUpdate = false;

            //判断会议是否开启,如果正在开启,更新“参会人员更新状态”,数据设置”更新“状态
            if (meeting_isOpening())
            {
                meeting_updateDelegate();
                isUpdate = true;
            }
            else if (meeting_isOpended())//如果会议已结束,直接退出
            {
                return(Status.FAILURE);
            }

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

            //验证同名参会人员是否存在
            wherelist.Clear();
            wherelist.Add("meetingID", createDelegate.meetingID);
            wherelist.Add("deviceID", createDelegate.deviceID);
            wherelist.Add("personID", createDelegate.userID);
            if (!unique <DelegateDAO, DelegateVO>(wherelist))
            {
                return(Status.NAME_EXIST);
            }

            DelegateDAO delegateDao = Factory.getInstance <DelegateDAO>();

            int delegateID = DelegateDAO.getID();

            if (delegateDao.insert <DelegateVO>(
                    new DelegateVO
            {
                delegateID = delegateID,
                personID = createDelegate.userID,
                deviceID = createDelegate.deviceID,
                meetingID = createDelegate.meetingID,
                personMeetingRole = createDelegate.userMeetingRole,
                isSignIn = false,
                isUpdate = isUpdate     //判断是否属于会议中新加入的信息
            }) < 0)
            {
                return(Status.FAILURE);
            }

            return(Status.SUCCESS);
        }
示例#2
0
        /// <summary>
        /// 同时创建多个参会人员
        /// </summary>
        /// <returns></returns>
        public Status createMultiple(List <DeviceForDelegate> devices, int meetingID, CreateDelegateForMeeting delegates)
        {
            if (delegates == null)
            {
                return(Status.SUCCESS);
            }
            List <int> delegateIDs = new List <int>();

            int tempDelegateID             = 0;
            DeviceForDelegate tempDevice   = null;
            DelegateVO        tempDelegate = null;

            Status status = Status.SUCCESS;

            int delegateNum = 1;

            if (delegates.speakerIDs != null)
            {
                if (delegates.speakerIDs.Contains(delegates.hostID))
                {
                    delegates.speakerIDs.Remove(delegates.hostID);
                }
                delegateNum += delegates.speakerIDs.Count;
            }
            if (delegates.otherIDs != null)
            {
                if (delegates.otherIDs.Contains(delegates.hostID))
                {
                    delegates.otherIDs.Remove(delegates.hostID);
                }
                delegateNum += delegates.otherIDs.Count;
            }

            DelegateDAO delegateDao = Factory.getInstance <DelegateDAO>();
            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            do
            {
                //如果设备数量不足则失败
                if (devices == null || devices.Count < delegateNum)
                {
                    status = Status.DEVICE_LACK;
                    break;
                }

                //添加主持人
                tempDelegateID = DelegateDAO.getID();
                tempDevice     = devices[0];
                devices.Remove(tempDevice);

                //验证同名参会人员是否存在
                wherelist.Clear();
                wherelist.Add("meetingID", meetingID);
                wherelist.Add("personID", delegates.hostID);
                if (!unique <DelegateDAO, DelegateVO>(wherelist))
                {
                    return(Status.NAME_EXIST);
                }

                tempDelegate = new DelegateVO
                {
                    delegateID        = tempDelegateID,
                    deviceID          = tempDevice.deviceID,
                    meetingID         = meetingID,
                    personID          = delegates.hostID,
                    isSignIn          = false,
                    isUpdate          = false,
                    personMeetingRole = 1
                };
                if (delegateDao.insert <DelegateVO>(tempDelegate) < 0)
                {
                    status = Status.DATABASE_OPERATOR_ERROR;
                    break;
                }
                else
                {
                    delegateIDs.Add(tempDelegateID);
                }

                //添加主讲人
                if (delegates.speakerIDs != null)
                {
                    foreach (var speakerID in delegates.speakerIDs)
                    {
                        tempDelegateID = DelegateDAO.getID();
                        tempDevice     = devices[0];
                        devices.Remove(tempDevice);

                        //验证同名参会人员是否存在
                        wherelist.Clear();
                        wherelist.Add("meetingID", meetingID);
                        wherelist.Add("personID", speakerID);
                        if (!unique <DelegateDAO, DelegateVO>(wherelist))
                        {
                            continue;
                        }

                        tempDelegate = new DelegateVO
                        {
                            delegateID        = tempDelegateID,
                            deviceID          = tempDevice.deviceID,
                            meetingID         = meetingID,
                            personID          = speakerID,
                            isSignIn          = false,
                            isUpdate          = false,
                            personMeetingRole = 2
                        };
                        if (delegateDao.insert <DelegateVO>(tempDelegate) < 0)
                        {
                            status = Status.DATABASE_OPERATOR_ERROR;
                            break;
                        }
                        else
                        {
                            delegateIDs.Add(tempDelegateID);
                        }
                    }
                }

                //添加参会人员
                if (delegates.otherIDs != null)
                {
                    foreach (var otherID in delegates.otherIDs)
                    {
                        tempDelegateID = DelegateDAO.getID();
                        tempDevice     = devices[0];
                        devices.Remove(tempDevice);

                        //验证同名参会人员是否存在
                        wherelist.Clear();
                        wherelist.Add("meetingID", meetingID);
                        wherelist.Add("personID", otherID);
                        if (!unique <DelegateDAO, DelegateVO>(wherelist))
                        {
                            continue;
                        }

                        tempDelegate = new DelegateVO
                        {
                            delegateID        = tempDelegateID,
                            deviceID          = tempDevice.deviceID,
                            meetingID         = meetingID,
                            personID          = otherID,
                            isSignIn          = false,
                            isUpdate          = false,
                            personMeetingRole = 0
                        };
                        if (delegateDao.insert <DelegateVO>(tempDelegate) < 0)
                        {
                            status = Status.DATABASE_OPERATOR_ERROR;
                            break;
                        }
                        else
                        {
                            delegateIDs.Add(tempDelegateID);
                        }
                    }
                }
            } while (false);

            if (status != Status.SUCCESS)
            {
                //删除之前添加的参会人员
                foreach (var delegateID in delegateIDs)
                {
                    delegateDao.delete(delegateID);
                }
            }

            return(status);
        }
示例#3
0
        /// <summary>
        /// 须其他程序调用,不能在本程序调用
        /// 添加测试数据
        /// </summary>
        public static void init()
        {
            Log.DebugInfo("测试数据初始化...");

            PersonDAO          personDao          = Factory.getInstance <PersonDAO>();
            RoleDAO            roleDao            = Factory.getInstance <RoleDAO>();
            Person_RoleDAO     person_roleDao     = Factory.getInstance <Person_RoleDAO>();
            PermissionDAO      permissionDao      = Factory.getInstance <PermissionDAO>();
            Role_PermissionDAO role_permissionDao = Factory.getInstance <Role_PermissionDAO>();

            DeviceDAO       deviceDao       = Factory.getInstance <DeviceDAO>();
            MeetingPlaceDAO meetingPlaceDao = Factory.getInstance <MeetingPlaceDAO>();

            MeetingDAO meetingDao = Factory.getInstance <MeetingDAO>();

            DelegateDAO delegateDao = Factory.getInstance <DelegateDAO>();

            AgendaDAO agendaDao = Factory.getInstance <AgendaDAO>();

            FileDAO fileDao = Factory.getInstance <FileDAO>();

            VoteDAO voteDao = Factory.getInstance <VoteDAO>();

            VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>();

            VoteOptionPersonResultDAO voteOptionPersonResultDao = Factory.getInstance <VoteOptionPersonResultDAO>();

            //============================

            voteOptionPersonResultDao.deleteAll_test("voteOptionPersonResult");
            voteOptionDao.deleteAll_test("voteOption");
            voteDao.deleteAll_test("vote");
            fileDao.deleteAll_test("file");
            agendaDao.deleteAll_test("agenda");
            delegateDao.deleteAll_test("delegate");
            meetingDao.deleteAll_test("meeting");

            deviceDao.deleteAll_test("device");
            meetingPlaceDao.deleteAll_test("meetingPlace");

            person_roleDao.deleteAll();
            personDao.deleteAll();

            #region 会议测试数据
            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            Dictionary <string, DeviceVO> devices = new Dictionary <String, DeviceVO>();
            int      deviceNum = 4;
            int[]    deviceIDs = new int[deviceNum];
            string[] IMEIs     = new string[deviceNum];
            for (int i = 0; i < deviceNum; i++)
            {
                deviceIDs[i] = DeviceDAO.getID();
            }
            IMEIs[0] = "862823023300520";
            IMEIs[1] = "862823023301916";
            IMEIs[2] = "359365002515686";
            IMEIs[3] = "862823023300546";

            for (int i = 0; i < deviceNum; i++)
            {
                devices.Add(IMEIs[i],
                            new DeviceVO
                {
                    deviceID    = deviceIDs[i],
                    IMEI        = IMEIs[i],
                    deviceIndex = i + 1,
                    deviceState = 0
                });
            }

            Console.WriteLine("添加设备");

            for (int i = 0; i < devices.Count; i++)
            {
                wherelist.Clear();
                wherelist.Add("IMEI", IMEIs[i]);
                DeviceVO tempVo = deviceDao.getOne <DeviceVO>(wherelist);
                if (tempVo != null)
                {
                    devices[IMEIs[i]] = tempVo;
                    deviceIDs[i]      = tempVo.deviceID;
                    continue;
                }
                Console.WriteLine(deviceDao.insert <DeviceVO>(devices[IMEIs[i]]));
            }



            Dictionary <String, MeetingPlaceVO> meetingPlaces = new Dictionary <string, MeetingPlaceVO>();

            int   meetingPlaceNum = 2;
            int[] meetingPlaceIDs = new int[meetingPlaceNum];

            string[] meetingPlaceNames = new string[meetingPlaceNum];
            for (int i = 0; i < meetingPlaceNum; i++)
            {
                meetingPlaceIDs[i] = MeetingPlaceDAO.getID();
            }
            meetingPlaceNames[0] = "学术会议室";
            meetingPlaceNames[1] = "决策室";

            for (int i = 0; i < meetingPlaceNum; i++)
            {
                meetingPlaces.Add(meetingPlaceNames[i],
                                  new MeetingPlaceVO
                {
                    meetingPlaceID       = meetingPlaceIDs[i],
                    meetingPlaceName     = meetingPlaceNames[i],
                    meetingPlaceCapacity = 200,
                    meetingPlaceState    = 0,
                    seatType             = 0
                });
            }

            //////////////////////////////////
            Console.WriteLine("添加会场及对应的会场类型");
            for (int i = 0; i < meetingPlaceNum; i++)
            {
                Console.WriteLine(meetingPlaceDao.insert <MeetingPlaceVO>(meetingPlaces[meetingPlaceNames[i]]));
            }


            int[]    personIDs   = new int[deviceNum];
            string[] personNames = new string[deviceNum];
            Dictionary <string, PersonVO> persons = new Dictionary <string, PersonVO>();
            for (int i = 0; i < deviceNum; i++)
            {
                personIDs[i] = PersonDAO.getID();
            }
            personNames[0] = "张丰";
            personNames[1] = "李志强";
            personNames[2] = "欧阳致远";
            personNames[3] = "杨棠";

            int personIndex = 0;
            persons.Add(personNames[personIndex],
                        new PersonVO
            {
                personID          = personIDs[personIndex],
                personName        = personNames[personIndex],
                personDepartment  = "董事",
                personJob         = "董事长",
                personDescription = "测试",
                personPassword    = "******",
                personState       = 0,
                personLevel       = 1
            });
            personIndex++;
            persons.Add(personNames[personIndex],
                        new PersonVO
            {
                personID          = personIDs[personIndex],
                personName        = personNames[personIndex],
                personDepartment  = "电子商务部",
                personJob         = "股东",
                personDescription = "测试",
                personPassword    = "******",
                personState       = 0,
                personLevel       = 3
            });
            personIndex++;
            persons.Add(personNames[personIndex],
                        new PersonVO
            {
                personID          = personIDs[personIndex],
                personName        = personNames[personIndex],
                personDepartment  = "财务部",
                personJob         = "股东",
                personDescription = "测试",
                personPassword    = "******",
                personState       = 0,
                personLevel       = 4
            });
            personIndex++;
            persons.Add(personNames[personIndex],
                        new PersonVO
            {
                personID          = personIDs[personIndex],
                personName        = personNames[personIndex],
                personDepartment  = "研发一部",
                personJob         = "股东",
                personDescription = "测试",
                personPassword    = "******",
                personState       = 0,
                personLevel       = 2
            });
            personIndex++;

            //////////////////////////////////////
            Console.WriteLine("添加用户");
            for (int i = 0; i < deviceNum; i++)
            {
                wherelist.Clear();
                wherelist.Add("personName", personNames[i]);
                PersonVO tempVo = personDao.getOne <PersonVO>(wherelist);
                if (tempVo != null)
                {
                    persons[personNames[i]] = tempVo;
                    personIDs[i]            = tempVo.personID;
                    continue;
                }
                Console.WriteLine(personDao.insert <PersonVO>(persons[personNames[i]]));
            }

            int[] person_roleIDs = new int[deviceNum];
            for (int i = 0; i < deviceNum; i++)
            {
                person_roleIDs[i] = Person_RoleDAO.getID();
            }

            List <Person_RoleVO> person_roles = new List <Person_RoleVO>();
            //默认为无权限角色:"成员"角色,roleID=3
            for (int i = 0; i < deviceNum; i++)
            {
                if (i == 3)
                {
                    person_roles.Add(new Person_RoleVO {
                        person_roleID = person_roleIDs[i], roleID = 2, personID = personIDs[i]
                    });
                }
                else
                {
                    person_roles.Add(new Person_RoleVO {
                        person_roleID = person_roleIDs[i], roleID = 3, personID = personIDs[i]
                    });
                }
            }
            Console.WriteLine("添加用户角色关联");
            for (int i = 0; i < deviceNum; i++)
            {
                wherelist.Clear();
                wherelist.Add("personID", personIDs[i]);
                Person_RoleVO tempVo = person_roleDao.getOne <Person_RoleVO>(wherelist);
                if (tempVo != null)
                {
                    continue;
                }
                Console.WriteLine(person_roleDao.insert <Person_RoleVO>(person_roles[i]));
            }

            ///////////////////////////////////////
            Console.WriteLine("添加会议");

            int       meetingID = MeetingDAO.getID();
            MeetingVO meeting   = new MeetingVO();
            meeting.meetingID          = meetingID;
            meeting.meetingPlaceID     = meetingPlaceIDs[0];
            meeting.meetingName        = "二零一六年年度股东大会暨股东扩大会议";
            meeting.meetingSummary     = "";
            meeting.meetingStatus      = 1;
            meeting.meetingStartedTime = (new DateTime(DateTime.Now.AddDays(6).Ticks));
            meeting.meetingToStartTime = (new DateTime(DateTime.Now.AddDays(5).Ticks));
            meeting.meetingDuration    = 150;
            meeting.personID           = 1;

            do
            {
                wherelist.Clear();
                wherelist.Add("meetingName", meeting.meetingName);
                MeetingVO tempVo = meetingDao.getOne <MeetingVO>(wherelist);
                if (tempVo != null)
                {
                    meetingID = tempVo.meetingID;
                    break;
                }
                Console.WriteLine(meetingDao.insert <MeetingVO>(meeting));
            } while (false);

            ////////////////////////////////////////////
            Console.WriteLine("添加参会人员");
            List <DelegateVO> delegates   = new List <DelegateVO>();
            int[]             delegateIDs = new int[deviceNum];

            for (int i = 0; i < deviceNum; i++)
            {
                delegateIDs[i] = DelegateDAO.getID();
            }
            int delegateIndex = 0;
            delegates.Add(
                new DelegateVO
            {
                delegateID        = delegateIDs[delegateIndex],
                deviceID          = deviceIDs[delegateIndex],
                personID          = personIDs[delegateIndex],
                meetingID         = meetingID,
                personMeetingRole = 1,
                isSignIn          = false
            });
            delegateIndex++;
            delegates.Add(
                new DelegateVO
            {
                delegateID        = delegateIDs[delegateIndex],
                deviceID          = deviceIDs[delegateIndex],
                personID          = personIDs[delegateIndex],
                meetingID         = meetingID,
                personMeetingRole = 0,
                isSignIn          = false
            });
            delegateIndex++;
            delegates.Add(
                new DelegateVO
            {
                delegateID        = delegateIDs[delegateIndex],
                deviceID          = deviceIDs[delegateIndex],
                personID          = personIDs[delegateIndex],
                meetingID         = meetingID,
                personMeetingRole = 0,
                isSignIn          = false
            });
            delegateIndex++;
            delegates.Add(
                new DelegateVO
            {
                delegateID        = delegateIDs[delegateIndex],
                deviceID          = deviceIDs[delegateIndex],
                personID          = personIDs[delegateIndex],
                meetingID         = meetingID,
                personMeetingRole = 2,
                isSignIn          = false
            });
            delegateIndex++;
            foreach (DelegateVO vo in delegates)
            {
                Console.WriteLine(delegateDao.insert <DelegateVO>(vo));
            }

            //////////////////////////////////////////
            Console.WriteLine("添加议程");
            int agendaNum = 3;
            Dictionary <int, AgendaVO> agendas = new Dictionary <int, AgendaVO>();
            int[] agendaIDs = new int[agendaNum];
            for (int i = 0; i < agendaNum; i++)
            {
                agendaIDs[i] = AgendaDAO.getID();
            }

            int agendaIndex = 0;
            agendas.Add(agendaIDs[agendaIndex],
                        new AgendaVO
            {
                agendaID       = agendaIDs[agendaIndex],
                agendaIndex    = agendaIndex + 1,
                agendaName     = "普通决议案",
                agendaDuration = 50,
                meetingID      = meetingID,
                personID       = personIDs[3],//主讲人
                isUpdate       = false
            });
            agendaIndex++;
            agendas.Add(agendaIDs[agendaIndex],
                        new AgendaVO
            {
                agendaID       = agendaIDs[agendaIndex],
                agendaIndex    = agendaIndex + 1,
                agendaName     = "具体项目负责人汇报",
                agendaDuration = 50,
                meetingID      = meetingID,
                personID       = personIDs[0],
                isUpdate       = false
            });
            agendaIndex++;
            agendas.Add(agendaIDs[agendaIndex],
                        new AgendaVO
            {
                agendaID       = agendaIDs[agendaIndex],
                agendaIndex    = agendaIndex + 1,
                agendaName     = "特别决议案",
                agendaDuration = 50,
                meetingID      = meetingID,
                personID       = personIDs[0],
                isUpdate       = false
            });
            agendaIndex++;
            for (int i = 0; i < agendaNum; i++)
            {
                Console.WriteLine(agendaDao.insert <AgendaVO>(agendas[agendaIDs[i]]));
            }

            //////////////////////////////////////////
            Console.WriteLine("添加附件");

            //////////////////////////////////////////


            List <VoteVO>       votes        = new List <VoteVO>();
            List <VoteOptionVO> vote1Options = new List <VoteOptionVO>();
            List <VoteOptionVO> vote2Options = new List <VoteOptionVO>();

            int   voteNum = 2;
            int[] voteIDs = new int[voteNum];
            for (int i = 0; i < voteNum; i++)
            {
                voteIDs[i] = VoteDAO.getID();
            }

            int   voteOptionNum  = 4;
            int[] vote1OptionIDs = new int[voteOptionNum];
            int[] vote2OptionIDs = new int[voteOptionNum];
            for (int i = 0; i < 4; i++)
            {
                vote1OptionIDs[i] = VoteOptionDAO.getID();
                vote2OptionIDs[i] = VoteOptionDAO.getID();
            }

            Console.WriteLine("添加表决");
            //表决
            int voteStatus = 0;
            votes.Add(
                new VoteVO
            {
                agendaID        = agendaIDs[2],
                voteID          = voteIDs[0],
                voteName        = "选举董事会成员、监事会成员",
                voteDescription = "选举本公司第二届董事会成员、第二届监事会成员",
                voteIndex       = 1,
                voteStatus      = voteStatus,
                voteType        = 2 //双选
            });

            votes.Add(
                new VoteVO
            {
                agendaID        = agendaIDs[2],
                voteID          = voteIDs[1],
                voteName        = "提请人选的决议",
                voteDescription = "提请公司董事会关于董事长人选的决议",
                voteIndex       = 1,
                voteStatus      = voteStatus,
                voteType        = 1
            });
            vote1Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[0],
                voteOptionID    = vote1OptionIDs[0],
                voteOptionIndex = 0,
                voteOptionName  = "张丰"
            });
            vote1Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[0],
                voteOptionID    = vote1OptionIDs[1],
                voteOptionIndex = 0,
                voteOptionName  = "欧阳致远"
            });
            vote1Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[0],
                voteOptionID    = vote1OptionIDs[2],
                voteOptionIndex = 0,
                voteOptionName  = "杨棠"
            });
            vote1Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[0],
                voteOptionID    = vote1OptionIDs[3],
                voteOptionIndex = 0,
                voteOptionName  = "李志强"
            });

            vote2Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[1],
                voteOptionID    = vote2OptionIDs[0],
                voteOptionIndex = 0,
                voteOptionName  = "张丰"
            });
            vote2Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[1],
                voteOptionID    = vote2OptionIDs[1],
                voteOptionIndex = 0,
                voteOptionName  = "李志强"
            });
            vote2Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[1],
                voteOptionID    = vote2OptionIDs[2],
                voteOptionIndex = 0,
                voteOptionName  = "欧阳致远"
            });
            vote2Options.Add(
                new VoteOptionVO
            {
                voteID          = voteIDs[1],
                voteOptionID    = vote2OptionIDs[3],
                voteOptionIndex = 0,
                voteOptionName  = "杨棠"
            });

            foreach (VoteVO vo in votes)
            {
                Console.WriteLine(voteDao.insert <VoteVO>(vo));
            }

            foreach (VoteOptionVO vo in vote1Options)
            {
                Console.WriteLine(voteOptionDao.insert <VoteOptionVO>(vo));
            }

            foreach (VoteOptionVO vo in vote2Options)
            {
                Console.WriteLine(voteOptionDao.insert <VoteOptionVO>(vo));
            }

            #endregion

            Log.DebugInfo("测试数据初始化结束");
        }