private void _onSourceClassChanged() {
    if (SourceClass != null) {
       _sourceNode = new SourceNode(SourceClass);
       _onSelectedClassesChanged(null, null);
       Root.Content = _sourceNode.Name;
       Selector.ItemsSource = _sourceNode.Children;
       GuiTimer.StartAfterRender(t => _expandSelector());
    } else {
       _sourceNode = null;
       Root.Content = null;
       Selector.ItemsSource = null;
    }
 }
         // Constructor
         public RelationNode(SourceNode parent, string name, RelationKind kind, bool isEnabled, bool isInitiallyExpanded, IEnumerable<BplClass> targetClasses) {
            IsEnabled = isEnabled;
            IsInitiallyExpanded = isInitiallyExpanded;
            Kind = kind;
            Name = name;
            Parent = parent;

            Children = new List<TargetNode>();
            foreach (var c in targetClasses) {
               Children.Add(new TargetNode(this, isEnabled, c));
            }
            UpdateSelection(true);
         }
Beispiel #3
0
        internal static void OnDocumentSaved(uint docCookie)
        {
            // The document identified by docCookie has been saved. Now we have to update
            // our internal data structures and persist them to file. This will ensure we
            // will display the same data again when the user closes and reopens the document.

            // If there is currently no clone report available there is nothing to do.
            if (!IsCloneReportAvailable)
            {
                return;
            }

            CloneDetectiveResult cloneDetectiveResult = CloneDetectiveResult;

            // Get the text buffer. We're done if this fails because that means it was not
            // a text document.
            IVsTextLines textLines = GetDocumentTextLines(docCookie);

            if (textLines == null)
            {
                return;
            }

            // Get the SourceFile of the document in our data structure. We're done if this
            // fails because that means the document was not included in clone detection.
            string     path       = GetDocumentPath(textLines);
            SourceNode sourceNode = cloneDetectiveResult.SourceTree.FindNode(path);

            if (sourceNode == null)
            {
                return;
            }
            SourceFile sourceFile = sourceNode.SourceFile;

            // And we need to be able to map existing clone markers to their corresponding
            // clone classes. If that fails we cannot update any clone information.
            DocumentInfo documentInfo;

            if (!_textLinesToDocInfos.TryGetValue(textLines, out documentInfo))
            {
                return;
            }

            // If the hash of the file didn't match when we opened it, we don't want to save
            // any changes.
            if (!documentInfo.HashMatched)
            {
                return;
            }

            // Store the new line count of the file. Be aware of the fact that the last line
            // is not taken into account if it is empty. Replace the fingerprint of the file
            // with the new one such that we get no problems when opening up the file the
            // next time.
            int lastLineIndex;
            int lastLineLength;

            if (ErrorHandler.Failed(textLines.GetLastLineIndex(out lastLineIndex, out lastLineLength)))
            {
                return;
            }
            sourceFile.Length      = lastLineIndex + ((lastLineLength > 0) ? 1 : 0);
            sourceFile.Fingerprint = GetHashFromFile(path);

            // We need to track which source file clone information was modified to be able
            // to update the rollups afterwards.
            HashSet <SourceFile> modifiedSourceFiles = new HashSet <SourceFile>();

            // Clear old clone information of the saved document as we're going to rebuild
            // it from scratch.
            foreach (Clone clone in sourceFile.Clones)
            {
                clone.CloneClass.Clones.Remove(clone);
            }
            sourceFile.Clones.Clear();
            modifiedSourceFiles.Add(sourceFile);

            // Store information about current position of each marker.
            foreach (KeyValuePair <IVsTextLineMarker, CloneClass> markerWithCloneClass in documentInfo.MarkersToCloneClasses)
            {
                // Retrieve the current text span of the marker we just enumerated.
                TextSpan[] span = new TextSpan[1];
                ErrorHandler.ThrowOnFailure(markerWithCloneClass.Key.GetCurrentSpan(span));

                // Create a new clone object and initialize it appropriately.
                Clone clone = new Clone();
                clone.CloneClass = markerWithCloneClass.Value;
                clone.SourceFile = sourceFile;
                clone.StartLine  = span[0].iStartLine;
                clone.LineCount  = span[0].iEndLine - span[0].iStartLine + 1;

                // Add the clone to the clone class as well as the source file.
                clone.CloneClass.Clones.Add(clone);
                clone.SourceFile.Clones.Add(clone);
            }

            // Remove clone classes with less than two clones.
            List <CloneClass> cloneClasses = cloneDetectiveResult.CloneReport.CloneClasses;

            for (int i = cloneClasses.Count - 1; i >= 0; i--)
            {
                List <Clone> clones = cloneClasses[i].Clones;
                if (clones.Count < 2)
                {
                    foreach (Clone clone in clones)
                    {
                        clone.SourceFile.Clones.Remove(clone);
                        modifiedSourceFiles.Add(clone.SourceFile);
                    }

                    cloneClasses.RemoveAt(i);
                }
            }

            // Save the new clone report to disk.
            string solutionPath    = VSPackage.Instance.GetSolutionPath();
            string cloneReportPath = PathHelper.GetCloneReportPath(solutionPath);

            CloneReport.ToFile(cloneReportPath, cloneDetectiveResult.CloneReport);

            // Rollup changes within the SourceTree.
            foreach (SourceFile modifiedSourceFile in modifiedSourceFiles)
            {
                SourceNode modifiedSourceNode = cloneDetectiveResult.SourceTree.FindNode(modifiedSourceFile.Path);
                SourceTree.RecalculateRollups(modifiedSourceNode);
            }

            // Send notification about changed result to listeners.
            OnCloneDetectiveResultChanged();
        }
        public override string ToString()
        {
            StringBuilder __sb    = new StringBuilder("TRelation(");
            bool          __first = true;

            if (Neo4jID != null && __isset.Neo4jID)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Neo4jID: ");
                __sb.Append(Neo4jID);
            }
            if (AoKID != null && __isset.AoKID)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("AoKID: ");
                __sb.Append(AoKID);
            }
            if (Labels != null && __isset.Labels)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Labels: ");
                __sb.Append(Labels);
            }
            if (RelationType != null && __isset.RelationType)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("RelationType: ");
                __sb.Append(RelationType);
            }
            if (SourceNode != null && __isset.SourceNode)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("SourceNode: ");
                __sb.Append(SourceNode == null ? "<null>" : SourceNode.ToString());
            }
            if (TargetNode != null && __isset.TargetNode)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("TargetNode: ");
                __sb.Append(TargetNode == null ? "<null>" : TargetNode.ToString());
            }
            if (Properties != null && __isset.Properties)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Properties: ");
                __sb.Append(Properties);
            }
            if (__isset.AttentionLevel)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("AttentionLevel: ");
                __sb.Append(AttentionLevel);
            }
            if (TruthValue != null && __isset.TruthValue)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("TruthValue: ");
                __sb.Append(TruthValue);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
