Exemple #1
0
        public IEnumerable <BooksellerView> GetBookseller(string loginName)
        {
            IList <Bookseller> booksellers = new List <Bookseller>();

            if (string.IsNullOrWhiteSpace(loginName))
            {
                booksellers.Add(
                    new Bookseller
                {
                    ID   = Guid.Empty,
                    Name = "你没有权限"
                });
            }
            else
            {
                var user = new TbmisUserAppl(loginName).GetUser();


                if (user.IsInRole("教材科"))
                {
                    booksellers = new BooksellerAppl().GetAll().ToList();
                }
                else
                {
                    booksellers.Add(
                        new Bookseller
                    {
                        ID   = (Guid)user.SchoolId,
                        Name = user.SchoolName
                    });
                }
            }
            return(_adapter.Adapt <BooksellerView>(booksellers));
        }
Exemple #2
0
        /// <summary>
        /// 根据登录名取书商
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable <BooksellerView> GetBooksellerByloginName(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            //跟据书商员工Id取书商Id
            var booksellerStaffs = _booksellerRepo.GetAll().Select(bs => bs.BooksellerStaffs);

            IList <BooksellerView> list = new List <BooksellerView>();

            foreach (var staff in booksellerStaffs)
            {
                var bookseller = staff.SingleOrDefault(s => s.ID == user.TbmisUserId);
                if (bookseller != null)
                {
                    var booksellers = new BooksellerView()
                    {
                        BooksellerId = bookseller.Bookseller_Id.ToString(),
                        Name         = bookseller.Bookseller.Name
                    };
                    list.Add(booksellers);
                }
            }

            return(list);
        }
        public IEnumerable <FeedbackForApprovalView> GetFeedbackWithNotApproval(string loginName, string booksellerId)
        {
            //登录用户
            var user = new TbmisUserAppl(loginName).GetUser();
            //书商ID
            var id = booksellerId.ConvertToGuid();

            IEnumerable <Feedback> feedbacks = new List <Feedback>();

            //如果是教务处或教材科,取全部
            if (user.IsInRole("教务处"))
            {
                var feedback = _repo.Find(t =>
                                          t.ApprovalState == ApprovalState.教务处审核中 &&
                                          t.Subscriptions.FirstOrDefault().Bookseller_Id == id
                                          );
                feedbacks = feedback;
            }
            else if (user.IsInRole("教材科"))
            {
                var feedback = _repo.Find(t =>
                                          t.ApprovalState == ApprovalState.教材科审核中 &&
                                          t.Subscriptions.FirstOrDefault().Bookseller_Id == id
                                          );
                feedbacks = feedback;
            }

            return(_adapter.Adapt <FeedbackForApprovalView>(feedbacks));
        }
        public IEnumerable<BooksellerView> GetBookseller(string loginName)
        {
            IList<Bookseller> booksellers = new List<Bookseller>();
            if (string.IsNullOrWhiteSpace(loginName))
            {
                booksellers.Add(
                    new Bookseller
                    {
                        ID = Guid.Empty,
                        Name = "你没有权限"
                    });
            }
            else
            {
                var user = new TbmisUserAppl(loginName).GetUser();

                if (user.IsInRole("教材科"))
                {
                    booksellers = new BooksellerAppl().GetAll().ToList();
                }
                else
                {
                    booksellers.Add(
                        new Bookseller
                        {
                            ID = (Guid)user.SchoolId,
                            Name = user.SchoolName
                        });
                }
            }
            return _adapter.Adapt<BooksellerView>(booksellers);
        }
Exemple #5
0
        public ResponseView SubmitDeclarationApproval(IEnumerable <DeclarationForApprovalView> declarations, string loginName, string suggestion, string remark)
        {
            //数据类型转换
            var sugg = suggestion.ConvertToBool();
            //审核人姓名与学院
            var user     = new TbmisUserAppl(loginName).GetUser();
            var division = user.SchoolName;
            var auditor  = user.TbmisUserName;

            //CUD仓储
            var repo = ServiceLocator.Current.GetInstance <IDeclarationRepository>();
            //操作响应类
            var result = new ResponseView();

            //处理审核记录
            //foreach (var item in declarations)
            //{
            //    var id = item.DeclarationId.ConvertToInt();
            //    var declaration = repo.First(t => t.DeclarationId == id);
            //    Domain.ApprovalService.CreateApproval<DeclarationApproval>(declaration, division, auditor, sugg, remark);
            //}
            //保存到db
            try
            {
                repo.Context.Commit();
                return(result);
            }
            catch (Exception)
            {
                result.IsSuccess = false;
                result.Message   = "提交审核失败";
                return(result);
            }
        }
        /// <summary>
        /// 根据登录名取学院
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable<School> GetSchoolByLoginName(string loginName)
        {
            //登录名取书商ID
            var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId;
            //取当前学期
            var term = new TermAppl().GetCurrentTerm().SchoolYearTerm;
            //取学生用书申报的ID集合
            var declarations = _repo.First(t =>
                t.ID == booksellerId
                ).Subscriptions.Where(t =>
                    t.SchoolYearTerm.Year == term.Year &&
                    t.SchoolYearTerm.Term == term.Term &&
                    t.FeedbackState == FeedbackState.征订成功 &&
                    t.Feedback.ApprovalState == ApprovalState.终审通过
                    ).SelectMany(t =>
                        t.StudentDeclarations
                        ).Select(t =>
                            t.ID
                            );
            //取学生班级
            var repo = ServiceLocator.Current.GetInstance<IStudentDeclarationRepository>();

            //取学院
            var schools = new List<School>();
            foreach (var item in declarations)
            {
                var schoolsOfDeclaration = repo.GetSchools(item).ToList();
                if (schoolsOfDeclaration.Count > 0)
                    schools.Concat(schoolsOfDeclaration);
            }

            return schools.Distinct();
        }
