/// <summary> /// Create a value from a list of items /// </summary> /// <param name="items">An enumerator providing the items to make up the sequence. Every /// member of this list must be an instance of <c>XdmItem</c> /// </param> public XdmValue(IEnumerable items) { JArrayList list = new JArrayList(); foreach (XdmItem c in items) { list.add((Item)c.Unwrap()); } value = new SequenceExtent(list); }
public DataElement(Tag tag, ValueRepresentation vr) { this.tag = tag; TransferSyntax = Tag.TransferSyntax; if (vr == null) { vr = ValueRepresentation.GetBy(Tag); } this.vr = vr; }
/// <summary> /// Create a value from a collection of items /// </summary> /// <param name="items">An enumerable collection providing the items to make up the sequence. Every /// member of this collection must be an instance of <c>XdmItem</c> /// </param> public XdmValue(IEnumerable items) { JArrayList list = new JArrayList(); foreach (XdmItem c in items) { list.add((Item)c.Unwrap()); } value = new SequenceExtent(list); }
private void WriteVRWithUndefinedValueLength(ValueRepresentation vr) { if (VRCoding == DicomVRCoding.Explicit) { DataWriter.Write(vr.Id.Item1); DataWriter.Write(vr.Id.Item2); DataWriter.WriteZeros(2); } DataWriter.Write(UndefinedLength); }
protected internal override Representation DispatchOtherProperty(object property, string param) { if (property is CompositeData) { return(DispatchCompositeData(( CompositeData )property)); } else { return(ValueRepresentation.@string(property.ToString())); } }
public BaseData(ConfigurationBase initializationData) { title = initializationData.Title; mainConfigType = initializationData.GetMainConfigType; configArea = initializationData.GetConfigArea; valueDataType = initializationData.ValueDataType; typography = initializationData.Typography; valueRepresentation = initializationData.ValueRepresentation; valueEditType = initializationData.ValueEditType; configRange = initializationData.configRange; this.processingIndex = initializationData.ProcessingIndex; }
public ConfigurationBase(string title, MainConfigType mainConfigType, ConfigArea configArea, ValueDataType valueDataType, Typography typography, ValueRepresentation valueRepresentation, ValueEditType valueEditType, ConfigRange configRange, int processingIndex) { Title = title; this.mainConfigType = mainConfigType; this.configArea = configArea; ValueDataType = valueDataType; Typography = typography; ValueRepresentation = valueRepresentation; ValueEditType = valueEditType; this.configRange = configRange; ProcessingIndex = processingIndex; }
/// <summary> /// Evaluate the query, returning the result as an <c>XdmValue</c> (that is, /// a sequence of nodes and/or atomic values). /// </summary> /// <returns> /// An <c>XdmValue</c> representing the results of the query /// </returns> /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure /// occurs while evaluating the query.</exception> public XdmValue Evaluate() { try { ValueRepresentation value = SequenceExtent.makeSequenceExtent(exp.iterator(context)); return(XdmValue.Wrap(value)); } catch (JXPathException err) { throw new DynamicError(err); } }
/// <summary> /// Create an XdmValue from an underlying Saxon ValueRepresentation object. /// This method is provided for the benefit of applications that need to mix /// use of the Saxon .NET API with direct use of the underlying objects /// and methods offered by the Java implementation. /// </summary> /// <param name="value">An object representing an XDM value in the /// underlying Saxon implementation.</param> /// <returns>An XdmValue that wraps the underlying Saxon value /// representation.</returns> public static XdmValue Wrap(ValueRepresentation value) { XdmValue result; if (value == null || value is EmptySequence) { return XdmEmptySequence.INSTANCE; } else if (value is JAtomicValue) { result = new XdmAtomicValue(); } else if (value is NodeInfo) { result = new XdmNode(); } else { result = new XdmValue(); } result.value = value; return result; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @POST public javax.ws.rs.core.Response exec(@Context InputFormat input, String data) public virtual Response Exec(InputFormat input, string data) { IDictionary <string, object> args; try { args = input.readMap(data); } catch (BadInputException e) { return(_output.badRequest(e)); } if (!args.ContainsKey("command")) { return(Response.status(Response.Status.BAD_REQUEST).entity("Expected command argument not present.").build()); } ScriptSession scriptSession; try { scriptSession = GetSession(args); } catch (System.ArgumentException e) { return(_output.badRequest(e)); } _log.debug(scriptSession.ToString()); try { Pair <string, string> result = scriptSession.Evaluate(( string )args["command"]); IList <Representation> list = new IList <Representation> { ValueRepresentation.@string(result.First()), ValueRepresentation.@string(result.Other()) }; return(_output.ok(new ListRepresentation(RepresentationType.STRING, list))); } catch (Exception e) { IList <Representation> list = new IList <Representation> { ValueRepresentation.@string(e.GetType() + " : " + e.Message + "\n"), ValueRepresentation.@string(null) }; return(_output.ok(new ListRepresentation(RepresentationType.STRING, list))); } }
public DataElementDictionaryEntry(string tag, string description, string vr, string vm, string retired) { this.tag = new Tag(tag); if (description == null) { description = ""; } this.description = description.Trim(); this.vr = ValueRepresentation.GetBy(vr, Tag); this.vm = new ValueMultiplicity(VR, vm); if (retired != null) { retired = retired.Trim().ToLower(); isRetired = (retired == "ret" || retired == "retired" || retired == "true"); } }
public override string Decode(ValueRepresentation vr, ReadOnlyMemory <byte> bytes) { string separators; if (vr is ISingleValue <string> ) { separators = "\r\n\t\f"; } else { separators = "\\"; if (vr is PersonName) { separators += "^="; } } return(Decode(bytes, separators)); }
/// <summary> /// Determines whether a specified file is an ACR-NEMA file. /// </summary> public static bool IsAcrNemaFile(string fileName) { FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); bool isStrictDecoded = ValueRepresentation.IsStrictDecoded; ValueRepresentation.IsStrictDecoded = false; try { Tag tag = new Tag(fileStream, TransferSyntax.Default); ValueRepresentation vr = ValueRepresentation.LoadFrom(fileStream, tag); if (vr.IsUndefined) { return(false); } ValueLength valueLength = new ValueLength(fileStream, vr); Value value = null; if (fileStream.Position + valueLength.Value <= fileStream.Length) { value = new Value(fileStream, vr, valueLength); } else { return(false); } return(true); } catch (Exception e) { return(false); } finally { fileStream.Close(); ValueRepresentation.IsStrictDecoded = isStrictDecoded; } }
/// <summary> /// Create an XdmValue from an underlying Saxon ValueRepresentation object. /// This method is provided for the benefit of applications that need to mix /// use of the Saxon .NET API with direct use of the underlying objects /// and methods offered by the Java implementation. /// </summary> /// <param name="value">An object representing an XDM value in the /// underlying Saxon implementation.</param> /// <returns>An XdmValue that wraps the underlying Saxon value /// representation.</returns> public static XdmValue Wrap(ValueRepresentation value) { XdmValue result; if (value == null || value is EmptySequence) { return(XdmEmptySequence.INSTANCE); } else if (value is JAtomicValue) { result = new XdmAtomicValue(); } else if (value is NodeInfo) { result = new XdmNode(); } else { result = new XdmValue(); } result.value = value; return(result); }
///<summary> /// Call a global user-defined function in the compiled query. ///</summary> ///<remarks> /// If this is called more than once (to evaluate the same function repeatedly with different arguments, /// or to evaluate different functions) then the sequence of evaluations uses the same values of global /// variables including external variables (query parameters); the effect of any changes made to query parameters /// between calls is undefined. /// </remarks> /// <param name="function"> /// The name of the function to be called /// </param> /// <param name="arguments"> /// The values of the arguments to be supplied to the function. These /// must be of the correct type as defined in the function signature (there is no automatic /// conversion to the required type). /// </param> /// <exception cref="ArgumentException">If no function has been defined with the given name and arity /// or if any of the arguments does not match its required type according to the function /// signature.</exception> /// <exception cref="DynamicError">If a dynamic error occurs in evaluating the function. /// </exception> public XdmValue CallFunction(QName function, XdmValue[] arguments) { JUserFunction fn = exp.getStaticContext().getUserDefinedFunction( function.Uri, function.LocalName, arguments.Length); if (fn == null) { throw new ArgumentException("No function with name " + function.ClarkName + " and arity " + arguments.Length + " has been declared in the query"); } try { // TODO: use the same controller in other interfaces such as run(), and expose it in a trapdoor API if (controller == null) { controller = exp.newController(); context.initializeController(controller); controller.defineGlobalParameters(); } ValueRepresentation[] vr = new ValueRepresentation[arguments.Length]; for (int i = 0; i < arguments.Length; i++) { SequenceType type = fn.getParameterDefinitions()[i].getRequiredType(); vr[i] = arguments[i].Unwrap(); if (!type.matches(Value.asValue(vr[i]), controller.getConfiguration())) { throw new ArgumentException("Argument " + (i + 1) + " of function " + function.ClarkName + " does not match the required type " + type.toString()); } } ValueRepresentation result = fn.call(vr, controller); return(XdmValue.Wrap(result)); } catch (JXPathException e) { throw new DynamicError(e); } }
internal static long GetDataElementLength(ValueRepresentation vr, DicomVRCoding vrCoding, long unpaddedValueLength) { if (unpaddedValueLength >= uint.MaxValue) { throw new ArgumentOutOfRangeException(nameof(unpaddedValueLength), $"{unpaddedValueLength} is out of 32-bit range"); } var valueLength = ((unpaddedValueLength % 2) != 0) ? (uint)unpaddedValueLength + 1 : (uint)unpaddedValueLength; long dataElementLength = 4; if (vrCoding == DicomVRCoding.Explicit) { dataElementLength += 2; if (vr is IHas16BitExplicitVRLength) { if (valueLength >= ushort.MaxValue) { throw new ArgumentOutOfRangeException(nameof(unpaddedValueLength), $"{unpaddedValueLength} is out of 16-bit range"); } dataElementLength += 2; } else { dataElementLength += 6; } } else { dataElementLength += 4; } dataElementLength += valueLength; return(dataElementLength); }
public override string Decode(ValueRepresentation vr, ReadOnlyMemory <byte> bytes) => Encoding.GetString(bytes.Span);
protected internal override Representation underlyingObjectToObject(TemporalAmount value) { return(ValueRepresentation.TemporalAmount(value)); }
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation) { List<Interval> _intervals = new List<Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write((i * (int)interval) + 1); //Response.Write(" - "); //Response.Write((i * (int)interval) + 1 + 7); //Response.Write(" | "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write(" - "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write("<br>"); _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i)); //Response.Write(" - "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i+1).AddDays(-1)); //Response.Write("<br>"); _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } //List<> // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "pokus"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; Dictionary<int, Series> series = new Dictionary<int, Series>(); //foreach (int channelId in channels) //{ // Channel channel = db.Channels.Where(c => c.ChannelId == channelId).FirstOrDefault(); // if (channel == null) continue; // Series s = new Series(channel.ChannelName, ViewType.Line); // s.ValueScaleType = ScaleType.Numerical; // s.ArgumentScaleType = ScaleType.DateTime; // series.Add(channelId, s); //} using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List<string> seriesNames = new List<string>(); int k = 0; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandText = string.Format("SELECT DISTINCT {0} FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End", ddlYGroupBy.SelectedValue); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Series s = new Series(reader[0].ToString(), ViewType.Line); s.ValueScaleType = ScaleType.Numerical; s.ArgumentScaleType = ScaleType.DateTime; seriesNames.Add(reader[0].ToString()); series.Add(k, s); k++; } reader.Close(); } // Draw series foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++ ) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesNames[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes //Response.Write(dr[0]); //Response.Write(" - "); //Response.Write(dr[1]); //Response.Write("<br>"); if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); } } dr.Close(); } } } } foreach (KeyValuePair<int, Series> serie in series) chart.Series.Add(serie.Value); //diagram DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Title.Text = "CZK"; xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; } //xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = 800; chart.Height = 500; chart.DataBind(); pnlGraph.Controls.Add(chart); }
protected internal override Representation underlyingObjectToObject(RelationshipType value) { return(ValueRepresentation.RelationshipType(value)); }
internal static void AssertUriMatches(string expectedRegex, ValueRepresentation uriRepr) { assertUriMatches(expectedRegex, RepresentationTestAccess.Serialize(uriRepr)); }
///<summary> /// Call a global user-defined function in the compiled query. ///</summary> ///<remarks> /// If this is called more than once (to evaluate the same function repeatedly with different arguments, /// or to evaluate different functions) then the sequence of evaluations uses the same values of global /// variables including external variables (query parameters); the effect of any changes made to query parameters /// between calls is undefined. /// </remarks> /// <param name="function"> /// The name of the function to be called /// </param> /// <param name="arguments"> /// The values of the arguments to be supplied to the function. These /// must be of the correct type as defined in the function signature (there is no automatic /// conversion to the required type). /// </param> /// <exception cref="ArgumentException">If no function has been defined with the given name and arity /// or if any of the arguments does not match its required type according to the function /// signature.</exception> /// <exception cref="DynamicError">If a dynamic error occurs in evaluating the function. /// </exception> public XdmValue CallFunction(QName function, XdmValue[] arguments) { JUserFunction fn = exp.getStaticContext().getUserDefinedFunction( function.Uri, function.LocalName, arguments.Length); if (fn == null) { throw new ArgumentException("No function with name " + function.ClarkName + " and arity " + arguments.Length + " has been declared in the query"); } try { // TODO: use the same controller in other interfaces such as run(), and expose it in a trapdoor API if (controller == null) { controller = exp.newController(); context.initializeController(controller); controller.defineGlobalParameters(); } ValueRepresentation[] vr = new ValueRepresentation[arguments.Length]; for (int i=0; i<arguments.Length; i++) { SequenceType type = fn.getParameterDefinitions()[i].getRequiredType(); vr[i] = arguments[i].Unwrap(); if (!type.matches(Value.asValue(vr[i]), controller.getConfiguration())) { throw new ArgumentException("Argument " + (i+1) + " of function " + function.ClarkName + " does not match the required type " + type.toString()); } } ValueRepresentation result = fn.call(vr, controller); return XdmValue.Wrap(result); } catch (JXPathException e) { throw new DynamicError(e); } }
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation) { List <Interval> _intervals = new List <Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write((i * (int)interval) + 1); //Response.Write(" - "); //Response.Write((i * (int)interval) + 1 + 7); //Response.Write(" | "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write(" - "); //Response.Write(from.AddDays((i * (int)interval) + 1 - 1)); //Response.Write("<br>"); _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { //Response.Write(i + 1); //Response.Write(": "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i)); //Response.Write(" - "); //Response.Write(new DateTime(from.Year, from.Month, 1).AddMonths(i+1).AddDays(-1)); //Response.Write("<br>"); _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } //List<> // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "pokus"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; Dictionary <int, Series> series = new Dictionary <int, Series>(); //foreach (int channelId in channels) //{ // Channel channel = db.Channels.Where(c => c.ChannelId == channelId).FirstOrDefault(); // if (channel == null) continue; // Series s = new Series(channel.ChannelName, ViewType.Line); // s.ValueScaleType = ScaleType.Numerical; // s.ArgumentScaleType = ScaleType.DateTime; // series.Add(channelId, s); //} using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List <string> seriesNames = new List <string>(); int k = 0; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandText = string.Format("SELECT DISTINCT {0} FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End", ddlYGroupBy.SelectedValue); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Series s = new Series(reader[0].ToString(), ViewType.Line); s.ValueScaleType = ScaleType.Numerical; s.ArgumentScaleType = ScaleType.DateTime; seriesNames.Add(reader[0].ToString()); series.Add(k, s); k++; } reader.Close(); } // Draw series foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesNames[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes //Response.Write(dr[0]); //Response.Write(" - "); //Response.Write(dr[1]); //Response.Write("<br>"); if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); } } dr.Close(); } } } } foreach (KeyValuePair <int, Series> serie in series) { chart.Series.Add(serie.Value); } //diagram DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Title.Text = "CZK"; xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; } //xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = 800; chart.Height = 500; chart.DataBind(); pnlGraph.Controls.Add(chart); }
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation, bool ajax) { List <Interval> _intervals = new List <Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } if (interval == IntervalType.Year) { for (int i = 0; i < to.Year - from.Year + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddYears(i), new DateTime(from.Year, from.Month, 1).AddYears(i + 1).AddDays(-1))); } } //foreach (Interval ii in _intervals) //{ // Response.Write(ii.Start); // Response.Write(" - "); // Response.Write(ii.End); // Response.Write("<br>"); //} // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); if (!ajax) { chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "Graf dle " + ddlYGroupBy.SelectedItem.Text.ToLower() + ":"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; } Dictionary <int, Series> series = new Dictionary <int, Series>(); List <bool> seriesVisibilities = new List <bool>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List <string> seriesNames = new List <string>(); List <string> seriesCriteria = new List <string>(); int k = 0; Culture = "cs-CZ"; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; StringBuilder text = new StringBuilder(""); #warning extract to function if (ddlYFilterType.SelectedIndex > 0) { if (_filerYValues.Count > 0) { text.Append(" AND ("); // Y Filter int i = 0; foreach (string s in _filerYValues) { text.Append(ddlYFilterType.SelectedValue); text.Append(" = '"); text.Append(s); text.Append("' "); if (i < _filerYValues.Count - 1) { text.Append("OR "); } i++; } text.Append(") "); } } string top = ""; if (chbTop.Checked) { int tp = Convert.ToInt32(txtTop.Text); if (!ajax) { tp += 1; } top = "TOP " + tp; } cmd.CommandText = string.Format("SELECT {2} {0}, {0} AS Value FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End {1} GROUP BY {0} ORDER BY Sum(CAST(replace(TurnoverEUR, ',', '.') as Decimal)) DESC", ddlYGroupBy.SelectedValue, text, top); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (ddlYGroupBy.SelectedValue == "ReselerGroupJoined") { seriesNames.Add(reader[1].ToString().Trim() == "" ? "NO-NAME" : reader[1].ToString()); } else { seriesNames.Add(reader[1].ToString().Trim() == "" ? "(neuvedeno)" : reader[1].ToString()); } if (!ajax) { Series s; if (rblValueDisplayMode.SelectedValue == "2" || ddlXValueType.SelectedValue == "Data") { s = new Series(reader[1].ToString(), ViewType.StackedBar); } else { s = new Series(reader[1].ToString(), ViewType.Line); } s.ValueScaleType = ScaleType.Numerical; if (ddlXValueType.SelectedValue == "Time") { s.ArgumentScaleType = ScaleType.DateTime; } if (ddlXValueType.SelectedValue == "Data") { s.ArgumentScaleType = ScaleType.Qualitative; } if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } //s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; seriesCriteria.Add(reader[0].ToString()); seriesVisibilities.Add(false); series.Add(k, s); k++; } } reader.Close(); } // Draw series // By Time // Enumerate series here and send them via ajax if (ajax) { lbYHaving.Items.Clear(); lbYHaving.Items.Add(allValues); foreach (string s in seriesNames) { lbYHaving.Items.Add(s); } DataBind(lbYHaving); return; } if (ddlXValueType.SelectedValue == "Time") { foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } if (ddlXValueType.SelectedValue == "Data") { using (SqlCommand command_data = new SqlCommand()) { command_data.Connection = conn; command_data.CommandText = "SELECT DISTINCT " + ddlXGroupByData.SelectedValue + " FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End"; command_data.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); command_data.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = command_data.ExecuteReader(); List <string> xData = new List <string>(); while (reader.Read()) { xData.Add(reader[0].ToString()); } reader.Close(); foreach (string xd in xData) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommandByData(xd, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(xd, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(xd, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } } } int l = 0; object yHaving = Request[lbYHaving.ClientID.Replace('_', '$')]; if (yHaving == null) { yHaving = allValues; } lbYHaving.Items.Clear(); if (yHaving.ToString() != allValues) { { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { lbYHaving.Items.Add(series[i].Name); foreach (string s in yHaving.ToString().Split(',')) { if (s == series[i].Name) { lbYHaving.Items[l].Selected = true; seriesVisibilities[i] = true; break; } else { seriesVisibilities[i] = false; } } l++; } } } } else { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i] && yHaving.ToString() != allValues) { lbYHaving.Items.Add(series[i].Name); } } } lbYHaving.Items.Insert(0, allValues); if (yHaving.ToString() == allValues) { lbYHaving.Items[0].Selected = true; } // Other for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { if (seriesVisibilities[i] && yHaving.ToString() == allValues) { lbYHaving.Items.Add(series[i].Name); } chart.Series.Add(series[i]); } } #region Compute sum Series suma = new Series("Suma", ViewType.Line); suma.ValueScaleType = ScaleType.Numerical; suma.ArgumentScaleType = ScaleType.DateTime; if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } DataTable grid = new DataTable(); string xArgumentName = ddlXValueType.SelectedItem.Text + " - dle "; if (ddlXValueType.SelectedValue == "Time") { xArgumentName += ddlXGroupByTime.SelectedItem.Text.ToLower(); } else { xArgumentName += ddlXGroupByData.SelectedItem.Text.ToLower(); } grid.Columns.Add(new DataColumn(xArgumentName)); for (int i = 0; i < chart.Series.Count; i++) { grid.Columns.Add(new DataColumn(chart.Series[i].Name)); } double sum; for (int j = 0; j < chart.Series[0].Points.Count; j++) { sum = 0; DataRow dr = grid.NewRow(); if (ddlXValueType.SelectedValue == "Time") { dr[0] = Convert.ToDateTime(chart.Series[0].Points[j].Argument).ToString("dd.MM.yyyy"); } else { dr[0] = chart.Series[0].Points[j].Argument; } for (int i = 0; i < chart.Series.Count; i++) { dr[i + 1] = chart.Series[i].Points[j].Values[0]; sum += chart.Series[i].Points[j].Values[0]; } grid.Rows.Add(dr); suma.Points.Add(new SeriesPoint(chart.Series[0].Points[j].Argument, new double[] { sum })); // Percent if (rblValueDisplayMode.SelectedValue == "2") { for (int i = 0; i < chart.Series.Count; i++) { if (sum == 0) { chart.Series[i].Points[j].Values[0] = 0; } else { chart.Series[i].Points[j].Values[0] = Math.Round(((chart.Series[i].Points[j].Values[0] / sum) * 1), 2); } } } if (rblValueDisplayMode.SelectedValue == "3") { if (j > 0) { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = chart.Series[i].Points[j].Values[0] - chart.Series[i].Points[j - 1].Values[0]; } } else { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = 0; } } } } suma.View.Color = System.Drawing.Color.Black; series.Add(series.Count, suma); if (rblValueDisplayMode.SelectedValue == "1") { chart.Series.Add(series[series.Count - 1]); } if (chbShowSum.Checked && rblValueDisplayMode.SelectedValue == "1" && ddlXValueType.SelectedValue == "Time") { int toBeRemoved = chart.Series.Count - 1; for (int j = 0; j < toBeRemoved; j++) { chart.Series.RemoveAt(0); } } // Show grid DataRow drSum = grid.NewRow(); for (int i = 1; i < grid.Columns.Count; i++) { double dSum = 0; for (int j = 0; j < grid.Rows.Count; j++) { dSum += Convert.ToDouble(grid.Rows[j][i]); } drSum[i] = dSum; } grid.Columns.Add(new DataColumn("Součet za svislou osu")); for (int i = 0; i < grid.Rows.Count; i++) { double dSum = 0; for (int j = 1; j < grid.Columns.Count - 1; j++) { dSum += Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]); } if (rblValueDisplayMode.SelectedValue == "2") { for (int j = 1; j < grid.Columns.Count - 1; j++) { if (dSum == 0) { grid.Rows[i][j] = "0"; } else { grid.Rows[i][j] = (Math.Round(Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]) / dSum, 4) * 100).ToString() + " %"; } } } grid.Rows[i][grid.Columns[grid.Columns.Count - 1]] = dSum; } grid.Rows.Add(drSum); grid.Rows[grid.Rows.Count - 1][0] = "Součet za vodorovnou osu"; gvGrid.DataSource = grid; gvGrid.DataBind(); #endregion #region Customize chart DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); if (ddlYValueType.SelectedIndex == 0) { xyDiagram.AxisY.Title.Text = "EUR"; } if (ddlYValueType.SelectedIndex == 1) { xyDiagram.AxisY.Title.Text = "Kusů"; } xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; case IntervalType.Year: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Year; break; } xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = Convert.ToInt32(txtScreenWidth.Text) - 50; chart.Height = 602; //chart.Height = Convert.ToInt32(txtScreenHeight.Text) - 230; #endregion chart.DataBind(); pnlGraph.Controls.Add(chart); }
public virtual ValueRepresentation Score() { return(ValueRepresentation.number(_score)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatInteger() public virtual void CanFormatInteger() { string entity = _json.assemble(ValueRepresentation.number(10)); assertEquals("10", entity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatString() public virtual void CanFormatString() { string entity = _json.assemble(ValueRepresentation.@string("expected value")); assertEquals(entity, "\"expected value\""); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatString() public virtual void CanFormatString() { _json.assemble(ValueRepresentation.@string("expected value")); assertEquals(_stream.ToString(), "\"expected value\""); }
protected internal override Representation underlyingObjectToObject(Point value) { return(ValueRepresentation.Point(value)); }
private ValueRepresentation Bool(bool?value) { return(ValueRepresentation.@string(value ? "true" : "false ")); }
public abstract string Decode(ValueRepresentation vr, ReadOnlyMemory <byte> bytes);
void DrawChart(DataTable data, DateTime from, DateTime to, IntervalType interval, ValueRepresentation representation, bool ajax) { List<Interval> _intervals = new List<Interval>(); if (interval == IntervalType.Day || interval == IntervalType.Week) { // Day by day or week by week for (int i = 0; i < (to.Subtract(from).TotalDays / (int)interval); i++) { _intervals.Add(new Interval(from.AddDays((i * (int)interval) + 1 - 1), from.AddDays((i * (int)interval) + (int)interval + 1 - 1))); } } if (interval == IntervalType.Month) { for (int i = 0; i < to.Month - from.Month + ((to.Year - from.Year) * 12) + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddMonths(i), new DateTime(from.Year, from.Month, 1).AddMonths(i + 1).AddDays(-1))); } } if (interval == IntervalType.Year) { for (int i = 0; i < to.Year - from.Year + 1; i++) { _intervals.Add(new Interval(new DateTime(from.Year, from.Month, 1).AddYears(i), new DateTime(from.Year, from.Month, 1).AddYears(i + 1).AddDays(-1))); } } //foreach (Interval ii in _intervals) //{ // Response.Write(ii.Start); // Response.Write(" - "); // Response.Write(ii.End); // Response.Write("<br>"); //} // Draw chart here item by item in _intervals WebChartControl chart = new WebChartControl(); if (!ajax) { chart.EnableViewState = false; ChartTitle title = new ChartTitle(); title.Text = "Graf dle " + ddlYGroupBy.SelectedItem.Text.ToLower() + ":"; title.Font = new System.Drawing.Font("Tahoma", 10); chart.Titles.Add(title); chart.FillStyle.FillMode = FillMode.Solid; } Dictionary<int, Series> series = new Dictionary<int, Series>(); List<bool> seriesVisibilities = new List<bool>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CanonConnectionStringMain"].ConnectionString)) { conn.Open(); List<string> seriesNames = new List<string>(); List<string> seriesCriteria = new List<string>(); int k = 0; Culture = "cs-CZ"; // Create series using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; StringBuilder text = new StringBuilder(""); #warning extract to function if (ddlYFilterType.SelectedIndex > 0) { if (_filerYValues.Count > 0) { text.Append(" AND ("); // Y Filter int i = 0; foreach (string s in _filerYValues) { text.Append(ddlYFilterType.SelectedValue); text.Append(" = '"); text.Append(s); text.Append("' "); if (i < _filerYValues.Count - 1) { text.Append("OR "); } i++; } text.Append(") "); } } string top = ""; if (chbTop.Checked) { int tp = Convert.ToInt32(txtTop.Text); if (!ajax) { tp += 1; } top = "TOP " + tp; } cmd.CommandText = string.Format("SELECT {2} {0}, {0} AS Value FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End {1} GROUP BY {0} ORDER BY Sum(CAST(replace(TurnoverEUR, ',', '.') as Decimal)) DESC", ddlYGroupBy.SelectedValue, text, top); cmd.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); cmd.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (ddlYGroupBy.SelectedValue == "ReselerGroupJoined") { seriesNames.Add(reader[1].ToString().Trim() == "" ? "NO-NAME" : reader[1].ToString()); } else { seriesNames.Add(reader[1].ToString().Trim() == "" ? "(neuvedeno)" : reader[1].ToString()); } if (!ajax) { Series s; if (rblValueDisplayMode.SelectedValue == "2" || ddlXValueType.SelectedValue == "Data") { s = new Series(reader[1].ToString(), ViewType.StackedBar); } else { s = new Series(reader[1].ToString(), ViewType.Line); } s.ValueScaleType = ScaleType.Numerical; if (ddlXValueType.SelectedValue == "Time") { s.ArgumentScaleType = ScaleType.DateTime; } if (ddlXValueType.SelectedValue == "Data") { s.ArgumentScaleType = ScaleType.Qualitative; } if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } //s.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; seriesCriteria.Add(reader[0].ToString()); seriesVisibilities.Add(false); series.Add(k, s); k++; } } reader.Close(); } // Draw series // By Time // Enumerate series here and send them via ajax if (ajax) { lbYHaving.Items.Clear(); lbYHaving.Items.Add(allValues); foreach (string s in seriesNames) { lbYHaving.Items.Add(s); } DataBind(lbYHaving); return; } if (ddlXValueType.SelectedValue == "Time") { foreach (Interval i in _intervals) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommand(i.Start, i.End, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(i.Start, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } if (ddlXValueType.SelectedValue == "Data") { using (SqlCommand command_data = new SqlCommand()) { command_data.Connection = conn; command_data.CommandText = "SELECT DISTINCT " + ddlXGroupByData.SelectedValue + " FROM PivotTable WHERE DateSale >= @Start AND DateSale < @End"; command_data.Parameters.Add(new SqlParameter("@Start", SqlDbType.DateTime) { Value = _intervals[0].Start }); command_data.Parameters.Add(new SqlParameter("@End", SqlDbType.DateTime) { Value = _intervals[_intervals.Count - 1].End }); SqlDataReader reader = command_data.ExecuteReader(); List<string> xData = new List<string>(); while (reader.Read()) { xData.Add(reader[0].ToString()); } reader.Close(); foreach(string xd in xData) { for (int j = 0; j < seriesNames.Count; j++) { using (SqlCommand command = GenerateReportCommandByData(xd, seriesCriteria[j])) { command.Connection = conn; SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { // Here it comes if (dr[0] is DBNull) { series[j].Points.Add(new SeriesPoint(xd, new double[] { 0 })); } else { series[j].Points.Add(new SeriesPoint(xd, new double[] { Convert.ToDouble(dr[0]) })); seriesVisibilities[j] = true; } } dr.Close(); } } } } } } int l = 0; object yHaving = Request[lbYHaving.ClientID.Replace('_', '$')]; if (yHaving == null) { yHaving = allValues; } lbYHaving.Items.Clear(); if (yHaving.ToString() != allValues) { { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { lbYHaving.Items.Add(series[i].Name); foreach (string s in yHaving.ToString().Split(',')) { if (s == series[i].Name) { lbYHaving.Items[l].Selected = true; seriesVisibilities[i] = true; break; } else { seriesVisibilities[i] = false; } } l++; } } } } else { for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i] && yHaving.ToString() != allValues) { lbYHaving.Items.Add(series[i].Name); } } } lbYHaving.Items.Insert(0, allValues); if (yHaving.ToString() == allValues) { lbYHaving.Items[0].Selected = true; } // Other for (int i = 0; i < series.Count; i++) { if (seriesVisibilities[i]) { if (seriesVisibilities[i] && yHaving.ToString() == allValues) { lbYHaving.Items.Add(series[i].Name); } chart.Series.Add(series[i]); } } #region Compute sum Series suma = new Series("Suma", ViewType.Line); suma.ValueScaleType = ScaleType.Numerical; suma.ArgumentScaleType = ScaleType.DateTime; if (ddlYValueType.SelectedValue == "4") { if (rblValueDisplayMode.SelectedValue != "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency; } if (rblValueDisplayMode.SelectedValue == "2") { suma.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; } } DataTable grid = new DataTable(); string xArgumentName = ddlXValueType.SelectedItem.Text + " - dle "; if (ddlXValueType.SelectedValue == "Time") { xArgumentName += ddlXGroupByTime.SelectedItem.Text.ToLower(); } else { xArgumentName += ddlXGroupByData.SelectedItem.Text.ToLower(); } grid.Columns.Add(new DataColumn(xArgumentName)); for (int i = 0; i < chart.Series.Count; i++) { grid.Columns.Add(new DataColumn(chart.Series[i].Name)); } double sum; for (int j = 0; j < chart.Series[0].Points.Count; j++) { sum = 0; DataRow dr = grid.NewRow(); if (ddlXValueType.SelectedValue == "Time") { dr[0] = Convert.ToDateTime(chart.Series[0].Points[j].Argument).ToString("dd.MM.yyyy"); } else { dr[0] = chart.Series[0].Points[j].Argument; } for (int i = 0; i < chart.Series.Count; i++) { dr[i+1] = chart.Series[i].Points[j].Values[0]; sum += chart.Series[i].Points[j].Values[0]; } grid.Rows.Add(dr); suma.Points.Add(new SeriesPoint(chart.Series[0].Points[j].Argument, new double[] { sum })); // Percent if (rblValueDisplayMode.SelectedValue == "2") { for (int i = 0; i < chart.Series.Count; i++) { if (sum == 0) { chart.Series[i].Points[j].Values[0] = 0; } else { chart.Series[i].Points[j].Values[0] = Math.Round(((chart.Series[i].Points[j].Values[0] / sum) * 1), 2); } } } if (rblValueDisplayMode.SelectedValue == "3") { if (j > 0) { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = chart.Series[i].Points[j].Values[0] - chart.Series[i].Points[j - 1].Values[0]; } } else { for (int i = 0; i < chart.Series.Count; i++) { chart.Series[i].Points[j].Values[0] = 0; } } } } suma.View.Color = System.Drawing.Color.Black; series.Add(series.Count, suma); if (rblValueDisplayMode.SelectedValue == "1") { chart.Series.Add(series[series.Count - 1]); } if (chbShowSum.Checked && rblValueDisplayMode.SelectedValue == "1" && ddlXValueType.SelectedValue == "Time") { int toBeRemoved = chart.Series.Count - 1; for (int j = 0; j < toBeRemoved; j++) { chart.Series.RemoveAt(0); } } // Show grid DataRow drSum = grid.NewRow(); for(int i = 1; i < grid.Columns.Count; i++) { double dSum = 0; for (int j = 0; j < grid.Rows.Count; j++) { dSum += Convert.ToDouble(grid.Rows[j][i]); } drSum[i] = dSum; } grid.Columns.Add(new DataColumn("Součet za svislou osu")); for (int i = 0; i < grid.Rows.Count; i++) { double dSum = 0; for (int j = 1; j < grid.Columns.Count - 1; j++) { dSum += Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]); } if (rblValueDisplayMode.SelectedValue == "2") { for (int j = 1; j < grid.Columns.Count - 1; j++) { if (dSum == 0) { grid.Rows[i][j] = "0"; } else { grid.Rows[i][j] = (Math.Round(Convert.ToDouble(grid.Rows[i][j] == null ? "0" : grid.Rows[i][j]) / dSum, 4) * 100).ToString() + " %"; } } } grid.Rows[i][grid.Columns[grid.Columns.Count-1]] = dSum; } grid.Rows.Add(drSum); grid.Rows[grid.Rows.Count - 1][0] = "Součet za vodorovnou osu"; gvGrid.DataSource = grid; gvGrid.DataBind(); #endregion #region Customize chart DevExpress.XtraCharts.XYDiagram xyDiagram = new XYDiagram(); if (ddlYValueType.SelectedIndex == 0) { xyDiagram.AxisY.Title.Text = "EUR"; } if (ddlYValueType.SelectedIndex == 1) { xyDiagram.AxisY.Title.Text = "Kusů"; } xyDiagram.AxisY.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisY.Label.Staggered = false; xyDiagram.AxisY.Title.Visible = true; xyDiagram.AxisY.Range.SideMarginsEnabled = true; xyDiagram.AxisY.Interlaced = true; xyDiagram.AxisX.Title.Font = new System.Drawing.Font("Tahoma", 8); xyDiagram.AxisX.Label.Staggered = true; xyDiagram.AxisX.Range.SideMarginsEnabled = true; xyDiagram.AxisX.Tickmarks.MinorVisible = false; xyDiagram.AxisX.Range.MinValue = from; xyDiagram.AxisX.Range.MaxValue = to; switch (interval) { case IntervalType.Day: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; break; case IntervalType.Week: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Day; xyDiagram.AxisX.GridSpacingAuto = false; xyDiagram.AxisX.GridSpacing = 7; break; case IntervalType.Month: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Month; break; case IntervalType.Year: xyDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Year; break; } xyDiagram.EnableZooming = true; chart.Diagram = xyDiagram; chart.Width = Convert.ToInt32(txtScreenWidth.Text) - 50; chart.Height = 602; //chart.Height = Convert.ToInt32(txtScreenHeight.Text) - 230; #endregion chart.DataBind(); pnlGraph.Controls.Add(chart); }
protected internal override Representation underlyingObjectToObject(string value) { return(ValueRepresentation.String(value)); }
public DataElement(string tag, string vr, TransferSyntax transferSyntax) { TransferSyntax = transferSyntax; this.tag = new Tag(tag, TransferSyntax); this.vr = ValueRepresentation.GetBy(vr, Tag); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatInteger() public virtual void CanFormatInteger() { _json.assemble(ValueRepresentation.number(10)); assertEquals("10", _stream.ToString()); }
/// <summary> /// Create an XdmValue from an underlying Saxon ValueRepresentation object. /// This method is provided for the benefit of applications that need to mix /// use of the Saxon .NET API with direct use of the underlying objects /// and methods offered by the Java implementation. /// </summary> /// <param name="value">An object representing an XDM value in the /// underlying Saxon implementation. If the parameter is null, /// the method returns null.</param> /// <returns>An XdmValue that wraps the underlying Saxon value /// representation.</returns> public static XdmValue Wrap(ValueRepresentation value) { XdmValue result; if (value == null) { return null; } if (value is JEmptySequence) { return XdmEmptySequence.INSTANCE; } else if (value is JAtomicValue) { result = new XdmAtomicValue(); } else if (value is NodeInfo) { result = new XdmNode(); } else if (value is JSingletonItem) { value = ((JSingletonItem)value).asItem(); result = new XdmNode(); } else { result = new XdmValue(); } result.value = value; return result; }