|
@@ -1,5 +1,6 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
@@ -15,9 +16,10 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
public delegate String OnGetWatermark(CoreRow row);
|
|
|
|
|
|
- public class DynamicDocumentGrid<TDocument, TEntity> : DynamicManyToManyGrid<TDocument, TEntity>
|
|
|
+ public class DynamicDocumentGrid<TDocument, TEntity, TEntityLink> : DynamicManyToManyGrid<TDocument, TEntity>
|
|
|
where TEntity : Entity, IPersistent, IRemotable, new()
|
|
|
- where TDocument : Entity, IEntityDocument, IPersistent, IRemotable, new() // Entity, IPersistent, IRemotable, IManyToMany<TEntity, Document>, new()
|
|
|
+ where TDocument : Entity, IEntityDocument<TEntityLink>, IPersistent, IRemotable, new() // Entity, IPersistent, IRemotable, IManyToMany<TEntity, Document>, new()
|
|
|
+ where TEntityLink : EntityLink<TEntity>, new()
|
|
|
{
|
|
|
private DynamicActionColumn supercedecolumn;
|
|
|
|
|
@@ -35,6 +37,8 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
public DynamicDocumentGrid()
|
|
|
{
|
|
|
+ Options.Add(DynamicGridOption.DragTarget);
|
|
|
+
|
|
|
MultiSelect = false;
|
|
|
HiddenColumns.Add(x => x.DocumentLink.ID);
|
|
|
HiddenColumns.Add(x => x.Superceded);
|
|
@@ -49,7 +53,7 @@ namespace InABox.DynamicGrid
|
|
|
return int.MaxValue;
|
|
|
}
|
|
|
|
|
|
- private BitmapImage SupercededImage(CoreRow row)
|
|
|
+ private BitmapImage SupercededImage(CoreRow? row)
|
|
|
{
|
|
|
if (row == null)
|
|
|
return Properties.Resources.tick.AsBitmapImage();
|
|
@@ -58,7 +62,7 @@ namespace InABox.DynamicGrid
|
|
|
return Properties.Resources.tick.AsBitmapImage();
|
|
|
}
|
|
|
|
|
|
- private bool SupercedeDocument(CoreRow row)
|
|
|
+ private bool SupercedeDocument(CoreRow? row)
|
|
|
{
|
|
|
var id = row.Get<TDocument, Guid>(x => x.ID);
|
|
|
var document = WorkingList.FirstOrDefault(x => x.ID.Equals(id));
|
|
@@ -67,12 +71,12 @@ namespace InABox.DynamicGrid
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private BitmapImage DocumentImage(CoreRow arg)
|
|
|
+ private BitmapImage DocumentImage(CoreRow? arg)
|
|
|
{
|
|
|
return Properties.Resources.view.AsBitmapImage();
|
|
|
}
|
|
|
|
|
|
- private bool ViewDocument(CoreRow row)
|
|
|
+ private bool ViewDocument(CoreRow? row)
|
|
|
{
|
|
|
var filename = row.Get<TDocument, string>(x => x.DocumentLink.FileName);
|
|
|
if (Path.GetExtension(filename).ToUpper().Equals(".PDF"))
|
|
@@ -130,7 +134,48 @@ namespace InABox.DynamicGrid
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public event OnGetWatermark OnGetWaterMark;
|
|
|
+ public event OnGetWatermark OnGetWaterMark;
|
|
|
+
|
|
|
+ protected override void OnDragEnd(Type entity, CoreTable table)
|
|
|
+ {
|
|
|
+ if(entity == typeof(Document))
|
|
|
+ {
|
|
|
+ var refresh = false;
|
|
|
+
|
|
|
+ var docIDS = table.Rows.Select(x => x.Get<Document, Guid>(x => x.ID)).ToArray();
|
|
|
+
|
|
|
+ var columns = new Columns<Document>(x => x.ID);
|
|
|
+ foreach(var column in VisibleColumns)
|
|
|
+ {
|
|
|
+ if (column.ColumnName.StartsWith("DocumentLink."))
|
|
|
+ {
|
|
|
+ columns.Add(string.Join('.', column.ColumnName.Split('.').Skip(1)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var docs = new Client<Document>()
|
|
|
+ .Query(
|
|
|
+ new Filter<Document>(x => x.ID).InList(docIDS),
|
|
|
+ columns);
|
|
|
+
|
|
|
+ foreach (var doc in docs.ToObjects<Document>())
|
|
|
+ {
|
|
|
+ var entityDocument = new TDocument();
|
|
|
+ entityDocument.EntityLink.ID = Item.ID;
|
|
|
+ entityDocument.DocumentLink.ID = doc.ID;
|
|
|
+ entityDocument.DocumentLink.Synchronise(doc);
|
|
|
+ SaveItem(entityDocument);
|
|
|
+ refresh = true;
|
|
|
+ }
|
|
|
+ if (refresh)
|
|
|
+ {
|
|
|
+ Refresh(false, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ base.OnDragEnd(entity, table);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
protected override void DoAdd()
|
|
|
{
|