Exemple #7
0
        public IEnumerable <StorageView> GetByLoginName(string loginName)
        {
            var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId;
            var storages     = _repo.Find(t => t.Bookseller_Id == booksellerId);

            return(_adapter.Adapt <StorageView>(storages));
        }
        /// <summary>
        /// 根据登录名取书商
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable<BooksellerView> GetBooksellerByloginName(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            //跟据书商员工Id取书商Id
            var booksellerStaffs = _booksellerRepo.GetAll().Select(bs => bs.BooksellerStaffs);

            IList<BooksellerView> list = new List<BooksellerView>();

            foreach (var staff in booksellerStaffs)
            {
                var bookseller = staff.SingleOrDefault(s => s.ID == user.TbmisUserId);
                if (bookseller != null)
                {
                    var booksellers = new BooksellerView()
                    {
                        BooksellerId = bookseller.Bookseller_Id.ToString(),
                        Name = bookseller.Bookseller.Name
                    };
                    list.Add(booksellers);
                }
            }

            return list;
        }
        /// <summary>
        /// 获取当前登录用户的书商
        /// </summary>
        /// <returns></returns>
        public Bookseller GetOfUser(string loginName)
        {
            var user       = new TbmisUserAppl(loginName).GetUser();
            var bookseller = _repo.First(t => t.ID == user.TbmisUserId);

            return(bookseller);
        }
        public ResponseView SubmitFeedbackApproval(IEnumerable <FeedbackForApprovalView> feedbacks, string loginName, string suggestion, string remark)
        {
            //审核意见
            var sugg = suggestion.ConvertToBool();
            //审核部门,审核人
            var user     = new TbmisUserAppl(loginName).GetUser();
            var division = user.SchoolName;
            var auditor  = user.TbmisUserName;
            //回告ID
            var ids = feedbacks.Select(t => t.FeedbackId.ConvertToGuid());
            //消息类
            var result = new ResponseView();

            //保存到db
            try
            {
                //处理审核记录
                var backs = _repo.Find(t => ids.Contains(t.ID)).ToList();
                backs.ForEach(t =>
                {
                    Domain.ApprovalService.CreateApproval <FeedbackApproval>(t, division, auditor, sugg, remark);
                });

                _repo.Context.Commit();
            }
            catch (Exception)
            {
                result.IsSuccess = false;
                result.Message   = "提交审核失败";
            }
            return(result);
        }
        public ResponseView SubmitTeacherDeclaration(DeclarationView view)
        {
            //类型转换
            var textId = view.TextbookId.ConvertToGuid();
            var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId;
            var count  = view.DeclarationCount.ConvertToInt();
            //当前学期
            var term = new TermAppl().GetMaxTerm().YearTerm;
            //操作响应类
            var result = new ResponseView();

            try
            {
                ////CUD仓储
                //var repo = ServiceLocator.Current.GetInstance<ITeacherDeclarationRepository>();
                ////创建申报
                //var declaration = Domain.DeclarationService.CreateDeclaration<TeacherDeclaration>(term, view.TeachingTaskNums.First(), textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);
                ////保存
                //repo.Add(declaration);
                ////提交到数据库
                //repo.Context.Commit();
                return(result);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "提交教师用书申报失败";
                return(result);
            }
        }
        public IEnumerable<DeclarationForApprovalView> GetDeclarationWithNotApproval(string loginName, string schoolId)
        {
            //登录用户
            var webUser = new TbmisUserAppl(loginName).GetUser();
            //最大学期
            var term = new TermAppl().GetMaxTerm().YearTerm;
            var id = schoolId.ConvertToGuid();

            IEnumerable<DeclarationJiaoWu> declarations = new List<DeclarationJiaoWu>();

            ////如果是教务处或教材科,取全部
            //if (webUser.IsInRole("教务处"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教务处审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            //else if (webUser.IsInRole("教材科"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教材科审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            ////如果是学院院长,返回所属学院
            //else if (webUser.IsInRole("学院院长"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.学院审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            ////如果是教研室主任,返回所属系教研室未审核记录
            //else if (webUser.IsInRole("教研室主任"))
            //{
            //    //取登录用户所属教研室ID
            //    var ids = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id).Select(t => t.DepartmentId);
            //    //取上述教研室申报的未审核用书
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教研室审核中 &&
            //        ids.Contains(t.TeachingTask.Department.DepartmentId));

            //}
            //结果处理
            if (declarations.Count() > 0)
            {
                return _adapter.Adapt<DeclarationForApprovalView>(declarations);
            }
            else
            {
                return new List<DeclarationForApprovalView>();
            }
        }
