Пример #1
0
 public void ModifyDocument(EditDescription editDescription, Func <SrmDocument, SrmDocument> action, Func <SrmDocumentPair, AuditLogEntry> logFunc = null)
 {
     if (_batchChangesOriginalDocument == null)
     {
         if (SkylineWindow != null)
         {
             SkylineWindow.ModifyDocument(editDescription.GetUndoText(DataSchemaLocalizer), action,
                                          logFunc ?? (docPair => AuditLogEntry.CreateSimpleEntry(MessageType.set_to_in_document_grid, docPair.NewDocumentType,
                                                                                                 editDescription.AuditLogParseString, editDescription.ElementRefName, CellValueToString(editDescription.Value))));
         }
         else
         {
             var doc = _documentContainer.Document;
             if (!_documentContainer.SetDocument(action(doc), doc))
             {
                 throw new InvalidOperationException(Resources
                                                     .SkylineDataSchema_VerifyDocumentCurrent_The_document_was_modified_in_the_middle_of_the_operation_);
             }
         }
         return;
     }
     VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
     _batchEditDescriptions.Add(editDescription);
     _document = action(_document.BeginDeferSettingsChanges());
 }
Пример #2
0
 public void ModifyDocument(EditDescription editDescription, Func <SrmDocument, SrmDocument> action)
 {
     if (_batchChangesOriginalDocument == null)
     {
         SkylineWindow.ModifyDocument(editDescription.GetUndoText(DataSchemaLocalizer), action);
         return;
     }
     VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
     _document = action(_document.BeginDeferSettingsChanges());
 }
Пример #3
0
        public AuditLogEntry LogEntryFromEditDescription(EditDescription editDescription, SrmDocumentPair docPair)
        {
            if (EqualExceptAuditLog(docPair.OldDoc, docPair.NewDoc))
            {
                return(AuditLogEntry.SKIP);
            }

            return(AuditLogEntry.CreateSimpleEntry(MessageType.set_to_in_document_grid, docPair.NewDocumentType,
                                                   editDescription.AuditLogParseString, editDescription.ElementRefName,
                                                   CellValueToString(editDescription.Value)));
        }
Пример #4
0
 public void ModifyDocument(EditDescription editDescription, Func <SrmDocument, SrmDocument> action, Func <SrmDocumentPair, AuditLogEntry> logFunc = null)
 {
     if (_batchChangesOriginalDocument == null)
     {
         SkylineWindow.ModifyDocument(editDescription.GetUndoText(DataSchemaLocalizer), action,
                                      logFunc ?? (docPair => AuditLogEntry.CreateSimpleEntry(docPair.OldDoc, MessageType.set_to_in_document_grid,
                                                                                             editDescription.ColumnCaption.GetCaption(DataSchemaLocalizer), editDescription.ElementRefName, CellValueToString(editDescription.Value))));
         return;
     }
     VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
     _batchEditDescriptions.Add(editDescription);
     _document = action(_document.BeginDeferSettingsChanges());
 }
Пример #5
0
        public override void SetValue(object component, object value)
        {
            var listItem  = (ListItem)component;
            var newRecord = listItem.GetRecord() as ListItem.NewRecordData;

            if (newRecord != null)
            {
                newRecord.UncommittedValues[AnnotationDef.Name] = value;
                return;
            }
            var existingRecord = listItem.GetRecord() as ListItem.ExistingRecordData;

            if (existingRecord == null)
            {
                throw new InvalidOperationException(@"Invalid row " + listItem.GetRecord()); // Cannot happen
            }
            var editDescription = EditDescription.SetAnnotation(AnnotationDef, value)
                                  .ChangeElementRef(((ListRef)ListRef.PROTOTYPE.ChangeName(ListName)).GetListItemRef(listItem));

            SkylineDataSchema.ModifyDocument(editDescription, doc =>
            {
                var listInfo = GetListInfo(doc);
                if (listInfo == null)
                {
                    throw new InvalidOperationException(Resources.ListColumnPropertyDescriptor_SetValue_List_has_been_deleted);
                }
                if (listInfo.ColumnIndex < 0)
                {
                    throw CommonException.Create(ListExceptionDetail.ColumnNotFound(ListName, AnnotationDef.Name));
                }
                int rowIndex = listInfo.ListData.RowIndexOf(existingRecord.ListItemId);
                if (rowIndex < 0)
                {
                    throw new ArgumentException(Resources.ListColumnPropertyDescriptor_SetValue_List_item_has_been_deleted_);
                }
                var listData = listInfo.ListData;
                listData     = listData.ChangeColumn(listInfo.ColumnIndex, listData.Columns[listInfo.ColumnIndex].SetValue(rowIndex, value));
                return(doc.ChangeSettings(
                           doc.Settings.ChangeDataSettings(

                               ChangeListData(doc.Settings.DataSettings, listData))));
            }, AuditLogEntry.SettingsLogFunction);
        }
Пример #6
0
 public void ModifyDocument(EditDescription editDescription, Func <SrmDocument, SrmDocument> action, Func <SrmDocumentPair, AuditLogEntry> logFunc = null)
 {
     if (_batchChangesOriginalDocument == null)
     {
         if (SkylineWindow != null)
         {
             SkylineWindow.ModifyDocument(editDescription.GetUndoText(DataSchemaLocalizer), action,
                                          logFunc ?? (docPair => LogEntryFromEditDescription(editDescription, docPair)));
         }
         else
         {
             var doc = _documentContainer.Document;
             if (!_documentContainer.SetDocument(action(doc), doc))
             {
                 throw new InvalidOperationException(Resources
                                                     .SkylineDataSchema_VerifyDocumentCurrent_The_document_was_modified_in_the_middle_of_the_operation_);
             }
         }
         return;
     }
     VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
     _batchEditDescriptions.Add(editDescription);
     _document = action(_document.BeginDeferSettingsChanges());
 }