blpapi override is requested but not represented in outputted value? - blpapi

I am requesting the field TRADING_DAY_START_TIME_EOD (Market Open time).
In excel I can give overrides so I am doing the same for blpapi. The request is:
securities[] = {
"/sedol1/<SEDOL> AU Equity"
}
fields[] = {
"TRADING_DAY_START_TIME_EOD"
}
overrides[] = {
overrides = {
fieldId = "SINGLE_DATE_OVERRIDE"
value = "2020-03-30"
}
}
}
even if I use a ridiculous value for the override e.g. "HELLO", it does not complain and still provides me with a solution. Any ideas why the override is not working?
Thanks!

Related

Eclipse JDT resolve unknown kind from annotation IMemberValuePair

I need to retrieve the value from an annotation such as this one that uses a string constant:
#Component(property = Constants.SERVICE_RANKING + ":Integer=10")
public class NyServiceImpl implements MyService {
But I am getting a kind of K_UNKNOWN and the doc says "the value is an expression that would need to be further analyzed to determine its kind". My question then is how do I perform this analysis? I could even manage to accept getting the plain source text value in this case.
The other answer looks basically OK, but let me suggest a way to avoid using the internal class org.eclipse.jdt.internal.core.Annotation and its method findNode():
ISourceRange range = annotation.getSourceRange();
ASTNode annNode = org.eclipse.jdt.core.dom.NodeFinder.perform(cu, range);
From here on you should be safe, using DOM API throughout.
Googling differently I found a way to resolve the expression. Still open to other suggestions if any. For those who might be interested, here is a snippet of code:
if (valueKind == IMemberValuePair.K_UNKNOWN) {
Annotation ann = (Annotation)annotation;
CompilationUnit cu = getAST(ann.getCompilationUnit());
ASTNode annNode = ann.findNode(cu);
NormalAnnotation na = (NormalAnnotation)annNode;
List<?> naValues = na.values();
Optional<?> optMvp = naValues.stream()
.filter(val-> ((MemberValuePair)val).getName().getIdentifier().equals(PROPERTY))
.findAny();
if (optMvp.isPresent()) {
MemberValuePair pair = (MemberValuePair)optMvp.get();
if (pair.getValue() instanceof ArrayInitializer) {
ArrayInitializer ai = (ArrayInitializer)pair.getValue();
for (Object exprObj : ai.expressions()) {
Expression expr = (Expression)exprObj;
String propValue = (String)expr.resolveConstantExpressionValue();
if (propValue.startsWith(Constants.SERVICE_RANKING)) {
return true;
}
}
}
else {
Expression expr = pair.getValue();
String propValue = (String)expr.resolveConstantExpressionValue();
if (propValue.startsWith(Constants.SERVICE_RANKING)) {
return true;
}
}
}
//report error
}
private CompilationUnit getAST(ICompilationUnit compUnit) {
final ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compUnit);
parser.setResolveBindings(true); // we need bindings later on
CompilationUnit unit = (CompilationUnit)parser.createAST(null);
return unit;
}

Change String length or decimal precision of field attribute dynamically

I'm trying to use setup data from one table to allow me to format fields on the fly / dynamically. I know I can change field names and visibility based on the PXUIFieldAttribute class, but changing the precision or string length is a bit trickier, obviously. From the research I've done, I've come up with the following example code that seems like it should work - but I get the error:
"Unable to cast object of type 'PX.Data.PXUIFieldAttribute' to type 'PX.Data.PXDBDecimalAttribute'.
I don't see why this is occurring...
protected virtual void xTACOpenSourceDetail_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
var osd = (PXCache)sender;
foreach (PXDBDecimalAttribute attribute in this.Caches<xTACOpenSourceDetail>().GetAttributes("Number1"))
{
PXDBDecimalAttribute someAttribute = attribute as PXDBDecimalAttribute;
if (someAttribute != null)
{
someAttribute.DBProperties._precision = 4;
}
}
}
I just tried the below code in sales order screen and it seems working!
var props = typeof(SOOrder).GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(PXDecimalAttribute)));
foreach (System.Reflection.PropertyInfo item in props)
{
PXDecimalAttribute.SetPrecision(this.Base.Caches[typeof(SOOrder)], item.Name, 1);
}
You might need to change this to match your DAC.

Creating Trending line on bar chart

