示例#1
0
        /// <summary>
        /// 移除最近记录;
        /// </summary>
        /// <param name="recentCaseRecord"></param>
        public void RemoveRecord(IRecentCaseRecord recentCaseRecord)
        {
            if (recentCaseRecord == null)
            {
                throw new ArgumentNullException(nameof(recentCaseRecord));
            }

            var xDoc = GetRecordsXDocument();

            if (xDoc == null)
            {
                LoggerService.WriteCallerLine($"{nameof(xDoc)} can't be null.");
                return;
            }
            if (xDoc.Root == null)
            {
                LoggerService.WriteCallerLine($"{nameof(xDoc.Root)} can't be null.");
                return;
            }


            //查找列表中是否有相同GUID的案件项;
            var elems = xDoc.Root.Elements(Constants.XmlElemName_RecentRecords_Record);

            var csElem = elems.FirstOrDefault(p => GetOriStringFromXmlValue(p.GetXElemValue(Constants.XmlElemName_RecentRecords_Record_CaseGUID)) == recentCaseRecord.CaseGUID);

            if (csElem == null)
            {
                return;
            }
            csElem.Remove();
            xDoc.Save(GetDataFileName());
        }
示例#2
0
        /// <summary>
        /// 添加RecordModel到group中;
        /// </summary>
        /// <param name="recordModel"></param>
        /// <param name="group"></param>
        private void AddRecordModelToGroup(IRecentCaseRecord record, RecentCaseRecordGroupModel group)
        {
            RecentCaseRecordModel recordModel = new RecentCaseRecordModel(record);

            group.Items.Add(recordModel);
            //订阅打开事件;
            recordModel.OpenCaseRequired += (sender, e) => {
                try {
                    //如若案件文件不存在,询问是否移除最近案件引用;
                    var csFilePath = $"{recordModel.Record.CasePath}\\{recordModel.Record.CaseName}{Constants.CaseFileExtention}";
                    if (!File.Exists(csFilePath))
                    {
                        if (MsgBoxService.Show(
                                LanguageService.TryGetStringWithFormat(Constants.MsgText_ConfirmToRemoveRecentCaseFormat, csFilePath),
                                MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                        {
                            RecentCaseRecordManagementService.RemoveRecord(recordModel.Record);
                            InitializeGroups();
                            return;
                        }
                    }

                    CaseService.Current.LoadCase(csFilePath);
                    RegionHelper.RequestNavigate(Contracts.MainPage.Constants.MainPageDocumentRegion, Contracts.MainPage.Constants.WelcomeView);
                }
                catch (Exception ex) {
                    LoggerService.WriteException(ex);
                }
            };
        }
示例#3
0
 public static void RemoveRecord(IRecentCaseRecord recentCaseRecord) => Current.RemoveRecord(recentCaseRecord);
 public RecentCaseRecordModel(IRecentCaseRecord recentCaseRecord)
 {
     this.Record = recentCaseRecord ?? throw new ArgumentNullException(nameof(recentCaseRecord));
 }