Esempio n. 1
0
 /// <summary> Tests a structure (segment or group) against the corresponding part of a profile.  </summary>
 public virtual NuGenHL7Exception[] testStructure(Structure s, ProfileStructure profile, System.String profileID)
 {
     System.Collections.ArrayList exList = new System.Collections.ArrayList(20);
     if (profile is Seg)
     {
         if (typeof(Segment).IsAssignableFrom(s.GetType()))
         {
             addToList(testSegment((Segment)s, (Seg)profile, profileID), exList);
         }
         else
         {
             exList.Add(new NuGenProfileNotHL7CompliantException("Mismatch between a segment in the profile and the structure " + s.GetType().FullName + " in the message"));
         }
     }
     else if (profile is SegGroup)
     {
         if (typeof(Group).IsAssignableFrom(s.GetType()))
         {
             addToList(testGroup((Group)s, (SegGroup)profile, profileID), exList);
         }
         else
         {
             exList.Add(new NuGenProfileNotHL7CompliantException("Mismatch between a group in the profile and the structure " + s.GetType().FullName + " in the message"));
         }
     }
     return(toArray(exList));
 }
 public ProfileStructure GetProfile(int id)
 {
     using (var context = new LoLEsportsDbContext())
     {
         using (var dbContextTransaction = context.Database.BeginTransaction())
         {
             try
             {
                 ProfileStructure newProf = new ProfileStructure();
                 Account          acc     = context.Account.Where(x => x.UserId == id).FirstOrDefault();
                 newProf.UserID        = acc.UserId;
                 newProf.UserName      = acc.UserName;
                 newProf.ChampionImage = context.Champion.Where(x => x.ChampionId == acc.ChampionId).Select(y => y.ChampionImage).FirstOrDefault();
                 newProf.error         = 0;
                 dbContextTransaction.Commit();
                 return(newProf);
             }
             catch (Exception)
             {
                 dbContextTransaction.Rollback();
                 ProfileStructure data = new ProfileStructure();
                 data.error   = 1;
                 data.message = "Database could not commit transaction.";
                 return(data);
             }
         }
     }
 }
 /// <summary>Makes child list long enough to accommodate setter.  </summary>
 private void  extendChildList(int index)
 {
     if (index >= this.children.Length)
     {
         ProfileStructure[] newCopy = new ProfileStructure[index + 1];
         Array.Copy(this.children, 0, newCopy, 0, this.children.Length);
         this.children = newCopy;
     }
 }
 /// <summary>Adds Class Comments to a Generated Method</summary>
 /// <param name="genMethod">a GeneratedRepGetter
 /// </param>
 /// <param name="profileStructure">the Profile Structure for which the comments are being added to
 /// </param>
 /// <param name="repType">the repetition Type
 /// </param>
 public void  decorateRepGetter(GeneratedRepGetter genMethod, ProfileStructure profileStructure, System.String repType)
 {
     genMethod.addToDescription("This method returns a reference to the " + profileStructure.Name + " child.");
     genMethod.addToComments("Min Repetitions" + profileStructure.Min);
     genMethod.addToComments("Max Repetitions" + profileStructure.Max);
     if (profileStructure.Max == -1)
     {
         genMethod.addToComments("@param rep The desired repetition number");
     }
     genMethod.addToComments("@return the child object reference. <b>rep must fall between " + profileStructure.Min + " and " + profileStructure.Max + "</b>");
     genMethod.addToComments("@throws Genetibase.NuGenHL7.conf.classes.exceptions.ConfRepException");
 }
Esempio n. 5
0
        /// <summary> Tests a group against a group section of a profile.</summary>
        public virtual NuGenHL7Exception[] testGroup(Group group, AbstractSegmentContainer profile, System.String profileID)
        {
            System.Collections.ArrayList exList            = new System.Collections.ArrayList(20);
            System.Collections.ArrayList allowedStructures = new System.Collections.ArrayList(20);

            for (int i = 1; i <= profile.Children; i++)
            {
                ProfileStructure struct_Renamed = profile.getChild(i);

                //only test a structure in detail if it isn't X
                if (!struct_Renamed.Usage.ToUpper().Equals("X".ToUpper()))
                {
                    allowedStructures.Add(struct_Renamed.Name);

                    //see which instances have content
                    try
                    {
                        Structure[] instances = group.getAll(struct_Renamed.Name);
                        System.Collections.ArrayList instancesWithContent = new System.Collections.ArrayList(10);
                        for (int j = 0; j < instances.Length; j++)
                        {
                            if (hasContent(instances[j]))
                            {
                                instancesWithContent.Add(instances[j]);
                            }
                        }

                        NuGenHL7Exception ce = testCardinality(instancesWithContent.Count, struct_Renamed.Min, struct_Renamed.Max, struct_Renamed.Usage, struct_Renamed.Name);
                        if (ce != null)
                        {
                            exList.Add(ce);
                        }

                        //test children on instances with content
                        for (int j = 0; j < instancesWithContent.Count; j++)
                        {
                            Structure           s = (Structure)instancesWithContent[j];
                            NuGenHL7Exception[] childExceptions = testStructure(s, struct_Renamed, profileID);
                            addToList(childExceptions, exList);
                        }
                    }
                    catch (NuGenHL7Exception)
                    {
                        exList.Add(new NuGenProfileNotHL7CompliantException(struct_Renamed.Name + " not found in message"));
                    }
                }
            }

            //complain about X structures that have content
            addToList(checkForExtraStructures(group, allowedStructures), exList);

            return(toArray(exList));
        }
        /// <summary>Indexed setter for property structure.  Lengthens child list if necessary.  </summary>
        /// <param name="index">Index of the property (starts at 1 following HL7 convention).
        /// </param>
        /// <param name="structure">New value of the property at <CODE>index</CODE>.
        ///
        /// </param>
        /// <throws>  ProfileException </throws>
        public virtual void  setChild(int index, ProfileStructure structure)
        {
            index--;
            extendChildList(index);
            ProfileStructure oldStructure = this.children[index];

            this.children[index] = structure;
            try
            {
                SupportClass.PropertyChangingEventArgs ve21 = new SupportClass.PropertyChangingEventArgs("structure", null, null);
            }
            catch (System.ArgumentOutOfRangeException vetoException)
            {
                this.children[index] = oldStructure;
                throw new NuGenProfileException(null, vetoException);
            }
            SupportClass.PropertyChangingEventArgs me21 = new SupportClass.PropertyChangingEventArgs("structure", null, null);
        }