I have a Bar chart on Kentico reporting section. And I know Kentico uses Microsoft Chart Controls. Microsoft Chart controls have the capability of creating a trending line on Bar graph - But I do see any option how I can utilize those on Kentico Reporting.
Is there any option there on reporting tool to get this trending line ?
If there is no option can anybody suggest anything else ?
Using custom module is the last option for me to try. If anybody has any specific suggestion regarding this custom module, please share that, too.
I am using Kentico 7.
Got it working the way Brend suggested however the mean is not coming up
ChartArea area = graph.ChartControl.ChartAreas[chartAreas - 1];
StripLine line = new StripLine();
// Set threshold line so that it is only shown once
line.Interval = 0;
// Set the threshold line to be drawn at the calculated mean of the first series
line.IntervalOffset = graph.ChartControl.DataManipulator.Statistics.Mean(graph.ChartControl.Series[0].Name);
line.BackColor = System.Drawing.Color.DarkGreen;
line.StripWidth = 0.25;
// Set text properties for the threshold line
//line.Text = "Mean";
line.ForeColor = System.Drawing.Color.Black;
// Add strip line to the chart
area.AxisY.StripLines.Add(line);
Also, for other trend line I am using bellow code, again having no luck as it looks like the datapoints are not set at the point where my code runs :
int chartAreas = graph.ChartControl.ChartAreas.Count;
if (chartAreas > 0)
{
graph.ChartControl.Series.Add("TrendLine");
graph.ChartControl.Series["TrendLine"].ChartType = SeriesChartType.Line;
graph.ChartControl.Series["TrendLine"].BorderWidth = 3;
graph.ChartControl.Series["TrendLine"].Color = System.Drawing.Color.Red;
// Line of best fit is linear
string typeRegression = "Linear";//"Exponential";//
// The number of days for Forecasting
string forecasting = "1";
// Show Error as a range chart.
string error = "false";
// Show Forecasting Error as a range chart.
string forecastingError = "false";
// Formula parameters
string parameters = typeRegression + ',' + forecasting + ',' + error + ',' + forecastingError;
graph.ChartControl.Series[0].Sort(PointSortOrder.Ascending, "X");
// Create Forecasting Series.
graph.ChartControl.DataManipulator.FinancialFormula(FinancialFormula.Forecasting, parameters, graph.ChartControl.Series[0], graph.ChartControl.Series["TrendLine"]);
}
The actual issue, I guess, is not having the graph.ChartControl.Series[0] at the place I am running my TrendLine generation code. Any idea how can I get it ?
Report charts are rendered through \CMSModules\Reporting\Controls\ReportGraph.ascx
You can modify the method GetReportGraph and add additional setup to the chart control ucChart based on some condition, e.g. the report name and chart name (you will have to hardcode that)
Note that you will need to modify Kentico code directly, so keep the changes at the lowest possible level, I recommend:
Put the extra setup code to an external class
Call it with just one extra line of code
Add comment to mark that extra line of code as customization
e.g.:
/* YourCompany */
MyChartExtender.ExtendChart(ucChart, ...);
/* YourCompany end */
Make sure you note that change for future upgrades
I've modified the controls before and you can use this code in the GetReportGraph() method just before enabling the subscription.
// apply the trendline
if (TrendValue > 0)
{
int chartAreas = graph.ChartControl.ChartAreas.Count;
if (chartAreas > 0)
{
ChartArea area = graph.ChartControl.ChartAreas[chartAreas - 1];
StripLine line = new StripLine();
line.IntervalOffset = TrendValue;
line.BorderColor = System.Drawing.ColorTranslator.FromHtml(TrendColor);
line.BackColor = System.Drawing.ColorTranslator.FromHtml(TrendColor);
line.StripWidth = TrendLineWidth;
line.ToolTip = TrendToolTip;
line.Text = TrendText;
line.TextLineAlignment = trendLineAlignment;
line.TextOrientation = TextOrientation.Horizontal;
line.TextAlignment = trendTextAlignment;
area.AxisY.StripLines.Add(line);
}
}
Of course you'll have to add the appropriate properties and pass the values through from the rest of the pages/controls using this control.
#region Trending
/// <summary>
/// Value for the single trendline for whole chart
/// </summary>
public int TrendValue
{
get
{
return mTrendValue;
}
set
{
mTrendValue = value;
}
}
/// <summary>
/// Color of the trend line in hex format (i.e. #0000FF)
/// </summary>
public string TrendColor
{
get
{
return mTrendColor;
}
set
{
mTrendColor = value;
}
}
/// <summary>
/// Tool tip of the trend line
/// </summary>
public string TrendToolTip
{
get
{
return mTrendToolTip;
}
set
{
mTrendToolTip = value;
}
}
/// <summary>
/// Text of the trend line
/// </summary>
public string TrendText
{
get
{
return mTrendText;
}
set
{
mTrendText = value;
}
}
/// <summary>
/// Trend line width
/// </summary>
public double TrendLineWidth
{
get
{
return mTrendLineWidth;
}
set
{
mTrendLineWidth = value;
}
}
string mTrendLineAlignment;
public string TrendLineAlignment
{
get
{
return mTrendLineAlignment;
}
set
{
mTrendLineAlignment = value;
}
}
private System.Drawing.StringAlignment trendLineAlignment
{
get
{
switch (TrendLineAlignment)
{
case "center":
return System.Drawing.StringAlignment.Center;
case "near":
return System.Drawing.StringAlignment.Near;
case "far":
return System.Drawing.StringAlignment.Far;
default:
return System.Drawing.StringAlignment.Near;
}
}
}
string mTrendTextAlignment;
public string TrendTextAlignment
{
get
{
return mTrendTextAlignment;
}
set
{
mTrendTextAlignment = value;
}
}
private System.Drawing.StringAlignment trendTextAlignment
{
get
{
switch (TrendTextAlignment)
{
case "center":
return System.Drawing.StringAlignment.Center;
case "near":
return System.Drawing.StringAlignment.Near;
case "far":
return System.Drawing.StringAlignment.Far;
default:
return System.Drawing.StringAlignment.Near;
}
}
}
#endregion

