Ejemplo n.º 1
0
        private Func <SrmDocumentPair, AuditLogEntry> GetAuditLogFunction(
            DataGridViewPasteHandler.BatchModifyInfo batchModifyInfo)
        {
            if (batchModifyInfo == null)
            {
                return(null);
            }
            return(docPair =>
            {
                MessageType singular, plural;
                var detailType = MessageType.set_to_in_document_grid;
                Func <EditDescription, object[]> getArgsFunc = descr => new object[]
                {
                    descr.AuditLogParseString, descr.ElementRefName,
                    CellValueToString(descr.Value)
                };

                switch (batchModifyInfo.BatchModifyAction)
                {
                case DataGridViewPasteHandler.BatchModifyAction.Paste:
                    singular = MessageType.pasted_document_grid_single;
                    plural = MessageType.pasted_document_grid;
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.Clear:
                    singular = MessageType.cleared_document_grid_single;
                    plural = MessageType.cleared_document_grid;
                    detailType = MessageType.cleared_cell_in_document_grid;
                    getArgsFunc = descr => new[]
                    { (object)descr.ColumnCaption.GetCaption(DataSchemaLocalizer), descr.ElementRefName };
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.FillDown:
                    singular = MessageType.fill_down_document_grid_single;
                    plural = MessageType.fill_down_document_grid;
                    break;

                default:
                    return null;
                }

                var entry = AuditLogEntry.CreateCountChangeEntry(singular, plural, docPair.NewDocumentType,
                                                                 _batchEditDescriptions,
                                                                 descr => MessageArgs.Create(descr.ColumnCaption.GetCaption(DataSchemaLocalizer)),
                                                                 null).ChangeExtraInfo(batchModifyInfo.ExtraInfo + Environment.NewLine);

                entry = entry.Merge(batchModifyInfo.EntryCreator.Create(docPair));

                return entry.AppendAllInfo(_batchEditDescriptions.Select(descr => new MessageInfo(detailType, docPair.NewDocumentType,
                                                                                                  getArgsFunc(descr))).ToList());
            });
        }
Ejemplo n.º 2
0
        public void CommitBatchModifyDocument(string description, DataGridViewPasteHandler.BatchModifyInfo batchModifyInfo)
        {
            if (null == _batchChangesOriginalDocument)
            {
                throw new InvalidOperationException();
            }
            string message = Resources.DataGridViewPasteHandler_EndDeferSettingsChangesOnDocument_Updating_settings;

            if (SkylineWindow != null)
            {
                SkylineWindow.ModifyDocument(description, document =>
                {
                    VerifyDocumentCurrent(_batchChangesOriginalDocument, document);
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Message = message
                    })
                    {
                        SrmDocument newDocument = document;
                        longWaitDlg.PerformWork(SkylineWindow, 1000, progressMonitor =>
                        {
                            var srmSettingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor,
                                                                                        message);
                            newDocument = _document.EndDeferSettingsChanges(_batchChangesOriginalDocument,
                                                                            srmSettingsChangeMonitor);
                        });
                        return(newDocument);
                    }
                }, GetAuditLogFunction(batchModifyInfo));
            }
            else
            {
                VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
                if (!_documentContainer.SetDocument(
                        _document.EndDeferSettingsChanges(_batchChangesOriginalDocument, null),
                        _batchChangesOriginalDocument))
                {
                    throw new InvalidOperationException(Resources
                                                        .SkylineDataSchema_VerifyDocumentCurrent_The_document_was_modified_in_the_middle_of_the_operation_);
                }
            }
            _batchChangesOriginalDocument = null;
            _batchEditDescriptions        = null;
            DocumentChangedEventHandler(_documentContainer, new DocumentChangedEventArgs(_document));
        }
Ejemplo n.º 3
0
        public void CommitBatchModifyDocument(string description, DataGridViewPasteHandler.BatchModifyInfo batchModifyInfo)
        {
            if (null == _batchChangesOriginalDocument)
            {
                throw new InvalidOperationException();
            }
            string message = Resources.DataGridViewPasteHandler_EndDeferSettingsChangesOnDocument_Updating_settings;

            SkylineWindow.ModifyDocument(description, document =>
            {
                VerifyDocumentCurrent(_batchChangesOriginalDocument, document);
                using (var longWaitDlg = new LongWaitDlg
                {
                    Message = message
                })
                {
                    SrmDocument newDocument = null;
                    longWaitDlg.PerformWork(SkylineWindow, 1000, progressMonitor =>
                    {
                        var srmSettingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor,
                                                                                    message);
                        newDocument = _document.EndDeferSettingsChanges(_batchChangesOriginalDocument.Settings, srmSettingsChangeMonitor);
                    });
                    return(newDocument);
                }
            }, docPair =>
            {
                MessageType singular, plural;
                var detailType = MessageType.set_to_in_document_grid;
                Func <EditDescription, object[]> getArgsFunc = descr => new object[]
                {
                    descr.ColumnCaption.GetCaption(DataSchemaLocalizer), descr.ElementRefName,
                    CellValueToString(descr.Value)
                };

                switch (batchModifyInfo.BatchModifyAction)
                {
                case DataGridViewPasteHandler.BatchModifyAction.Paste:
                    singular = MessageType.pasted_document_grid_single;
                    plural   = MessageType.pasted_document_grid;
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.Clear:
                    singular    = MessageType.cleared_document_grid_single;
                    plural      = MessageType.cleared_document_grid;
                    detailType  = MessageType.cleared_cell_in_document_grid;
                    getArgsFunc = descr => new[] { (object)descr.ColumnCaption.GetCaption(DataSchemaLocalizer), descr.ElementRefName };
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.FillDown:
                    singular = MessageType.fill_down_document_grid_single;
                    plural   = MessageType.fill_down_document_grid;
                    break;

                default:
                    return(null);
                }

                var entry = AuditLogEntry.CreateCountChangeEntry(docPair.OldDoc, singular, plural,
                                                                 _batchEditDescriptions,
                                                                 descr => MessageArgs.Create(descr.ColumnCaption.GetCaption(DataSchemaLocalizer)),
                                                                 null).ChangeExtraInfo(batchModifyInfo.ExtraInfo + Environment.NewLine);

                entry = entry.Merge(batchModifyInfo.EntryCreator.Create(docPair));

                return(entry.AppendAllInfo(_batchEditDescriptions.Select(descr => new MessageInfo(detailType,
                                                                                                  getArgsFunc(descr))).ToList()));
            });
            _batchChangesOriginalDocument = null;
            _batchEditDescriptions        = null;
            DocumentChangedEventHandler(_documentContainer, new DocumentChangedEventArgs(_document));
        }