Exemple #13
0
        public IEnumerable <DeclarationForApprovalView> GetDeclarationWithNotApproval(string loginName, string schoolId)
        {
            //登录用户
            var webUser = new TbmisUserAppl(loginName).GetUser();
            //最大学期
            var term = new TermAppl().GetMaxTerm().YearTerm;
            var id   = schoolId.ConvertToGuid();

            IEnumerable <DeclarationJiaoWu> declarations = new List <DeclarationJiaoWu>();

            ////如果是教务处或教材科,取全部
            //if (webUser.IsInRole("教务处"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教务处审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            //else if (webUser.IsInRole("教材科"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教材科审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            ////如果是学院院长,返回所属学院
            //else if (webUser.IsInRole("学院院长"))
            //{
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.学院审核中 &&
            //        t.TeachingTask.Department.School_Id == id
            //        );
            //}
            ////如果是教研室主任,返回所属系教研室未审核记录
            //else if (webUser.IsInRole("教研室主任"))
            //{
            //    //取登录用户所属教研室ID
            //    var ids = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id).Select(t => t.DepartmentId);
            //    //取上述教研室申报的未审核用书
            //    declarations = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教研室审核中 &&
            //        ids.Contains(t.TeachingTask.Department.DepartmentId));

            //}
            //结果处理
            if (declarations.Count() > 0)
            {
                return(_adapter.Adapt <DeclarationForApprovalView>(declarations));
            }
            else
            {
                return(new List <DeclarationForApprovalView>());
            }
        }
Exemple #14
0
        /// <summary>
        /// 获取当前登录用户的学院
        /// </summary>
        /// <returns></returns>
        public IEnumerable <School> GetSchoolOfUser(string loginName)
        {
            //取业务用户
            var user = new TbmisUserAppl(loginName).GetUser();

            var schools = _teacherRepo.First(t => t.ID == user.TbmisUserId)
                          .Departments
                          .Select(t => t.School);

            return(schools);
        }
        /// <summary>
        /// 获取当前登录用户的学院
        /// </summary>
        /// <returns></returns>
        public IEnumerable<School> GetSchoolOfUser(string loginName)
        {
            //取业务用户
            var user = new TbmisUserAppl(loginName).GetUser();

            var schools = _teacherRepo.First(t => t.ID == user.TbmisUserId)
                  .Departments
                  .Select(t => t.School);

            return schools;
        }
        /// <summary>
        /// 根据登录名取学院
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable <SchoolView> GetSchoolByloginName(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            //取当前登录用户的学院

            var schoolAppl = new SchoolAppl();
            var school     = schoolAppl.GetSchoolOfUser(loginName);

            return(_adapter.Adapt <SchoolView>(school));
        }
Exemple #17
0
        public IEnumerable <SchoolView> GetSchoolWithNotApproval(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();
            //最大学期
            var term = new TermAppl().GetMaxTerm().YearTerm;

            IList <School> schools = new List <School>();

            ////如果是教务处或教材科,取全部学院
            //if (user.IsInRole("教务处"))
            //{
            //    var school = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教务处审核中
            //        ).Select(t =>
            //            t.TeachingTask.Department.School
            //            ).Distinct();
            //    schools = school.ToList();
            //}
            //else if (user.IsInRole("教材科"))
            //{
            //    var school = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教材科审核中
            //        ).Select(t =>
            //            t.TeachingTask.Department.School
            //            ).Distinct();
            //    schools = school.ToList();
            //}
            ////如果是学院院长,返回所属学院
            //else if (user.IsInRole("学院院长") || user.IsInRole("教研室主任"))
            //{
            //    var school = new School { SchoolId = (Guid)user.SchoolId, Name = user.SchoolName };
            //    schools.Add(school);
            //}
            if (schools.Count > 0)
            {
                return(_adapter.Adapt <SchoolView>(schools));
            }
            else
            {
                IEnumerable <SchoolView> school = new List <SchoolView>
                {
                    new SchoolView {
                        SchoolId = string.Empty, Name = "没有需要审核的学院"
                    }
                };
                return(school);
            }
        }