Beispiel #5
0
        private void UpdateSelection(string filePath)
        {
            SourceNode newSourceNode = FindSourceNode(filePath);

            UpdateIntersection(newSourceNode);
        }
Beispiel #6
0
        //if transformer equals null create a file without source code viewer
        private void WriteFile(string path, string fileName, CodeTransformer transformer = null)
        {
            LanguageWriter  languageWriter = new CSharpWriter();
            HtmlWriteHelper htmlWriter     = new HtmlWriteHelper();

            htmlWriter.WriteLine("<!DOCTYPE html>");
            htmlWriter.WriteLine();

            htmlWriter.OpenTag("head");

            //link styles
            htmlWriter.OpenTag("style", "type=\"text/css\"");
            htmlWriter.WriteLine("a:link { text-decoration: none; }");
            htmlWriter.WriteLine("a:visited { text-decoration: none; }");
            htmlWriter.WriteLine("a:active { text-decoration: none; }");
            htmlWriter.WriteLine("a:active { text-decoration: underline; color: red; }");
            htmlWriter.WriteLine("pre { margin: 0px; }");
            htmlWriter.WriteLine("code { margin: 0px; }");
            htmlWriter.CloseTag();
            htmlWriter.CloseTag();

            htmlWriter.OpenTag("body", "style=\"overflow-x: hidden; overflow-y: hidden\"");

            //main grid
            htmlWriter.OpenTag("div", "style=\"display: grid; grid-template-columns: auto auto; grid-column-gap: 10px; justify-content: start\"");

            //file names list
            // "display: grid" makes it expand to fill the vertical space
            htmlWriter.OpenTag("ol", "style=\"grid-column: 1; display: grid; overflow-y: auto;\"");

            int count = 1;

            foreach (var tuple in fileNames)
            {
                htmlWriter.OpenTag("li");
                if (tuple.Key != transformer)
                {
                    htmlWriter.OpenTag("a", $"style=\"link\" href=\"{Path.Combine(Path.GetFullPath(path), tuple.Value)}\"");
                }
                else
                {
                    htmlWriter.OpenTag("a", $"style=\"color: red\" href=\"{Path.Combine(Path.GetFullPath(path), tuple.Value)}\"");
                }
                htmlWriter.WriteLine(tuple.Key.GetFriendlyName());
                htmlWriter.CloseTag();
                htmlWriter.CloseTag();

                count++;
            }
            htmlWriter.CloseTag();
            htmlWriter.WriteLine();

            //code viewer
            // height is 99vh to make room for the scrollbar
            htmlWriter.OpenTag("div", "class=\"container\" style=\"grid-column: 2; display: grid; overflow: auto; max-height: 99vh; max-width: 100vw\"");

            //write source code
            if (transformer != null)
            {
                htmlWriter.OpenTag("pre");
                htmlWriter.OpenTag("code", "class=\"language-csharp\"");

                if (transformer.Transform.Context.Results.ErrorCount > 0)
                {
                    foreach (var error in transformer.Transform.Context.Results.ErrorsAndWarnings)
                    {
                        foreach (var line in StringUtil.Lines(error.ToString()))
                        {
                            htmlWriter.Append("// ");
                            htmlWriter.Append(StringUtil.EscapeXmlCharacters(line));
                            htmlWriter.Append(Environment.NewLine);
                        }
                        htmlWriter.Append(Environment.NewLine);
                    }
                }

                foreach (ITypeDeclaration itd in transformer.transformMap.Values)
                {
                    using (var writer = new StringWriter())
                    {
                        SourceNode node = languageWriter.GeneratePartialSource(itd);
                        LanguageWriter.WriteSourceNode(writer, node);
                        string code = StringUtil.EscapeXmlCharacters(writer.ToString().Trim());
                        htmlWriter.Append(code);
                    }
                }

                htmlWriter.CloseTag();
                htmlWriter.CloseTag();
                htmlWriter.CloseTag();
                htmlWriter.CloseTag();

                //highlighting
                htmlWriter.OpenTag("link", "rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/vs2015.min.css\"", true);
                htmlWriter.OpenTag("script", "src=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js\"", true);
                htmlWriter.OpenTag("script");
                htmlWriter.WriteLine("hljs.initHighlightingOnLoad();");
            }
            else
            {
                htmlWriter.CloseTag();
            }

            htmlWriter.CloseTag();
            htmlWriter.CloseTag();

            htmlWriter.SaveToFile(Path.Combine(path, fileName));
        }
 public ConverterMessage(SourceNode node, string text)
 {
     Node = node;
     Text = text;
 }
        public void BasicTest()
        {
            SourceNode sc = this.AssertTranslationUnit(@"void f() { }");

            Assert.That(sc.Children.Single(), Is.InstanceOf <FuncDefNode>());
        }
