Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Notifications.Structures.Module;

namespace Sungero.Examples.Module.Docflow.Server
{
Expand Down Expand Up @@ -105,16 +104,18 @@ public override bool CanConvertToPdfInteractively(Sungero.Docflow.IOfficialDocum
/// <returns>Текст запроса.</returns>
public override string GetStoragePolicySettingsQuery(DateTime now)
{
return string.Format(Docflow.Queries.Module.CreateStoragePolicySettings, Sungero.Docflow.Constants.Module.StoragePolicySettingsTableName, now.ToString("yyyy-MM-dd HH:mm:ss"));
return string.Format(Docflow.Queries.Module.CreateStoragePolicySettings, Sungero.Docflow.Constants.Module.StoragePolicySettingsTableName);
}

/// <summary>
/// Перекрытие. Получить запрос получения документов для перемещения.
/// Перекрытие. Получить запрос отбора документов для переноса в заданном диапазоне Id.
/// </summary>
/// <param name="fromId">Нижняя граница диапазона Id (не включительно).</param>
/// <param name="batchUpperBoundId">Верхняя граница диапазона Id (включительно).</param>
/// <returns>Текст запроса.</returns>
public override string GetDocumentsToTransferQuery()
public override string GetDocumentsToTransferWithIdRangeQuery(long fromId, long batchUpperBoundId)
{
return string.Format(Docflow.Queries.Module.SelectDocumentsToTransfer, Sungero.Docflow.Constants.Module.StoragePolicySettingsTableName);
return string.Format(Docflow.Queries.Module.SelectDocumentsToTransferWithIdRange, Sungero.Docflow.Constants.Module.StoragePolicySettingsTableName, fromId, batchUpperBoundId);
}

/// <summary>
Expand All @@ -128,27 +129,5 @@ public override List<Nullable<Enumeration>> GetMultipleMembersRoles()

return roles;
}

/// <summary>
/// Перекрытие. Добавить отслеживание отправки к параметрам обработки рассылки о новых и просроченных заданиях.
/// </summary>
/// <returns>Параметры обработки рассылки о новых и просроченных заданиях.</returns>
public override IProcessingParameters CreateAssignmentsMailingProcessingParameters()
{
var parameters = base.CreateAssignmentsMailingProcessingParameters();
parameters.TrackProcess = true;
return parameters;
}

/// <summary>
/// Перекрытие. Добавить отслеживание отправки к параметрам обработки рассылки со сводкой о заданиях.
/// </summary>
/// <returns>Параметры обработки рассылки со сводкой о заданиях.</returns>
public override IProcessingParameters CreateSummaryMailingProcessingParameters()
{
var parameters = base.CreateSummaryMailingProcessingParameters();
parameters.TrackProcess = true;
return parameters;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ if exists (select * from information_schema.tables where table_name = '{0}')
drop table {0}

select r.Storage, rdk.DocumentKind,
case when r.DocDateType = 'DocumentDate' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as DocumentDate,
case when r.DocDateType = 'Modified' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as Modified,
case when r.DocDateType = 'LastRead' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as LastRead,
case when r.DocDateType = 'DocumentDate' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as DocumentDate,
case when r.DocDateType = 'Modified' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as Modified,
case when r.DocDateType = 'LastRead' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as LastRead,
case when r.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef' then r.[Priority] else r.[Priority] + (select coalesce(max(r2.[Priority]), 0) from Sungero_Docflow_StoragePolicy r2 where r2.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef') end as [Priority],
case when coalesce(r.NextRetention, '{1}') <= '{1}' then 1 else 0 end as NeedRetention
case when coalesce(r.NextRetention, @now) <= @now then 1 else 0 end as NeedRetention
into {0}
from Sungero_Docflow_StoragePolicy r
join Sungero_Docflow_SPolicyDocKind rdk
Expand All @@ -15,13 +15,20 @@ into {0}

insert into {0}
select r.Storage, rdk.Id,
case when r.DocDateType = 'DocumentDate' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as DocumentDate,
case when r.DocDateType = 'Modified' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as Modified,
case when r.DocDateType = 'LastRead' then dateadd(DD, -1 * r.DaysToMove, '{1}') else '2100-01-01 00:00:00.000' end as LastRead,
case when r.DocDateType = 'DocumentDate' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as DocumentDate,
case when r.DocDateType = 'Modified' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as Modified,
case when r.DocDateType = 'LastRead' then dateadd(DD, -1 * r.DaysToMove, @now) else @maxDate end as LastRead,
case when r.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef' then r.[Priority] else r.[Priority] + (select coalesce(max(r2.[Priority]), 0) from Sungero_Docflow_StoragePolicy r2 where r2.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef') end as [Priority],
case when coalesce(r.NextRetention, '{1}') <= '{1}' then 1 else 0 end as NeedRetention
case when coalesce(r.NextRetention, @now) <= @now then 1 else 0 end as NeedRetention
from Sungero_Docflow_StoragePolicy r
join Sungero_Docflow_DocumentKind rdk
on 1=1
where r.Status = 'Active'
and not exists (select 1 from Sungero_Docflow_SPolicyDocKind k where k.StoragePolicy = r.Id);
and not exists (select 1 from Sungero_Docflow_SPolicyDocKind k where k.StoragePolicy = r.Id);