Exemple #18
0
        public ResponseView SubmitInStock(InventoryView inventory, string instockCount, string loginName)
        {
            var count   = instockCount.ConvertToInt();
            var person  = new TbmisUserAppl(loginName).GetUser().TbmisUserName;
            var inve    = _adapter.Adapt <Inventory>(inventory);
            var inveNew = new Inventory();
            //var inveNew = inve;
            var repo   = ServiceLocator.Current.GetInstance <IInventoryRepository>();
            var result = new ResponseView();

            //是否已存在库存
            if (inve.ID != null && inve.ID != Guid.Empty)
            {
                //取出库存
                inveNew = repo.First(t => t.ID == inve.ID);
                //更新架位号
                inveNew.ShelfNumber = inve.ShelfNumber;
            }
            else
            {
                inveNew = inve;
            }

            //修改库存数量
            inveNew.InventoryCount += count;
            //创建库存异动记录
            InventoryService.CreateStockRecord <InStockRecord>(inveNew, person, count);

            try
            {
                if (inveNew.ID == null || inve.ID == Guid.Empty)
                {
                    repo.Add(inveNew);
                }
                else
                {
                    repo.Modify(inveNew);
                }

                repo.Context.Commit();
                return(result);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "入库操作失败";
                return(result);
            }
        }
