/// <summary>
        ///  新增记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnAddClickAsync(object sender, RoutedEventArgs e)
        {
            Lib.MemberAppraise NewRecord = new Lib.MemberAppraise()
            {
                MemberId = _CurUcViewModel.CurMember.Id,
                UserId   = AppSet.LoginUser.Id
            };

            UC_AppraiseWin AddWin = new UC_AppraiseWin(NewRecord);

            if (AddWin.ShowDialog().Value)
            {
                IEnumerable <MemberAppraise> MemberPlayMonths = await DataMemberAppraiseRepository.GetRecords(new MemberAppraiseSearch()
                {
                    MemberId = NewRecord.MemberId,
                    UserId   = NewRecord.UserId
                });

                ExcuteResult excuteResult = await DataMemberAppraiseRepository.AddRecord(NewRecord);

                if (excuteResult.State == 0)
                {
                    NewRecord.Id = excuteResult.Tag;
                    _CurUcViewModel.CurRecords.Add(NewRecord);
                }
                else
                {
                    AppFuns.ShowMessage(excuteResult.Msg, Caption: "失败");
                }
            }
        }
        /// <summary>
        /// 编辑一条记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnEditClickAsync(object sender, RoutedEventArgs e)
        {
            if (RecordListBox.SelectedItem is Lib.MemberAppraise SelectedRec)
            {
                Lib.MemberAppraise RecCloneObj = CloneObject <Lib.MemberAppraise, Lib.MemberAppraise> .Trans(SelectedRec);

                UC_AppraiseWin AddWin = new UC_AppraiseWin(RecCloneObj);

                if (AddWin.ShowDialog().Value)
                {
                    ExcuteResult excuteResult = await DataMemberAppraiseRepository.UpdateRecord(RecCloneObj);

                    if (excuteResult.State == 0)
                    {
                        PropertyInfo[] TargetAttris = SelectedRec.GetType().GetProperties();
                        PropertyInfo[] SourceAttris = RecCloneObj.GetType().GetProperties();
                        foreach (PropertyInfo item in SourceAttris)
                        {
                            var tempObj = TargetAttris.Where(x => x.Name.Equals(item.Name, StringComparison.Ordinal)).FirstOrDefault();
                            if (tempObj != null)
                            {
                                item.SetValue(SelectedRec, item.GetValue(RecCloneObj));
                            }
                        }
                    }
                    else
                    {
                        AppFuns.ShowMessage(excuteResult.Msg, Caption: "失败", isErr: true);
                    }
                }
            }
        }
            public async System.Threading.Tasks.Task SearchRecords()
            {
                if (SearchCondition != null)
                {
                    SearchCondition.MemberId = CurMember.Id;
                    SearchCondition.UserId   = AppSet.LoginUser.Id;

                    IEnumerable <MemberAppraise> TempRecords = await DataMemberAppraiseRepository.GetRecords(SearchCondition);

                    CurRecords.Clear();
                    TempRecords?.ToList().ForEach(e =>
                    {
                        CurRecords.Add(e);
                    });
                }
            }
            public async System.Threading.Tasks.Task InitVMAsync(Lib.MemberInfoEntity PMember)
            {
                CurMember = PMember;
                if (PMember != null)
                {
                    MemberAppraiseSearch SearchCondition = new MemberAppraiseSearch()
                    {
                        MemberId = PMember.Id, UserId = AppSet.LoginUser.Id
                    };
                    IEnumerable <MemberAppraise> MemberPrizePunishss = await DataMemberAppraiseRepository.GetRecords(SearchCondition);

                    CurRecords.Clear();
                    MemberPrizePunishss?.ToList().ForEach(e =>
                    {
                        CurRecords.Add(e);
                    });
                }
            }
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtnDelClickAsync(object sender, RoutedEventArgs e)
        {
            if (RecordListBox.SelectedItem is Lib.MemberAppraise SelectedRec)
            {
                if (AppFuns.ShowMessage($"确认要删除该条考核信息吗?", Caption: "确认", showYesNo: true))
                {
                    ExcuteResult excuteResult = await DataMemberAppraiseRepository.DeleteRecord(SelectedRec);

                    if (excuteResult.State == 0)
                    {
                        _CurUcViewModel.CurRecords.Remove(SelectedRec);
                    }
                    else
                    {
                        AppFuns.ShowMessage(excuteResult.Msg, Caption: "失败", isErr: true);
                    }
                }
            }
        }
        public void Render(FlowDocument FlowDoc, string Caption, string DateStr, MemoryStream UserHeadStream, Lib.MemberInfoEntity PCurMember)
        {
            if (PCurMember == null)
            {
                return;
            }

            DocVM = new DocViewModel
            {
                CurMember = PCurMember
            };

            //设置标题

            if (string.IsNullOrWhiteSpace(Caption))
            {
                DocVM.Caption = "事 业 编 制 人 员 基 本 情 况 表";
            }
            else
            {
                DocVM.Caption = Caption;
            }
            DocVM.DateStr = DateStr;

            //设置员工头像
            if (UserHeadStream != null)
            {
                //TableCell Cell_UserPhoto = FlowDoc.FindName("UserPhotoCell") as TableCell;
                //Paragraph TParagraph = new Paragraph
                //{
                //    TextAlignment = TextAlignment.Center
                //};
                //ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
                //ImageBrush HeadImgBrush = new ImageBrush((ImageSource)imageSourceConverter.ConvertFrom(UserHeadStream));
                //Border HeadImg = new Border
                //{
                //    Width = 120,
                //    Height = 170,
                //    Background = HeadImgBrush
                //};
                //TParagraph.Inlines.Add(HeadImg);
                //Cell_UserPhoto.Blocks.Add(TParagraph);
            }
            //填充职工简历
            var TempResumes = DataMemberResumeRepository.GetRecords(new Lib.MemberResumeSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;
            TableCell Cell_Resume = FlowDoc.FindName("Cell_Resume") as TableCell;

            if (TempResumes != null && TempResumes.Count() > 0)
            {
                List <Lib.MemberResume> MemberResumes = TempResumes.OrderBy(x => x.BeginDate).ToList();
                for (int i = 0; i < MemberResumes.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].BeginDate.ToString("yyyy年MM月—")));
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].EndDate.ToString("yyyy年MM月")));
                    TParagraph.Inlines.Add(new Run(MemberResumes[i].Content));
                    if (!string.IsNullOrWhiteSpace(MemberResumes[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberResumes[i].Remark})"));
                    }
                    Cell_Resume.Blocks.Add(TParagraph);
                }
            }
            else
            {
                Paragraph TParagraph = new Paragraph();
                TParagraph.TextAlignment = TextAlignment.Left;
                TParagraph.Inlines.Add(new TextBlock()
                {
                    Height = 400
                });
                Cell_Resume.Blocks.Add(TParagraph);
            }
            //填充职工奖惩信息
            var TempPrizePunish = DataMemberPrizePunishRepository.GetRecords(new Lib.MemberPrizePunishSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempPrizePunish != null && TempPrizePunish.Count() > 0)
            {
                TableCell Cell_PrizePunish = FlowDoc.FindName("Cell_PrizePunish") as TableCell;
                List <Lib.MemberPrizePunishEntity> MemberPrizePunishs = TempPrizePunish.OrderByDescending(x => x.PrizrOrPunishType).ToList();
                for (int i = 0; i < MemberPrizePunishs.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].OccurDate.ToString("yyyy年MM月")));
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishName));
                    TParagraph.Inlines.Add(new Run(MemberPrizePunishs[i].PrizrOrPunishUnit));
                    if (!string.IsNullOrWhiteSpace(MemberPrizePunishs[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberPrizePunishs[i].Remark})"));
                    }
                    Cell_PrizePunish.Blocks.Add(TParagraph);
                }
            }
            //填充职工年度考核信息
            var TempAppraise = DataMemberAppraiseRepository.GetRecords(new Lib.MemberAppraiseSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempAppraise != null && TempAppraise.Count() > 0)
            {
                TableCell Cell_Appraise = FlowDoc.FindName("Cell_Appraise") as TableCell;
                List <Lib.MemberAppraise> MemberAppraises = TempAppraise.OrderByDescending(x => x.Year).ToList();
                for (int i = 0; i < MemberAppraises.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberAppraises[i].Year));
                    TParagraph.Inlines.Add(new Run(MemberAppraises[i].Result));
                    if (!string.IsNullOrWhiteSpace(MemberAppraises[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberAppraises[i].Remark})"));
                    }
                    Cell_Appraise.Blocks.Add(TParagraph);
                }
            }
            //填充职工社会关系
            var TempRelations = DataMemberRelationsRepository.GetRecords(new Lib.MemberRelationsSearch()
            {
                UserId   = AppSet.LoginUser.Id,
                MemberId = DocVM.CurMember.Id
            }).Result;

            if (TempRelations != null && TempRelations.Count() > 0)
            {
                TableCell Cell_Appraise = FlowDoc.FindName("Cell_Relations") as TableCell;
                List <Lib.MemberRelations> MemberRelationses = TempRelations.OrderBy(x => x.OrderIndex).ToList();
                for (int i = 0; i < MemberRelationses.Count; i++)
                {
                    Paragraph TParagraph = new Paragraph();
                    TParagraph.TextAlignment = TextAlignment.Left;
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Relation));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Name));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].UnitName));
                    TParagraph.Inlines.Add(new Run(MemberRelationses[i].Role));
                    if (!string.IsNullOrWhiteSpace(MemberRelationses[i].Remark))
                    {
                        TParagraph.Inlines.Add(new Run($"({MemberRelationses[i].Remark})"));
                    }
                    Cell_Appraise.Blocks.Add(TParagraph);
                }
            }

            FlowDoc.DataContext = DocVM;
        }
        /// <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>();
            }
        }