Exemplo n.º 1
0
        /// <summary>
        /// 初始化各属性值
        /// </summary>
        private async void InitPropsAsync()
        {
            if (string.IsNullOrEmpty(_CurPageViewModel.EntityMember.Id))
            {
                //  AppFuns.ShowMessage("若要开始,请选输入员工身份证号!", "输入不正确")).ShowDialog();
                return;
            }
            var MemberInfo = await DataMemberRepository.ReadEntity(_CurPageViewModel.EntityMember.Id);

            Stream UserHeadStream = null;

            if (MemberInfo != null)  //数据表中已存在该记录。
            {
                _CurPageViewModel.isEditFlag = true;
                _CurPageViewModel            = new CurPageViewModel(MemberInfo);
                //读取用户头像信息
                var UserPhotos = await DataMemberFileRepository.ReadFiles(new MemberFileSearch()
                {
                    UserId   = AppSet.LoginUser.Id,
                    MemberId = _CurPageViewModel.EntityMember.Id,
                    Name     = _CurPageViewModel.EntityMember.Id
                }).ConfigureAwait(false);

                UserPhotos = UserPhotos.OrderByDescending(x => x.UpDateTime);
                if (UserPhotos != null && UserPhotos.Count() > 0)
                {
                    UserHeadStream = await DataMemberFileRepository.DownloadFileStream(UserPhotos.First().Id, null);
                }
            }
            else
            {
                _CurPageViewModel.isEditFlag = false;
            }
            App.Current.Dispatcher.Invoke(() =>
            {
                if (UserHeadStream != null)
                {
                    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(UserHeadStream);
                    MemoryStream PhotoStream     = new MemoryStream();
                    bitmap.Save(PhotoStream, System.Drawing.Imaging.ImageFormat.Png);
                    _CurPageViewModel.UseHeadImage.BeginInit();
                    //如果希望关闭用于创建 BitmapImage的流,请将 CacheOption 设置为 BitmapCacheOption.OnLoad。
                    //默认 OnDemand 缓存选项保留对流的访问权限,直到需要映像,并且清除由垃圾回收器处理
                    _CurPageViewModel.UseHeadImage.CacheOption  = BitmapCacheOption.OnLoad;
                    _CurPageViewModel.UseHeadImage.StreamSource = PhotoStream;
                    _CurPageViewModel.UseHeadImage.EndInit();
                    PhotoStream.Dispose();
                }

                DataContext = _CurPageViewModel;
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 查询待发放信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnSearchClickAsync(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(mSearch.Id))
            {
                return;
            }
            List <Lib.MemberInfoEntity> Members = await DataMemberRepository.ReadMembers(mSearch);

            if (Members == null || Members.Count < 1)
            {
                return;
            }
            //读取用户头像信息
            MemoryStream             UserHeadStream = null;
            IEnumerable <MemberFile> UserPhotos     = await DataMemberFileRepository.ReadFiles(new MemberFileSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = Members[0].Id,
                Name     = Members[0].Id
            });

            UserPhotos = UserPhotos.OrderByDescending(x => x.UpDateTime);
            if (UserPhotos != null && UserPhotos.Count() > 0)
            {
                Stream TempStream = await DataMemberFileRepository.DownloadFileStream(UserPhotos.First().Id, null);

                System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(TempStream);
                UserHeadStream = new MemoryStream();
                bitmap.Save(UserHeadStream, System.Drawing.Imaging.ImageFormat.Png);
                TempStream.Dispose();

                //TempBitMap = new BitmapImage();
                //TempBitMap.BeginInit();
                //TempBitMap.CacheOption = BitmapCacheOption.OnLoad;
                //TempBitMap.StreamSource = UserHeadStream;
                //TempBitMap.EndInit();
                //TempBitMap.Freeze();
                //UserHeadStream.Dispose();
            }
            string DateStr = $"打印日期:{DateTime.Now:yyy-MM-dd}";

            CreateFlowDoc("PrintMemberSheetFlowDot.xaml", null, DateStr, UserHeadStream, Members[0], P_DocWidth: 793, P_DocHeight: 1122);
        }
        /// <summary>
        /// 读取用户的各类信息
        /// </summary>
        /// <returns></returns>
        public async Task InitPropsAsync()
        {
            //读取用户头像信息
            IEnumerable <MemberFile> UserPhotos = await DataMemberFileRepository.ReadFiles(new MemberFileSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = CurMember.Id,
                Name     = CurMember.Id
            });

            UserPhotos = UserPhotos.OrderByDescending(x => x.UpDateTime);
            if (UserPhotos != null && UserPhotos.Count() > 0)
            {
                MemoryStream UserHeadStream = null;
                MemoryStream TempStream     = await DataMemberFileRepository.DownloadFileStream(UserPhotos.First().Id, null);

                if (TempStream != null)
                {
                    System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(TempStream);
                    UserHeadStream = new MemoryStream();
                    bitmap.Save(UserHeadStream, System.Drawing.Imaging.ImageFormat.Png);
                    HeadImage = new BitmapImage();
                    HeadImage.BeginInit();
                    HeadImage.CacheOption  = BitmapCacheOption.OnLoad;
                    HeadImage.StreamSource = UserHeadStream;
                    HeadImage.EndInit();
                    HeadImage.Freeze();
                    //UserHeadStream.Dispose();导出时要用此流
                }
            }
            //读取用户简历
            var Resumes = await DataMemberResumeRepository.GetRecords(new MemberResumeSearch()
            {
                MemberId = CurMember.Id,
                UserId   = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            Resumes      = Resumes?.OrderBy(x => x.BeginDate);
            this.Resumes = Resumes?.ToList();
            //读取用户社会关系
            var Relations = await DataMemberRelationsRepository.GetRecords(new MemberRelationsSearch()
            {
                MemberId = CurMember.Id,
                UserId   = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            Relations      = Relations?.OrderBy(x => x.OrderIndex);
            this.Relations = Relations?.ToList();
            //读取用户奖惩信息
            var PrizePunishs = await DataMemberPrizePunishRepository.GetRecords(new MemberPrizePunishSearch()
            {
                MemberId = CurMember.Id,
                UserId   = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            PrizePunishs      = PrizePunishs?.OrderByDescending(x => x.OccurDate).Take(5);
            this.PrizePunishs = PrizePunishs?.ToList();
            //读取用户近三年考核情况
            var Appraises = await DataMemberAppraiseRepository.GetRecords(new MemberAppraiseSearch()
            {
                MemberId = CurMember.Id,
                UserId   = AppSet.LoginUser.Id
            }).ConfigureAwait(false);

            Appraises      = Appraises?.OrderByDescending(x => x.Year).Take(3);
            this.Appraises = Appraises?.ToList();
            //确保各类集合不为空
            if (this.Resumes == null)
            {
                this.Resumes = new List <MemberResume>();
            }
            if (this.Relations == null)
            {
                this.Relations = new List <MemberRelations>();
            }
            if (this.PrizePunishs == null)
            {
                this.PrizePunishs = new List <MemberPrizePunish>();
            }
            if (this.Appraises == null)
            {
                this.Appraises = new List <MemberAppraise>();
            }
        }