Exemple #19
0
        /// <summary>
        /// 根据学院ID,取当前用户所属系教研室
        /// </summary>
        /// <param name="schoolId"></param>
        /// <returns></returns>
        public IEnumerable <Department> GetDepartmentBySchoolId(string loginName, Guid schoolId)
        {
            //取登录用户
            var tbmisUserAppl = new TbmisUserAppl(loginName);
            var user          = tbmisUserAppl.GetUser();

            var departments = _teacherRepo.First(t =>
                                                 t.ID == user.TbmisUserId
                                                 ).Departments
                              .Where(d =>
                                     d.School_Id == schoolId
                                     );

            return(departments);
        }
        /// <summary>
        /// 根据学院ID,取当前用户所属系教研室
        /// </summary>
        /// <param name="schoolId"></param>
        /// <returns></returns>
        public IEnumerable<Department> GetDepartmentBySchoolId(string loginName, Guid schoolId)
        {
            //取登录用户
            var tbmisUserAppl = new TbmisUserAppl(loginName);
            var user = tbmisUserAppl.GetUser();

            var departments = _teacherRepo.First(t =>
                            t.ID == user.TbmisUserId
                            ).Departments
                            .Where(d =>
                                d.School_Id == schoolId
                                );

            return departments;
        }
        public IEnumerable <SchoolView> GetSchoolByLoginName(string loginName)
        {
            var user = new TbmisUserAppl(loginName).GetUser();
            IEnumerable <School> schools = new List <School>();

            //领导,显示全部学院
            if (user.IsInRole("教材科") || user.IsInRole("教务处"))
            {
                schools = new SchoolAppl().GetSchools();
            }
            else
            {
                schools = new SchoolAppl().GetSchoolOfUser(loginName);
            }

            schools = schools.OrderBy(t => t.Name);

            return(_adapter.Adapt <SchoolView>(schools));
        }
        public IEnumerable <BooksellerView> GetBooksellerWithNotApproval(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            IList <Bookseller> booksellers = new List <Bookseller>();

            //如果是教务处或教材科,取全部学院
            if (user.IsInRole("教务处"))
            {
                var bookseller = _repo.Find(t =>
                                            t.ApprovalState == ApprovalState.教务处审核中
                                            ).SelectMany(t =>
                                                         t.Subscriptions
                                                         ).Select(t =>
                                                                  t.Bookseller
                                                                  ).Distinct();
                booksellers = bookseller.ToList();
            }
            else if (user.IsInRole("教材科"))
            {
                var bookseller = _repo.Find(t =>
                                            t.ApprovalState == ApprovalState.教材科审核中
                                            ).SelectMany(t =>
                                                         t.Subscriptions
                                                         ).Select(t =>
                                                                  t.Bookseller
                                                                  ).Distinct();
                booksellers = bookseller.ToList();
            }
            if (booksellers.Count == 0)
            {
                var bookseller = new Bookseller
                {
                    ID   = Guid.Empty,
                    Name = "没有需要审核的书商"
                };
                booksellers.Add(bookseller);
            }

            return(_adapter.Adapt <BooksellerView>(booksellers));
        }
        public IEnumerable<BooksellerView> GetBooksellerWithNotApproval(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            IList<Bookseller> booksellers = new List<Bookseller>();

            //如果是教务处或教材科,取全部学院
            if (user.IsInRole("教务处"))
            {
                var bookseller = _repo.Find(t =>
                    t.ApprovalState == ApprovalState.教务处审核中
                    ).SelectMany(t =>
                        t.Subscriptions
                        ).Select(t =>
                            t.Bookseller
                            ).Distinct();
                booksellers = bookseller.ToList();
            }
            else if (user.IsInRole("教材科"))
            {
                var bookseller = _repo.Find(t =>
                    t.ApprovalState == ApprovalState.教材科审核中
                    ).SelectMany(t =>
                        t.Subscriptions
                        ).Select(t =>
                            t.Bookseller
                            ).Distinct();
                booksellers = bookseller.ToList();
            }
            if (booksellers.Count == 0)
            {
                var bookseller = new Bookseller
                {
                    ID = Guid.Empty,
                    Name = "没有需要审核的书商"
                };
                booksellers.Add(bookseller);
            }

            return _adapter.Adapt<BooksellerView>(booksellers);
        }
        public IEnumerable <DepartmentView> GetDepartmentBySchoolId(string loginName, string schoolId)
        {
            var id   = schoolId.ConvertToGuid();
            var user = new TbmisUserAppl(loginName).GetUser();
            IEnumerable <Department> departments = new List <Department>();

            ////领导角色,显示全部教研室
            //if (user.IsInRole("学院院长") || user.IsInRole("教材科") || user.IsInRole("教务处"))
            //{
            //    departments = new DepartmentAppl().GetDepartmentBySchoolId(id);
            //}
            //else
            //{
            //    departments = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id);
            //}

            //显示全部教研室
            departments = new DepartmentAppl().GetDepartmentBySchoolId(id);

            departments = departments.OrderBy(t => t.Name);
            return(_adapter.Adapt <DepartmentView>(departments));
        }
        /// <summary>
        /// 根据登录名取学院
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable <School> GetSchoolByLoginName(string loginName)
        {
            //登录名取书商ID
            var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId;
            //取当前学期
            var term = new TermAppl().GetCurrentTerm().SchoolYearTerm;
            //取学生用书申报的ID集合
            var declarations = _repo.First(t =>
                                           t.ID == booksellerId
                                           ).Subscriptions.Where(t =>
                                                                 t.SchoolYearTerm.Year == term.Year &&
                                                                 t.SchoolYearTerm.Term == term.Term &&
                                                                 t.FeedbackState == FeedbackState.征订成功 &&
                                                                 t.Feedback.ApprovalState == ApprovalState.终审通过
                                                                 ).SelectMany(t =>
                                                                              t.StudentDeclarations
                                                                              ).Select(t =>
                                                                                       t.ID
                                                                                       );
            //取学生班级
            var repo = ServiceLocator.Current.GetInstance <IStudentDeclarationRepository>();

            //取学院
            var schools = new List <School>();

            foreach (var item in declarations)
            {
                var schoolsOfDeclaration = repo.GetSchools(item).ToList();
                if (schoolsOfDeclaration.Count > 0)
                {
                    schools.Concat(schoolsOfDeclaration);
                }
            }

            return(schools.Distinct());
        }
 /// <summary>
 /// 获取当前登录用户的书商
 /// </summary>
 /// <returns></returns>
 public Bookseller GetOfUser(string loginName)
 {
     var user = new TbmisUserAppl(loginName).GetUser();
     var bookseller = _repo.First(t => t.ID == user.TbmisUserId);
     return bookseller;
 }
 public string GetFeedbackPerson(string loginName)
 {
     var name = new TbmisUserAppl(loginName).GetUser().TbmisUserName;
     return name;
 }
        public ResponseView SubmitInStock(InventoryView inventory, string instockCount, string loginName)
        {
            var count = instockCount.ConvertToInt();
            var person = new TbmisUserAppl(loginName).GetUser().TbmisUserName;
            var inve = _adapter.Adapt<Inventory>(inventory);
            var inveNew = new Inventory();
            //var inveNew = inve;
            var repo = ServiceLocator.Current.GetInstance<IInventoryRepository>();
            var result = new ResponseView();

            //是否已存在库存
            if (inve.ID != null && inve.ID != Guid.Empty)
            {
                //取出库存
                inveNew = repo.First(t => t.ID == inve.ID);
                //更新架位号
                inveNew.ShelfNumber = inve.ShelfNumber;
            }
            else
            {
                inveNew = inve;
            }

            //修改库存数量
            inveNew.InventoryCount += count;
            //创建库存异动记录
            InventoryService.CreateStockRecord<InStockRecord>(inveNew, person, count);

            try
            {
                if (inveNew.ID == null || inve.ID == Guid.Empty)
                {
                    repo.Add(inveNew);
                }
                else
                {
                    repo.Modify(inveNew);
                }

                repo.Context.Commit();
                return result;
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "入库操作失败";
                return result;
            }
        }
        //public ResponseView SubmitStudentDeclaration(IEnumerable<TeachingTaskView> teachingTaskViews, string textbookId, string loginName, string mobile, string telephone, string declarationCount)
        public ResponseView SubmitStudentDeclaration(DeclarationView view)
        {
            //数据类型转换

            var count = view.DeclarationCount.ConvertToInt();
            //取对象
            var term = new TermAppl().GetMaxTerm().YearTerm;  //学期
            var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId;  //教师ID
            var teacher = _teacherRepo.First(t => t.ID == teacId);  //教师

            var repo = ServiceLocator.Current.GetInstance<IStudentDeclarationRepository>();//CUD专用仓储

            //重载构造函数参数的写法,使得仓储共用工作单元,实现事务
            //配置文件中要添加name为Update的IUnitOfWork的Mapto

            //var declRepo = ServiceLocator.Current.GetInstance<IDeclarationRepository>(new ParameterOverrides()
            //        {
            //            {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")}
            //        });
            //var subRepo = ServiceLocator.Current.GetInstance<ISubscriptionRepository>(new ParameterOverrides()
            //        {
            //            {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")}
            //        });

            //操作响应类
            var result = new ResponseView();
            //错误消息
            var faultMessage = string.Empty;
            //返回消息
            var messageForResponse = new StringBuilder();
            //成功数量
            var successCount = 0;

            //需要教材
            //if (!view.NotNeedTextbook)
            //{
            //    //取教材
            //    var textId = view.TextbookId.ConvertToGuid();
            //    var book = _textbookRepo.First(t => t.ID == textId);  //教材

            //    //为教学任务中的每个学生班级创建用书申报
            //    foreach (var item in view.TeachingTaskNums)
            //    {
            //        //取教学任务
            //        var task = _teachingTaskRepo.First(t => t.TeachingTaskNum == item);

            //        //创建学生用书申报
            //        var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);

            //        //取出教学任务中的学生班级,依次处理
            //        foreach (var proClass in task.ProfessionalClasses)
            //        {
            //            //检查班级是否满足申报条件
            //            if (Domain.DeclarationService.CanDeclaration(proClass, book, ref faultMessage))
            //            {
            //                //创建申报班级
            //                Domain.DeclarationService.CreateDeclarationClass(declaration, proClass);
            //            }
            //            else
            //            {
            //                //记录出错信息
            //                messageForResponse.Append(faultMessage);
            //                faultMessage = string.Empty;
            //            }
            //        }

            //        //检查可申报该教材的班级数量
            //        if (declaration.DeclarationClasses.Count() == task.ProfessionalClasses.Count())
            //        {
            //            //将申报添加到仓储
            //            repo.Add(declaration);
            //            successCount++;
            //        }
            //    }

            //}
            //else    //不需要教材
            //{
            //    foreach (var item in view.TeachingTaskNums)
            //    {
            //        //创建学生用书申报
            //        var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, null, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);

            //        //将申报添加到仓储
            //        repo.Add(declaration);
            //        successCount++;
            //    }
            //}
            try
            {
                //将申报保存到数据库
                repo.Context.Commit();
                //返回消息
                result.Message = string.Format("共{0}个教学班,成功{1}个教学班",
                    view.TeachingTaskNums.Count(),
                    successCount
                    );
                //如果没有全部成功提交,增加错误消息
                if (view.TeachingTaskNums.Count() != successCount)
                {
                    result.Message += string.Format(",失败{0}个教学班{1}失败原因:{2}",
                        view.TeachingTaskNums.Count() - successCount,
                        " ",
                        messageForResponse
                        );
                }

                return result;
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "提交学生用书申报失败";
                return result;
            }
        }
 public string GetAuditor(string loginName)
 {
     var name = new TbmisUserAppl(loginName).GetUser().TbmisUserName;
     return name;
 }
        public ResponseView SubmitDeclarationApproval(IEnumerable<DeclarationForApprovalView> declarations, string loginName, string suggestion, string remark)
        {
            //数据类型转换
            var sugg = suggestion.ConvertToBool();
            //审核人姓名与学院
            var user = new TbmisUserAppl(loginName).GetUser();
            var division = user.SchoolName;
            var auditor = user.TbmisUserName;

            //CUD仓储
            var repo = ServiceLocator.Current.GetInstance<IDeclarationRepository>();
            //操作响应类
            var result = new ResponseView();

            //处理审核记录
            //foreach (var item in declarations)
            //{
            //    var id = item.DeclarationId.ConvertToInt();
            //    var declaration = repo.First(t => t.DeclarationId == id);
            //    Domain.ApprovalService.CreateApproval<DeclarationApproval>(declaration, division, auditor, sugg, remark);
            //}
            //保存到db
            try
            {
                repo.Context.Commit();
                return result;
            }
            catch (Exception)
            {
                result.IsSuccess = false;
                result.Message = "提交审核失败";
                return result;
            }
        }
 public IEnumerable<StorageView> GetByLoginName(string loginName)
 {
     var booksellerId = new TbmisUserAppl(loginName).GetUser().SchoolId;
     var storages = _repo.Find(t => t.Bookseller_Id == booksellerId);
     return _adapter.Adapt<StorageView>(storages);
 }