Beispiel #9
0
        public AddUI()
        {
            string errorMsg = "";

            WithTitle("Add new Source Node");

            AddSection()
            .WithFields(new List <IField>()
            {
                Map(x => x.Name).AsSectionField <TextBox>()
                .WithLength(20)
                .LabelTextIs("Node Name")
                .Required()
                .TextFormatIs("^[ a-zA-Z]+$"),

                Map(x => x.HostName).AsSectionField <TextBox>()
                .WithLength(30)
                .LabelTextIs("Host Name")
                .Required()
                .TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"),

                Map(x => x.IpAddress).AsSectionField <TextBox>()
                .WithLength(12)
                .LabelTextIs("IP Address")
                .Required()
                .TextFormatIs(@"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"),


                Map(x => x.Port).AsSectionField <TextBox>()
                .Required()
                .TextFormatIs(@"^(6553[0-5]|655[0-2][0-9]|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})$"),     // \d = [0-9]



                HasMany(x => x.Schemes).AsSectionField <MultiSelect>()
                .Of <Scheme>(() => { return(new SchemeDAO().Get().ToList()); })
                .WithColumn(x => x.Name)
                .WithColumn(x => x.Route.Name, "Route")
                .WithColumn(x => x.Description)
                .ListOf(x => x.Name, x => x.ID).WithEditableText()
                .LabelTextIs("Schemes").Required(),


                AddSectionButton()
                .ApplyMod <IconMod>(x => x.WithIcon(Ext.Net.Icon.Disk))
                .WithText("Add")
                .SubmitTo(x =>
                {
                    bool flag = false;


                    try
                    {
                        //check for uniqueness
                        SourceNodeDAO sourceNodeDao = new SourceNodeDAO();
                        if (!sourceNodeDao.isUniqueName(x.Name))
                        {
                            errorMsg += "Name must be unique";
                            flag      = false;
                        }
                        else if (!sourceNodeDao.isUniqueHostName(x.HostName))
                        {
                            errorMsg += "Host name must be unique";
                            flag      = false;
                        }
                        else if (!sourceNodeDao.isUniqueIpAddress(x.IpAddress))
                        {
                            errorMsg += "IP address must be unique";
                            flag      = false;
                        }
                        else if (!sourceNodeDao.isUniquePort(x.Port))
                        {
                            errorMsg += "Port must be unique";
                            flag      = false;
                        }
                        else
                        {
                            SourceNode sourceNode = new SourceNode {
                                DateCreated = DateTime.Now, DateModified = DateTime.Now, Name = x.Name, HostName = x.HostName, Port = x.Port, IpAddress = x.IpAddress, NodeType = NodeType.Server, Status = NodeStatus.Active, Schemes = x.Schemes
                            };
                            new SourceNodeDAO().Insert(sourceNode);
                            flag = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        errorMsg     += "An error occured";
                        string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                        MessageLogger.LogError(logMsg);
                    }
                    return(flag);     //Success
                })
                .OnSuccessDisplay(x =>
                {
                    return(x.Name + "Node added successfully.");
                })
                .OnFailureDisplay(x => { return("Unable to add Node\n" + errorMsg); })
                .OnSuccessRedirectTo("/sourcenodemanagement/add")
            });
        }
Beispiel #10
0
 public void Can_create_any_node_with_minimal_arguments(SourceNode node)
 {
     node.Should().NotBeNull();
 }
Beispiel #11
0
        // Validate
        protected override bool InternalValidate(Program program, IRow oldRow, IRow newRow, BitArray valueFlags, string columnName, bool isDescending, bool isProposable)
        {
            if (isDescending && PropagateValidate)
            {
                IRow localOldRow;
                if (!(oldRow.DataType.Columns.Equivalent(DataType.Columns)))
                {
                    localOldRow = new Row(program.ValueManager, DataType.RowType);
                    oldRow.CopyTo(localOldRow);
                }
                else
                {
                    localOldRow = oldRow;
                }
                try
                {
                    IRow localNewRow;
                    if (!(newRow.DataType.Columns.Equivalent(DataType.Columns)))
                    {
                        localNewRow = new Row(program.ValueManager, DataType.RowType);
                        newRow.CopyTo(localNewRow);
                    }
                    else
                    {
                        localNewRow = newRow;
                    }
                    try
                    {
                        Row oldSourceRow = new Row(program.ValueManager, SourceNode.DataType.RowType, (NativeRow)localOldRow.AsNative);
                        try
                        {
                            oldSourceRow.ValuesOwned = false;

                            Row newSourceRow = new Row(program.ValueManager, SourceNode.DataType.RowType, (NativeRow)localNewRow.AsNative);
                            try
                            {
                                newSourceRow.ValuesOwned = false;

                                bool changed = SourceNode.Validate(program, oldSourceRow, newSourceRow, valueFlags, columnName == String.Empty ? String.Empty : newSourceRow.DataType.Columns[localNewRow.DataType.Columns.IndexOfName(columnName)].Name);

                                if (changed && !ReferenceEquals(newRow, localNewRow))
                                {
                                    localNewRow.CopyTo(newRow);
                                }
                                return(changed);
                            }
                            finally
                            {
                                newSourceRow.Dispose();
                            }
                        }
                        finally
                        {
                            oldSourceRow.Dispose();
                        }
                    }
                    finally
                    {
                        if (!ReferenceEquals(newRow, localNewRow))
                        {
                            localNewRow.Dispose();
                        }
                    }
                }
                finally
                {
                    if (!ReferenceEquals(oldRow, localOldRow))
                    {
                        localOldRow.Dispose();
                    }
                }
            }
            return(false);
        }
Beispiel #12
0
        public override void ApplyProperties()
        {
            ApplyType();

            foreach (var childElement in SourceNode.Elements())
            {
                var elementValue = childElement.Value;

                switch (childElement.Name.ToString())
                {
                case "name":
                    Name             = elementValue;
                    VstParameterName = elementValue;
                    ParentValuePath.AddRange(Parent.ParentValuePath);
                    ParentValuePath.Add(Name);
                    break;

                case "address":
                    if (!HasOffset)
                    {
                        //Offset = ParseAddress(elementValue, Parent.StartAddress);
                        //StartAddress = Parent.StartAddress + Offset;
                    }

                    break;

                case "size":
                    IsAutoCalculatedSize = false;
                    Size = ParseSize(elementValue);
                    break;

                case "default":
                    DefaultValue = elementValue;
                    break;

                case "range":
                    Range = elementValue;
                    break;

                case "type":
                    break;

                /*case "size":
                 *  Size = ApplySize(ParseSize(elementValue));
                 *  break;*/
                default:
                    Debug.WriteLine(
                        $"RolandValue.ApplyProperties: Unknown element {childElement.Name} at line {((IXmlLineInfo) childElement).LineNumber}");
                    break;
                }
            }

            ValuePath = string.Join(".", ParentValuePath);

            if (IsAutoCalculatedSize)
            {
                CalculateSize();
            }

            CalculatedSize = GetTypeSize();

            FileSize = Size;

            DoCallback("RolandValue.AfterParse");
        }
Beispiel #13
0
 public virtual TResult Visit(SourceNode node) => this.VisitChildren(node);
Beispiel #14
0
 public static XmlDocumentKind GetXmlDocumentKindOrUnknown(this SourceNode node)
 => node.Kind.GetXmlDocumentKindOrUnknown();
Beispiel #15
0
 public override int GetHashCode()
 {
     return(SourceNode.GetHashCode() + 31 * EventType.GetHashCode());
 }
Beispiel #16
0
 public InMemoryTree(SourceNode root)
 {
     this.root = root;
 }
 private static string GetDisplayString(SourceNode node)
 {
     return(node is INameableNode named ? $"{node.Kind} '{named.Name}'"
         : node.IsList?node.GetChildInfoFromParent().Name
            : node.Kind.ToString());
 }
 public static void Serialize(this SourceNode node, Stream stream)
 {
     Serializer.Serialize(node, new StreamWriter(stream));
 }
Beispiel #19
0
            protected void ehRemoveFolder(object aSender, EventArgs aE)
            {
                // TODO Implement for collection

                SourceNode.Delete();
            }
 public static void Serialize(this SourceNode node, TextWriter writer)
 {
     Serializer.Serialize(node, writer);
 }
Beispiel #21
0
 public override string ToString()
 {
     return(SourceNode.ToString() + " -> " + DestinationNode.ToString());
 }
Beispiel #22
0
 public void Update(SourceNode channel)
 {
     Repo.Update(channel);
 }
Beispiel #23
0
 /// <summary>
 /// Add a diagnostic to the bag.
 /// </summary>
 internal static WhamDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, SourceNode node)
 {
     return(diagnostics.Add(code, node.GetLocation()));
 }
