static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string str in importedAssets) { DefinitionObject definition = AssetDatabase.LoadAssetAtPath <DefinitionObject>(str); if (definition != null) { UpdateDefinitions(); return; } } foreach (string str in deletedAssets) { if (str.Contains(".asset")) { int start = str.LastIndexOf("/") + 1; int end = str.IndexOf(".asset"); string name = str.Substring(start, end - start); // Check if it is contained if (DefineUtility.ContainsDefineSymbol(name.ToUpper())) { UpdateDefinitions(); return; } } } }
public string GetDefinition(DefinitionObject _object) { if (_object == null) { throw new ArgumentNullException(); } _definition.Append($"CREATE TABLE [{_object.FullName.Schema}].[{_object.Name}](\n"); SetColumns(_object); SetPrimaryUniqueKeys(_object, true); SetPrimaryUniqueKeys(_object, false); _definition.Append(")\n\n"); SetCheckConstraints(_object); _definition.Append("\n\n"); SetForeingKeyConstraint(_object); string definition = _definition.ToString(); Match match; while ((match = _bracketRegex.Match(definition)).Success) { definition = definition.Remove(match.Groups[1].Index, 1); } return(definition); }
private void DeleteVariable(HttpContext context) { string path = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject item = new DefinitionObject(Global.Core, source, path); item.Delete(); if (source.Contains("ReportDefinitions")) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(source); XmlNode xmlNodeResults = xmlDocument.DocumentElement.SelectSingleNode("Results"); if (xmlNodeResults != null) { xmlNodeResults.ParentNode.RemoveChild(xmlNodeResults); xmlDocument.Save(source); } } }
public VariableSelector(DefinitionObject variable, bool editable = true) { this.Editable = editable; this.Variable = variable; this.Load += VariableSelector_Load; }
private string RenderMeanEquation( string source, DefinitionObject variable, XmlNode xmlNodeVariable, object idStudy ) { StringBuilder meanEquation = new StringBuilder(); // Run through all category ids of the variable. foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes) { if (xmlNodeCategory.Name == "ScoreGroup") { continue; } DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory); meanEquation.Append(string.Format( "([{3}{0}.{1}] * {2} / [{3}{0}]) + ", variable.GetValue("Name"), category.GetValue("Name"), category.GetValue("Value"), idStudy != null ? "/" + idStudy + "\\" : "" )); } if (xmlNodeVariable.ChildNodes.Count != 0) { meanEquation = meanEquation.Remove(meanEquation.Length - 3, 3); } return(meanEquation.ToString()); }
private void RemoveScoreFromGroup(HttpContext context) { string path = context.Request.Params["Path"]; string groupPath = context.Request.Params["GroupPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; string groupSource = context.Request.Params["GroupSource"]; DefinitionObject score = new DefinitionObject(Global.Core, source, path); DefinitionObject group = new DefinitionObject(Global.Core, groupSource, groupPath); if (score.StorageType == DatabaseCore.StorageMethodType.Database) { // Delete the score group link. Global.Core.TaxonomyCategoryLinks.Delete((Guid)Global.Core.TaxonomyCategoryLinks.GetValue( "Id", new string[] { "IdScoreGroup", "IdTaxonomyCategory" }, new object[] { group.GetValue("Id"), score.GetValue("Id") } )); } else { score.Delete(); } }
private void DeleteScoreGroup(HttpContext context) { string xPath = context.Request.Params["XPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject scoreGroup = new DefinitionObject(Global.Core, source, xPath); if (scoreGroup.StorageType == DatabaseCore.StorageMethodType.Database) { // Get all categories of the score group. List <object[]> scoreGroupCategories = Global.Core.TaxonomyCategoryLinks.GetValues( new string[] { "Id" }, new string[] { "IdScoreGroup" }, new object[] { scoreGroup.GetValue("Id") } ); // Run through all categories of the scrore group. foreach (object[] scoreGroupCategory in scoreGroupCategories) { // Remove the category from the score group. Global.Core.TaxonomyCategoryLinks.Delete((Guid)scoreGroupCategory[0]); } } scoreGroup.Delete(); }
private string RenderSampleVarianceEquation( string source, DefinitionObject variable, XmlNode xmlNodeVariable, object idStudy ) { StringBuilder result = new StringBuilder(); result.Append(RenderStdDevEquation( source, variable, xmlNodeVariable, idStudy ).Replace("return", "var_result = ")); result.Append(Environment.NewLine); result.Append(Environment.NewLine); result.Append(string.Format( "return Math.Sqrt(var_result / Math.Pow([{1}{0}] - 1, 0.5));", variable.GetValue("Name"), idStudy != null ? "/" + idStudy + "\\" : "" )); return(result.ToString()); }
private static Definition DefinitionObjectToModel(DefinitionObject def, int termId) { return(new Definition() { text = def.text, rank = (byte)def.rank, language = def.language, termId = termId }); }
private void DeleteScore(HttpContext context) { string xPath = context.Request.Params["XPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject obj = new DefinitionObject(Global.Core, source, xPath); obj.Delete(); }
private void GetEquation(HttpContext context) { string path = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject item = new DefinitionObject(Global.Core, source, path); context.Response.Write(HttpUtility.HtmlDecode((string)item.GetValue("Equation"))); }
private void ShowScore(HttpContext context) { string xPath = context.Request.Params["XPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject item = new DefinitionObject(Global.Core, source, xPath); item.SetValue("Enabled", true); item.Save(); }
private void SetScoreName(HttpContext context) { string xPath = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; string value = context.Request.Params["Value"]; DefinitionObject item = new DefinitionObject(Global.Core, source, xPath); item.SetValue("Name", value); item.Save(); }
private void SetEquation(HttpContext context) { string path = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; string equation = context.Request.Params["Equation"]; DefinitionObject item = new DefinitionObject(Global.Core, source, path); item.SetValue("Equation", equation); item.Save(); }
private void SetScoreFactor(HttpContext context) { string xPath = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; double value = 0.0; double.TryParse(context.Request.Params["Value"], out value); DefinitionObject item = new DefinitionObject(Global.Core, source, xPath); item.SetValue("Value", value); item.Save(); }
private void ReorderScale(HttpContext context) { string xPath = context.Request.Params["XPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject score = new DefinitionObject(Global.Core, source, xPath); int order = int.Parse(context.Request.Params["Order"]); int oldOrder = int.Parse(score.GetValue("Order").ToString()); score.SetValue("Order", order); score.Save(); DefinitionObject[] scores = score.GetParent().GetChilds(); foreach (DefinitionObject _score in scores) { int _order = int.Parse(_score.GetValue("Order").ToString()); if (_order < order) { continue; } if (_order >= oldOrder) { continue; } if (_score.GetValue("Id") == score.GetValue("Id")) { continue; } _score.SetValue( "Order", (_order + 1) ); _score.Save(); } ReOrderScores(scores.OrderBy(x => int.Parse(x.GetValue("Order").ToString())).ToArray()); }
private void InsertSampleVariance(HttpContext context) { string xPath = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; XmlDocument document = new XmlDocument(); document.Load(source); XmlNode xmlNodeVariable = document.SelectSingleNode(xPath).ParentNode; object idStudy = null; if (!bool.Parse(xmlNodeVariable.Attributes["IsTaxonomy"].Value)) { idStudy = Global.Core.Variables.GetValue( "IdStudy", "Id", Guid.Parse(xmlNodeVariable.Attributes["Id"].Value) ); } DefinitionObject variable = new DefinitionObject(Global.Core, source, xmlNodeVariable); string equation = RenderSampleVarianceEquation( source, variable, xmlNodeVariable, idStudy ); xmlNodeVariable.InnerXml += (string.Format( "<ScoreGroup Id=\"{0}\" Name=\"\" ShowInChart=\"False\" Order=\"{2}\" Value=\"0\" Color=\"444444\" Label2057=\"Sample variance\" Equation=\"{1}\" HasValues=\"True\" SignificantLetter=\"F\"></ScoreGroup> ", Guid.NewGuid(), equation.ToString(), xmlNodeVariable.ChildNodes.Count )); document.Save(source); }
private void CombineScales(HttpContext context) { string xPath = context.Request.Params["XPath"]; string name = context.Request.Params["Name"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; string source2 = context.Request.Params["Source2"]; string path = context.Request.Params["Path"]; string path2 = context.Request.Params["Path2"]; // Set the default for the language to english GB. int idLanguage = 2057; // Check if a specific language is defined. if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } DefinitionObject score = new DefinitionObject(Global.Core, source, path); DefinitionObject score2 = new DefinitionObject(Global.Core, source2, path2); if (string.IsNullOrEmpty(path2)) { score2 = null; } string resultPath = score.Combine(score2); //context.Response.Write(idScoreGroup.ToString()); string result = RenderScoreToJson(new DefinitionObject( Global.Core, source, path ), idLanguage); context.Response.Write(result); }
private void GetScore(HttpContext context) { string xPath = context.Request.Params["Path"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject item = new DefinitionObject(Global.Core, source, xPath); // Set the default for the language to english GB. int idLanguage = 2057; // Check if a specific language is defined. if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } context.Response.Write(RenderScoreToJson(item, idLanguage)); }
private void RenderHeadline(ExcelWriter writer) { int a = 0; foreach (LinkBiDefinitionDimension filter in this.Definition.Dimensions) { DefinitionObject _filter = new DefinitionObject( this.Core, this.Definition.FileName, filter.XmlNode ); //writer.Write(a++, 0, filter.Name); writer.Write(a++, 0, _filter.GetLabel(this.Definition.Settings.IdLanguage)); } //foreach (LinkBiDefinitionDimension measure in this.Definition.Measures) //{ writer.Write(a++, 0, "variablename"); writer.Write(a++, 0, "response"); //} if (this.DisplayUnweightedBase) { writer.Write(a++, 0, "unweighted base"); } if (this.DisplayEffectiveBase) { writer.Write(a++, 0, "Effective base"); } writer.Write(a++, 0, "base"); writer.Write(a++, 0, "value"); if (this.ExportPercentage) { writer.Write(a++, 0, "percentage"); } }
private void UpdateScoreGroupName(HttpContext context) { string path = context.Request.Params["Path"]; string name = context.Request.Params["Value"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; // Set the default for the language to english GB. int idLanguage = 2057; // Check if a specific language is defined. if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } DefinitionObject score = new DefinitionObject(Global.Core, source, path); score.SetLabel(idLanguage, name); score.Save(); }
private void UpdateScoreLabel(HttpContext context) { // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; string xPath = context.Request.Params["XPath"]; string label = context.Request.Params["Value"]; DefinitionObject item = new DefinitionObject(Global.Core, source, xPath); // Set the default for the language to english GB. int idLanguage = 2057; // Check if a specific language is defined. if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } item.SetLabel(idLanguage, label); item.Save(); }
private string[] RenderHeadline() { foreach (LinkBiDefinitionDimension filter in this.Definition.Dimensions) { DefinitionObject _filter = new DefinitionObject( this.Core, this.Definition.FileName, filter.XmlNode ); if (sbFieldNames.ToString() == "") { sbFieldNames.Append("["); sbFieldTypes.Append("["); } sbFieldNames.Append("\"" + _filter.GetLabel(this.Definition.Settings.IdLanguage) + "\","); sbFieldTypes.Append("\"string\","); } sbFieldNames.Append("\"variablename\","); sbFieldTypes.Append("\"string\","); sbFieldNames.Append("\"responses\","); sbFieldTypes.Append("\"string\","); if (this.DisplayUnweightedBase) { sbFieldNames.Append("\"unweighted base\","); sbFieldTypes.Append("\"float\","); } if (this.DisplayEffectiveBase) { sbFieldNames.Append("\"Effective base\","); sbFieldTypes.Append("\"float\","); } sbFieldNames.Append("\"base\","); sbFieldTypes.Append("\"float\","); sbFieldNames.Append("\"value\","); sbFieldTypes.Append("\"float\","); if (this.ExportPercentage) { sbFieldNames.Append("\"percentage\","); sbFieldTypes.Append("\"float\","); } sbFieldNames = sbFieldNames.Remove(sbFieldNames.Length - 1, 1); sbFieldTypes = sbFieldTypes.Remove(sbFieldTypes.Length - 1, 1); sbFieldNames.Append("]"); sbFieldTypes.Append("]"); return(new string[] { sbFieldNames.ToString(), sbFieldTypes.ToString(), }); }
public override void Render(StringBuilder writer, HierarchyFilter hierarchyFilter) { string[] chartingColors = LoadChartingColors(); int i = 0; // Select the xml node that contains the chart's data. XmlNodeList xmlNodes = this.Document.SelectNodes(this.PathDimension + "/*[not(self::Variable)][not(self::MeanScore)]"); // Open an array for the values. writer.Append("["); // FOR TEST ONLY: foreach (XmlNode xmlNodeCategory in xmlNodes) { if (xmlNodeCategory.ParentNode.Attributes["IsNestedBase"] != null && bool.Parse(xmlNodeCategory.ParentNode.Attributes["IsNestedBase"].Value) == true) { continue; } if (xmlNodeCategory.Attributes["ShowInChart"] != null && bool.Parse(xmlNodeCategory.Attributes["ShowInChart"].Value) == false) { continue; } DefinitionObject test = new DefinitionObject( base.Core, this.Source, string.Format( "//Variable/{0}[@Id=\"{1}\"]", xmlNodeCategory.Name, xmlNodeCategory.Attributes["Id"].Value ) ); object enabled = test.GetValue("Enabled"); if (enabled != null && bool.Parse((string)enabled) == false) { continue; } writer.Append("{"); Guid idCategory = Guid.Parse(xmlNodeCategory.Attributes["Id"].Value); string categoryName = (string)test.GetValue("Name"); string categoryLabel = (string)test.GetLabel(base.IdLanguage); XmlNode xmlNode = xmlNodeCategory.SelectSingleNode("Variable[@IsNestedBase=\"True\"]"); if (xmlNode == null) { xmlNode = xmlNodeCategory.SelectSingleNode("Variable"); } if (xmlNode == null) { xmlNode = xmlNodeCategory; } double value = 0.0; double baseValue = 0; if (xmlNode.Attributes["Value"] != null) { if (xmlNode.Attributes["Value"] != null) { value = double.Parse(xmlNode.Attributes["Value"].Value); } if (xmlNode.ParentNode.Attributes["Position"].Value == "Top") { if (xmlNode.ParentNode.Attributes["Base"] != null) { baseValue = double.Parse(xmlNode.ParentNode.Attributes["Base"].Value); } } else { if (xmlNode.Attributes["Base"] != null) { baseValue = double.Parse(xmlNode.Attributes["Base"].Value); } } } else { if (xmlNode.Attributes["Base"] != null) { value = double.Parse(xmlNode.Attributes["Base"].Value); } if (xmlNode.Attributes["VariableBase"] != null) { baseValue = double.Parse(xmlNode.Attributes["VariableBase"].Value); } else if (xmlNodeCategory.ParentNode.Attributes["Base"] != null) { baseValue = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value); } } /*if (xmlNodeCategory.Attributes["Base"] != null) * value = double.Parse(xmlNodeCategory.Attributes["Base"].Value); * else if (xmlNodeCategory.ParentNode.Attributes["Base"] != null) * value = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value); * * if (xmlNode.Attributes["Value"] != null) * { * baseValue = value; * value = double.Parse(xmlNode.Attributes["Value"].Value); * } * else * { * if (xmlNodeCategory.ParentNode.Attributes["Base"] != null) * baseValue = double.Parse(xmlNodeCategory.ParentNode.Attributes["Base"].Value); * }*/ if (baseValue != 0) { value = value * 100 / baseValue; } else { value = 0; } if (chartingColors.Length == i) { i = 0; } writer.Append(string.Format( "\"dimension\": \"{0}\", \"value\": \"{1}\", \"Label\": \"{2}\",\"Color_{0}\": \"{3}\"", categoryName, value.ToString(new CultureInfo(2057)), HttpUtility.HtmlEncode(categoryLabel), chartingColors[i++] )); if (xmlNodeCategory.ChildNodes.Count > 0 && xmlNodeCategory.FirstChild.Attributes["Id"].Value != "00000000-0000-0000-0000-000000000000") { writer.Append(string.Format( ", \"XPATH\": \"{0}\"", HttpUtility.UrlEncode(xmlNodeCategory.GetXPath(true) + "/Variable") )); } writer.Append("},"); } if (xmlNodes.Count > 0) { writer = writer.Remove(writer.Length - 1, 1); } // Close the values array. writer.Append("]"); }
private void RenderMeasure(LinkBiDefinitionDimension measure, StringBuilder writer, int columnOffset, string selection, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); // Check if the measure's variable is a numeric variable. if (measure.Type == VariableType.Numeric) { Data data = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); writer.Append(data.Value.ToString(new CultureInfo("en-GB"))); writer.Append(","); i++; if (totalToProcess != 0) { int progress = (int)(i * 100 / totalToProcess); if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } else { filter = storageMethod.GetRespondents(measure, filter, this.Definition.WeightingFilters); string baseValue = filter.Base.ToString(new CultureInfo("en-GB")); string uBaseValue = filter.Responses.Count.ToString(new CultureInfo("en-GB")); int rowOffset = i; // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode.GetXPath() ); Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); for (int r = 0; r < scoreFilter.Responses.Count; r++) { //writer.Append(selection); writer.Append(_score.GetLabel(this.Definition.Settings.IdLanguage).Replace(",", ",") + ","); //writer.Append(Environment.NewLine); break; } i++; if (totalToProcess != 0) { int progress = (int)(i * 100 / totalToProcess); if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } }
private void RenderMeasure(LinkBiDefinitionDimension measure, ExcelWriter writer, int columnOffset, Data filter = null) { DataCore.Classes.StorageMethods.Database storageMethod = new DataCore.Classes.StorageMethods.Database( base.Core, null ); int rowOffset = i; if (measure.Type == VariableType.Numeric) { Data result = storageMethod.GetRespondentsNumeric( measure.Identity, measure.IsTaxonomy, this.Core.CaseDataLocation, filter, this.Definition.WeightingFilters ); double baseValue = result.Base; string uBaseValueStr = result.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValueStr = result.Responses.Count.ToString(new CultureInfo("en-GB")); string baseValueStr = baseValue.ToString(new CultureInfo("en-GB")); writer.Write( columnOffset + 2, i, baseValueStr ); writer.Write( columnOffset + 3, i, result.Responses.Values.Sum(x => x[0]).ToString(new CultureInfo("en-GB")) ); i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } else { filter = storageMethod.GetRespondents( measure, filter, this.Definition.WeightingFilters ); double baseValue = filter.Base; string uBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string eBaseValueStr = filter.Responses.Count.ToString(new CultureInfo("en-GB")); string baseValueStr = baseValue.ToString(new CultureInfo("en-GB")); // Run through all scores of the measure. foreach (LinkBiDefinitionDimensionScore score in measure.Scores) { if (score.Hidden) { continue; } if (measure.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode ); /*writer.Write( * columnOffset + 1, * i, * score.Label * );*/ writer.Write( columnOffset + 1, i, _score.GetLabel(this.Definition.Settings.IdLanguage) ); int columnOffset2 = 0; if (this.DisplayUnweightedBase) { columnOffset2 = 1; writer.Write( columnOffset + 2, i, uBaseValueStr ); } if (this.DisplayEffectiveBase) { columnOffset2 = 1; writer.Write( columnOffset + 2, i, eBaseValueStr ); } writer.Write( columnOffset + columnOffset2 + 2, i, baseValueStr ); double value; Data scoreFilter = score.GetRespondents(filter, this.StorageMethod); value = scoreFilter.Value; writer.Write( columnOffset + columnOffset2 + 3, i, value.ToString(new CultureInfo("en-GB")) ); if (this.ExportPercentage) { double percentage = (value * 100 / baseValue); if (double.IsNaN(percentage)) { percentage = 0.0; } writer.Write( columnOffset + columnOffset2 + 4, i, percentage.ToString(new CultureInfo("en-GB")) ); } i++; if (totalToProcess != 0) { int progress = i * 100 / totalToProcess; if (progress == 100) { base.Progress = 99; } else { base.Progress = progress; } } } } for (int a = rowOffset; a < i; a++) { DefinitionObject _measure = new DefinitionObject( this.Core, this.Definition.FileName, measure.XmlNode ); /*writer.Write( * columnOffset, * a, * measure.Label * );*/ writer.Write( columnOffset, a, _measure.GetLabel(this.Definition.Settings.IdLanguage) ); } }
private void RenderDimension(LinkBiDefinitionDimension dimension, ExcelWriter writer, int offset, Data dataFilter = null) { Data scoreFilter; // Run through all filter scores of the filter. foreach (LinkBiDefinitionDimensionScore score in dimension.Scores) { if (score.Hidden) { continue; } if (dimension.IsTaxonomy && score.Persistent && base.Definition.HierarchyFilter.TaxonomyCategories.ContainsKey(score.Identity) == false) { continue; } int rowOffset = i; scoreFilter = score.GetRespondents(dataFilter, this.StorageMethod); if (this.Definition.Dimensions.Count > (offset + 1)) { RenderDimension( this.Definition.Dimensions[offset + 1], writer, offset + 1, scoreFilter ); } else { foreach (LinkBiDefinitionDimension measure in this.Definition.Measures) { RenderMeasure( measure, writer, offset + 1, scoreFilter ); } } for (int a = rowOffset; a < i; a++) { DefinitionObject _score = new DefinitionObject( this.Core, this.Definition.FileName, score.XmlNode ); /*writer.Write( * offset, * a, * score.Label * );*/ writer.Write( offset, a, _score.GetLabel(this.Definition.Settings.IdLanguage) ); } //i++; } }
private string RenderStdDevEquation( string source, DefinitionObject variable, XmlNode xmlNodeVariable, object idStudy ) { StringBuilder meanEquation = new StringBuilder(); // Run through all category ids of the variable. foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes) { if (xmlNodeCategory.Name == "ScoreGroup") { continue; } DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory); meanEquation.Append(string.Format( "([{3}{0}.{1}] * {2}) + ", variable.GetValue("Name"), category.GetValue("Name"), category.GetValue("Value"), idStudy != null ? "/" + idStudy + "\\" : "" )); } if (xmlNodeVariable.ChildNodes.Count != 0) { meanEquation = meanEquation.Remove(meanEquation.Length - 3, 3); } StringBuilder equation = new StringBuilder(); equation.Append("double var_mean = Math.Pow("); equation.Append(meanEquation.ToString()); equation.Append(string.Format( ", 2) / [{1}{0}];", variable.GetValue("Name"), idStudy != null ? "/" + idStudy + "\\" : "" )); equation.Append(Environment.NewLine); equation.Append("double var_result = "); // Run through all category ids of the variable. foreach (XmlNode xmlNodeCategory in xmlNodeVariable.ChildNodes) { if (xmlNodeCategory.Name == "ScoreGroup") { continue; } DefinitionObject category = new DefinitionObject(Global.Core, source, xmlNodeCategory); equation.Append(string.Format( "([{3}{0}.{1}] * Math.Pow({3}{2}, 2)) + ", variable.GetValue("Name"), category.GetValue("Name"), category.GetValue("Value"), idStudy != null ? "/" + idStudy + "\\" : "" )); } if (xmlNodeVariable.ChildNodes.Count != 0) { equation = equation.Remove(equation.Length - 3, 3); } equation.Append(" - var_mean"); equation.Append(";"); equation.Append(Environment.NewLine); equation.Append(Environment.NewLine); equation.Append(string.Format( "var_result = var_result / ([{1}{0}] - 1);", variable.GetValue("Name"), idStudy != null ? "/" + idStudy + "\\" : "" )); equation.Append(Environment.NewLine); equation.Append("return Math.Pow(var_result, 0.5);"); return(equation.ToString()); }
private string RenderScoreToJson(DefinitionObject score, int idLanguage) { StringBuilder result = new StringBuilder(); if (score.IsScoreGroup()) { object _enabled = score.GetValue("Enabled"); result.Append("{"); result.Append(string.Format( " \"Type\": \"ScoreGroup\", \"Id\": \"{0}\", \"Name\": \"{1}\", \"Order\": \"{2}\", \"Path\": \"{3}\", \"Source\": \"{4}\", \"Value\": \"{5}\", \"Enabled\": {6}, \"Color\":\"{7}\", \"Scores\": [", score.GetValue("Id"), HttpUtility.HtmlEncode(score.GetLabel(idLanguage)), score.GetValue("Order"), score.Path.Replace("\"", "\\\""), score.Source, score.GetValue("Value"), _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(), score.GetValue("Color") )); /*foreach (XmlNode xmlNodeScore in xmlNode.ChildNodes) * { * result.Append(RenderScoreToJson(xmlNodeScore, idLanguage)); * result.Append(","); * }*/ DefinitionObject[] childScores = score.GetChilds(); foreach (DefinitionObject childScore in childScores) { result.Append(RenderScoreToJson(childScore, idLanguage)); result.Append(","); } if (childScores.Length > 0) { result = result.Remove(result.Length - 1, 1); } result.Append("] }"); } else { object _enabled = score.GetValue("Enabled"); result.Append("{"); result.Append(string.Format( " \"Type\": \"{0}\", \"Id\": \"{1}\", \"Label\": \"{2}\", \"Order\": \"{3}\", \"Path\": \"{4}\", \"Enabled\": {5}, \"Source\": \"{6}\", \"Name\": \"{7}\", \"Value\": \"{8}\" ", score.TypeName, score.GetValue("Id"), HttpUtility.HtmlEncode(score.GetLabel(idLanguage)), score.GetValue("Order"), score.Path.Replace("\"", "\\\""), _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(), score.Source, HttpUtility.HtmlEncode(score.GetValue("Name")), score.GetValue("Value") )); result.Append("}"); } return(result.ToString()); }
private void GetScores(HttpContext context) { string xPath = context.Request.Params["XPath"]; // Get the source string from the http request's parameters. string source = context.Request.Params["Source"]; DefinitionObject variable = new DefinitionObject( Global.Core, source, xPath ); StringBuilder result = new StringBuilder(); result.Append("{ \"Scores\" : ["); // Set the default for the language to english GB. int idLanguage = 2057; // Check if a specific language is defined. if (context.Request.Params["IdLanguage"] != null) { idLanguage = int.Parse(context.Request.Params["IdLanguage"]); } DefinitionObject[] scores = variable.GetChilds(); HierarchyFilter hierarchyFilter; if (context.Request.UrlReferrer.ToString().EndsWith("LinkBi.aspx")) { hierarchyFilter = Global.HierarchyFilters[(string)HttpContext.Current.Session["LinkBiDefinition"]]; } else if (HttpContext.Current.Session["ReportDefinition"] != null) { hierarchyFilter = Global.HierarchyFilters[(string)HttpContext.Current.Session["ReportDefinition"]]; } else { string fileName = System.IO.Path.Combine( HttpContext.Current.Request.PhysicalApplicationPath, "Fileadmin", "ExportDefinitions", Global.User.Id + ".xml" ); hierarchyFilter = Global.HierarchyFilters[fileName]; } if (!hierarchyFilter.IsLoaded) { hierarchyFilter.Load(); } bool isTaxonomy = false; if (context.Request.UrlReferrer.ToString().EndsWith("Exports.aspx") || context.Request.UrlReferrer.ToString().EndsWith("TaxonomyManager.aspx")) { if (variable.GetValue("Id").ToString() != "") { isTaxonomy = true; } } else { isTaxonomy = bool.Parse((string)variable.GetValue("IsTaxonomy")); } foreach (DefinitionObject score in scores) { object persistant = score.GetValue("Persistent", false, false); if (isTaxonomy && persistant != null) { if (!hierarchyFilter.TaxonomyCategories.ContainsKey(Guid.Parse(score.GetValue("Id").ToString()))) { continue; } } result.Append(RenderScoreToJson(score, idLanguage)); result.Append(","); } if (scores.Length > 0) { result = result.Remove(result.Length - 1, 1); } result.Append("]}"); context.Response.Write(result.ToString()); }