Exemple #33
0
        public string GetAuditor(string loginName)
        {
            var name = new TbmisUserAppl(loginName).GetUser().TbmisUserName;

            return(name);
        }
        public string GetAuditor(string loginName)
        {
            var user = new TbmisUserAppl(loginName).GetUser();

            return(user.TbmisUserName);
        }
        //public ResponseView SubmitStudentDeclaration(IEnumerable<TeachingTaskView> teachingTaskViews, string textbookId, string loginName, string mobile, string telephone, string declarationCount)
        public ResponseView SubmitStudentDeclaration(DeclarationView view)
        {
            //数据类型转换

            var count = view.DeclarationCount.ConvertToInt();
            //取对象
            var term    = new TermAppl().GetMaxTerm().YearTerm;                    //学期
            var teacId  = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId; //教师ID
            var teacher = _teacherRepo.First(t => t.ID == teacId);                 //教师


            var repo = ServiceLocator.Current.GetInstance <IStudentDeclarationRepository>();//CUD专用仓储

            //重载构造函数参数的写法,使得仓储共用工作单元,实现事务
            //配置文件中要添加name为Update的IUnitOfWork的Mapto

            //var declRepo = ServiceLocator.Current.GetInstance<IDeclarationRepository>(new ParameterOverrides()
            //        {
            //            {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")}
            //        });
            //var subRepo = ServiceLocator.Current.GetInstance<ISubscriptionRepository>(new ParameterOverrides()
            //        {
            //            {"unitOfWork", ServiceLocator.Current.GetInstance<IUnitOfWork>("Update")}
            //        });

            //操作响应类
            var result = new ResponseView();
            //错误消息
            var faultMessage = string.Empty;
            //返回消息
            var messageForResponse = new StringBuilder();
            //成功数量
            var successCount = 0;

            //需要教材
            //if (!view.NotNeedTextbook)
            //{
            //    //取教材
            //    var textId = view.TextbookId.ConvertToGuid();
            //    var book = _textbookRepo.First(t => t.ID == textId);  //教材

            //    //为教学任务中的每个学生班级创建用书申报
            //    foreach (var item in view.TeachingTaskNums)
            //    {
            //        //取教学任务
            //        var task = _teachingTaskRepo.First(t => t.TeachingTaskNum == item);

            //        //创建学生用书申报
            //        var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);


            //        //取出教学任务中的学生班级,依次处理
            //        foreach (var proClass in task.ProfessionalClasses)
            //        {
            //            //检查班级是否满足申报条件
            //            if (Domain.DeclarationService.CanDeclaration(proClass, book, ref faultMessage))
            //            {
            //                //创建申报班级
            //                Domain.DeclarationService.CreateDeclarationClass(declaration, proClass);
            //            }
            //            else
            //            {
            //                //记录出错信息
            //                messageForResponse.Append(faultMessage);
            //                faultMessage = string.Empty;
            //            }
            //        }

            //        //检查可申报该教材的班级数量
            //        if (declaration.DeclarationClasses.Count() == task.ProfessionalClasses.Count())
            //        {
            //            //将申报添加到仓储
            //            repo.Add(declaration);
            //            successCount++;
            //        }
            //    }

            //}
            //else    //不需要教材
            //{
            //    foreach (var item in view.TeachingTaskNums)
            //    {
            //        //创建学生用书申报
            //        var declaration = Domain.DeclarationService.CreateDeclaration<StudentDeclaration>(term, item, null, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);

            //        //将申报添加到仓储
            //        repo.Add(declaration);
            //        successCount++;
            //    }
            //}
            try
            {
                //将申报保存到数据库
                repo.Context.Commit();
                //返回消息
                result.Message = string.Format("共{0}个教学班,成功{1}个教学班",
                                               view.TeachingTaskNums.Count(),
                                               successCount
                                               );
                //如果没有全部成功提交,增加错误消息
                if (view.TeachingTaskNums.Count() != successCount)
                {
                    result.Message += string.Format(",失败{0}个教学班{1}失败原因:{2}",
                                                    view.TeachingTaskNums.Count() - successCount,
                                                    " ",
                                                    messageForResponse
                                                    );
                }

                return(result);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "提交学生用书申报失败";
                return(result);
            }
        }
        public IEnumerable<SchoolView> GetSchoolByLoginName(string loginName)
        {
            var user = new TbmisUserAppl(loginName).GetUser();
            IEnumerable<School> schools = new List<School>();

            //领导,显示全部学院
            if (user.IsInRole("教材科") || user.IsInRole("教务处"))
            {
                schools = new SchoolAppl().GetSchools();
            }
            else
            {
                schools = new SchoolAppl().GetSchoolOfUser(loginName);
            }

            schools = schools.OrderBy(t => t.Name);

            return _adapter.Adapt<SchoolView>(schools);
        }
        public IEnumerable<FeedbackForApprovalView> GetFeedbackWithNotApproval(string loginName, string booksellerId)
        {
            //登录用户
            var user = new TbmisUserAppl(loginName).GetUser();
            //书商ID
            var id = booksellerId.ConvertToGuid();

            IEnumerable<Feedback> feedbacks = new List<Feedback>();

            //如果是教务处或教材科,取全部
            if (user.IsInRole("教务处"))
            {
                var feedback = _repo.Find(t =>
                    t.ApprovalState == ApprovalState.教务处审核中 &&
                    t.Subscriptions.FirstOrDefault().Bookseller_Id == id
                    );
                feedbacks = feedback;
            }
            else if (user.IsInRole("教材科"))
            {
                var feedback = _repo.Find(t =>
                    t.ApprovalState == ApprovalState.教材科审核中 &&
                    t.Subscriptions.FirstOrDefault().Bookseller_Id == id
                    );
                feedbacks = feedback;
            }

            return _adapter.Adapt<FeedbackForApprovalView>(feedbacks);
        }
        public ResponseView SubmitFeedbackApproval(IEnumerable<FeedbackForApprovalView> feedbacks, string loginName, string suggestion, string remark)
        {
            //审核意见
            var sugg = suggestion.ConvertToBool();
            //审核部门,审核人
            var user = new TbmisUserAppl(loginName).GetUser();
            var division = user.SchoolName;
            var auditor = user.TbmisUserName;
            //回告ID
            var ids = feedbacks.Select(t => t.FeedbackId.ConvertToGuid());
            //消息类
            var result = new ResponseView();
            //保存到db
            try
            {
                //处理审核记录
                var backs = _repo.Find(t => ids.Contains(t.ID)).ToList();
                backs.ForEach(t =>
                    {
                        Domain.ApprovalService.CreateApproval<FeedbackApproval>(t, division, auditor, sugg, remark);
                    });

                _repo.Context.Commit();
            }
            catch (Exception)
            {
                result.IsSuccess = false;
                result.Message = "提交审核失败";
            }
            return result;
        }
        /// <summary>
        /// 根据登录名取学院
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public IEnumerable<SchoolView> GetSchoolByloginName(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();

            //取当前登录用户的学院

            var schoolAppl = new SchoolAppl();
            var school = schoolAppl.GetSchoolOfUser(loginName);
            return _adapter.Adapt<SchoolView>(school);
        }
