Beispiel #1
0
        void ProcessFragment(MIPreFsh fragTempCmds,
                             MIFragment frag)
        {
            const String fcn = "ProcessFragment";

            this.appliedMacros.Clear();
            this.incompatibleMacros.Clear();

            String relativePath = this.SetProfileVariables(frag.SourceFile);

            if (String.IsNullOrEmpty(frag.Parent) == true)
            {
                this.ConversionError(ClassName, fcn, $"Fragment {frag.Name} missing parent!");
                return;
            }

            if (relativePath.ToUpper().StartsWith(@"FRAGMENTS\"))
            {
                relativePath = relativePath.Substring(10);
            }
            String absolutePath = Path.Combine(this.FragDir, relativePath);

            absolutePath = Path.GetFullPath(absolutePath);

            if (this.FileItems.TryGetValue(absolutePath.ToUpper().Trim(), out FileData fd) == false)
            {
                fd = new FileData();
                fd.AbsoluteOutputPath = absolutePath;
                this.FileItems.Add(absolutePath.ToUpper().Trim(), fd);
            }
            else
            {
                fd.AppendLine("");
                fd.AppendLine("");
                fd.AppendLine("");
            }

            VariablesBlock        localVb = StartNewFrag(frag, out String name);
            List <VariablesBlock> local   = new List <VariablesBlock>();

            local.Insert(0, this.GlobalVars);
            local.Insert(0, this.profileVariables);
            local.Insert(0, localVb);

            this.skipRedirects = false;
            this.Process(fragTempCmds.Items, fd, local);
            this.skipRedirects = true;

            this.Process(frag.Items, fd, local);
        }
Beispiel #2
0
        void ProcessApplyFrag(MIApply apply,
                              FileData fd,
                              MIFragment frag,
                              List <VariablesBlock> local)
        {
            const String fcn = "ProcessApplyMacro";

            if (apply.Parameters.Count != 0)
            {
                String fullMsg = $"{apply.SourceFile}, line {apply.LineNumber} Fragment {apply.Name} takes no parameters.";
                fullMsg += this.ApplyLongStackTrace();
                this.ConversionError(ClassName, fcn, fullMsg);
                return;
            }

            bool firstFlag = false;

            if (this.appliedMacros.Contains(apply.Name) == false)
            {
                this.appliedMacros.Add(apply.Name);
                firstFlag = true;
            }

            if ((frag.OnceFlag == true) && (firstFlag == false))
            {
                return;
            }

            if (this.incompatibleMacros.Contains(apply.Name))
            {
                String fullMsg = $"{apply.SourceFile}, line {apply.LineNumber} {apply.Name} has been marked as incompatible with this profile";
                fullMsg += this.ApplyLongStackTrace();
                this.ConversionError(ClassName, fcn, fullMsg);
                return;
            }

            VariablesBlock        localVb   = StartNewFrag(frag, out String name);
            List <VariablesBlock> fragLocal = new List <VariablesBlock>();

            fragLocal.AddRange(local);
            fragLocal.Insert(0, localVb);

            FileData macroData = fd;

            this.applyStack.Push(apply);                    // this is for stack tracing during errors
            this.Process(frag.Items, macroData, fragLocal);
            this.applyStack.Pop();
        }
Beispiel #3
0
        VariablesBlock StartNewFrag(MIFragment frag,
                                    out String name)
        {
            name = frag.Name;
            if (name.Contains('.'))
            {
                name = name.Substring(name.LastIndexOf('.') + 1);
            }

            VariablesBlock localVb = new VariablesBlock();

            localVb.Add("%Id%", name);
            localVb.Add("%FragmentId%", name);
            localVb.Add("%FParent%", frag.Parent);
            localVb.Add("%FTitle%", frag.Title);
            localVb.Add("%FDescription%", frag.Description);
            String fragmentUrl = $"{this.BaseUrl}/StructureDefinition/{name}";

            localVb.Add("%FUrl%", fragmentUrl);

            //this.appliedMacros.Clear();
            //this.incompatibleMacros.Clear();
            return(localVb);
        }