Exemple #1
0
        public async Task <ListResultDto <NameValueDto> > GetStatistics()
        {
            //Disabled filters to access to all tenant's data, not for only current tenant.
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant, AbpDataFilters.MustHaveTenant))
            {
                var statisticItems = new List <NameValueDto>
                {
                    new NameValueDto(
                        L("Tenants"),
                        (await _tenantRepository.CountAsync()).ToString()
                        ),
                    new NameValueDto(
                        L("Users"),
                        (await _userRepository.CountAsync()).ToString()
                        ),
                    new NameValueDto(
                        L("Events"),
                        (await _eventRepository.CountAsync()).ToString()
                        ),
                    new NameValueDto(
                        L("Registrations"),
                        (await _eventRegistrationRepository.CountAsync()).ToString()
                        )
                };

                return(new ListResultDto <NameValueDto>(statisticItems));
            }
        }
Exemple #2
0
        protected override void DoWork()
        {
            //只在工作时间执行
            var hour = DateTime.Now.Hour;

            if (hour < 8 || hour > 18)
            {
                return;
            }
            Logger.Info("开始延期任务检测");
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant, AbpDataFilters.MustHaveTenant))
            {
                var taskQuery = _processTaskManager.GetAll().Include(o => o.Part).ThenInclude(o => o.Project);
                //获取所有延期未上机,延期未下机,到料后未上机,工时超预计的任务
                var delayStartTasks = taskQuery.Where(o => o.StartDate == null && o.AppointDate != null && o.AppointDate.Value < DateTime.Now).ToList();
                SendDelayTaskMessage(delayStartTasks, DelayType.DelayStart);
                var delayEndTasks = taskQuery.Where(o => o.EndDate == null && o.RequireDate != null && o.RequireDate.Value < DateTime.Now).ToList();
                SendDelayTaskMessage(delayEndTasks, DelayType.DelayEnd);
                var receivedNotStartTasks = taskQuery.Where(o => o.StartDate == null && o.ReceiveDate != null && o.AppointDate.Value < DateTime.Now).ToList();
                SendDelayTaskMessage(receivedNotStartTasks, DelayType.ReceiveNotStart);
                var exceedHourTasks = taskQuery.Where(o => o.StartDate != null && o.EstimateHours != null && o.EndDate == null && (DateTime.Now - Convert.ToDateTime(o.StartDate)).TotalHours > Convert.ToDouble(o.EstimateHours.Value)).ToList();
                SendDelayTaskMessage(exceedHourTasks, DelayType.ExceedHour);
                CurrentUnitOfWork.SaveChanges();
            }
        }