Beispiel #24
0
 public void Save(SourceNode channel)
 {
     Repo.Save(channel);
 }
 public void Write(TProtocol oprot)
 {
     oprot.IncrementRecursionDepth();
     try
     {
         TStruct struc = new TStruct("TRelation");
         oprot.WriteStructBegin(struc);
         TField field = new TField();
         if (Neo4jID != null && __isset.Neo4jID)
         {
             field.Name = "Neo4jID";
             field.Type = TType.String;
             field.ID   = 1;
             oprot.WriteFieldBegin(field);
             oprot.WriteString(Neo4jID);
             oprot.WriteFieldEnd();
         }
         if (AoKID != null && __isset.AoKID)
         {
             field.Name = "AoKID";
             field.Type = TType.String;
             field.ID   = 2;
             oprot.WriteFieldBegin(field);
             oprot.WriteString(AoKID);
             oprot.WriteFieldEnd();
         }
         if (Labels != null && __isset.Labels)
         {
             field.Name = "Labels";
             field.Type = TType.Set;
             field.ID   = 3;
             oprot.WriteFieldBegin(field);
             {
                 oprot.WriteSetBegin(new TSet(TType.String, Labels.Count));
                 foreach (string _iter40 in Labels)
                 {
                     oprot.WriteString(_iter40);
                 }
                 oprot.WriteSetEnd();
             }
             oprot.WriteFieldEnd();
         }
         if (RelationType != null && __isset.RelationType)
         {
             field.Name = "RelationType";
             field.Type = TType.String;
             field.ID   = 4;
             oprot.WriteFieldBegin(field);
             oprot.WriteString(RelationType);
             oprot.WriteFieldEnd();
         }
         if (SourceNode != null && __isset.SourceNode)
         {
             field.Name = "SourceNode";
             field.Type = TType.Struct;
             field.ID   = 5;
             oprot.WriteFieldBegin(field);
             SourceNode.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (TargetNode != null && __isset.TargetNode)
         {
             field.Name = "TargetNode";
             field.Type = TType.Struct;
             field.ID   = 6;
             oprot.WriteFieldBegin(field);
             TargetNode.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (Properties != null && __isset.Properties)
         {
             field.Name = "Properties";
             field.Type = TType.Map;
             field.ID   = 7;
             oprot.WriteFieldBegin(field);
             {
                 oprot.WriteMapBegin(new TMap(TType.String, TType.Struct, Properties.Count));
                 foreach (string _iter41 in Properties.Keys)
                 {
                     oprot.WriteString(_iter41);
                     Properties[_iter41].Write(oprot);
                 }
                 oprot.WriteMapEnd();
             }
             oprot.WriteFieldEnd();
         }
         if (__isset.AttentionLevel)
         {
             field.Name = "AttentionLevel";
             field.Type = TType.Double;
             field.ID   = 8;
             oprot.WriteFieldBegin(field);
             oprot.WriteDouble(AttentionLevel);
             oprot.WriteFieldEnd();
         }
         if (TruthValue != null && __isset.TruthValue)
         {
             field.Name = "TruthValue";
             field.Type = TType.Map;
             field.ID   = 10;
             oprot.WriteFieldBegin(field);
             {
                 oprot.WriteMapBegin(new TMap(TType.String, TType.Double, TruthValue.Count));
                 foreach (string _iter42 in TruthValue.Keys)
                 {
                     oprot.WriteString(_iter42);
                     oprot.WriteDouble(TruthValue[_iter42]);
                 }
                 oprot.WriteMapEnd();
             }
             oprot.WriteFieldEnd();
         }
         oprot.WriteFieldStop();
         oprot.WriteStructEnd();
     }
     finally
     {
         oprot.DecrementRecursionDepth();
     }
 }
Beispiel #26
0
 /// <summary>
 /// Returns a string representation for debugging purposes.
 /// </summary>
 public override string ToString()
 {
     return((IsClose ? "</" : "<") + SourceNode.GetType().Name + ">");
 }
        public SourceNodeTests()
        {
            var annotatedNode = SourceNode.Valued("id", "myId1");

            annotatedNode.AddAnnotation("a string annotation");

            patient = SourceNode.Node("Patient",
                                      SourceNode.Resource("contained", "Observation", SourceNode.Valued("valueBoolean", "true")),
                                      SourceNode.Valued("active", "true",
                                                        annotatedNode,
                                                        SourceNode.Valued("id", "myId2"),
                                                        SourceNode.Node("extension",
                                                                        SourceNode.Valued("value", "4")),
                                                        SourceNode.Node("extension",
                                                                        SourceNode.Valued("value", "world!"))));
        }
Beispiel #28
0
 public static void Client_RequestCancelled(object sender, PeerRequestCancelledEventArgs e)
 {
     Iso8583Message response = e.Request.RequestMessage as Iso8583Message;
     SourceNode     source   = e.Request.Payload as SourceNode;
 }
Beispiel #29
0
        /// <summary>
        /// Applies the type to this memory section
        /// </summary>
        /// <exception cref="Exception"></exception>
        public virtual void ApplyType()
        {
            var typeElement = SourceNode.Element("type");

            if (typeElement == null)
            {
                throw new Exception(
                          $"Found a struct with no type definition in line {((IXmlLineInfo) typeElement).LineNumber}");
            }

            Type = typeElement.Value;

            var structTypeNode = GetStructType(SourceNode.Document, typeElement.Value);

            foreach (var childElement in structTypeNode.Elements().ToList())
            {
                var elementValue = childElement.Value;
                switch (childElement.Name.ToString())
                {
                case "name":
                    if (elementValue != "$name")
                    {
                        if (!string.IsNullOrWhiteSpace(Name))
                        {
                            Debug.WriteLine(
                                $"ApplyType: Overwriting name '{Name}' with '{elementValue}' from structType {typeElement.Value} at {((IXmlLineInfo) SourceNode).LineNumber}");
                        }
                        else
                        {
                            if (UseArrayIndex)
                            {
                                Name = elementValue + "[" + ArrayIndex + "]";
                            }
                            else
                            {
                                Name = elementValue;
                            }


                            ParentValuePath.AddRange(Parent.ParentValuePath);


                            ParentValuePath.Add(Name);
                            ValuePath = string.Join(".", ParentValuePath);
                        }
                    }


                    break;

                case "address":
                    if (elementValue != "$address")
                    {
                        throw new Exception(
                                  $"ApplyType: Unexpected absolute address from structType {typeElement.Value} at {((IXmlLineInfo) SourceNode).LineNumber}");
                    }

                    break;

                case "size":
                    IsAutoCalculatedSize = false;
                    Size     = ParseSize(elementValue);
                    FileSize = Size;
                    break;

                case "struct":
                    break;

                case "value":
                case "value-rvs":
                    break;

                case "type":
                    break;

                default:
                    Debug.WriteLine(
                        $"ParseStruct: Unknown type {childElement.Name} at {((IXmlLineInfo) childElement).LineNumber}");
                    break;
                }
            }


            DoCallback("RolandStructBeforeApplyChilds");

            foreach (var childElement in structTypeNode.Elements().ToList())
            {
                switch (childElement.Name.ToString())
                {
                case "struct":

                    ApplyFoo(childElement, false);


                    break;

                case "value":
                case "value-rvs":
                    ApplyFoo(childElement, true);
                    break;
                }
            }

            //

            if (IsAutoCalculatedSize)
            {
                FileSize = FileOffset;
                Size     = ChildOffset;
            }
            else
            {
                FileSize = FileOffset;
            }

            CalculatedSize = ChildOffset;
        }
Beispiel #30
0
 public override Binder DefaultVisit(SourceNode node)
 {
     return(VisitCore(node.Parent));
 }
Beispiel #31
0
        public static void LogTransaction(Iso8583Message incomingMessage, SourceNode sourceNode = null, Scheme scheme = null, Fee fee = null, bool needReversal = false)
        {
            var      instCode            = incomingMessage.Fields[2].ToString().Substring(0, 6);
            string   transactionTypeCode = (incomingMessage.Fields[3].ToString().Substring(0, 2));
            string   channelCode         = incomingMessage.Fields[123].ToString().Substring(13, 2);
            string   cardPan             = incomingMessage.Fields[2].ToString();
            string   response            = string.Empty;
            string   responseCode        = string.Empty;
            DateTime transmissionDate    = DateTime.UtcNow;

            TransactionLog transactionLog = new TransactionLog();

            try
            {
                transactionLog.MTI     = incomingMessage.MessageTypeIdentifier.ToString();
                transactionLog.STAN    = incomingMessage.Fields[11].ToString();
                transactionLog.Amount  = Convert.ToDouble(incomingMessage.Fields[4].ToString());
                transactionLog.CardPAN = cardPan;
                var channel = new ChannelManager().GetByCode(channelCode);
                if (channel != null)
                {
                    transactionLog.Channel = channel.Name;
                }
                var trnx = new TransactionTypeManager().GetByCode(transactionTypeCode);
                if (trnx != null)
                {
                    transactionLog.TransactionType = trnx.Name;
                }
                transactionLog.SourceNode      = sourceNode.Name;
                transactionLog.TransactionDate = transmissionDate;
                transactionLog.DateCreated     = DateTime.Now;
                transactionLog.DateModified    = DateTime.Now;

                string orDataElt = incomingMessage.Fields[90].ToString();
                int    length    = orDataElt.Length;
                transactionLog.OriginalDataElement = orDataElt.Length > 19 ? orDataElt.Remove(0, (length - 19)) : orDataElt;

                try
                {
                    responseCode = incomingMessage.Fields[39].Value.ToString();
                }
                catch (Exception) { }


                if (scheme != null)
                {
                    transactionLog.Scheme = scheme.Name;
                    transactionLog.Route  = scheme.Route.Name;

                    transactionLog.SinkNode = scheme.Route.SinkNode.Name;
                }

                try
                {
                    string  value  = incomingMessage.Fields[28].Value.ToString();
                    decimal result = 0;
                    if (Decimal.TryParse(value, out result))
                    {
                        transactionLog.Charge = result;
                    }
                }
                catch (Exception) { }
                if (fee != null)
                {
                    transactionLog.Fee = fee.Name;
                }
                if (responseCode != null)
                {
                    transactionLog.ResponseCode = responseCode;
                }
                if (responseCode != null)
                {
                    transactionLog.ResponseDescription = MessageDefinition.GetResponseDescription(responseCode);
                }
                string acc1 = incomingMessage.Fields[102].Value.ToString();
                string acc2 = incomingMessage.Fields[103].Value.ToString();
                transactionLog.Account1         = acc1;
                transactionLog.Account2         = acc2;
                transactionLog.IsReversePending = needReversal;

                if (incomingMessage.MessageTypeIdentifier.ToString() == "430" && responseCode == "00")
                {
                    transactionLog.IsReversed = true;
                    // SetReversalStatus(incomingMsg, responseCode);  //here
                }

                if (new TransactionLogManager().AddTransactionLog(transactionLog))
                {
                    Log("Transaction log::: " + transactionLog.STAN + " " + transactionLog.TransactionDate);
                }
                else
                {
                    Log("Transaction log::: not successful");
                }
            }
            catch (Exception ex)
            {
                Log("Error occurred while logging transaction \n" + ex.Message);
                Console.ForegroundColor = ConsoleColor.Red;
            }
        }
Beispiel #32
0
 public static SourceTree CreateForRoot(SourceNode rootNode) =>
 new InMemoryTree(rootNode);