Example #1
0
        private void actionPreviewRestoredData_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            ListPropertyEditor editor = (this.View as DetailView).FindItem("DeletedItems") as ListPropertyEditor;

            if (editor != null)
            {
                IObjectSpace space          = Application.CreateObjectSpace();
                RestoredObjectsParameters p = new RestoredObjectsParameters();
                using (AuditTrailRestoreHelper helper = new AuditTrailRestoreHelper(space))
                {
                    foreach (RestoreItemDetails details in editor.ListView.SelectedObjects)
                    {
                        helper.RestoreObject(space.GetObject <AuditDataItemPersistent>(details.AuditTrailItem));
                    }

                    foreach (object obj in helper.RestoredObjects)
                    {
                        p.ObjectsToRestore.Add(new RestoredObjectDetails()
                        {
                            Name = CaptionHelper.GetDisplayText(obj), Type = CaptionHelper.GetClassCaption(XafTypesInfo.Instance.FindTypeInfo(obj.GetType()).Type.FullName)
                        });
                    }
                }

                IObjectSpace previewspace = Application.CreateObjectSpace(typeof(RestoredObjectsParameters));
                e.View = Application.CreateDetailView(previewspace, p);
                e.DialogController.SaveOnAccept = false;
            }
        }
        private void actionRestoreData_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
        {
            RestoreDataParameters p      = e.PopupWindowViewCurrentObject as RestoreDataParameters;
            DetailView            view   = e.PopupWindowView as DetailView;
            ListPropertyEditor    editor = view.FindItem("DeletedItems") as ListPropertyEditor;

            IObjectSpace space = Application.CreateObjectSpace();

            using (AuditTrailRestoreHelper helper = new AuditTrailRestoreHelper(space))
            {
                foreach (RestoreItemDetails details in editor.ListView.SelectedObjects)
                {
                    helper.RestoreObject(space.GetObject <AuditDataItemPersistent>(details.AuditTrailItem));
                }

                helper.MarkAsRestored();
                space.CommitChanges();
            }
        }