Exemple #3
0
        protected async override void DoWork()
        {
            try
            {
                using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
                {
                    var exchangeRates = _exchangeRatesRepository.GetAllList();

                    foreach (var exchangeRate in exchangeRates)
                    {
                        var currencyFrom = _currenciesRepository.FirstOrDefault(exchangeRate.CurrencyId);

                        if (currencyFrom != null)
                        {
                            await DownloadAndUpdateExchangeRateAsync(exchangeRate, currencyFrom.Code, "USD");

                            await _exchangeRatesRepository.UpdateAsync(exchangeRate);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(String.Empty, ex);
            }
        }
 protected override void DoWork()
 {
     using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
     {
         var today = DateTime.Now;
         var allUnFinishedTodos = _todoRepository.GetAll();
         var found = (from todo in allUnFinishedTodos
                      where todo.HistoryStatuses.OrderByDescending(a => a.CreationTime).FirstOrDefault()
                      != null &&
                      todo.HistoryStatuses.OrderByDescending(a => a.CreationTime).FirstOrDefault().StatusType !=
                      (int)StatusTypes.Status.Success
                      select todo).ToList();
         foreach (var allUnFinishedTodo in found)
         {
             if (allUnFinishedTodo.DueDate.HasValue)
             {
                 if (allUnFinishedTodo.DueDate < today)
                 {
                     //Time is over
                     allUnFinishedTodo.SetStatus(StatusTypes.Status.OffTime);
                     //Send mail to responsible
                 }
                 if (allUnFinishedTodo.DueDate == today)
                 {
                     //Is critical
                     allUnFinishedTodo.SetStatus(StatusTypes.Status.Critical);
                     //Send mail to responsible
                 }
             }
         }
         CurrentUnitOfWork.SaveChanges();
     }
 }
        /// <summary>
        /// 获取一个任务的表格包含转发记录,原来是使用的Get方法,现在直接用这个接口取链式
        /// 任务详情页面
        /// </summary>
        /// <param name="input"></param>
        /// <returns>任务</returns>
        public async Task <PagedResultDto <TaskItemAssignmentDto> > GetAssignment(EntityDto <Guid> input)
        {
            var entity = await GetEntityByIdAsync(input.Id);

            CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant);
            // 关闭软删除筛选器
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
            {
                var entityList = Repository.GetAll()
                                 .Where(q => q.SubProjectId == entity.SubProjectId)
                                 .Where(q => q.ProcedureStepTaskItemId == entity.ProcedureStepTaskItemId)
                                 // 如果subProjectId没有值,则使用RootAssignmentId筛选
                                 .WhereIf(!entity.SubProjectId.HasValue, v => v.RootAssignmentId == entity.RootAssignmentId)
                                 .OrderBy(q => q.CreationTime).Include(v => v.User);
                var list = entityList.Select(q => q.MapTo <TaskItemAssignmentDto>()).ToList();
                // 向第一个元素填入需要的信息
                list[0].TaskItem = (await _taskItemManager.GetAsync(entity.TaskItemId)).MapTo <TaskItemDto>();
                // 如果subProjectId为空则不进行操作 SubProjectId为空,无法继续操作
                if (entity.SubProjectId.HasValue)
                {
                    list[0].SubProject = (await _subProjectManager.GetAsync((Guid)entity.SubProjectId))
                                         .MapTo <SubProjectDto>();
                }
                return(new PagedResultDto <TaskItemAssignmentDto>(await entityList.CountAsync(), list));
            }
        }
        public async Task <List <HoSoDoanThamDinh37Dto> > XemDoanThamDinh(long hoSoId)
        {
            var hoSoDoanThamDinhList = await _hoSoDoanThamDinh.GetAll().Where(x => x.HoSoId == hoSoId).ToListAsync();

            List <HoSoDoanThamDinh37Dto> ThanhVienDoanThamDinhList = new List <HoSoDoanThamDinh37Dto>();

            foreach (var item in hoSoDoanThamDinhList)
            {
                var thanhVien = new HoSoDoanThamDinh37Dto();
                thanhVien.VaiTroEnum    = item.VaiTroEnum;
                thanhVien.TrangThaiXuLy = item.TrangThaiXuLy;
                thanhVien.NoiDungYKien  = item.NoiDungYkien;
                if (item.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.KHONG_DAT)
                {
                    thanhVien.StrTrangThai = "Hồ sơ không đạt";
                }
                if (item.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.DAT)
                {
                    thanhVien.StrTrangThai = "Hồ sơ đạt";
                }
                using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
                {
                    var thanhVienDoanObj = await _userRepos.GetAsync(item.UserId.Value);

                    if (thanhVienDoanObj != null)
                    {
                        thanhVien.HoTen = thanhVienDoanObj.Surname + " " + thanhVienDoanObj.Name;
                    }
                }
                ThanhVienDoanThamDinhList.Add(thanhVien);
            }
            return(ThanhVienDoanThamDinhList);
        }
Exemple #7
0
        public async Task <long> CreateUserFrontEndAsync(CreateOrUpdateUserInput input)
        {
            input.User.UserName = input.User.UserName.Replace(" ", "");

            int tenancyDoanhNghiepId = 1;

            if (!ConfigurationManager.AppSettings["TENANTCY_ID_DOANH_NGHIEP"].IsNullOrEmpty())
            {
                tenancyDoanhNghiepId = Convert.ToInt32(ConfigurationManager.AppSettings["TENANTCY_ID_DOANH_NGHIEP"]);
            }
            await _userPolicy.CheckMaxUserCountAsync(tenancyDoanhNghiepId);

            var user = input.User.MapTo <User>(); //Passwords is not mapped (see mapping configuration)

            user.TenantId = tenancyDoanhNghiepId;

            //Set password
            if (!input.User.Password.IsNullOrEmpty())
            {
                CheckErrors(await UserManager.PasswordValidator.ValidateAsync(input.User.Password));
            }
            else
            {
                input.User.Password = User.CreateRandomPassword();
            }

            user.Password = new PasswordHasher().HashPassword(input.User.Password);
            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
            {
                foreach (var roleName in input.AssignedRoleNames)
                {
                    //var role = _roleManager.Roles.FirstOrDefault(x => x.Name == roleName);
                    var role = await _roleManager.GetRoleByNameAsync(roleName);

                    user.Roles.Add(new UserRole(tenancyDoanhNghiepId, user.Id, role.Id));
                }
            }

            user.PhongBanId = input.User.PhongBanId;

            await UserManager.CreateAsync(user);

            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Send activation email
            if (input.SendActivationEmail)
            {
                await _userEmailer.SendEmailConfirmRegisterAsync(user);
            }
            return(user.Id);
        }
Exemple #8
0
        public GetPlayersOutput GetPlayer()
        {
            var result = _playeRepository.GetPlayersWithMap(0);

            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                //XXX
                unitOfWork.Complete();
                _unitOfWorkManager.Current.Completed += (sender, args) => { /* TODO: 給派發的人發送郵件*/ };
            }

            var ev = EventBus.Register <TaskCompletedEventData>(e =>
            {
                // XXXX
            });

            ev.Dispose();


            using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
            {
                // disable filter
            }

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
            {
            }

            return(new GetPlayersOutput());
        }
Exemple #9
0
        public virtual async Task <AccessTokenDto> InitializeAccessToken(InitializeAccessTokenInputDto input)
        {
            CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete);
            // AccessToken token = _accessTokenRepository
            AccessToken token = await this.Repository.GetAsync(input.AccessTokenId);

            try
            {
                _accessTokenManager.InitializeToken(token, input.Code);

                var output = MapToEntityDto(token);
                return(output);
            }
            catch (OceanException oceanError)
            {
                throw new UserFriendlyException(
                          oceanError.getError_code(),
                          oceanError.getError_message(),
                          oceanError
                          );
            }
            catch (Exception exc)
            {
                throw new UserFriendlyException(
                          exc.Message,
                          exc.ToString(),
                          exc
                          );
            }
        }
        /// <summary>
        /// 零件的报工明细
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public virtual async Task <object> GetPartReportInfos(int partId, string where)
        {
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MustHaveTenant))
            {
                var query = Resolve <ProcessTaskReportManager>().GetAll()
                            .Include(o => o.ProcessTask).ThenInclude(o => o.ProcessType)
                            .Where(o => MESDbContext.GetJsonValueNumber(o.ProcessTask.Part.Project.Unit.Property, "$.TenantId") == AbpSession.TenantId.Value)
                            .Where(o => o.ProcessTask.PartId == partId);

                if (!string.IsNullOrEmpty(where))
                {
                    query = query.Where(where);
                }

                return(await query.Select(o => new
                {
                    o.ReportType,
                    o.ProcessTask.ProcessType.ProcessTypeName,
                    o.ReportTime,
                    o.Files
                }).ToListAsync());

                //return await query.ToListAsync();
            }
        }