Exemple #40
0
        public string GetFeedbackPerson(string loginName)
        {
            var name = new TbmisUserAppl(loginName).GetUser().TbmisUserName;

            return(name);
        }
        public ResponseView SubmitTeacherDeclaration(DeclarationView view)
        {
            //类型转换
            var textId = view.TextbookId.ConvertToGuid();
            var teacId = new TbmisUserAppl(view.Declarant).GetUser().TbmisUserId;
            var count = view.DeclarationCount.ConvertToInt();
            //当前学期
            var term = new TermAppl().GetMaxTerm().YearTerm;
            //操作响应类
            var result = new ResponseView();

            try
            {
                ////CUD仓储
                //var repo = ServiceLocator.Current.GetInstance<ITeacherDeclarationRepository>();
                ////创建申报
                //var declaration = Domain.DeclarationService.CreateDeclaration<TeacherDeclaration>(term, view.TeachingTaskNums.First(), textId, teacId, view.Mobile, view.Telephone, count, view.NotNeedTextbook);
                ////保存
                //repo.Add(declaration);
                ////提交到数据库
                //repo.Context.Commit();
                return result;
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "提交教师用书申报失败";
                return result;
            }
        }
        public IEnumerable<SchoolView> GetSchoolWithNotApproval(string loginName)
        {
            //系统用户
            var user = new TbmisUserAppl(loginName).GetUser();
            //最大学期
            var term = new TermAppl().GetMaxTerm().YearTerm;

            IList<School> schools = new List<School>();

            ////如果是教务处或教材科,取全部学院
            //if (user.IsInRole("教务处"))
            //{
            //    var school = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教务处审核中
            //        ).Select(t =>
            //            t.TeachingTask.Department.School
            //            ).Distinct();
            //    schools = school.ToList();
            //}
            //else if (user.IsInRole("教材科"))
            //{
            //    var school = _declRepo.Find(t =>
            //        t.Term == term &&
            //        t.ApprovalState == ApprovalState.教材科审核中
            //        ).Select(t =>
            //            t.TeachingTask.Department.School
            //            ).Distinct();
            //    schools = school.ToList();
            //}
            ////如果是学院院长,返回所属学院
            //else if (user.IsInRole("学院院长") || user.IsInRole("教研室主任"))
            //{
            //    var school = new School { SchoolId = (Guid)user.SchoolId, Name = user.SchoolName };
            //    schools.Add(school);
            //}
            if (schools.Count > 0)
            {
                return _adapter.Adapt<SchoolView>(schools);
            }
            else
            {
                IEnumerable<SchoolView> school = new List<SchoolView>
                {
                    new SchoolView { SchoolId = string.Empty, Name = "没有需要审核的学院" }
                };
                return school;
            }
        }
 public string GetAuditor(string loginName)
 {
     var user = new TbmisUserAppl(loginName).GetUser();
     return user.TbmisUserName;
 }
        public IEnumerable<DepartmentView> GetDepartmentBySchoolId(string loginName, string schoolId)
        {
            var id = schoolId.ConvertToGuid();
            var user = new TbmisUserAppl(loginName).GetUser();
            IEnumerable<Department> departments = new List<Department>();

            ////领导角色,显示全部教研室
            //if (user.IsInRole("学院院长") || user.IsInRole("教材科") || user.IsInRole("教务处"))
            //{
            //    departments = new DepartmentAppl().GetDepartmentBySchoolId(id);
            //}
            //else
            //{
            //    departments = new DepartmentAppl().GetDepartmentBySchoolId(loginName, id);
            //}

            //显示全部教研室
            departments = new DepartmentAppl().GetDepartmentBySchoolId(id);

            departments = departments.OrderBy(t => t.Name);
            return _adapter.Adapt<DepartmentView>(departments);
        }