Esempio n. 7
0
        /// <summary>This method creates the segment group name which is comprised of all the
        /// underlying segments names put together
        /// </summary>
        /// <param name="segGroup">the SegGroup to build
        /// </param>
        public static System.String generateSegGroupName(SegGroup segGroup)
        {
            System.String name = new System.Text.StringBuilder().ToString();

            for (int i = 1; i <= segGroup.Children; i++)
            {
                ProfileStructure child = segGroup.getChild(i);
                if (child is Seg)
                {
                    name += child.Name;
                }
                else
                {
                    name += generateSegGroupName((SegGroup)child);
                }
            }

            return(name);
        }
 /// <summary>Adds Class Comments to a Generated Class</summary>
 /// <param name="genClass">a GeneratedConformanceContainer
 /// </param>
 /// <param name="ps">the Profile Structure for which the comments are being added to
 /// </param>
 public void  decorateProfileStructure(GeneratedConformanceContainer genClass, ProfileStructure ps)
 {
     genClass.addClassComment("This represents a constrained " + ps.Name + " segment, with the following properties:");
     genClass.addClassComment("<table>");
     addOptionalComment(genClass, "Name", ps.Name);
     addOptionalComment(genClass, "Usage", ps.Usage);
     addOptionalComment(genClass, "Description", ps.Description);
     addOptionalComment(genClass, "Implementation Note", ps.ImpNote);
     addOptionalComment(genClass, "Predicate", ps.Predicate);
     addOptionalComment(genClass, "Reference", ps.Reference);
     addOptionalComment(genClass, "Minimum Repetitions ", ps.Min + "");
     addOptionalComment(genClass, "Maximum Repetitions ", ps.Max + "");
     genClass.addClassComment("</table>");
 }
		/// <summary> Tests a structure (segment or group) against the corresponding part of a profile.  </summary>
		public virtual NuGenHL7Exception[] testStructure(Structure s, ProfileStructure profile, System.String profileID)
		{
			System.Collections.ArrayList exList = new System.Collections.ArrayList(20);
			if (profile is Seg)
			{
				if (typeof(Segment).IsAssignableFrom(s.GetType()))
				{
					addToList(testSegment((Segment) s, (Seg) profile, profileID), exList);
				}
				else
				{
					exList.Add(new NuGenProfileNotHL7CompliantException("Mismatch between a segment in the profile and the structure " + s.GetType().FullName + " in the message"));
				}
			}
			else if (profile is SegGroup)
			{
				if (typeof(Group).IsAssignableFrom(s.GetType()))
				{
					addToList(testGroup((Group) s, (SegGroup) profile, profileID), exList);
				}
				else
				{
					exList.Add(new NuGenProfileNotHL7CompliantException("Mismatch between a group in the profile and the structure " + s.GetType().FullName + " in the message"));
				}
			}
			return toArray(exList);
		}
		/// <summary>Makes child list long enough to accommodate setter.  </summary>
		private void  extendChildList(int index)
		{
			if (index >= this.children.Length)
			{
				ProfileStructure[] newCopy = new ProfileStructure[index + 1];
				Array.Copy(this.children, 0, newCopy, 0, this.children.Length);
				this.children = newCopy;
			}
		}
		/// <summary>Indexed setter for property structure.  Lengthens child list if necessary.  </summary>
		/// <param name="index">Index of the property (starts at 1 following HL7 convention).
		/// </param>
		/// <param name="structure">New value of the property at <CODE>index</CODE>.
		/// 
		/// </param>
		/// <throws>  ProfileException </throws>
		public virtual void  setChild(int index, ProfileStructure structure)
		{
			index--;
			extendChildList(index);
			ProfileStructure oldStructure = this.children[index];
			this.children[index] = structure;
			try
			{
				SupportClass.PropertyChangingEventArgs ve21 = new SupportClass.PropertyChangingEventArgs("structure", null, null);


			}
			catch (System.ArgumentOutOfRangeException vetoException)
			{
				this.children[index] = oldStructure;
				throw new NuGenProfileException(null, vetoException);
			}
			SupportClass.PropertyChangingEventArgs me21 = new SupportClass.PropertyChangingEventArgs("structure", null, null);


		}