/** * Use a Getter to retrieve data * @param recordType type of record being retrieved (eg. databsae table name) * @param operationName query being performed for the record type (eg. findById, findByName, findActive, getInsertedId) * @param queryValues values that will be passed through queryMapper and then strategyMethod to perform the query * @return {number} The x value. */ Get(recordType, operationName, queryValues) { //TODO: C# let bus = maglev.maglev.MagLev.getInstance('persistence'); //TODO: C# let args = [recordType, operationName, queryValues]; //TODO: C# let ret = bus.call('Persistence.Get', args); //TODO: C# return ret; }
public double this[recordType type] { get { switch (type) { case recordType.TimeSinceMark: return timeSinceMark; case recordType.AltitudeASL: return altitudeASL; case recordType.DownRange: return downRange; case recordType.SpeedSurface: return speedSurface; case recordType.SpeedOrbital: return speedOrbital; case recordType.Acceleration: return acceleration; case recordType.Q: return Q; case recordType.AoA: return AoA; case recordType.AltitudeTrue: return altitudeTrue; case recordType.Pitch: return pitch; case recordType.Mass: return mass; default: return 0; } } }
public double this[recordType type] { get { switch (type) { case recordType.TimeSinceMark: return(timeSinceMark); case recordType.CurrentStage: return(currentStage); case recordType.AltitudeASL: return(altitudeASL); case recordType.DownRange: return(downRange); case recordType.SpeedSurface: return(speedSurface); case recordType.SpeedOrbital: return(speedOrbital); case recordType.Acceleration: return(acceleration); case recordType.Q: return(Q); case recordType.AoA: return(AoA); case recordType.AltitudeTrue: return(altitudeTrue); case recordType.Pitch: return(pitch); case recordType.Mass: return(mass); case recordType.GravityLosses: return(gravityLosses); case recordType.DragLosses: return(dragLosses); case recordType.SteeringLosses: return(steeringLosses); case recordType.DeltaVExpended: return(deltaVExpended); default: return(0); } } }
/// <summary> /// Perform a Matching Test to ensure no Schema elements are missing from the Element Mapping File /// </summary> /// <param name="elementMappingTable">The Element Mapping Table</param> private void PerformMatchingTest(DataTable elementMappingTable) { this.mainWindowObject.StatusLabel.Content = "Performing a Matching Test to ensure no Schema elements are missing from the Element Mapping File..."; DoEvents(); recordType matchingTest = new recordType(); List <string> elementsNotInMappingFile = new List <string>(); Type matchingType = matchingTest.GetType(); PropertyInfo[] matchingProps = matchingType.GetProperties(); foreach (PropertyInfo p in matchingProps) { string attributeName = string.Empty; if (p.GetCustomAttribute(typeof(XmlElementAttribute)) != null) { XmlElementAttribute attr = (XmlElementAttribute)p.GetCustomAttribute(typeof(XmlElementAttribute)); attributeName = attr.ElementName; } if (attributeName != string.Empty) { if (this.GetDataColumnName(attributeName, elementMappingTable) == null) { if (!p.Name.Contains("Specified")) { elementsNotInMappingFile.Add(attributeName); } } } else { if (this.GetDataColumnName(p.Name, elementMappingTable) == null) { if (!p.Name.Contains("Specified")) { elementsNotInMappingFile.Add(p.Name); } } } } if (elementsNotInMappingFile.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (string element in elementsNotInMappingFile) { sb.Append(element + Environment.NewLine); } MessageBox.Show("The following schema elements are not in the Mapping File and will be ignored:" + Environment.NewLine + Environment.NewLine + sb.ToString()); } }
/// <summary> /// Get a list of results to be appended to the dataset object /// </summary> /// <param name="rows">The Data Rows from the supplied Data File </param> /// <param name="elementMappingTable">The Element Mapping Table</param> /// <returns>A list of XML Element result objects</returns> private List <recordType> GetResults(List <DataRow> rows, DataTable elementMappingTable) { this.mainWindowObject.StatusLabel.Content = "Generating XML ..."; DoEvents(); this.mainWindowObject.pbrDecoding.Value = 0; this.mainWindowObject.pbrDecoding.Minimum = 0; this.mainWindowObject.pbrDecoding.Maximum = rows.Count; try { List <recordType> results = new List <recordType>(); foreach (DataRow row in rows) { this.mainWindowObject.pbrDecoding.Value = rows.IndexOf(row) + 1; DoEvents(); recordType resultObject = new recordType(); Type t = resultObject.GetType(); PropertyInfo[] props = t.GetProperties(); foreach (PropertyInfo p in props) { string attributeName = string.Empty; if (p.GetCustomAttribute(typeof(XmlElementAttribute)) != null) { XmlElementAttribute attr = (XmlElementAttribute)p.GetCustomAttribute(typeof(XmlElementAttribute)); attributeName = attr.ElementName; this.CreateXMLElement(attributeName, row, resultObject, elementMappingTable); } this.CreateXMLElement(p.Name, row, resultObject, elementMappingTable); } results.Add(resultObject); } return(results); } catch (Exception ex) { MessageBox.Show("Error getting results: " + ex.Message); return(null); } }
public double this[recordType type] { get { switch (type) { case recordType.TimeSinceMark: return(timeSinceMark); case recordType.AltitudeASL: return(altitudeASL); case recordType.DownRange: return(downRange); case recordType.SpeedSurface: return(speedSurface); case recordType.SpeedOrbital: return(speedOrbital); case recordType.Acceleration: return(acceleration); case recordType.Q: return(Q); case recordType.AoA: return(AoA); case recordType.AltitudeTrue: return(altitudeTrue); case recordType.Pitch: return(pitch); case recordType.Mass: return(mass); default: return(0); } } }
public string Export(IEnumerable<ReadingList> readingLists) { if (!readingLists.HasContent()) return null; var xmlDoc = new ListRecords(); var recordList = new Collection<recordType>(); foreach (var list in readingLists) { var record = new recordType { header = new headerType { identifier = list.Uri } }; recordList.Add(record); } xmlDoc.record = recordList.ToArray(); var builder = new StringBuilder(); var settings = new XmlWriterSettings {OmitXmlDeclaration = false, Indent = true}; var ns = new XmlSerializerNamespaces(); ns.Add("", ""); var serializer = new XmlSerializer(typeof(ListRecords)); using (var writer = XmlWriter.Create(builder, settings)) { serializer.Serialize(writer, xmlDoc, ns); } return builder.ToString(); }
/// <summary> /// Create the XML Element /// </summary> /// <param name="resultElementName">The Name of the XML Element to be created</param> /// <param name="row">The DataRow from the DBF file</param> /// <param name="resultObject">The result object being added</param> /// <param name="elementMappingTable">The DataTable containing the Element Mapping</param> private void CreateXMLElement(string resultElementName, DataRow row, recordType resultObject, DataTable elementMappingTable) { // Get the DBF Column name from the codes.xml file string dataColumnName = this.GetDataColumnName(resultElementName, elementMappingTable); // Ensure that such a DBF Column exists if (dataColumnName != null && row.Table.Columns.Contains(dataColumnName)) { // Get the content of the DBF column string givenString = row[dataColumnName].ToString().Trim(); // If there is conent, create the XML element, otherwise skip if (givenString != string.Empty) { PropertyInfo prop = resultObject.GetType().GetProperty(resultElementName.Replace(".", ""), BindingFlags.Public | BindingFlags.Instance); if (prop != null && prop.CanWrite) { if (prop.PropertyType == typeof(string)) { prop.SetValue(resultObject, givenString, null); } if (prop.PropertyType == typeof(decimal)) { decimal decimalValue; decimal.TryParse(givenString, out decimalValue); prop.SetValue(resultObject, decimalValue, null); PropertyInfo propSpecified = resultObject.GetType().GetProperty(resultElementName + "Specified", BindingFlags.Public | BindingFlags.Instance); if (propSpecified != null && propSpecified.CanWrite && decimalValue != 0) { propSpecified.SetValue(resultObject, true, null); } } if (prop.PropertyType == typeof(SSDCompoundType)) { if (givenString.IndexOf("=") > -1) { // If there is a $ separator, there are multiple attributes string[] attributeArray; if (givenString.IndexOf("$") > -1) { attributeArray = givenString.Split("$".ToCharArray()); } else { attributeArray = new string[1]; attributeArray[0] = givenString; } List <SSDCompoundTypeValue> values = new List <SSDCompoundTypeValue>(); for (int i = 0; i < attributeArray.Length; i++) { SSDCompoundTypeValue ctv = new SSDCompoundTypeValue(); ctv.name = attributeArray[i].Split("=".ToCharArray())[0]; ctv.Value = attributeArray[i].Split("=".ToCharArray())[1]; values.Add(ctv); } SSDCompoundType newSSDCompoundType = new SSDCompoundType(); newSSDCompoundType.value = values.ToArray(); prop.SetValue(resultObject, newSSDCompoundType, null); } else { SSDCompoundType newSSDCompoundType = new SSDCompoundType(); newSSDCompoundType.Text = new string[1]; newSSDCompoundType.Text[0] = givenString; prop.SetValue(resultObject, newSSDCompoundType, null); } } if (prop.PropertyType == typeof(SSDRepeatableType)) { SSDRepeatableType newSSDRepeatableType = new SSDRepeatableType(); //// List<String> rvalues = new List<String>(); //// rvalues.Add(givenString); //// newSSDRepeatableType.value = rvalues.ToArray(); newSSDRepeatableType.Text = new string[1]; newSSDRepeatableType.Text[0] = givenString; prop.SetValue(resultObject, newSSDRepeatableType, null); } } } } }
/** * Use a Mutator to change stored data * @param recordType type of record being changed (eg. databsae table name) * @param operationName action being performed on the record (eg. insert, update) * @param recordData data being updated or saved by passing through updateMapper and then strategyMethod */ Mutate(recordType, operationName, recordData) { //TODO: C# let bus = maglev.maglev.MagLev.getInstance('persistence'); //TODO: C# let args = [recordType, operationName, recordData]; //TODO: bus.call('Persistence.Mutate', args); }
/** * Set up a Getter to retrieve data * @param recordType type of record being retrieved (eg. databsae table name) * @param operationName query being performed for the record type (eg. findById, findByName, findActive, getInsertedId) * @param strategyMethod method to call to actually perform the data retrieval * @param queryMapper method to call on queryValues before calling strategyMethod with the results * @param resultMapper method to call on data returned from the strategyMethod before returning the results * @param useQueryValuesAsParams if set to true, the queryValues will be passed as the arguments to strategyMethod, rather than as the first argument */ AddGetter(recordType, operationName, strategyMethod, queryMapper, resultMapper, useQueryValuesAsParams) { //TODO: C# let bus = maglev.maglev.MagLev.getInstance('persistence'); //TODO: C# let args = [recordType, operationName, strategyMethod, queryMapper, resultMapper, useQueryValuesAsParams]; //TODO: bus.call('Persistence.AddGetter', args); }
/** * Set up a Mutator to change stored data * @param recordType type of record being changed (eg. databsae table name) * @param operationName action being performed on the record (eg. insert, update) * @param strategyMethod method to call to actually perform the mutation * @param updateMapper method to call on recordData before calling strategyMethod with the results * @param useRecordDataAsParams if set to true, the recordData will be passed as the arguments to strategyMethod, rather than as the first argument */ AddMutator(recordType, operationName, strategyMethod, updateMapper, useRecordDataAsParams) { //TODO: C# let bus = maglev.maglev.MagLev.getInstance('persistence'); //TODO: C# let args = [recordType, operationName, strategyMethod, updateMapper, useRecordDataAsParams]; //TODO: bus.call('Persistence.AddMutator', args); }