internal static IList<Tag> ParseTags(JsonReader xr, ErrorList errors) { try { var tagObj = JObject.Load(xr); var tagListContents = tagObj[TagListSerializer.TAGLIST_ROOT] as JObject; if (tagObj.Count == 1 && tagListContents != null) { var categoryArray = tagListContents[BundleXmlParser.XATOM_CATEGORY] as JArray; if (tagListContents.Count == 1 && categoryArray != null) return ParseTags(categoryArray); else errors.Add("TagList contains unexpected child elements"); } else errors.Add("Unexpected property found at start of TagList object"); } catch (Exception exc) { errors.Add("Exception while loading taglist: " + exc.Message); } return null; }
public ErrorList GenerateSet(Context ctx, Action<Context> exp) { Ctx = ctx; Errors.Clear(); var errors = new ErrorList(); if (T.Type == 0) { var error = (CommonErrorNode) T; errors.ErrorParse(error); return Errors; } var child = (CommonTree) T.Children[0]; switch (child.Type) { case 0: { var error = (CommonErrorNode) child; errors.ErrorParse(error); break; } case TemplateLexer.MStart: case TemplateLexer.EStart: { EmitSet(child, exp); //pop off voidtype from final function in chain break; } default: { break; } } return Errors; }
internal BaseScripter(CSLite_Scripter owner) { this.Owner = owner; this.symbol_table = new SymbolTable(this); this.code = new Code(this); this.module_list = new ModuleList(this); this.parser_list = new ParserList(); this.Error_List = new ErrorList(this); this.Warning_List = new ErrorList(this); this.PPDirectiveList = new StringList(false); this.RegisteredTypes = new RegisteredTypeList(); this.RegisteredNamespaces = new StringList(false); this.UserTypes = new Hashtable(); this.UserNamespaces = new StringList(false); this.ForbiddenNamespaces = new StringList(false); this.UserInstances = new Hashtable(); this.UserVariables = new Hashtable(); this.OperatorHelpers = new Hashtable(); this.available_types = new StringList(false); this.ForbiddenTypes = new StringList(false); this.EntryId = 0; this.event_dispatcher = new EventDispatcher(this, "CSLiteEventDispatcher"); if (CSLite_Scripter.AUTO_IMPORTING_SWITCH) { this.RegisterAvailableNamespaces(); } }
/// <summary>Creates a new <see cref="BplDocumentFormatter"/> instance.</summary> public BplDocumentFormatter() { Errors = new ErrorList(); IndentChars = " "; NewLineChars = "\r\n"; PrettyPrint = false; SkipDefaults = true; }
public void BinaryParsing() { string xmlString = @"<Binary id='pic1' contentType='image/gif' xmlns='http://hl7.org/fhir'>R0lGODlhEwARAPcAAAAAAAAA/+9aAO+1AP/WAP/eAP/eCP/eEP/eGP/nAP/nCP/nEP/nIf/nKf/nUv/nWv/vAP/vCP/vEP/vGP/vIf/vKf/vMf/vOf/vWv/vY//va//vjP/3c//3lP/3nP//tf//vf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAAEALAAAAAATABEAAAi+AAMIDDCgYMGBCBMSvMCQ4QCFCQcwDBGCA4cLDyEGECDxAoAQHjxwyKhQAMeGIUOSJJjRpIAGDS5wCDly4AALFlYOgHlBwwOSNydM0AmzwYGjBi8IHWoTgQYORg8QIGDAwAKhESI8HIDgwQaRDI1WXXAhK9MBBzZ8/XDxQoUFZC9IiCBh6wEHGz6IbNuwQoSpWxEgyLCXL8O/gAnylNlW6AUEBRIL7Og3KwQIiCXb9HsZQoIEUzUjNEiaNMKAAAA7</Binary>"; ErrorList errors = new ErrorList(); Binary result = (Binary)FhirParser.ParseResourceFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual("image/gif", result.ContentType); Assert.AreEqual(993, result.Content.Length); Assert.IsTrue(Encoding.ASCII.GetString(result.Content).StartsWith("GIF89a")); byte[] data = result.Content; File.WriteAllBytes(@"c:\temp\test.gif", data); string json = "{ Binary: { contentType : \"image/gif\", " + "content: \"R0lGODlhEwARAPcAAAAAAAAA/+9aAO+1AP/WAP/eAP/eCP/eEP/eGP/nAP/nCP/nEP/nIf/nKf/nUv/nWv/vAP/vCP/vEP/vGP/vIf/vKf/vMf/vOf/vWv/vY//va//vjP/3c//3lP/3nP//tf//vf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAAEALAAAAAATABEAAAi+AAMIDDCgYMGBCBMSvMCQ4QCFCQcwDBGCA4cLDyEGECDxAoAQHjxwyKhQAMeGIUOSJJjRpIAGDS5wCDly4AALFlYOgHlBwwOSNydM0AmzwYGjBi8IHWoTgQYORg8QIGDAwAKhESI8HIDgwQaRDI1WXXAhK9MBBzZ8/XDxQoUFZC9IiCBh6wEHGz6IbNuwQoSpWxEgyLCXL8O/gAnylNlW6AUEBRIL7Og3KwQIiCXb9HsZQoIEUzUjNEiaNMKAAAA7\" } }"; errors.Clear(); result = (Binary)FhirParser.ParseResourceFromJson(json, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual("image/gif", result.ContentType); Assert.AreEqual(993, result.Content.Length); Assert.IsTrue(Encoding.ASCII.GetString(result.Content).StartsWith("GIF89a")); }
/// <summary> /// Parse Identifier /// </summary> public static Hl7.Fhir.Model.Identifier ParseIdentifier(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Identifier existingInstance = null ) { Hl7.Fhir.Model.Identifier result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Identifier(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element use else if( atName == "use" ) result.UseElement = CodeParser.ParseCode<Hl7.Fhir.Model.Identifier.IdentifierUse>(reader, errors); // Parse element label else if( atName == "label" ) result.LabelElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element system else if( atName == "system" ) result.SystemElement = FhirUriParser.ParseFhirUri(reader, errors); // Parse element key else if( atName == "key" ) result.KeyElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element period else if( atName == "period" ) result.Period = PeriodParser.ParsePeriod(reader, errors); // Parse element assigner else if( atName == "assigner" ) result.Assigner = ResourceReferenceParser.ParseResourceReference(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
internal static IList<Tag> ParseTags(XmlReader xr, ErrorList errors) { xr.MoveToContent(); try { var taglist = (XElement)XElement.ReadFrom(xr); if (taglist.Name == BundleXmlParser.XFHIRNS + TagListSerializer.TAGLIST_ROOT) { if (taglist.Elements().All(xe => xe.Name == BundleXmlParser.XFHIRNS + BundleXmlParser.XATOM_CATEGORY)) return ParseTags(taglist.Elements()); else errors.Add("TagList contains unexpected child elements"); } else errors.Add(String.Format("Unexpected element name {0} found at start of TagList", taglist.Name)); } catch (Exception exc) { errors.Add("Exception while loading taglist: " + exc.Message); } return null; }
public void ParseEmptyPrimitive() { string xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' />"; ErrorList errors = new ErrorList(); FhirString result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.LocalId.ToString()); xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' value='' />"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.LocalId.ToString()); string jsonString = "{ \"someString\" : { \"_id\" : \"4\" } }"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.LocalId.ToString()); jsonString = "{ \"someString\" : { \"_id\" : \"4\", \"value\" : \"\" } }"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.LocalId.ToString()); }
public override void Execute() { try { DTE service = (DTE)this.GetService(typeof(DTE)); list = new ErrorList(service); if (IsDisposeCheckerInstalled()) { string disposeCheckerPath = ""; string[] folders = new string[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe") }; bool disposeCheckerFound = false; foreach (string path in folders) { if (File.Exists(path)) { disposeCheckerFound = true; disposeCheckerPath = path; break; } } if (!disposeCheckerFound) { MessageBox.Show("SPDisposeCheck not found at installation location"); } //first check for rebuild foreach (Project project in Helpers.GetSelectedProjects(service)) { if (DeploymentHelpers.CheckRebuildForProject(service, project)) { } } foreach (Project project in Helpers.GetSelectedProjects(service)) { currentProject = project; string projectpath = project.FullName; projectpath = projectpath.Substring(0, projectpath.LastIndexOf('\\', projectpath.Length - 2)); RunProcess(service, disposeCheckerPath, "\"" + projectpath + "\""); } } else { if (MessageBox.Show("SPDisposeCheck is not installed. Go to download page?", "Not installed", MessageBoxButtons.YesNo) == DialogResult.Yes) { Window win = service.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow); CommandWindow comwin = (CommandWindow)win.Object; comwin.SendInput("nav \"http://code.msdn.microsoft.com/SPDisposeCheck\"", true); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); return result; }
/// <summary> /// Parse Quantity /// </summary> public static Hl7.Fhir.Model.Quantity ParseQuantity(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Quantity existingInstance = null ) { Hl7.Fhir.Model.Quantity result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Quantity(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element value else if( atName == "value" ) result.ValueElement = FhirDecimalParser.ParseFhirDecimal(reader, errors); // Parse element comparator else if( atName == "comparator" ) result.ComparatorElement = CodeParser.ParseCode<Hl7.Fhir.Model.Quantity.QuantityCompararator>(reader, errors); // Parse element units else if( atName == "units" ) result.UnitsElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element system else if( atName == "system" ) result.SystemElement = FhirUriParser.ParseFhirUri(reader, errors); // Parse element code else if( atName == "code" ) result.CodeElement = CodeParser.ParseCode(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
/// <summary> /// Parse CodeableConcept /// </summary> public static Hl7.Fhir.Model.CodeableConcept ParseCodeableConcept(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.CodeableConcept existingInstance = null ) { Hl7.Fhir.Model.CodeableConcept result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.CodeableConcept(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element coding else if( atName == "coding" ) { result.Coding = new List<Hl7.Fhir.Model.Coding>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "coding") ) result.Coding.Add(CodingParser.ParseCoding(reader, errors)); reader.LeaveArray(); } // Parse element text else if( atName == "text" ) result.TextElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element primary else if( atName == "primary" ) result.PrimaryElement = IdRefParser.ParseIdRef(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
/// <summary> /// Parse Choice /// </summary> public static Hl7.Fhir.Model.Choice ParseChoice(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Choice existingInstance = null ) { Hl7.Fhir.Model.Choice result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Choice(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element code else if( atName == "code" ) result.CodeElement = CodeParser.ParseCode(reader, errors); // Parse element option else if( atName == "option" ) { result.Option = new List<Hl7.Fhir.Model.Choice.ChoiceOptionComponent>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "option") ) result.Option.Add(ChoiceParser.ParseChoiceOptionComponent(reader, errors)); reader.LeaveArray(); } // Parse element isOrdered else if( atName == "isOrdered" ) result.IsOrderedElement = FhirBooleanParser.ParseFhirBoolean(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
/// <summary> /// Parse InterestOfCare /// </summary> public static Hl7.Fhir.Model.InterestOfCare ParseInterestOfCare(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.InterestOfCare existingInstance = null ) { Hl7.Fhir.Model.InterestOfCare result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.InterestOfCare(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element language else if( atName == "language" ) result.LanguageElement = CodeParser.ParseCode(reader, errors); // Parse element text else if( atName == "text" ) result.Text = NarrativeParser.ParseNarrative(reader, errors); // Parse element contained else if( atName == "contained" ) { result.Contained = new List<Hl7.Fhir.Model.Resource>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "contained") ) result.Contained.Add(ParserUtils.ParseContainedResource(reader,errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
internal override ErrorList ValidateRules() { var result = new ErrorList(); string dummy; if (!TryParseValue( Value, out dummy )) result.Add("Not a correctly formatted date value"); return result; }
/// <summary> /// Parse Schedule /// </summary> public static Hl7.Fhir.Model.Schedule ParseSchedule(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Schedule existingInstance = null ) { Hl7.Fhir.Model.Schedule result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Schedule(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element event else if( atName == "event" ) { result.Event = new List<Hl7.Fhir.Model.Period>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "event") ) result.Event.Add(PeriodParser.ParsePeriod(reader, errors)); reader.LeaveArray(); } // Parse element repeat else if( atName == "repeat" ) result.Repeat = ScheduleParser.ParseScheduleRepeatComponent(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
/// <summary> /// Parse ElementComponent /// </summary> public static Hl7.Fhir.Model.Profile.ElementComponent ParseElementComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Profile.ElementComponent existingInstance = null ) { Hl7.Fhir.Model.Profile.ElementComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Profile.ElementComponent(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element path else if( atName == "path" ) result.PathElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element name else if( atName == "name" ) result.NameElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element slicing else if( atName == "slicing" ) result.Slicing = ProfileParser.ParseElementSlicingComponent(reader, errors); // Parse element definition else if( atName == "definition" ) result.Definition = ProfileParser.ParseElementDefinitionComponent(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if(Numerator != null ) result.AddRange(Numerator.Validate()); if(Denominator != null ) result.AddRange(Denominator.Validate()); return result; }
internal override ErrorList ValidateRules() { var result = new ErrorList(); result.AddRange(base.ValidateRules()); if (Content == null) result.Add("Entry must contain (possibly 0-length) data"); if (ContentType == null) result.Add("Entry must contain a contentType"); return result; }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if(Low != null ) result.AddRange(Low.Validate()); if(High != null ) result.AddRange(High.Validate()); return result; }
public virtual ErrorList Validate() { var result = new ErrorList(); result.AddRange(ValidateRules()); if(Extension != null ) Extension.ForEach(elem => result.AddRange(elem.Validate())); if(LocalIdElement != null ) result.AddRange(LocalIdElement.Validate()); return result; }
partial void Changed_Errors(ErrorList oldValue, ErrorList newValue) { if (oldValue != null) { oldValue.CollectionChanged -= Errors_CollectionChanged; } if (newValue != null) { newValue.CollectionChanged += Errors_CollectionChanged; } UpdateErrorCount(newValue); }
/// <summary> /// Parse AnimalComponent /// </summary> public static Hl7.Fhir.Model.Patient.AnimalComponent ParseAnimalComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Patient.AnimalComponent existingInstance = null ) { Hl7.Fhir.Model.Patient.AnimalComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Patient.AnimalComponent(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element species else if( atName == "species" ) result.Species = CodeableConceptParser.ParseCodeableConcept(reader, errors); // Parse element breed else if( atName == "breed" ) result.Breed = CodeableConceptParser.ParseCodeableConcept(reader, errors); // Parse element genderStatus else if( atName == "genderStatus" ) result.GenderStatus = CodeableConceptParser.ParseCodeableConcept(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
/// <summary> /// Parse ResourceReference /// </summary> public static Hl7.Fhir.Model.ResourceReference ParseResourceReference(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ResourceReference existingInstance = null ) { Hl7.Fhir.Model.ResourceReference result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ResourceReference(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if( atName == "extension" ) { result.Extension = new List<Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while( ParserUtils.IsAtArrayElement(reader, "extension") ) result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); reader.LeaveArray(); } // Parse element _id else if( atName == "_id" ) result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); // Parse element type else if( atName == "type" ) result.TypeElement = CodeParser.ParseCode(reader, errors); // Parse element reference else if( atName == "reference" ) result.ReferenceElement = FhirStringParser.ParseFhirString(reader, errors); // Parse element display else if( atName == "display" ) result.DisplayElement = FhirStringParser.ParseFhirString(reader, errors); else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return result; }
public void ParsePrimitive() { string xmlString = "<someBoolean xmlns='http://hl7.org/fhir' value='true' id='3141' />"; ErrorList errors = new ErrorList(); FhirBoolean result = (FhirBoolean)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count == 0, errors.ToString()); Assert.AreEqual(true, result.Value); Assert.AreEqual("3141", result.Id.ToString()); string jsonString = "{\"someBoolean\": { \"value\" : true, \"_id\" : \"3141\" } }"; errors.Clear(); result = (FhirBoolean)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count == 0, errors.ToString()); Assert.AreEqual(true, result.Value); Assert.AreEqual("3141", result.Id.ToString()); }
internal override ErrorList ValidateRules() { var result = new ErrorList(); if (Value == null) result.Add("Id values cannot be empty"); else { string dummy; if (!TryParseValue(this.Value, out dummy)) result.Add("Not an correctly formatted id value"); } return result; }
public static ITemplateType ApplyBinary(ITemplateType lhs, ITemplateType rhs, int id, ErrorList errors) { if (rhs == null || lhs == null) return null; var op = (Operator) id; try { var rt = lhs.ApplyBinary(op, rhs); return PrimitiveType.Create(rt); } catch (Exception e) { errors.ErrorRuntimeError(e); } return null; }
public void CatchTagListParseErrors() { ErrorList errors = new ErrorList(); var tl = FhirParser.ParseTagListFromXml(xmlTagListE1, errors); Assert.IsTrue(errors.Count != 0, errors.ToString()); errors.Clear(); tl = FhirParser.ParseTagListFromXml(xmlTagListE2, errors); Assert.IsTrue(errors.Count != 0, errors.ToString()); errors.Clear(); tl = FhirParser.ParseTagListFromJson(jsonTagListE1, errors); Assert.IsTrue(errors.Count != 0, errors.ToString()); errors.Clear(); tl = FhirParser.ParseTagListFromJson(jsonTagListE2, errors); Assert.IsTrue(errors.Count != 0, errors.ToString()); errors.Clear(); }
public void NarrativeParsing() { string xmlString = @"<testNarrative xmlns='http://hl7.org/fhir'> <status value='generated' /> <div xmlns='http://www.w3.org/1999/xhtml'>Whatever</div> </testNarrative>"; ErrorList errors = new ErrorList(); Narrative result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value); Assert.IsTrue(result.Div != null); xmlString = @"<testNarrative xmlns='http://hl7.org/fhir'> <status value='generated' /> <xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'>Whatever</xhtml:div> </testNarrative>"; errors.Clear(); result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value); Assert.IsTrue(result.Div != null); xmlString = @"<testNarrative xmlns='http://hl7.org/fhir' xmlns:xhtml='http://www.w3.org/1999/xhtml'> <status value='generated' /> <xhtml:div>Whatever</xhtml:div> </testNarrative>"; errors.Clear(); result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value); Assert.IsTrue(result.Div != null); string jsonString = "{ \"testNarrative\" : {" + "\"status\" : { \"value\" : \"generated\" }, " + "\"div\" : " + "\"<div xmlns='http://www.w3.org/1999/xhtml'>Whatever</div>\" } }"; errors.Clear(); result = (Narrative)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value); Assert.IsTrue(result.Div != null); }
internal override ErrorList ValidateRules() { var result = new ErrorList(); if (Value.IsAbsoluteUri) { string dummy; string dummy2; var urnValue = Value.ToString(); if (urnValue.StartsWith("urn:oid:") && !Oid.TryParseValue(urnValue, out dummy)) result.Add(String.Format("Uri is an urn:oid, but the oid {0} is incorrect",urnValue)); else if (urnValue.StartsWith("urn:uuid:") && !Uuid.TryParseValue(urnValue, out dummy2)) result.Add(String.Format("Uri is an urn:uuid, but the uuid {0} is incorrect", urnValue)); } return result; }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Code != null) { result.AddRange(Code.Validate()); } if (Source != null) { result.AddRange(Source.Validate()); } if (DateElement != null) { result.AddRange(DateElement.Validate()); } if (OrderedElement != null) { result.AddRange(OrderedElement.Validate()); } if (ModeElement != null) { result.AddRange(ModeElement.Validate()); } if (Entry != null) { Entry.ForEach(elem => result.AddRange(elem.Validate())); } if (EmptyReason != null) { result.AddRange(EmptyReason.Validate()); } return(result); }
public void ParseEmptyPrimitive() { string xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' />"; ErrorList errors = new ErrorList(); FhirString result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.Id.ToString()); xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' value='' />"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.Id.ToString()); string jsonString = "{ \"someString\" : { \"_id\" : \"4\" } }"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.Id.ToString()); jsonString = "{ \"someString\" : { \"_id\" : \"4\", \"value\" : \"\" } }"; errors.Clear(); result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors); Assert.IsTrue(errors.Count() == 0, errors.ToString()); Assert.IsNotNull(result); Assert.IsNull(result.Value); Assert.AreEqual("4", result.Id.ToString()); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Origin != null) { result.AddRange(Origin.Validate()); } if (PeriodElement != null) { result.AddRange(PeriodElement.Validate()); } if (FactorElement != null) { result.AddRange(FactorElement.Validate()); } if (LowerLimitElement != null) { result.AddRange(LowerLimitElement.Validate()); } if (UpperLimitElement != null) { result.AddRange(UpperLimitElement.Validate()); } if (DimensionsElement != null) { result.AddRange(DimensionsElement.Validate()); } if (DataElement != null) { result.AddRange(DataElement.Validate()); } return(result); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (UseElement != null) { result.AddRange(UseElement.Validate()); } if (TextElement != null) { result.AddRange(TextElement.Validate()); } if (FamilyElement != null) { FamilyElement.ForEach(elem => result.AddRange(elem.Validate())); } if (GivenElement != null) { GivenElement.ForEach(elem => result.AddRange(elem.Validate())); } if (PrefixElement != null) { PrefixElement.ForEach(elem => result.AddRange(elem.Validate())); } if (SuffixElement != null) { SuffixElement.ForEach(elem => result.AddRange(elem.Validate())); } if (Period != null) { result.AddRange(Period.Validate()); } return(result); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Name != null) { result.AddRange(Name.Validate()); } if (TextElement != null) { result.AddRange(TextElement.Validate()); } if (Answer != null) { result.AddRange(Answer.Validate()); } if (Choice != null) { Choice.ForEach(elem => result.AddRange(elem.Validate())); } if (Options != null) { result.AddRange(Options.Validate()); } if (Data != null) { result.AddRange(Data.Validate()); } if (RemarksElement != null) { result.AddRange(RemarksElement.Validate()); } return(result); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Encounter != null) { result.AddRange(Encounter.Validate()); } if (RequestOrderId != null) { result.AddRange(RequestOrderId.Validate()); } if (ReceiverOrderId != null) { result.AddRange(ReceiverOrderId.Validate()); } if (RequestTest != null) { RequestTest.ForEach(elem => result.AddRange(elem.Validate())); } if (BodySite != null) { result.AddRange(BodySite.Validate()); } if (Requester != null) { result.AddRange(Requester.Validate()); } if (ClinicalInfoElement != null) { result.AddRange(ClinicalInfoElement.Validate()); } return(result); }
private void ProcessErrors(ErrorList errors) { TextLocation offset = GetSelectionPosition(); DebugLocator locator = Service.GetLocator(); string locatorLocator = locator == null ? null : locator.Locator; for (int index = errors.Count - 1; index >= 0; index--) { Exception exception = errors[index]; bool isWarning; var compilerException = exception as CompilerException; if (compilerException != null) { isWarning = compilerException.ErrorLevel == CompilerErrorLevel.Warning; } else { isWarning = false; } Dataphoria.Warnings.AppendError(this, exception, isWarning); } }
private void Validate() { if (Text1.Length > 127) { throw new ArgumentException(); } if (string.IsNullOrEmpty(Text2)) { ErrorList.Add("You must to fill out textbox2"); } else if (string.IsNullOrEmpty(Text3)) { ErrorList.Add("You must to fill out textbox3"); } else { Regex regex = new Regex(@"........."); Match match = regex.Match(Email); if (!match.Success) { ErrorList.Add("e-mail is inlvalid"); } } }
// default validation private void DefaultValidateAction(JProperty jprop, ConditionAttribute attr) { string propertyName = attr.CheckName; // 檢查設定的名稱與Json的是否一致 if (!propertyName.Equals(jprop.Name)) { ErrorList.Add(String.Format("property:({0}) [Name] expected: [{0}], actual is [{1}]", propertyName, jprop.Name)); } // 檢查(非預設值且必要)設定的資料型別與json的值型別是否一致 if (attr.JsonType != JTokenType.None && attr.Required && jprop.Value.Type != attr.JsonType) { ErrorList.Add(String.Format("property:({0}) [Type] expected: {1}, actual is {2}", propertyName, attr.JsonType.ToString(), jprop.Value.Type.ToString())); } // (若為字串型別)檢查內容字串的長度與設定是否一致 if (attr.JsonType == JTokenType.String && attr.StringMaxLength != 0) { var val = jprop.Value.Value <string>(); if (val != null && val.Length > attr.StringMaxLength) { ErrorList.Add(String.Format("property:({0}) [StringMaxLength] expected: {1}, actual is {2}", propertyName, attr.StringMaxLength, val.Length)); } } }
/// <summary> /// Register price factors. /// </summary> public override void RegisterFactors(PriceFactorList factors, ErrorList errors) { base.RegisterFactors(factors, errors); CFListBaseDeal <TCashflowList> deal = (CFListBaseDeal <TCashflowList>)fDeal; if (string.IsNullOrEmpty(fDeal.GetIssuer())) { return; } if (UseSurvivalProbability()) { factors.RegisterInterface <ISurvivalProb>(string.IsNullOrEmpty(deal.GetSurvivalProbability()) ? deal.GetIssuer() : deal.GetSurvivalProbability()); } if (RespectDefault()) { factors.Register <RecoveryRate>(InterestRateUtils.GetRateId(deal.GetRecoveryRate(), deal.GetIssuer())); factors.Register <CreditRating>(deal.GetIssuer()); } fSettlementOffsetHelper.ValidateHolidayCalendars(factors.CalendarData, errors); }
/// <summary> Called for each node after activation. </summary> /// <remarks> Optimistically attempts to activate each child. The last error (if any) will be thrown. </remarks> protected internal virtual void AfterActivate() { ErrorList errors = null; foreach (Node child in Children) { try { child.AfterActivate(); } catch (Exception exception) { if (errors == null) { errors = new ErrorList(); } errors.Add(exception); } } if (errors != null) { HostNode.Session.ReportErrors(this.HostNode, errors); } }
public bool GetPersonRow(ErrorList err, int idp, SalarySheetInfo sh) { var table_persons = MyData.DataSetKlons.PERSONS; IDP = idp; var dr_person = table_persons.FindByID(idp); if (dr_person == null) { var es = string.Format("{0} ({1}-{2})", IDP, sh.CalendarMonth.Year, sh.CalendarMonth.Month); err.AddError(es, "Nav darbinieka"); return(false); } var drs_persons_r = dr_person.GetPERSONS_RRows().OrderBy(d => d.EDIT_DATE).ToArray(); var dt2 = sh.MDT2; DR_Person_r = PeriodInfo.FindNearestBefore(drs_persons_r, dt2, d => d.EDIT_DATE); if (DR_Person_r == null) { var es = string.Format("{0} {1} ({2}-{3})", dr_person.FNAME, dr_person.LNAME, sh.CalendarMonth.Year, sh.CalendarMonth.Month); err.AddError(es, "Norādītajam periodam nav ievadīti darbinieka dati."); return(false); } return(true); }
protected override void LoadData() { ISalesOrderService svcSalesOrder = DI.Resolve <ISalesOrderService>(); ErrorList errorList = new ErrorList(); try { SalesOrderDetail_ReadOutput outDetail_Read; using (TimeTracker.ServiceCall) outDetail_Read = svcSalesOrder.Detail_Read((int)obj.SalesOrderDetailIdProperty.TransportValue); obj.FromDataContract(outDetail_Read); } catch (Exception ex) { errorList.MergeWith(ErrorList.FromException(ex)); } if (svcSalesOrder is IDisposable) { ((IDisposable)svcSalesOrder).Dispose(); } errors.List.DataSource = errorList.Errors; errors.List.DataBind(); Page.DataBind(); }
public void AddReturnedValue(ReturnedState returnedState, string description) { try { switch (returnedState) { case ReturnedState.Information: InformationList.Add(description); break; case ReturnedState.Error: ErrorList.Add(description); break; case ReturnedState.Warning: WarningList.Add(description); break; } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { if (DI.DefaultServiceProvider == null) { throw new InvalidOperationException("Default service provider is not initialized."); } try { // TODO: validate context.UserName and context.Password here. // Use DI.DefaultServiceProvider to access any services. string user = string.IsNullOrEmpty(context.UserName) ? "Guest" : context.UserName; ClaimsIdentity guestIdentity = new ClaimsIdentity(); guestIdentity.AddClaim(new Claim(ClaimTypes.Name, user)); context.Validated(new AuthenticationTicket(guestIdentity, new AuthenticationProperties())); } catch (Exception ex) { ErrorParser errorParser = DI.DefaultServiceProvider.GetService <ErrorParser>(); ErrorList errors = errorParser.FromException(ex); context.SetError("invalid_grant", errors.ErrorsText); } return(Task.FromResult <object>(null)); }
/// <summary> /// 检查连接是否正常 /// </summary> /// <param name="state"></param> private void OnTick(object state) { if (ErrorList.Count == 0) { return; } for (int i = 0; i < ErrorList.Count; i++) { var connS = ErrorList[i]; try { ErrorList[i].Error++; NpgsqlConnection conn = new NpgsqlConnection(connS.ConnectionString); conn.Open(); conn.Close(); ErrorList.RemoveAt(i); ConnectionList.Add(connS); Console.WriteLine("连接正常,重新放入连接池:[{0}]", connS.ConnectionString); } catch { } } }
public override bool IsValid() { return(!ErrorList.Any()); }
/// <summary> /// Parse Test /// </summary> public static Hl7.Fhir.Model.Test ParseTest(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Test existingInstance = null) { Hl7.Fhir.Model.Test result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Test(); try { string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { // Parse element extension if (ParserUtils.IsAtFhirElement(reader, "extension")) { result.Extension = new List <Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element language else if (ParserUtils.IsAtFhirElement(reader, "language")) { result.Language = CodeParser.ParseCode(reader, errors); } // Parse element text else if (ParserUtils.IsAtFhirElement(reader, "text")) { result.Text = NarrativeParser.ParseNarrative(reader, errors); } // Parse element contained else if (ParserUtils.IsAtFhirElement(reader, "contained")) { result.Contained = new List <Hl7.Fhir.Model.Resource>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "contained")) { result.Contained.Add(ParserUtils.ParseContainedResource(reader, errors)); } reader.LeaveArray(); } // Parse element _id else if (ParserUtils.IsAtFhirElement(reader, "_id")) { result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id")); } // Parse element stringErr else if (ParserUtils.IsAtFhirElement(reader, "stringErr")) { result.StringErr = new List <Hl7.Fhir.Model.FhirString>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "stringErr")) { result.StringErr.Add(FhirStringParser.ParseFhirString(reader, errors)); } reader.LeaveArray(); } // Parse element stringCorr else if (ParserUtils.IsAtFhirElement(reader, "stringCorr")) { result.StringCorr = new List <Hl7.Fhir.Model.FhirString>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "stringCorr")) { result.StringCorr.Add(FhirStringParser.ParseFhirString(reader, errors)); } reader.LeaveArray(); } // Parse element booleanErr else if (ParserUtils.IsAtFhirElement(reader, "booleanErr")) { result.BooleanErr = new List <Hl7.Fhir.Model.FhirBoolean>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "booleanErr")) { result.BooleanErr.Add(FhirBooleanParser.ParseFhirBoolean(reader, errors)); } reader.LeaveArray(); } // Parse element booleanCorr else if (ParserUtils.IsAtFhirElement(reader, "booleanCorr")) { result.BooleanCorr = new List <Hl7.Fhir.Model.FhirBoolean>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "booleanCorr")) { result.BooleanCorr.Add(FhirBooleanParser.ParseFhirBoolean(reader, errors)); } reader.LeaveArray(); } // Parse element integerErr else if (ParserUtils.IsAtFhirElement(reader, "integerErr")) { result.IntegerErr = new List <Hl7.Fhir.Model.Integer>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "integerErr")) { result.IntegerErr.Add(IntegerParser.ParseInteger(reader, errors)); } reader.LeaveArray(); } // Parse element integerCorr else if (ParserUtils.IsAtFhirElement(reader, "integerCorr")) { result.IntegerCorr = new List <Hl7.Fhir.Model.Integer>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "integerCorr")) { result.IntegerCorr.Add(IntegerParser.ParseInteger(reader, errors)); } reader.LeaveArray(); } // Parse element decimalErr else if (ParserUtils.IsAtFhirElement(reader, "decimalErr")) { result.DecimalErr = new List <Hl7.Fhir.Model.FhirDecimal>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "decimalErr")) { result.DecimalErr.Add(FhirDecimalParser.ParseFhirDecimal(reader, errors)); } reader.LeaveArray(); } // Parse element decimalCorr else if (ParserUtils.IsAtFhirElement(reader, "decimalCorr")) { result.DecimalCorr = new List <Hl7.Fhir.Model.FhirDecimal>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "decimalCorr")) { result.DecimalCorr.Add(FhirDecimalParser.ParseFhirDecimal(reader, errors)); } reader.LeaveArray(); } // Parse element b64Err else if (ParserUtils.IsAtFhirElement(reader, "b64Err")) { result.B64Err = new List <Hl7.Fhir.Model.Base64Binary>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "b64Err")) { result.B64Err.Add(Base64BinaryParser.ParseBase64Binary(reader, errors)); } reader.LeaveArray(); } // Parse element b64Corr else if (ParserUtils.IsAtFhirElement(reader, "b64Corr")) { result.B64Corr = new List <Hl7.Fhir.Model.Base64Binary>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "b64Corr")) { result.B64Corr.Add(Base64BinaryParser.ParseBase64Binary(reader, errors)); } reader.LeaveArray(); } // Parse element instantErr else if (ParserUtils.IsAtFhirElement(reader, "instantErr")) { result.InstantErr = new List <Hl7.Fhir.Model.Instant>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "instantErr")) { result.InstantErr.Add(InstantParser.ParseInstant(reader, errors)); } reader.LeaveArray(); } // Parse element instantCorr else if (ParserUtils.IsAtFhirElement(reader, "instantCorr")) { result.InstantCorr = new List <Hl7.Fhir.Model.Instant>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "instantCorr")) { result.InstantCorr.Add(InstantParser.ParseInstant(reader, errors)); } reader.LeaveArray(); } // Parse element uriErr else if (ParserUtils.IsAtFhirElement(reader, "uriErr")) { result.UriErr = new List <Hl7.Fhir.Model.FhirUri>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "uriErr")) { result.UriErr.Add(FhirUriParser.ParseFhirUri(reader, errors)); } reader.LeaveArray(); } // Parse element uriCorr else if (ParserUtils.IsAtFhirElement(reader, "uriCorr")) { result.UriCorr = new List <Hl7.Fhir.Model.FhirUri>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "uriCorr")) { result.UriCorr.Add(FhirUriParser.ParseFhirUri(reader, errors)); } reader.LeaveArray(); } // Parse element idrefSingle else if (ParserUtils.IsAtFhirElement(reader, "idrefSingle")) { result.IdrefSingle = IdRefParser.ParseIdRef(reader, errors); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); } catch (Exception ex) { errors.Add(ex.Message, reader); } return(result); }
public void AddError(CodeError error) { ErrorList.Add(error); }
/// <summary> /// Parse Identifier /// </summary> public static Hl7.Fhir.Model.Identifier ParseIdentifier(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Identifier existingInstance = null) { Hl7.Fhir.Model.Identifier result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Identifier(); string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if (atName == "extension") { result.Extension = new List <Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element _id else if (atName == "_id") { result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); } // Parse element use else if (atName == "use") { result.UseElement = CodeParser.ParseCode <Hl7.Fhir.Model.Identifier.IdentifierUse>(reader, errors); } // Parse element label else if (atName == "label") { result.LabelElement = FhirStringParser.ParseFhirString(reader, errors); } // Parse element system else if (atName == "system") { result.SystemElement = FhirUriParser.ParseFhirUri(reader, errors); } // Parse element key else if (atName == "key") { result.KeyElement = FhirStringParser.ParseFhirString(reader, errors); } // Parse element period else if (atName == "period") { result.Period = PeriodParser.ParsePeriod(reader, errors); } // Parse element assigner else if (atName == "assigner") { result.Assigner = ResourceReferenceParser.ParseResourceReference(reader, errors); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); return(result); }
public void parselimits() { char[] delimiterChars = { ',' }; WebClient webClient = new WebClient(); Stream stream = webClient.OpenRead(FileName); StreamReader r = new StreamReader(stream); while (!r.EndOfStream) { string line = r.ReadLine(); if (line != null) { line.Trim(); } //Storing all these as arrays if (line.StartsWith("LIMITS-TASK")) { string[] items = line.Split(delimiterChars); int j = 0; if (!items.Contains("1") || !items.Contains("500")) { ErrorList.Add("tasks can only be 1 and have a maximum of 500"); } else { for (int i = 0; i < items.Length; i++) { if (items[i] == "1" || items[i] == "500") { LimitsTask[j] = Convert.ToInt32(items[i]); j++; } } } } if (line.StartsWith("LIMITS-PROCESSORS")) { string[] items = line.Split(delimiterChars); int j = 0; if (!items.Contains("1") || !items.Contains("1000")) { ErrorList.Add("processors can only be 1 and have a maximum of 1000"); } else { for (int i = 0; i < items.Length; i++) { if (items[i] == "1" || items[i] == "1000") { LimitsProcessor[j] = Convert.ToInt32(items[i]); j++; } } } } if (line.StartsWith("LIMITS-PROCESSOR-FREQUENCIES")) { string[] items = line.Split(delimiterChars); int j = 0; for (int i = 0; i < items.Length; i++) { if (items[i].Any(char.IsDigit)) { LimitsProcessorFrequencies[j] = Convert.ToDouble(items[i]); j++; } } } } r.Close(); //Console.WriteLine("the number of tasks is correct with:" + TaskNumber); }
private void Transfer() { if (service == null || targetService == null) { MessageBox.Show("You must select both a source and a target organization", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (lvSourceDashboards.SelectedItems.Count == 0) { MessageBox.Show("You must select at least one dashboard to be transfered", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ManageWorkingState(true); informationPanel = InformationPanel.GetInformationPanel(this, "Transfering dashboards...", 340, 150); SendMessageToStatusBar(this, new StatusBarMessageEventArgs("Transfering dashboards...")); var bwTransferDashboards = new BackgroundWorker { WorkerReportsProgress = true }; bwTransferDashboards.DoWork += (sender, e) => { var dashboards = (List <Entity>)e.Argument; var errors = new List <Tuple <string, string> >(); foreach (var dbEntity in dashboards) { var name = dbEntity.GetAttributeValue <string>("name"); var worker = (BackgroundWorker)sender; worker.ReportProgress(0, "Transfering dashboard '" + name + "'..."); try { var dashboard = new AppCode.Dashboard(dbEntity, service, targetService); dashboard.Transfer(); } catch (FaultException <OrganizationServiceFault> error) { if (error.HResult == -2146233087) { errors.Add(new Tuple <string, string>(name, "The dashboard you tried to transfer already exists but you don't have read access to it. Get access to this dashboard on the target organization to update it")); } else { errors.Add(new Tuple <string, string>(name, error.Message)); } } } e.Result = errors; }; bwTransferDashboards.RunWorkerCompleted += (sender, e) => { Controls.Remove(informationPanel); informationPanel.Dispose(); SendMessageToStatusBar(this, new StatusBarMessageEventArgs("")); ManageWorkingState(false); var errors = (List <Tuple <string, string> >)e.Result; if (errors.Count > 0) { var errorDialog = new ErrorList((List <Tuple <string, string> >)e.Result); errorDialog.ShowDialog(ParentForm); } }; bwTransferDashboards.ProgressChanged += (sender, e) => { InformationPanel.ChangeInformationPanelMessage(informationPanel, e.UserState.ToString()); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(e.UserState.ToString())); }; bwTransferDashboards.RunWorkerAsync(lvSourceDashboards.SelectedItems.Cast <ListViewItem>().Select(v => (Entity)v.Tag).ToList()); }
/// <summary> /// Parse Distance /// </summary> public static Hl7.Fhir.Model.Distance ParseDistance(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Distance existingInstance = null) { Hl7.Fhir.Model.Distance result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Distance(); QuantityParser.ParseQuantity(reader, errors, result); return(result); }
internal static BundleEntry LoadEntry(string xml, ErrorList errors) { return(LoadEntry(Util.XmlReaderFromString(xml), errors)); }
private static BundleEntry loadEntry(XElement entry, ErrorList errors) { BundleEntry result; errors.DefaultContext = "An atom entry"; try { if (entry.Name == XTOMBSTONE + XATOM_DELETED_ENTRY) { result = new DeletedEntry(); result.Id = Util.UriValueOrNull(entry.Attribute(XATOM_DELETED_REF)); if (result.Id != null) { errors.DefaultContext = String.Format("Entry '{0}'", result.Id.ToString()); } } else { XElement content = entry.Element(XATOMNS + XATOM_CONTENT); var id = Util.UriValueOrNull(entry.Element(XATOMNS + XATOM_ID)); if (id != null) { errors.DefaultContext = String.Format("Entry '{0}'", id.ToString()); } if (content != null) { var parsed = getContents(content, errors); if (parsed != null) { result = ResourceEntry.Create(parsed); } else { return(null); } } else { throw new InvalidOperationException("BundleEntry has empty content: cannot determine Resource type in parser."); } result.Id = id; } result.Links = getLinks(entry.Elements(XATOMNS + XATOM_LINK)); result.Tags = TagListParser.ParseTags(entry.Elements(XATOMNS + XATOM_CATEGORY)); if (result is DeletedEntry) { ((DeletedEntry)result).When = Util.InstantOrNull(entry.Attribute(XATOM_DELETED_WHEN)); } else { ResourceEntry re = (ResourceEntry)result; re.Title = Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_TITLE)); re.LastUpdated = Util.InstantOrNull(entry.Element(XATOMNS + XATOM_UPDATED)); re.Published = Util.InstantOrNull(entry.Element(XATOMNS + XATOM_PUBLISHED)); re.AuthorName = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null : Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR) .Element(XATOMNS + XATOM_AUTH_NAME)); re.AuthorUri = entry.Elements(XATOMNS + XATOM_AUTHOR).Count() == 0 ? null : Util.StringValueOrNull(entry.Element(XATOMNS + XATOM_AUTHOR) .Element(XATOMNS + XATOM_AUTH_URI)); } } catch (Exception exc) { errors.Add("Exception while reading entry: " + exc.Message); return(null); } finally { errors.DefaultContext = null; } return(result); }
private static ManagedEntryList loadEntries(IEnumerable <XElement> entries, Bundle parent, ErrorList errors) { var result = new ManagedEntryList(parent); foreach (var entry in entries) { var loaded = loadEntry(entry, errors); if (entry != null) { result.Add(loaded); } } return(result); }
public InvalidBrandException(ErrorList errors, Brand entity) : base(errors, entity) { }
private void SaveChanges() { if (cmbEntities.SelectedItem == null) { MessageBox.Show("You must select an entity", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ManageWorkingState(true); informationPanel = InformationPanel.GetInformationPanel(this, "Processing entity...", 340, 150); var entityitem = (EntityItem)cmbEntities.SelectedItem; var itemsToProcess = lvAttributes.Items .Cast <ListViewItem>() .Where(i => !string.IsNullOrEmpty(i.SubItems[0].Text) && !string.IsNullOrEmpty(i.Text)) // Only get items where action is filled .Select(i => new { Action = i.SubItems[0].Text, Metadata = AttributeMetadataRow.FromListViewItem(i) }) .ToList(); var bwTransferData = new BackgroundWorker { WorkerReportsProgress = true }; bwTransferData.DoWork += (sender, e) => { var errors = new List <Tuple <string, string> >(); var helper = new EntityHelper(entityitem.LogicalName, entityitem.LanguageCode, service); for (int i = 0; i < itemsToProcess.Count; i++) { // TODO: Validate each row //if (item.SubItems.Count == 6) //{ var item = itemsToProcess[i]; var attributeMetadata = item.Metadata; InformationPanel.ChangeInformationPanelMessage(informationPanel, string.Format("Processing attribute {0}...", attributeMetadata.LogicalName)); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(string.Format("{0}/{1}", i + 1, itemsToProcess.Count))); try { var attribute = EntityHelper.GetAttributeFromTypeName(attributeMetadata.AttributeType); if (attribute == null) { errors.Add(new Tuple <string, string>(attributeMetadata.DisplayName, $"The Attribute Type \"{attributeMetadata.AttributeType}\" is not yet supported.")); continue; } attribute.LoadFromAttributeMetadataRow(attributeMetadata); attribute.Entity = entityitem.LogicalName; switch (item.Action) { case "Create": if (cbCreate.Checked) { attribute.CreateAttribute(service); } break; case "Update": if (cbUpdate.Checked) { attribute.UpdateAttribute(service); } break; case "Delete": if (cbDelete.Checked) { attribute.DeleteAttribute(service); } break; } } catch (FaultException <OrganizationServiceFault> error) { errors.Add(new Tuple <string, string>(attributeMetadata.DisplayName, error.Message)); } //} //else //{ // errors.Add(new Tuple<string, string>(item.Name, string.Format("Invalid row! Unexpected subitems count [{0}]", item.SubItems.Count))); //} } helper.Publish(); e.Result = errors; }; bwTransferData.RunWorkerCompleted += (sender, e) => { Controls.Remove(informationPanel); informationPanel.Dispose(); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(string.Empty)); ManageWorkingState(false); var errors = (List <Tuple <string, string> >)e.Result; if (errors.Count > 0) { var errorDialog = new ErrorList((List <Tuple <string, string> >)e.Result); errorDialog.ShowDialog(ParentForm); } PopulateAttributes(); }; bwTransferData.ProgressChanged += (sender, e) => { InformationPanel.ChangeInformationPanelMessage(informationPanel, e.UserState.ToString()); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(e.UserState.ToString())); }; bwTransferData.RunWorkerAsync(); }
private void ImportAttributes() { if (cmbEntities.SelectedItem == null) { MessageBox.Show("You must select an entity", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txtTemplatePath.Text)) { MessageBox.Show("You must select a template file", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ManageWorkingState(true); informationPanel = InformationPanel.GetInformationPanel(this, "Loading template...", 340, 150); SendMessageToStatusBar(this, new StatusBarMessageEventArgs("Loading template...")); var entityItem = (EntityItem)cmbEntities.SelectedItem; var items = new List <ListViewItem>(); var bwTransferData = new BackgroundWorker { WorkerReportsProgress = true }; bwTransferData.DoWork += (sender, e) => { var attributes = (List <ListViewItem>)e.Argument; var entityitem = entityItem; var errors = new List <Tuple <string, string> >(); var nrOfCreates = 0; var nrOfUpdates = 0; var nrOfDeletes = 0; try { using (FileStream stream = File.Open(txtTemplatePath.Text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (SpreadsheetDocument document = SpreadsheetDocument.Open(stream, false)) { var sheet = document.WorkbookPart.Workbook.Sheets.Cast <Sheet>().Where(s => s.Name == entityitem.LogicalName).FirstOrDefault(); if (sheet == null) { errors.Add(new Tuple <string, string>(entityitem.LogicalName, "Entity sheet is not found in the template!")); } else { var sheetid = sheet.Id; var sheetData = ((WorksheetPart)document.WorkbookPart.GetPartById(sheetid)).Worksheet.GetFirstChild <SheetData>(); var templaterows = sheetData.ChildElements.Cast <Row>().ToArray(); // For shared strings, look up the value in the shared strings table. var stringTable = document.WorkbookPart.GetPartsOfType <SharedStringTablePart>().FirstOrDefault()?.SharedStringTable; // Check all existing attributes foreach (var item in attributes) { var row = templaterows.Where(r => TemplateHelper.GetCellValue(r, 0, stringTable) == item.SubItems[1].Text).FirstOrDefault(); var attributeMetadataRow = AttributeMetadataRow.FromListViewItem(item); attributeMetadataRow.UpdateFromTemplateRow(row, stringTable); var listViewItem = attributeMetadataRow.ToListViewItem(); listViewItem.Tag = item.Tag; items.Add(listViewItem); if (attributeMetadataRow.Action == "Update") { nrOfUpdates++; listViewItem.ForeColor = ColorUpdate; } else if (attributeMetadataRow.Action == "Delete") { nrOfDeletes++; listViewItem.ForeColor = ColorDelete; } else { listViewItem.ForeColor = System.Drawing.Color.Black; } InformationPanel.ChangeInformationPanelMessage(informationPanel, string.Format("Processing new attribute {0}...", item.Text)); } // Check new attributes for (int i = 1; i < templaterows.Length; i++) { var row = templaterows[i]; var logicalname = TemplateHelper.GetCellValue(row, 0, stringTable); if (!string.IsNullOrEmpty(logicalname)) { var attribute = attributes.Select(a => (AttributeMetadata)a.Tag).Where(a => a.LogicalName == logicalname).FirstOrDefault(); if (attribute == null) { InformationPanel.ChangeInformationPanelMessage(informationPanel, string.Format("Processing new attribute {0}...", logicalname)); var attributeMetadataRow = AttributeMetadataRow.FromTableRow(row, stringTable); attributeMetadataRow.Action = "Create"; var listViewItem = attributeMetadataRow.ToListViewItem(); listViewItem.BackColor = ColorCreate; items.Add(listViewItem); nrOfCreates++; } } } } } SendMessageToStatusBar(this, new StatusBarMessageEventArgs(string.Format("{0} create; {1} update; {2} delete", nrOfCreates, nrOfUpdates, nrOfDeletes))); } catch (FaultException <OrganizationServiceFault> error) { errors.Add(new Tuple <string, string>(entityitem.LogicalName, error.Message)); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(string.Empty)); } e.Result = errors; }; bwTransferData.RunWorkerCompleted += (sender, e) => { lvAttributes.BeginUpdate(); // Add attributes here to avoid accessing lvAttributes across threads. lvAttributes.Items.Clear(); foreach (var item in items) { lvAttributes.Items.Add(item); } lvAttributes.EndUpdate(); Controls.Remove(informationPanel); informationPanel.Dispose(); ManageWorkingState(false); var errors = (List <Tuple <string, string> >)e.Result; if (errors.Count > 0) { var errorDialog = new ErrorList((List <Tuple <string, string> >)e.Result); errorDialog.ShowDialog(ParentForm); } }; bwTransferData.ProgressChanged += (sender, e) => { InformationPanel.ChangeInformationPanelMessage(informationPanel, e.UserState.ToString()); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(e.UserState.ToString())); }; bwTransferData.RunWorkerAsync(lvAttributes.Items.Cast <ListViewItem>().ToList()); }
private void ExportAttributes() { if (cmbEntities.SelectedItem == null) { MessageBox.Show("You must select an entity", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ManageWorkingState(true); var selectedLogicalName = (EntityItem)cmbEntities.SelectedItem; var saveFileDlg = new SaveFileDialog() { Title = "Save the entity template", Filter = "Excel Workbook|*.xlsx", FileName = string.Format("{0}_attributeeditor.xlsx", selectedLogicalName?.LogicalName) }; saveFileDlg.ShowDialog(); // If the file name is not an empty string open it for saving. if (!string.IsNullOrEmpty(saveFileDlg.FileName)) { informationPanel = InformationPanel.GetInformationPanel(this, "Exporting attributes...", 340, 150); SendMessageToStatusBar(this, new StatusBarMessageEventArgs("Initializing attributes...")); var bwTransferData = new BackgroundWorker { WorkerReportsProgress = true }; bwTransferData.DoWork += (sender, e) => { var attributes = (List <AttributeMetadata>)e.Argument; var entityitem = selectedLogicalName; var errors = new List <Tuple <string, string> >(); try { using (SpreadsheetDocument document = SpreadsheetDocument.Create(saveFileDlg.FileName, SpreadsheetDocumentType.Workbook)) { WorkbookPart workbookPart; Sheets sheets; SheetData sheetData; TemplateHelper.InitDocument(document, out workbookPart, out sheets); TemplateHelper.CreateSheet(workbookPart, sheets, entityitem.LogicalName, out sheetData); #region Header var headerRow = new Row(); foreach (var field in AttributeMetadataRow.GetColumns()) { headerRow.AppendChild(TemplateHelper.CreateCell(field.Type, field.Header)); } sheetData.AppendChild(headerRow); #endregion #region Data foreach (var attribute in attributes) { if (attribute == null) { continue; } var attributeType = EntityHelper.GetAttributeFromTypeName(attribute.AttributeType.Value.ToString()); if (attributeType == null) { continue; } attributeType.LoadFromAttributeMetadata(attribute); var metadataRow = attributeType.ToAttributeMetadataRow(); sheetData.AppendChild(metadataRow.ToTableRow()); } #endregion workbookPart.Workbook.Save(); } } catch (FaultException <OrganizationServiceFault> error) { errors.Add(new Tuple <string, string>(entityitem.LogicalName, error.Message)); } e.Result = errors; }; bwTransferData.RunWorkerCompleted += (sender, e) => { Controls.Remove(informationPanel); informationPanel.Dispose(); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(string.Empty)); ManageWorkingState(false); var errors = (List <Tuple <string, string> >)e.Result; if (errors.Count > 0) { var errorDialog = new ErrorList((List <Tuple <string, string> >)e.Result); errorDialog.ShowDialog(ParentForm); } }; bwTransferData.ProgressChanged += (sender, e) => { InformationPanel.ChangeInformationPanelMessage(informationPanel, e.UserState.ToString()); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(e.UserState.ToString())); }; bwTransferData.RunWorkerAsync(lvAttributes.Items.Cast <ListViewItem>().Select(v => (AttributeMetadata)v.Tag).ToList()); } }