Beispiel #1
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="delegates"></param>
        /// <returns></returns>
        public Status deleteMultipe(List <int> delegates)
        {
            if (delegates == null || delegates.Count == 0)
            {
                return(Status.SUCCESS);
            }

            //用于出错后恢复数据
            var    backup = new List <DelegateVO>();
            Status status = Status.SUCCESS;

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

            foreach (int delegateID in delegates)
            {
                DelegateVO delegateVo = delegateDao.getOne <DelegateVO>(delegateID);
                if (delegateVo == null)
                {
                    status = Status.NONFOUND;
                }

                //初始化会议操作
                meeting_initOperator(delegateVo.meetingID);
                //判断会议是否开启,如果不是”未开启“,直接退出
                if (!meeting_isNotOpen())
                {
                    status = Status.MEETING_OPENING;
                    break;
                }

                Dictionary <string, object> wherelist = new Dictionary <string, object>();
                //检查是否为主讲人,且是否存在主讲的议程,如果存在,直接返回
                wherelist.Clear();
                wherelist.Add("meetingID", delegateVo.meetingID);
                wherelist.Add("personID", delegateVo.personID);
                var tempAgenda = agendaDao.getAll <AgendaVO>(wherelist);
                if (tempAgenda != null && tempAgenda.Count > 0)
                {
                    status = Status.DELEGATE_USED;
                    break;
                }

                backup.Add(delegateVo);
                if (delegateDao.delete(delegateID) < 0)//删除失败就 恢复数据,返回
                {
                    status = Status.FAILURE;
                    break;
                }
            }
            if (status != Status.SUCCESS)
            {
                foreach (var delegateVo in backup)
                {
                    delegateDao.insert <DelegateVO>(delegateVo);
                }
            }
            return(status);
        }
Beispiel #2
0
        /// <summary>
        /// 删除会议时使用
        /// </summary>
        /// <param name="meetingID"></param>
        /// <returns></returns>
        public Status deleteAll(int meetingID)
        {
            Dictionary <string, object> wherelist = new Dictionary <string, object>();
            DelegateDAO delegateDao = Factory.getInstance <DelegateDAO>();

            wherelist.Add("meetingID", meetingID);
            delegateDao.delete(wherelist);
            return(Status.SUCCESS);
        }
Beispiel #3
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);
        }