public void RefreshData() { var votedata = new VoteDAO().GetAllVoteData(cbxPosition.SelectedItem.ToString()); dgvAuditTral.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dgvAuditTral.DataSource = votedata; }
/// <summary> /// 删除会议时使用 /// </summary> /// <param name="agendaID"></param> /// <returns></returns> public Status deleteAll(int agendaID) { Dictionary <string, object> wherelist = new Dictionary <string, object>(); VoteDAO voteDao = Factory.getInstance <VoteDAO>(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); wherelist.Add("agendaID", agendaID); var voteVolist = voteDao.getAll <VoteVO>(wherelist); if (voteVolist != null) { foreach (var voteVo in voteVolist) { wherelist.Clear(); wherelist.Add("voteID", voteVo.voteID); voteOptionDao.delete(wherelist); } } wherelist.Clear(); wherelist.Add("agendaID", agendaID); voteDao.delete(wherelist);//删除表决 return(Status.SUCCESS); }
public void SetUp() { session = HibernateSession.SessionFactory().OpenSession(); voteDao = new VoteDAO(session); songDao = new SongDAO(session); bandDao = new BandDAO(session); }
public Status deleteMultipe(List <int> votes) { if (votes == null || votes.Count == 0) { return(Status.SUCCESS); } VoteDAO voteDao = Factory.getInstance <VoteDAO>(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); AgendaDAO agendaDao = Factory.getInstance <AgendaDAO>(); Dictionary <string, object> wherelist = new Dictionary <string, object>(); foreach (int voteID in votes) { //获取表决信息 VoteVO voteVo = voteDao.getOne <VoteVO>(voteID); if (voteVo == null) { continue; } //判断投票是否未开启,如果 不是”未开启“,直接退出 if (!IsNotOpen_Vote(voteVo.voteStatus)) { return(Status.FAILURE); } //获取议程信息 AgendaVO agendaVo = agendaDao.getOne <AgendaVO>(voteVo.agendaID); if (agendaVo == null) { continue; } //初始化会场操作 meeting_initOperator(agendaVo.meetingID); //判断会议是否 未开启,如果 不是”未开启“,直接退出 if (!meeting_isNotOpen()) { return(Status.FAILURE); } //删除选项 wherelist.Clear(); wherelist.Add("voteID", voteID); voteOptionDao.delete(wherelist); //更新其他投票的序号信息 voteDao.updateIndex(voteVo.agendaID, voteVo.voteIndex); //删除当前投票 voteDao.delete(voteVo.voteID); } return(Status.SUCCESS); }
public Status getAll(int agendaID, out List <VoteInfo> votes) { votes = new List <VoteInfo>(); Dictionary <string, object> wherelist = new Dictionary <string, object>(); VoteDAO voteDao = Factory.getInstance <VoteDAO>(); wherelist.Add("agendaID", agendaID); List <VoteVO> voteVolist = voteDao.getAll <VoteVO>(wherelist); if (voteVolist == null) { return(Status.NONFOUND); } foreach (VoteVO voteVo in voteVolist) { wherelist.Clear(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); wherelist.Add("voteID", voteVo.voteID); List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist); List <String> optionList = new List <string>(); if (voteOptionVolist != null) { //将选项按序号排序 voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex); foreach (VoteOptionVO voteOptionVo in voteOptionVolist) { optionList.Add(voteOptionVo.voteOptionName); } } votes.Add( new VoteInfo { voteID = voteVo.voteID, voteName = voteVo.voteName, voteDescription = voteVo.voteDescription, voteType = voteVo.voteType, optionNum = optionList.Count, options = optionList }); } return(Status.SUCCESS); }
public Status getOne(int voteID, out VoteInfo vote) { vote = new VoteInfo(); try { Dictionary <string, object> wherelist = new Dictionary <string, object>(); VoteDAO voteDao = Factory.getInstance <VoteDAO>(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); VoteVO voteVo = voteDao.getOne <VoteVO>(voteID); if (voteVo == null) { return(Status.NONFOUND); } //获取表决选项列表 List <string> voteOptions = new List <string>(); wherelist.Add("voteID", voteID); List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist); //将选项按序号排序 voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex); //填充返回列表 if (voteOptionVolist != null) { foreach (VoteOptionVO voteOptionVo in voteOptionVolist) { voteOptions.Add(voteOptionVo.voteOptionName); } } vote.agendaID = voteVo.agendaID; vote.voteID = voteVo.voteID; vote.voteName = voteVo.voteName; vote.voteDescription = voteVo.voteDescription; vote.voteType = voteVo.voteType; vote.optionNum = voteOptions.Count; vote.options = voteOptions; return(Status.SUCCESS); } catch (Exception e) { Log.LogInfo("为更新获取表决信息", e); return(Status.SERVER_EXCEPTION); } }
public Status create(CreateVote vote) { //修正字符串 vote.voteName = vote.voteName.Trim(); vote.voteDescription = vote.voteDescription.Trim(); //检查参数格式 if (!checkFormat(vote.voteOptions)) { return(Status.FORMAT_ERROR); } //验证当前用户的更新当前会议权限 AgendaDAO agendaDao = Factory.getInstance <AgendaDAO>(); AgendaVO agendaVo = agendaDao.getOne <AgendaVO>(vote.agendaID); if (agendaVo == null) { return(Status.FAILURE); } //初始化会议操作 meeting_initOperator(agendaVo.meetingID); bool isUpdate = false; //判断会议是否开启,如果开启,更新"更新状态”,设置数据更新状态 if (meeting_isOpening()) { meeting_updatevote(); isUpdate = true; } else if (meeting_isOpended())//如果会议已结束,直接退出 { return(Status.FAILURE); } Dictionary <string, object> wherelist = new Dictionary <string, object>(); // 插入投票 VoteDAO voteDao = Factory.getInstance <VoteDAO>(); wherelist.Clear(); wherelist.Add("agendaID", vote.agendaID); List <VoteVO> voteVolist = voteDao.getAll <VoteVO>(wherelist); //设置新的投票编号 int voteIndex = voteVolist == null ? 1 : voteVolist.Count + 1; // 先获取新的ID int newVoteID = VoteDAO.getID(); if (voteDao.insert <VoteVO>( new VoteVO { voteID = newVoteID, voteIndex = voteIndex, voteName = vote.voteName, voteDescription = vote.voteDescription, voteType = vote.voteType, voteStatus = 0, // 未开 agendaID = vote.agendaID, isUpdate = isUpdate }) < 0) { return(Status.FAILURE); } // 插入投票选项列表 int index = 1; VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); if (vote.voteOptions != null) { HashSet <string> hs = new HashSet <string>(vote.voteOptions); foreach (string voteOption in hs) { if (voteOptionDao.insert <VoteOptionVO>( new VoteOptionVO { voteOptionID = VoteOptionDAO.getID(), voteOptionName = voteOption, voteOptionIndex = index, voteID = newVoteID }) < 0) { return(Status.FAILURE); } ++index; } } return(Status.SUCCESS); }
public Status update(UpdateVote vote) { VoteDAO voteDao = Factory.getInstance <VoteDAO>(); VoteVO voteVo = voteDao.getOne <VoteVO>(vote.voteID); if (voteVo == null) { return(Status.NONFOUND); } //修正字符串 vote.voteName = vote.voteName.Trim(); vote.voteDescription = vote.voteDescription.Trim(); //检查参数格式 if (!checkFormat(vote.voteOptions)) { return(Status.FORMAT_ERROR); } AgendaDAO agendaDao = Factory.getInstance <AgendaDAO>(); AgendaVO agendaVo = agendaDao.getOne <AgendaVO>(voteVo.agendaID); if (agendaVo == null) { return(Status.FAILURE); } //初始化会议操作 meeting_initOperator(agendaVo.meetingID); //判断会议是否开启,如果正在开启,直接退出 if (meeting_isOpening()) { return(Status.MEETING_OPENING); } else if (meeting_isOpended())//如果会议已结束,直接退出 { return(Status.FAILURE); } // 更新vote Dictionary <string, object> wherelist = new Dictionary <string, object>(); wherelist.Add("voteName", vote.voteName); wherelist.Add("voteDescription", vote.voteDescription); wherelist.Add("voteType", vote.voteType); if (voteDao.update(wherelist, vote.voteID) < 0) { return(Status.FAILURE); } // 清空投票选项列表 VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); Dictionary <string, object> wherelist1 = new Dictionary <string, object>(); wherelist1.Add("voteID", vote.voteID); voteOptionDao.delete(wherelist1); // 重写投票选项列表 int index = 1; if (vote.voteOptions != null) { HashSet <string> hs = new HashSet <string>(vote.voteOptions); foreach (string voteOption in hs) { int newVoteOptionID = VoteOptionDAO.getID(); if (voteOptionDao.insert <VoteOptionVO>( new VoteOptionVO { voteOptionID = newVoteOptionID, voteOptionName = voteOption, voteOptionIndex = index, voteID = vote.voteID }) < 0) { return(Status.FAILURE); } ++index; } } return(Status.SUCCESS); }
/// <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("测试数据初始化结束"); }
/// <summary> /// 此函数必须单独运行,同时停止其他持有数据库的程序的运行, /// 防止其他程序对数据库主键产生冲突。 /// 初始化过程,表中主键ID为人为直接制定 /// </summary> static void reset() { //================== #region 除所有数据 Queue <String> tableNames = new Queue <string>(); tableNames.Enqueue("person_role"); tableNames.Enqueue("role_permission"); tableNames.Enqueue("role"); tableNames.Enqueue("permission"); tableNames.Enqueue("voteOptionPersonResult"); tableNames.Enqueue("voteOption"); tableNames.Enqueue("vote"); tableNames.Enqueue("file"); tableNames.Enqueue("agenda"); tableNames.Enqueue("delegate"); tableNames.Enqueue("meeting"); tableNames.Enqueue("meetingPlace"); tableNames.Enqueue("person"); tableNames.Enqueue("device"); tableNames.Enqueue("person"); while (tableNames.Count != 0) { //删除数据库数据,不使用DAO string commandText = "delete from " + tableNames.Dequeue() + ";"; DBFactory.GetInstance().ExecuteNonQuery(commandText, null); } #endregion ///////////////////////////////////////////////////////////////////////// #region 初始化数据库表操作对象 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>(); #endregion #region webServer 系统初始化数据 #region 添加超级管理员用户 Console.WriteLine("添加超级管理员用户"); PersonVO admin = new PersonVO(); int adminID = 1;//超级管理员用户ID固定为1 admin.personID = adminID; admin.personName = "超级管理员"; admin.personDepartment = "##"; admin.personJob = "##"; admin.personDescription = "***"; admin.personPassword = "******"; admin.personState = 1; admin.isAdmin = true; Console.WriteLine(personDao.insert <PersonVO>(admin)); #endregion #region 角色、权限 #region 添加系统基本角色 1-超级管理员,2-会议组织者,3-成员 Console.WriteLine("添加系统基本角色"); //系统角色,超级管理员角色ID=1,会议组织者=2,成员=3 int[] roleIDs = new int[3]; roleIDs[0] = 1; roleIDs[1] = 2; roleIDs[2] = 3; List <RoleVO> roles = new List <RoleVO>(); roles.Add(new RoleVO { roleID = roleIDs[0], roleName = "超级管理员", isIntegrant = true }); roles.Add(new RoleVO { roleID = roleIDs[1], roleName = "会议组织者", isIntegrant = true }); roles.Add(new RoleVO { roleID = roleIDs[2], roleName = "成员", isIntegrant = true }); foreach (RoleVO vo in roles) { Console.WriteLine(roleDao.insert <RoleVO>(vo)); } #endregion #region 添加权限(超级管理员角色) Console.WriteLine("添加权限(超级管理员角色)"); List <PermissionVO> permissions_admin = new List <PermissionVO>(); #region 超级管理员角色的权限列表 // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "进入管理员首页", permissionDescription = "Account-Admin" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "查看会场", permissionDescription = "MeetingPlace-GetMeetingPlaces" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加会场", permissionDescription = "MeetingPlace-CreateMeetingPlace" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新前获取会场", permissionDescription = "MeetingPlace-GetMeetingPlaceForUpdate" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新会场", permissionDescription = "MeetingPlace-UpdateMeetingPlace" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新会场状态", permissionDescription = "MeetingPlace-UpdateMeetingPlaceAvailable" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "查看设备", permissionDescription = "Device-GetDevices" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加设备", permissionDescription = "Device-CreateDevice" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新前获取设备", permissionDescription = "Device-GetDeviceForUpdate" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新设备", permissionDescription = "Device-UpdateDevice" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新设备状态", permissionDescription = "Device-UpdateDeviceAvailable" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "查看用户", permissionDescription = "User-GetUsers" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加用户", permissionDescription = "User-CreateUser" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新前获取用户", permissionDescription = "User-GetUserForUpdate" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新用户", permissionDescription = "User-UpdateUser" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "更新用户状态", permissionDescription = "User-UpdateUserAvailable" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "导入用户信息", permissionDescription = "User-Upload" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "查看权限", permissionDescription = "Role-GetPermissions" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "查看角色", permissionDescription = "Role-GetRoles" }); // permissions_admin.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "创建角色", permissionDescription = "Role-CreateRole" }); foreach (PermissionVO vo in permissions_admin) { Console.WriteLine(permissionDao.insert <PermissionVO>(vo)); } #endregion #region 建立超级管理员角色与权限关联 Console.WriteLine("建立超级管理员角色与权限关联"); //管理员角色、权限 List <Role_PermissionVO> role_permissions_admin = new System.Collections.Generic.List <Role_PermissionVO>(); foreach (PermissionVO permissionVo in permissions_admin) { role_permissions_admin.Add( new Role_PermissionVO { role_permissionID = Role_PermissionDAO.getID(), roleID = roleIDs[0], permissionID = permissionVo.permissionID }); } foreach (Role_PermissionVO vo in role_permissions_admin) { Console.WriteLine(role_permissionDao.insert <Role_PermissionVO>(vo)); } #endregion #endregion #region 添加权限(组织者角色) Console.WriteLine("建立权限(组织者角色)"); List <PermissionVO> permissions_org = new List <PermissionVO>(); #region 组织者角色的权限列表 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "进入组织者首页", permissionDescription = "Account-Organizor" }); #region 会议 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "展示会议", permissionDescription = "Meeting-Show_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加会议", permissionDescription = "Meeting-Add_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "编辑会议", permissionDescription = "Meeting-Edit_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "删除会议", permissionDescription = "Meeting-Delete_organizor" }); #endregion ///================================================= #region 参会人员 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "参会人员首页", permissionDescription = "Delegate-Index_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "编辑参会人员", permissionDescription = "Delegate-Edit_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加参会人员", permissionDescription = "Delegate-Add_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "删除参会人员", permissionDescription = "Delegate-Delete_organizor" }); #endregion //=========================================== #region 议程 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "议程首页", permissionDescription = "Agenda-Index_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加议程", permissionDescription = "Agenda-Add_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "编辑议程", permissionDescription = "Agenda-Edit_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "删除议程", permissionDescription = "Agenda-Delete_organizor" }); #endregion //=========================================== #region 附件 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "附件首页", permissionDescription = "Document-Index_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "上传附件", permissionDescription = "Document-Add_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "转换附件", permissionDescription = "Document-StartConvert" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "下载附件", permissionDescription = "Document-Download" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "删除附件", permissionDescription = "Document-Delete_organizor" }); #endregion //================================================ #region 表决 // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "表决首页", permissionDescription = "Vote-Index_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "添加表决", permissionDescription = "Vote-Add_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "编辑表决", permissionDescription = "Vote-Edit_organizor" }); // permissions_org.Add( new PermissionVO { permissionID = PermissionDAO.getID(), permissionName = "删除表决", permissionDescription = "Vote-Delete_organizor" }); #endregion foreach (PermissionVO vo in permissions_org) { Console.WriteLine(permissionDao.insert <PermissionVO>(vo)); } #endregion //============================================== #region 组织者角色与权限关联 Console.WriteLine("建立组织者角色与权限关联"); //组织者角色、权限 List <Role_PermissionVO> role_permissions_org = new System.Collections.Generic.List <Role_PermissionVO>(); foreach (PermissionVO permissionVo in permissions_org) { role_permissions_org.Add( new Role_PermissionVO { role_permissionID = Role_PermissionDAO.getID(), roleID = roleIDs[1], permissionID = permissionVo.permissionID }); } foreach (Role_PermissionVO vo in role_permissions_org) { Console.WriteLine(role_permissionDao.insert <Role_PermissionVO>(vo)); } #endregion #endregion #region 超级管理员用户与超级管理员角色关联 Console.WriteLine("建立超级管理员用户与超级管理员角色关联"); int person_roleID = Person_RoleDAO.getID(); Person_RoleVO adminPR = new Person_RoleVO { person_roleID = person_roleID, personID = adminID, roleID = roleIDs[0] }; Console.WriteLine(person_roleDao.insert <Person_RoleVO>(adminPR)); #endregion #endregion #endregion }