LEFT JOIN vAgreementCostEventTypevw P ON Z.Type_AgreementCostEventTypeId = P.AgreementCostEventTypeId
LEFT JOIN AgreementCostEventMilestoneFactvw
Q ON Z.AgreementCostEventDimKey = Q.AgreementCostEventDimKey AND Q.DeletedDate IS NULL
LEFT JOIN MilestoneDimvw R ON Q.AgreementCostEventHasMilestone_MilestoneDimKey = R.MilestoneDimKey AND R.IsDeleted = 0 AND ISNULL(R.ObjectStatus,'') <> @ObjectStatusPendingDelete
select @BaseManagedEntityID = A.BaseManagedEntityId,
@OrganizationDimKey = B.AgreementHasOrganization_OrganizationDimKey,
@CostCenterDimKey = C.AgreementHasCostCenter_CostCenterDimKey,
@LocationDimKey = D.AgreementHasLocation_LocationDimKey
from AgreementDimvw A
LEFT JOIN AgreementOrganizationFactvw B ON A.AgreementDimKey = B.AgreementDimKey AND B.DeletedDate IS NULL
LEFT JOIN AgreementCostCenterFactvw C ON A.AgreementDimKey = C.AgreementDimKey AND C.DeletedDate IS NULL
LEFT JOIN AgreementLocationFactvw D ON A.AgreementDimKey = D.AgreementDimKey AND D.DeletedDate IS NULL
where a.AgreementDimKey = @AgreementDimKey
-- When called as a Contract Detail the @ContractID will be null
-- When called from the End Of Contract report it will be null for agreements that do not have a contract
-- When called as a Contract Detail we use Like '%' to select the contract
-- When called from the End of Contract it will use the Contact id if apppropriate
SELECT @pContractID = ISNULL(NULLIF(rtrim(ltrim(@ContractID)),''),'%')
select @Organization = '',
@Row_count = 1
WHILE @OrganizationDimKey IS NOT NULL AND @Row_count <> 0
BEGIN
SELECT @Organization = A.DisplayName + ' \ ' + @Organization,
@OrganizationDimKey = B.OrganizationDimKey
FROM OrganizationDimvw A
LEFT JOIN OrganizationChildOrganizationFactvw B ON A.OrganizationDimKey = B.OrganizationContainsChildOrganization_OrganizationDimKey
AND B.DeletedDate is null
where A.OrganizationDimKey = @OrganizationDimKey
AND ISNULL(A.ObjectStatus,'') <> @ObjectStatusPendingDelete
SELECT @Row_count = @@Rowcount
END
select @Organization = left(@Organization,ABS(LEN(@Organization)-2))
select @Location = '',
@Row_count = 1
WHILE @LocationDimKey IS NOT NULL AND @Row_count <> 0
BEGIN
SELECT @Location = A.DisplayName + ' \ ' + @Location,
@LocationDimKey = B.LocationDimKey
FROM LocationDimvw A
LEFT JOIN LocationChildLocationFactvw B ON A.LocationDimKey = B.LocationContainsChildLocation_LocationDimKey
AND B.DeletedDate is null
where A.LocationDimKey = @LocationDimKey
AND ISNULL(A.ObjectStatus,'') <> @ObjectStatusPendingDelete
SELECT @Row_count = @@Rowcount
END
select @Location = left(@Location,ABS(LEN(@Location)-2))
select @CostCenter = '',
@Row_count = 1
WHILE @CostCenterDimKey IS NOT NULL AND @Row_count <> 0
BEGIN
SELECT @CostCenter = A.DisplayName + ' \ ' + @CostCenter,
@CostCenterDimKey = B.CostCenterDimKey
FROM CostCenterDimvw A
LEFT JOIN CostCenterChildCostCenterFactvw B ON A.CostCenterDimKey = B.CostCenterContainsChildCostCenter_CostCenterDimKey
AND B.DeletedDate is null
where A.CostCenterDimKey = @CostCenterDimKey
AND ISNULL(A.ObjectStatus,'') <> @ObjectStatusPendingDelete
SELECT @Row_count = @@Rowcount
END
;with vDisplayStringDimvw AS (
SELECT A.DisplayName,A.BaseManagedEntityId
FROM DisplayStringDimvw A
WHERE A.LanguageCode = @UserLanguage)
select C.LifecycleStatus,
d.Status,
E.Program,
F.ContractTimeUnit,
g.ContractTransferability,
H.UserDefinedAgreementType,
I.DisplayName Contact,
@CostCenter CostCenter,
@Organization Organization,
@Location Location,
B.AgreementNumber,
B.Amount,
B.AmountIsoCurrencyCode,
B.Ceiling,
B.CeilingIsoCurrencyCode,
B.Coverage,
B.Description,
B.DisplayName,
B.Duration,
B.EffectiveDate,
B.ExpirationDate,
B.Notes,
B.TermsAndConditions,
B.Conract_DisplayName,
B.Contract_Id
from (
-- User Defined Agreement
select a.AgreementNumber AgreementNumber,
NULL Amount,
NULL AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
NULL Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
a.EffectiveDate EffectiveDate,
a.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
a.Type_UserDefinedAgreementTypeId Type_UserDefinedAgreementTypeId,
b.UserDefinedAgreementHasContact_ContactDimKey ContactDimkKey,
null Conract_DisplayName,
null Contract_Id
from UserDefinedAgreementDimvw a
left join UserDefinedAgreementContactFactvw b on a.UserDefinedAgreementDimKey = b.UserDefinedAgreementDimKey
and b.DeletedDate is null
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Lease Agreement
select a.AgreementNumber AgreementNumber,
NULL Amount,
NULL AmountIsoCurrencyCode,
a.Ceiling Ceiling,
a.CeilingIsoCurrencyCode CeilingIsoCurrencyCode,
NULL Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
f.EffectiveDate EffectiveDate,
f.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
a.Transferability_ContractTransferabilityId Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
b.LeaseAgreementContainsContact_ContactDimKey ContactDimKey,
f.DisplayName Conract_DisplayName,
f.Id Contract_Id
from LeaseAgreementDimvw a
left join LeaseAgreementContactFactvw b on a.LeaseAgreementDimKey = b.LeaseAgreementDimKey
and b.DeletedDate is null
LEFT JOIN (
select
d.DisplayName,
d.EffectiveDate,
d.ExpirationDate,
d.Id,
e.LeaseAgreementDimKey
from LeaseContractDimvw d
join LeaseAgreementContractFactvw e ON d.LeaseContractDimKey = e.LeaseAgreementContainsLeaseContract_LeaseContractDimKey
where d.Id = @pContractID
AND d.IsDeleted = 0
AND ISNULL(d.ObjectStatus,'') <> @ObjectStatusPendingDelete
)
f on a.LeaseAgreementDimKey = f.LeaseAgreementDimKey
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Disposal Agreement
select a.AgreementNumber AgreementNumber,
NULL Amount,
NULL AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
NULL Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
c.EffectiveDate EffectiveDate,
c.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
e.ContractHasContact_ContactDimKey ContactDimKey,
c.DisplayName Conract_DisplayName,
c.Id Contract_Id
from DisposalAgreementDimvw a
left join DisposalAgreementContractFactvw b on a.DisposalAgreementDimKey = b.DisposalAgreementDimKey and b.DeletedDate is null
left join DisposalContractDimvw c on b.DisposalAgreementContainsDisposalContract_DisposalContractDimKey = c.DisposalContractDimKey and ISNULL(c.ObjectStatus,'') <> @ObjectStatusPendingDelete and c.IsDeleted = 0
AND c.Id like @pContractID
left join ContractDimvw d on c.EntityDimKey = d.EntityDimKey and ISNULL(d.ObjectStatus,'') <> @ObjectStatusPendingDelete and d.IsDeleted = 0
left join ContractContactFactvw e on d.ContractDimKey = e.ContractDimKey and e.DeletedDate is null
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Support Agreement
select
a.AgreementNumber AgreementNumber,
a.Amount Amount,
a.AmountIsoCurrencyCode AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
a.Coverage Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
c.EffectiveDate EffectiveDate,
c.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
e.ContractHasContact_ContactDimKey ContactDimKey,
c.DisplayName Conract_DisplayName,
c.Id Contract_Id
from SupportAgreementDimvw a
left join SupportAgreementContractFactvw b on a.SupportAgreementDimKey = b.SupportAgreementDimKey and b.DeletedDate is null
left join SupportContractDimvw c on b.SupportAgreementContainsSupportContract_SupportContractDimKey = c.SupportContractDimKey and ISNULL(c.ObjectStatus,'') <> @ObjectStatusPendingDelete and c.IsDeleted = 0
AND c.Id like @pContractID
left join ContractDimvw d on c.EntityDimKey = d.EntityDimKey and ISNULL(d.ObjectStatus,'') <> @ObjectStatusPendingDelete and d.IsDeleted = 0
left join ContractContactFactvw e on d.ContractDimKey = e.ContractDimKey and e.DeletedDate is null
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Warranty Agreement
select
a.AgreementNumber AgreementNumber,
NULL Amount,
NULL AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
NULL Coverage,
a.Description Description,
a.DisplayName DisplayName,
a.Duration Duration,
a.DurationUnit_ContractTimeUnitId DurationUnit_ContractTimeUnitId,
f.EffectiveDate EffectiveDate,
f.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
b.WarrantyAgreementContainsContact_ContactDimKey ContacctDimKey,
f.DisplayName Conract_DisplayName,
f.Id Contract_Id
from WarrantyAgreementDimvw a
left join WarrantyAgreementContactFactvw b on a.WarrantyAgreementDimKey = b.WarrantyAgreementDimKey
and b.DeletedDate is null
LEFT JOIN ( select d.DisplayName,
d.EffectiveDate,
d.ExpirationDate,
d.Id,
e.WarrantyAgreementDimKey
from WarrantyContractDimvw d
join WarrantyAgreementContractFactvw e ON d.WarrantyContractDimKey = e.WarrantyAgreementContainsWarrantyContract_WarrantyContractDimKey
where d.Id like @pContractID
AND d.IsDeleted = 0
AND ISNULL(d.ObjectStatus,'') <> @ObjectStatusPendingDelete)
f on a.WarrantyAgreementDimKey = f.WarrantyAgreementDimKey
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Software License Agreement
select a.AgreementNumber AgreementNumber,
NULL Amount,
NULL AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
NULL Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
a.EffectiveDate EffectiveDate,
a.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
a.Program_LicensingProgramId Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
B.SoftwareLicenseAgreementContainsContact_ContactDimKey ContactDimKey,
null Conract_DisplayName,
null Contract_Id
from SWLicenseAgtDimvw a
left join SWAgreementContactFactvw b on a.SWLicenseAgtDimKey = b.SWLicenseAgtDimKey
and b.DeletedDate is null
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete
UNION ALL
-- Software Maintenance and Support Agreements
select a.AgreementNumber AgreementNumber,
a.Amount Amount,
a.AmountIsoCurrencyCode AmountIsoCurrencyCode,
NULL Ceiling,
NULL CeilingIsoCurrencyCode,
a.Coverage Coverage,
a.Description Description,
a.DisplayName DisplayName,
NULL Duration,
NULL DurationUnit_ContractTimeUnitId,
a.EffectiveDate EffectiveDate,
a.ExpirationDate ExpirationDate,
a.LifeCycleStatus_AgreementLifeCycleStatusId LifeCycleStatus_AgreementLifeCycleStatusId,
a.Notes Notes,
NULL Program_LicensingProgramId,
a.Status_EntityStatusId Status_EntityStatusId,
a.TermsAndConditions TermsAndConditions,
NULL Transferability_ContractTransferabilityId,
NULL Type_UserDefinedAgreementTypeId,
b.SoftwareMaintenanceAgreementContainsContact_ContactDimKey ContactDimKey,
null Conract_DisplayName,
null Contract_Id
from SWMaintAgtDimvw a
left join SWMaintAgtContactFactvw b on a.SWMaintAgtDimKey = b.SWMaintAgtDimKey
and b.DeletedDate is null
WHERE a.BaseManagedEntityId = @BaseManagedEntityID
AND a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete)
B
LEFT JOIN (
SELECT a.AgreementLifeCycleStatusId,
ISNULL(b.DisplayName,
a.AgreementLifeCycleStatusValue) LifecycleStatus
FROM AgreementLifeCycleStatusvw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) C ON B.LifeCycleStatus_AgreementLifeCycleStatusId = C.AgreementLifeCycleStatusId
LEFT JOIN (
SELECT a.EntityStatusId,
ISNULL(b.DisplayName,
a.EntityStatusValue) Status
FROM EntityStatus a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) D ON B.Status_EntityStatusId = D.EntityStatusID
LEFT JOIN (
SELECT a.LicensingProgramId,
ISNULL(b.DisplayName,
a.LicensingProgramValue) Program
FROM LicensingProgramvw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) E ON B.Program_LicensingProgramId = e.LicensingProgramId
LEFT JOIN (
SELECT a.ContractTimeUnitId,
ISNULL(b.DisplayName,
a.ContractTimeUnitValue) ContractTimeUnit
FROM ContractTimeUnitvw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) F ON B.DurationUnit_ContractTimeUnitId = F.ContractTimeUnitId
LEFT JOIN (
SELECT a.ContractTransferabilityId,
ISNULL(b.DisplayName,
a.ContractTransferabilityValue) ContractTransferability
FROM ContractTransferability a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) G ON B.Transferability_ContractTransferabilityId = G.ContractTransferabilityId
LEFT JOIN (
SELECT a.UserDefinedAgreementTypeId,
ISNULL(b.DisplayName,
a.UserDefinedAgreementTypeValue) UserDefinedAgreementType
FROM UserDefinedAgreementTypevw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) H ON B.Type_UserDefinedAgreementTypeId = H.UserDefinedAgreementTypeId
LEFT JOIN ContactDimvw I ON B.ContactDimkKey = I.ContactDimKey </CommandText>
</Query>
<Fields>
<Field Name="LifecycleStatus">
<DataField>LifecycleStatus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Status">
<DataField>Status</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Amount">
<DataField>Amount</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="AmountIsoCurrencyCode">
<DataField>AmountIsoCurrencyCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Program">
<DataField>Program</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="AgreementNumber">
<DataField>AgreementNumber</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="ContractTimeUnit">
<DataField>ContractTimeUnit</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Contact">
<DataField>Contact</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CostCenter">
<DataField>CostCenter</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="ContractTransferability">
<DataField>ContractTransferability</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Organization">
<DataField>Organization</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Ceiling">
<DataField>Ceiling</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="Location">
<DataField>Location</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UserDefinedAgreementType">
<DataField>UserDefinedAgreementType</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="CeilingIsoCurrencyCode">
<DataField>CeilingIsoCurrencyCode</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Coverage">
<DataField>Coverage</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Description">
<DataField>Description</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="DisplayName">
<DataField>DisplayName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Duration">
<DataField>Duration</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="EffectiveDate">
<DataField>EffectiveDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="ExpirationDate">
<DataField>ExpirationDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="Notes">
<DataField>Notes</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="TermsAndConditions">
<DataField>TermsAndConditions</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Conract_DisplayName">
<DataField>Conract_DisplayName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Contract_Id">
<DataField>Contract_Id</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
<DataSet Name="AgreementContractManager">
<Query>
<DataSourceName>DWDataMart</DataSourceName>
<QueryParameters>
<QueryParameter Name="@ObjectStatusPendingDelete">
<Value>=Parameters!ObjectStatusPendingDelete.Value</Value>
</QueryParameter>
<QueryParameter Name="@AgreementDimKey">
<Value>=Parameters!AgreementDimKey.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>select b.DisplayName from AgreementSystemUserFactvw a
join SystemUserDimvw b on a.AgreementOwnedBySystemUser_SystemUserDimKey = b.SystemUserDimKey
and isnull(b.ObjectStatus,'') <> @ObjectStatusPendingDelete
and b.IsDeleted = 0
where a.DeletedDate is null
and a.AgreementDimKey = @AgreementDimKey</CommandText>
</Query>
<Fields>
<Field Name="DisplayName">
<DataField>DisplayName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
<DataSet Name="AgreementSupplier">
<Query>
<DataSourceName>DWDataMart</DataSourceName>
<QueryParameters>
<QueryParameter Name="@ObjectStatusPendingDelete">
<Value>=Parameters!ObjectStatusPendingDelete.Value</Value>
</QueryParameter>
<QueryParameter Name="@AgreementDimKey">
<Value>=Parameters!AgreementDimKey.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>
select b.DisplayName from AgreementCompanyFactvw a
join CompanyDimvw b on a.AgreementSuppliedByCompany_CompanyDimKey = b.CompanyDimKey
and isnull(b.ObjectStatus,'') <> @ObjectStatusPendingDelete
and b.IsDeleted = 0
where a.DeletedDate is null
and a.AgreementDimKey = @AgreementDimKey</CommandText>
</Query>
<Fields>
<Field Name="DisplayName">
<DataField>DisplayName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
<DataSet Name="MileStone">
<Query>
<DataSourceName>DWDataMart</DataSourceName>
<QueryParameters>
<QueryParameter Name="@UserLanguage">
<Value>=Code.GetReportLocLanguageCode()</Value>
</QueryParameter>
<QueryParameter Name="@ObjectStatusPendingDelete">
<Value>=Parameters!ObjectStatusPendingDelete.Value</Value>
</QueryParameter>
<QueryParameter Name="@AgreementDimKey">
<Value>=Parameters!AgreementDimKey.Value</Value>
</QueryParameter>
</QueryParameters>
<CommandText>;WITH vMilestoneType as (
SELECT A.MilestoneTypeId,
ISNULL(B.DisplayName, A.MilestoneTypeValue) AS MilestoneType
FROM MilestoneTypevw A
LEFT JOIN DisplayStringDim B ON A.EnumTypeId = B.BaseManagedEntityId
AND B.LanguageCode = @UserLanguage)
SELECT A.AgreementNumber,
D.MilestoneDimKey,
D.Id,
E.MilestoneType,
D.EffectiveDate,
D.DisplayName,
D.Description
FROM AgreementDimvw A
INNER JOIN ConfigItemDimvw B ON A.EntityDimKey = B.EntityDimKey AND B.IsDeleted = 0 AND ISNULL(B.ObjectStatus,'') <> @ObjectStatusPendingDelete
INNER JOIN ConfigItemMilestoneFactvw C ON B.ConfigItemDimKey = C.ConfigItemDimKey AND C.DeletedDate IS NULL
INNER JOIN MilestoneDimvw D ON C.ConfigItemHasMilestones_MilestoneDimKey = D.MilestoneDimKey AND D.IsDeleted = 0 AND ISNULL(D.ObjectStatus,'') <> @ObjectStatusPendingDelete
LEFT JOIN vMilestoneType E ON D.Type_MilestoneTypeId = E.MilestoneTypeId
select a.AgreementNumber AgreementNumber,
a.Description Description,
a.DisplayName DisplayName,
a.EffectiveDate EffectiveDate,
a.ExpirationDate ExpirationDate,
a.Notes Notes,
a.TermsAndConditions TermsAndConditions,
c.LifecycleStatus,
D.Status,
H.UserDefinedAgreementType
from UserDefinedAgreementDimvw A
join UserDefinedAgreementAgreementFactvw B on a.UserDefinedAgreementDimKey = B.UserDefinedAgreementDimKey
and b.UserDefinedAgreementRelatesToAgreement_AgreementDimKey = @AgreementDimKey
and b.DeletedDate is null
LEFT JOIN (
SELECT a.AgreementLifeCycleStatusId,
ISNULL(b.DisplayName,
a.AgreementLifeCycleStatusValue) LifecycleStatus
FROM AgreementLifeCycleStatusvw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) C ON A.LifeCycleStatus_AgreementLifeCycleStatusId = C.AgreementLifeCycleStatusId
LEFT JOIN (
SELECT a.EntityStatusId,
ISNULL(b.DisplayName,
a.EntityStatusValue) Status
FROM EntityStatus a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) D ON A.Status_EntityStatusId = D.EntityStatusID
LEFT JOIN (
SELECT a.UserDefinedAgreementTypeId,
ISNULL(b.DisplayName,
a.UserDefinedAgreementTypeValue) UserDefinedAgreementType
FROM UserDefinedAgreementTypevw a
LEFT JOIN vDisplayStringDimvw b
ON a.EnumTypeId = b.BaseManagedEntityId) H ON A.Type_UserDefinedAgreementTypeId = H.UserDefinedAgreementTypeId
WHERE a.IsDeleted = 0
AND ISNULL(a.ObjectStatus,'') <> @ObjectStatusPendingDelete</CommandText>
</Query>
<Fields>
<Field Name="AgreementNumber">
<DataField>AgreementNumber</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Description">
<DataField>Description</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="DisplayName">
<DataField>DisplayName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="EffectiveDate">
<DataField>EffectiveDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="ExpirationDate">
<DataField>ExpirationDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="Notes">
<DataField>Notes</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="TermsAndConditions">
<DataField>TermsAndConditions</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="LifecycleStatus">
<DataField>LifecycleStatus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Status">
<DataField>Status</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UserDefinedAgreementType">
<DataField>UserDefinedAgreementType</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportParameters>
<ReportParameter Name="LT_Report">
<DataType>String</DataType>
<DefaultValue>
<DataSetReference>
<DataSetName>LT_Report</DataSetName>
<ValueField>XML_F52E2B61_18A1_11d1_B105_00805F49916B</ValueField>
</DataSetReference>
</DefaultValue>
<Hidden>true</Hidden>
</ReportParameter>
<ReportParameter Name="AgreementDimKey">
<DataType>Integer</DataType>
<Prompt>AgreementDimKey</Prompt>
</ReportParameter>
<ReportParameter Name="ExpiredThreshold">
<DataType>Integer</DataType>
<DefaultValue>
<DataSetReference>
<DataSetName>ContractAdminSettings</DataSetName>
<ValueField>ExpiredThresholdDays</ValueField>
</DataSetReference>
</DefaultValue>
<Prompt xml:space="preserve"> </Prompt>
<Hidden>true</Hidden>
</ReportParameter>
<ReportParameter Name="CloseToExpiredThreshold">
<DataType>Integer</DataType>
<DefaultValue>
<DataSetReference>
<DataSetName>ContractAdminSettings</DataSetName>
<ValueField>CloseToExpiredThresholdDays</ValueField>
</DataSetReference>
</DefaultValue>
<Prompt xml:space="preserve"> </Prompt>
<Hidden>true</Hidden>
</ReportParameter>
<ReportParameter Name="ObjectStatusPendingDelete">
<DataType>String</DataType>
<DefaultValue>
<Values>
<Value>System.ConfigItem.ObjectStatusEnum.PendingDelete</Value>
</Values>
</DefaultValue>
<Hidden>true</Hidden>
</ReportParameter>
<ReportParameter Name="ContractID">
<DataType>String</DataType>
<Nullable>true</Nullable>
<AllowBlank>true</AllowBlank>
<Prompt>ReportParameter1</Prompt>
<Hidden>true</Hidden>
</ReportParameter>
</ReportParameters>
<Code><Script>Const LocTableStringQuery As String = "R/S[@N='{0}']/text()"
Const TimeZoneParameterName As String = "TimeZone"
Const SD_BaseTypeParameterName As String = "StartDate_BaseType"
Const SD_BaseValueParameterName As String = "StartDate_BaseValue"
Const SD_OffsetTypeParameterName As String = "StartDate_OffsetType"
Const SD_OffsetValueParameterName As String = "StartDate_OffsetValue"
Const ED_BaseTypeParameterName As String = "EndDate_BaseType"
Const ED_BaseValueParameterName As String = "EndDate_BaseValue"
Const ED_OffsetTypeParameterName As String = "EndDate_OffsetType"
Const ED_OffsetValueParameterName As String = "EndDate_OffsetValue"
Const IsRelativeTimeSupported As Boolean = False
Const TimeTypeParameterName As String = "TimeType"
Const TimeWeekMapParameterName As String = "TimeWeekMap"
Dim LocTables As System.Collections.Generic.Dictionary(Of String, Microsoft.EnterpriseManagement.Reporting.XmlStringTable)
Dim ReportTimeZone As Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation
Dim ReportStartDate As DateTime
Dim ReportEndDate As DateTime
Dim ReportTime As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime
Dim ReportCulture As System.Globalization.CultureInfo
Dim ParameterProcessor As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor
Dim TargetList As String
Protected Overrides Sub OnInit()
LocTables = new System.Collections.Generic.Dictionary(Of String, Microsoft.EnterpriseManagement.Reporting.XmlStringTable)()
ReportTimeZone = Microsoft.EnterpriseManagement.Reporting.TimeZoneInformation.Current
ReportStartDate = DateTime.MinValue
ReportEndDate = DateTime.MinValue
ReportTime = Nothing
ReportCulture = System.Globalization.CultureInfo.GetCultureInfo(Report.User("Language"))
ParameterProcessor = New Microsoft.EnterpriseManagement.Reporting.ParameterProcessor(ReportCulture)
TargetList =Nothing
End Sub
'Public Function GetCallingManagementGroupId() As String
' Return 'Microsoft.EnterpriseManagement.Reporting.ReportingConfiguration.M'anagementGroupId
'End Function
Public Function GetReportLocLanguageCode() As String
Return ReportCulture.ThreeLetterWindowsLanguageName
End Function
Public Function GetReportLCID() As Integer
Return ReportCulture.LCID
End Function
Public Function GetLocTable(Name As String) As Microsoft.EnterpriseManagement.Reporting.XmlStringTable
Dim LocTable As Microsoft.EnterpriseManagement.Reporting.XmlStringTable
If Not LocTables.TryGetValue(Name, LocTable) Then
LocTable = New Microsoft.EnterpriseManagement.Reporting.XmlStringTable(LocTableStringQuery, Report.Parameters(Name).Value)
LocTables.Add(Name, LocTable)
End If
Return LocTable
End Function
Public Function GetReportTimeZone() As Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation
If IsNothing(ReportTimeZone) Then ReportTimeZone = Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation.FromValueString(Report.Parameters(TimeZoneParameterName).Value)
Return ReportTimeZone
End Function
Public Function ToDbDate(ByVal DateValue As DateTime) As DateTime
return GetReportTimeZone.ToUniversalTime(DateValue)
End Function
Public Function ToReportDate(ByVal DateValue As DateTime) As DateTime
return GetReportTimeZone.ToLocalTime(DateValue)
End Function
Public Function GetReportStartDate() As DateTime
If (ReportStartDate = DateTime.MinValue) Then
If (IsRelativeTimeSupported) Then
ReportStartDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(SD_BaseTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(SD_OffsetTypeParameterName).Value, Report.Parameters(SD_OffsetValueParameterName).Value, Report.Parameters(TimeTypeParameterName).Value)
Else
ReportStartDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(SD_BaseTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(SD_OffsetTypeParameterName).Value, Report.Parameters(SD_OffsetValueParameterName).Value)
End if
End If
return ReportStartDate
End Function
Public Function GetReportEndDate() As DateTime
If (ReportEndDate = DateTime.MinValue) Then
If (IsRelativeTimeSupported) Then
ReportEndDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(ED_BaseTypeParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, Report.Parameters(ED_OffsetTypeParameterName).Value, Report.Parameters(ED_OffsetValueParameterName).Value, Report.Parameters(TimeTypeParameterName).Value)
If IsBusinessHours(GetReportTimeFilter()) Then ReportEndDate = ReportCulture.Calendar.AddDays(ReportEndDate, 1)
Else
ReportEndDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(ED_BaseTypeParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, Report.Parameters(ED_OffsetTypeParameterName).Value, Report.Parameters(ED_OffsetValueParameterName).Value)
End if
End If
return ReportEndDate
End Function
Public Function GetReportTimeFilter() As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime
If IsNothing(ReportTime) Then ReportTime = New Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime(Report.Parameters(TimeTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, CStr(Join(Report.Parameters(TimeWeekMapParameterName).Value, ",")))
return ReportTime
End Function
Public Function IsBusinessHours(Value As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime) As Boolean
return (Not IsNothing(Value)) And (Value.TimeType = Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTimeType.Business)
End Function
Public Function FormatDateTime(Format As String, Value As DateTime) As String
return Value.ToString(Format, ReportCulture)
End Function
Public Function FormatNumber(Format As String, Value As Decimal) As String
return Value.ToString(Format, ReportCulture)
End Function
Public Function FormatString(Format As String, ParamArray Values() as Object) As String
return String.Format(ReportCulture, Format, Values)
End Function
Public Function NullFormatString(Format As String, Value as String) As String
return IIF(String.IsNullOrEmpty(Value), String.Empty, String.Format(ReportCulture, Format, Value))
End Function
Public Function FormatBusinessHours(Format As String, Value As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime) As String
Dim result As String
If IsBusinessHours(Value) Then
Dim firstDay As DayOfWeek
Dim days As System.Collections.Generic.List(Of String)
firstDay = ReportCulture.DateTimeFormat.FirstDayOfWeek
days = new System.Collections.Generic.List(Of String)()
For loopDay As DayOfWeek = DayOfWeek.Sunday To DayOfWeek.Saturday
Dim day As DayOfWeek
day = CType((CInt(loopDay) + CInt(firstDay)) Mod 7, DayOfWeek)
If value.WeekMap.Contains(day) Then days.Add(ReportCulture.DateTimeFormat.GetAbbreviatedDayName(day))
Next loopDay
result = FormatString(Format, DateTime.Today.Add(Value.StartTime).ToString(ReportCulture.DateTimeFormat.ShortTimePattern), DateTime.Today.Add(Value.EndTime).ToString(ReportCulture.DateTimeFormat.ShortTimePattern), String.Join(",", days.ToArray()))
Else
result = String.Empty
End if
return result
End Function
Public Function BuildXmlValueList(ByVal ValueList() As Object) As String
Return Microsoft.EnterpriseManagement.Reporting.MultiValueParameter.ToXml("Data", "Value", ValueList)
End Function
REM -------------------------------------------------
Dim ReportFormatList As System.Collections.Generic.Dictionary(Of String, IDataFormatter)
Const FormatListParameterName As String = "DataFormat"
REM -------------------------------------------------
Public Interface IDataFormatter
Function FormatData(ByVal Value As String) As String
End Interface
Public Class RankDataFormatter
Implements IDataFormatter
Private Series As System.Collections.Generic.SortedDictionary(Of Decimal, String)
Private Culture As System.Globalization.CultureInfo
Public Sub New(ByVal Config As System.Xml.XmlNode, ByVal ReportCulture As System.Globalization.CultureInfo)
Culture = ReportCulture
Series = New System.Collections.Generic.SortedDictionary(Of Decimal, String)()
For Each SeriesXml As System.Xml.XmlNode In Config.ChildNodes
Series.Add(Decimal.Parse(SeriesXml.Attributes("Rank").Value), SeriesXml.Attributes("Format").Value)
Next
End Sub
Public Function FormatData(ByVal Value As String) As String Implements IDataFormatter.FormatData
Dim Result As String = CDec(Value).ToString("G", Culture)
For Each FormatItem As System.Collections.Generic.KeyValuePair(Of Decimal, String) In Series
Dim RunningValue As Decimal = Math.Round(Value / FormatItem.Key)
If RunningValue > 0 Then
Result = String.Format(Culture, FormatItem.Value, RunningValue.ToString("G", Culture))
Else
Exit For
End If
Next
Return Result
End Function
End Class
Public Class LookupDataFormatter
Implements IDataFormatter
Private MappingTable As System.Collections.Generic.IDictionary(Of String, String)
Public Sub New(ByVal Config As System.Xml.XmlNode)
MappingTable = New System.Collections.Generic.Dictionary(Of String, String)(StringComparer.OrdinalIgnoreCase)
For Each SeriesXml As System.Xml.XmlNode In Config.ChildNodes
MappingTable.Add(Decimal.Parse(SeriesXml.Attributes("Value").Value), SeriesXml.Attributes("Label").Value)
Next
End Sub
Public Function FormatData(ByVal Value As String) As String Implements IDataFormatter.FormatData
Dim Result As String
If MappingTable.ContainsKey(Value) Then
Result = MappingTable(Value)
Else
Result = Value
End If
Return Result
End Function
End Class
Public Function GetReportFormatList() As System.Collections.Generic.Dictionary(Of String, IDataFormatter)
If IsNothing(ReportFormatList) Then
Dim Xml As System.Xml.XmlDocument = New System.Xml.XmlDocument()
Xml.LoadXml(Report.Parameters(FormatListParameterName).Value)
ReportFormatList = New System.Collections.Generic.Dictionary(Of String, IDataFormatter)(StringComparer.OrdinalIgnoreCase)
For Each Node As System.Xml.XmlNode In Xml.DocumentElement.ChildNodes
Dim Formatter As IDataFormatter = Nothing
Select Case Node.Attributes("Type").Value.ToUpper()
Case "RANK"
Formatter = New RankDataFormatter(Node, ReportCulture)
Case "LOOKUP"
Formatter = New LookupDataFormatter(Node)
End Select
If Not IsNothing(Formatter) Then
ReportFormatList.Add(Node.Attributes("Name").Value, Formatter)
End If
Next
End If
Return ReportFormatList
End Function
Public Function FormatData(ByVal FormatName As String, ByVal DataType As String, ByVal Value As String)
Dim FormatList As System.Collections.Generic.Dictionary(Of String, IDataFormatter) = GetReportFormatList()
If Not String.IsNullOrEmpty(FormatName) And Not IsNothing(FormatList) Then
If FormatList.ContainsKey(FormatName) Then
Return FormatList(FormatName).FormatData(Value)
End If
End If
If Not String.IsNullOrEmpty(DataType) Then
If DataType = "DateTime" Then
Return FormatDateTime("g", CDate(Value))
ElseIf DataType.StartsWith("UInt") Then
Return FormatNumber("G", Value)
End If
End If
Return Value
End Function
REM ----------------------------------------
Public Dim CurrentObjectList As String
Public Function InitList(ByRef List As String) As String
List = String.Empty
Return List
End Function
Public Function AddListItem(ByRef List As String, Item as String) As String
List = List + Item
Return List
End Function
Public Function GetObjectList(ByVal OptionsXml As String) As String()
Dim Xml As System.Xml.XmlDocument
Xml = New System.Xml.XmlDocument()
Xml.LoadXml(OptionsXml)
Dim Result As System.Collections.Generic.List(Of String)
Result = New System.Collections.Generic.List(Of String)
For Each ObjectNode As System.Xml.XmlNode In Xml.SelectNodes("/Value/Object")
If Not Result.Contains(ObjectNode.InnerText) Then
Result.Add(ObjectNode.InnerText)
End If
Next
Return Result.ToArray()
End Function
</Script></Code>
<Language>en-US</Language>
<CodeModules>
<CodeModule>Microsoft.EnterpriseManagement.Reporting.Code, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</CodeModule>
<CodeModule>System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</CodeModule>
</CodeModules>
<ConsumeContainerWhitespace>true</ConsumeContainerWhitespace>
<rd:ReportUnitType>Inch</rd:ReportUnitType>
<rd:ReportID>c149c887-0af1-4cb8-b2b7-057731e8b2ad</rd:ReportID>
</Report>