insert into {0}
select s.Id, rdk.Id, @maxDate, @maxDate, @maxDate, -1, 1
from Sungero_Core_Storage s
join Sungero_Docflow_DocumentKind rdk
on 1=1
where s.IsDefault = 1;
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ END $$;
SELECT r.Storage, rdk.DocumentKind,
CASE
WHEN r.DocDateType = 'DocumentDate'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS DocumentDate,
CASE
WHEN r.DocDateType = 'Modified'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS Modified,
CASE
WHEN r.DocDateType = 'LastRead'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
END AS LastRead,
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS LastRead,
CASE
WHEN r.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef'
THEN r.Priority
ELSE r.Priority + (SELECT COALESCE(MAX(r2.Priority), 0) FROM Sungero_Docflow_StoragePolicy r2 WHERE r2.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef')
END AS Priority,
CASE
WHEN COALESCE(r.NextRetention, '{1}') <= '{1}'
WHEN COALESCE(r.NextRetention, @now) <= @now
THEN 1
ELSE 0
END AS NeedRetention
Expand All @@ -41,31 +41,38 @@ INSERT INTO {0}
SELECT r.Storage, rdk.Id,
CASE
WHEN r.DocDateType = 'DocumentDate'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS DocumentDate,
CASE
WHEN r.DocDateType = 'Modified'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS Modified,
CASE
WHEN r.DocDateType = 'LastRead'
THEN TO_TIMESTAMP('{1}','YYYY-MM-DD HH24:MI:SS') - r.DaysToMove * INTERVAL '1 day'
ELSE TO_TIMESTAMP('2100-01-01 00:00:00.000','YYYY-MM-DD HH24:MI:SS')
THEN @now - r.DaysToMove * INTERVAL '1 day'
ELSE @maxDate
END AS LastRead,
CASE
WHEN r.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef'
THEN r.Priority
ELSE r.Priority + (SELECT COALESCE(MAX(r2.Priority), 0) FROM Sungero_Docflow_StoragePolicy r2 WHERE r2.Discriminator = '9fed5653-77e7-4543-b071-6586033907ef')
END AS Priority,
CASE
WHEN COALESCE(r.NextRetention, '{1}') <= '{1}'
WHEN COALESCE(r.NextRetention, @now) <= @now
THEN 1
ELSE 0
END AS NeedRetention
FROM Sungero_Docflow_StoragePolicy r
JOIN Sungero_Docflow_DocumentKind rdk
ON 1=1
WHERE r.Status = 'Active'
AND NOT EXISTS (SELECT 1 FROM Sungero_Docflow_SPolicyDocKind k WHERE k.StoragePolicy = r.Id);
AND NOT EXISTS (SELECT 1 FROM Sungero_Docflow_SPolicyDocKind k WHERE k.StoragePolicy = r.Id);

INSERT INTO {0}
SELECT s.Id, rdk.Id, @maxDate, @maxDate, @maxDate, -1, 1
FROM Sungero_Core_Storage s
JOIN Sungero_Docflow_DocumentKind rdk
ON 1=1
WHERE s.IsDefault = TRUE;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
with RankedDocs as (
select doc.Id,
doc.Storage_Docflow_Sungero as CurrentStorage,
t.Storage as TargetStorage,
t.NeedRetention,
row_number() over (
partition by doc.Id
order by t.Priority desc
) as rn
from Sungero_Content_EDoc doc
join (select EntityId, max(HistoryDate) as HD
from Sungero_Content_DocHistory
where Action in ('Read', 'Create', 'Update')
and VersionNumber is not null
and Operation <> 'DataTransfer'
group by EntityId) as hld
on hld.EntityId = doc.Id
join {0} t
on t.DocumentKind = doc.DocumentKind_Docflow_Sungero
and doc.DocumentDate_Docflow_Sungero <= t.DocumentDate
and doc.Modified <= t.Modified
and hld.HD <= t.LastRead
where t.NeedRetention = 1
and doc.Storage_Docflow_Sungero is not null
and t.Storage != doc.Storage_Docflow_Sungero
and doc.Id > {1}
and doc.Id <= {2}
)
select Id, TargetStorage
from RankedDocs
where rn = 1