MonoTouch Dialog elements are not updating/repainting themselves

I have the following in a Section:
_favElement = new StyledStringElement (string.Empty);
_favElement.Alignment = UITextAlignment.Center;
if (_room.IsFavourite) {
_favElement.Image = UIImage.FromBundle ("Images/thumbs_up.png");
_favElement.Caption = "Unmark as Favourite";
} else {
_favElement.Image = null;
_favElement.Caption = "Mark as Favourite";
}
_favElement.Tapped += favElement_Tapped;
Then when I press the element I want the following to happen:
private void favElement_Tapped ()
{
if (_room.IsFavourite) {
_favElement.Image = null;
_favElement.Caption = "Mark as Favourite";
} else {
_favElement.Image = UIImage.FromBundle ("Images/thumbs_up.png");
_favElement.Caption = "Unmark as Favourite";
}
_room.IsFavourite = !_room.IsFavourite;
}
However the image and text does not change in the actual element when the element is tapped. Is there a refresh method or something that must be called? I've also tried changing the Accessory on Tapped as well and nothing changes. The properties behind do reflect the correct values though.
An alternative to reloading the UITableView is to reload the Element using code like this (copied from Touch.Unit):
if (GetContainerTableView () != null) {
var root = GetImmediateRootElement ();
root.Reload (this, UITableViewRowAnimation.Fade);
}
assuming that your code is in DialogViewController,add this
this.ReloadData();
but in your case I recommend you to use BooleanImageElement

Get item’s metadata with Entity Framework?

I'm working with Sharepoint 2010.
I need to know the date of creation/edition and the author/editor of items in my sharepoint's Lists, but I didn't find a solution to map these columns with Entity Framework.
I tried this kind of code :
[Microsoft.SharePoint.Linq.ColumnAttribute(Name = "tp_author", Storage = "_author", ReadOnly = true, FieldType = "User")]
public SPUser Author
{
get
{
return this._author;
}
set
{
if (!value.Equals(this._author))
{
this.OnPropertyChanging("Author", this._author);
this._author = value;
this.OnPropertyChanged("Author");
}
}
}
But with that code, Sharepoint give me this error:
Invalid transfer type Microsoft.SharePoint.SPUser
I also tried with other types for _author, but it doesn't change anything.
Is there a way to make this mapping?
SPMetal generates the following code for a user field
[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]
public System.Nullable<int> AssignedToId {
get {
return this._assignedToId;
}
set {
if ((value != this._assignedToId)) {
this.OnPropertyChanging("AssignedToId", this._assignedToId);
this._assignedToId = value;
this.OnPropertyChanged("AssignedToId");
}
}
}
[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]
public string AssignedTo {
get {
return this._assignedTo;
}
set {
if ((value != this._assignedTo)) {
this.OnPropertyChanging("AssignedTo", this._assignedTo);
this._assignedTo = value;
this.OnPropertyChanged("AssignedTo");
}
}
}

Resources