Exemple #11
0
        public override async Task <PagedResultDto <AccessTokenDto> > GetAll(QueryBaseDto input)
        {
            CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete);
            var result = await base.GetAll(input);

            return(result);
        }
Exemple #12
0
        public virtual AlibabaOpenplatformTradeModelTradeInfo GetTradeInfo(string appKey, string memberId, long orderId)
        {
            CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete);
            var trade = this._tradeManager.GetTradeInfor(appKey, memberId, orderId);

            return(trade);
        }
        /// <summary>
        /// 获取子项目所有的信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <GetAllSubProjectStageLogOutput> GetAll(GetAllSubProjectStageLogInput input)
        {
            var subProject = await _repositorySubProject.GetAsync(input.SubProjectId);

            // 获取构件的更改记录
            CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant);
            var logs = _repositorySubProjectStageLog.GetAll().Where(v => v.SubProjectId == input.SubProjectId)
                       .Include(v => v.TaskItemAssignment).ThenInclude(v => v.User)
                       .Include(v => v.TaskItemAssignment).ThenInclude(v => v.TaskItem)
                       .Include(v => v.TaskItemAssignment).ThenInclude(v => v.ProcedureStepTaskItem).ThenInclude(v => v.ProcedureStep)
                       .Include(v => v.CreatorUser)
                       .Select(v => v.MapTo <SubProjectStageLogDto>());
            // 被分派的工作项
            var ptStates = (await _taskItemManager.GetTaskItemsBySubProjectId(input.SubProjectId))
                           .Include(v => v.TaskItemAssignments)
                           // map的时候用一个方法来添加一些内容
                           .Select(a => MapToPtStateDto(a, input.SubProjectId));
            // 添加构件项目工序的优先级列表
            var priorityList = _repositoryProcedureStep.GetAll().Where(v => v.ProcedureId == subProject.ProcedureId)
                               .Select(v => v.Priority).OrderBy(v => v);

            return(new GetAllSubProjectStageLogOutput
            {
                SubProject = subProject.MapTo <SubProjectDto>(),
                SubProjectStageLogs = await logs.ToListAsync(),
                PtsState = await ptStates.ToListAsync(),
                PriorityList = await priorityList.ToListAsync()
            });
        }
        public async Task <DeleteDto> DeleteOrUnDeleteAsync(int bookId)
        {
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete, FilterNames.Approved))
            {
                var book = await _bookRepository.GetAsync(bookId);

                if (book == null)
                {
                    throw new AbpException("Book not found");
                }

                // TODO: логику восстановления книги вынести в отдельный метод репозитория
                var isDeleted = book.IsDeleted;
                if (isDeleted)
                {
                    book.IsDeleted     = false;
                    book.DeletionTime  = null;
                    book.DeleterUserId = null;
                }
                else
                {
                    await _bookRepository.DeleteAsync(bookId);
                }

                return(new DeleteDto
                {
                    Id = book.Id,
                    IsDeleted = !isDeleted,
                    Title = book.Title
                });
            }
        }
        public async Task <ApproveDto> ApproveAsync(int bookId)
        {
            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete, FilterNames.Approved))
            {
                var book = await _bookRepository.GetAsync(bookId);

                if (book == null)
                {
                    throw new AbpException("Book not found");
                }

                book.IsApproved = true;

                if (book.IsDeleted)
                {
                    await DeleteOrUnDeleteAsync(book.Id);
                }

                return(new ApproveDto
                {
                    Id = book.Id,
                    IsApproved = book.IsApproved,
                    Title = book.Title
                });
            }
        }