Skip to content

Commit

Permalink
return no-value if date time is MinValue or time is lower than zero
Browse files Browse the repository at this point in the history
  • Loading branch information
danielklecha committed Sep 25, 2024
1 parent f2690b2 commit 54bc841
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions SharpIpp/Mapping/Profiles/GetJobAttributesProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,27 @@ public void CreateMaps(IMapperConstructor mapper)
dic.Add( JobAttribute.Compression, new IppAttribute[] { new IppAttribute( Tag.Keyword, JobAttribute.Compression, map.Map<string>( src.Compression ) ) } );
if ( src.Copies != null )
dic.Add( JobAttribute.Copies, new IppAttribute[] { new IppAttribute( Tag.Integer, JobAttribute.Copies, src.Copies.Value ) } );
if ( src.DateTimeAtCompleted != null )
dic.Add( JobAttribute.DateTimeAtCompleted, new IppAttribute[] { new IppAttribute( Tag.DateTime, JobAttribute.DateTimeAtCompleted, src.DateTimeAtCompleted.Value ) } );
if ( src.DateTimeAtCreation != null )
dic.Add( JobAttribute.DateTimeAtCreation, new IppAttribute[] { new IppAttribute( Tag.DateTime, JobAttribute.DateTimeAtCreation, src.DateTimeAtCreation.Value ) } );
if ( src.DateTimeAtProcessing != null )
dic.Add( JobAttribute.DateTimeAtProcessing, new IppAttribute[] { new IppAttribute( Tag.DateTime, JobAttribute.DateTimeAtProcessing, src.DateTimeAtProcessing.Value ) } );
if (src.DateTimeAtCompleted != null)
{
if (src.DateTimeAtCompleted.Value > DateTime.MinValue)
dic.Add(JobAttribute.DateTimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.DateTime, JobAttribute.DateTimeAtCompleted, src.DateTimeAtCompleted.Value) });
else
dic.Add(JobAttribute.DateTimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.DateTimeAtCompleted, NoValue.Instance) });
}
if (src.DateTimeAtCreation != null)
{
if (src.DateTimeAtCreation.Value > DateTime.MinValue)
dic.Add(JobAttribute.DateTimeAtCreation, new IppAttribute[] { new IppAttribute(Tag.DateTime, JobAttribute.DateTimeAtCreation, src.DateTimeAtCreation.Value) });
else
dic.Add(JobAttribute.DateTimeAtCreation, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.DateTimeAtCreation, NoValue.Instance) });
}
if (src.DateTimeAtProcessing != null)
{
if (src.DateTimeAtProcessing.Value > DateTime.MinValue)
dic.Add(JobAttribute.DateTimeAtProcessing, new IppAttribute[] { new IppAttribute(Tag.DateTime, JobAttribute.DateTimeAtProcessing, src.DateTimeAtProcessing.Value) });
else
dic.Add(JobAttribute.DateTimeAtProcessing, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.DateTimeAtProcessing, NoValue.Instance) });
}
if ( src.DocumentFormat != null )
dic.Add( JobAttribute.DocumentFormat, new IppAttribute[] { new IppAttribute( Tag.MimeMediaType, JobAttribute.DocumentFormat, src.DocumentFormat ) } );
if ( src.DocumentName != null )
Expand Down Expand Up @@ -173,12 +188,27 @@ public void CreateMaps(IMapperConstructor mapper)
dic.Add( JobAttribute.PrintQuality, new IppAttribute[] { new IppAttribute( Tag.Enum, JobAttribute.PrintQuality, (int)src.PrintQuality.Value ) } );
if ( src.Sides != null )
dic.Add( JobAttribute.Sides, new IppAttribute[] { new IppAttribute( Tag.Keyword, JobAttribute.Sides, map.Map<string>( src.Sides ) ) } );
if ( src.TimeAtCompleted != null )
dic.Add( JobAttribute.TimeAtCompleted, new IppAttribute[] { new IppAttribute( Tag.Integer, JobAttribute.TimeAtCompleted, src.TimeAtCompleted.Value ) } );
if ( src.TimeAtCreation != null )
dic.Add( JobAttribute.TimeAtCreation, new IppAttribute[] { new IppAttribute( Tag.Integer, JobAttribute.TimeAtCreation, src.TimeAtCreation.Value ) } );
if ( src.TimeAtProcessing != null )
dic.Add( JobAttribute.TimeAtProcessing, new IppAttribute[] { new IppAttribute( Tag.Integer, JobAttribute.TimeAtProcessing, src.TimeAtProcessing.Value ) } );
if (src.TimeAtCompleted != null)
{
if (src.TimeAtCompleted.Value >= 0)
dic.Add(JobAttribute.TimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.Integer, JobAttribute.TimeAtCompleted, src.TimeAtCompleted.Value) });
else
dic.Add(JobAttribute.TimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.TimeAtCompleted, NoValue.Instance) });
}
if (src.TimeAtCreation != null)
{
if (src.TimeAtCreation.Value >= 0)
dic.Add(JobAttribute.TimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.Integer, JobAttribute.TimeAtCreation, src.TimeAtCreation.Value) });
else
dic.Add(JobAttribute.TimeAtCompleted, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.TimeAtCreation, NoValue.Instance) });
}
if (src.TimeAtProcessing != null)
{
if (src.TimeAtProcessing.Value >= 0)
dic.Add(JobAttribute.TimeAtProcessing, new IppAttribute[] { new IppAttribute(Tag.Integer, JobAttribute.TimeAtProcessing, src.TimeAtProcessing.Value) });
else
dic.Add(JobAttribute.TimeAtProcessing, new IppAttribute[] { new IppAttribute(Tag.NoValue, JobAttribute.TimeAtProcessing, NoValue.Instance) });
}
return dic;
} );
}
Expand Down

0 comments on commit 54bc841

Please sign in to comment.