Exemple #1
0
        private void ProcessMessageBodyLines(string messageBody, bool hasTradeEnvirlop)
        {
            string          regExp      = hasTradeEnvirlop ? GetSubRegExp() : GetBodyRegExp();
            MatchCollection resultMatch = Regex.Matches(messageBody, regExp);

            int[]         posArray  = Regex.Matches(messageBody, regExp).Cast <Match>().Select(m => m.Index).ToArray();
            List <string> textArray = Split(messageBody, posArray);

            int pos = 0;

            if (resultMatch != null)
            {
                foreach (Match m in resultMatch)
                {
                    string code = m.ToString();
                    //Actual Code
                    int   codeOffset  = 0;
                    int   length      = code.Length - 1;
                    Match matchOffset = Regex.Match(code, "[0-9]"); // Find firt number pos
                    if (matchOffset.Success)
                    {
                        codeOffset = matchOffset.Index;
                    }
                    if (code.EndsWith(":"))
                    {
                        length = code.Length - (codeOffset + 1);
                    }
                    string actualCode = code.Substring(codeOffset, length);
                    //Message has Envirlop
                    if (actualCode.Equals("77E"))
                    {
                        //Take the string from this and send to process again
                        string string77E = messageBody.Substring(posArray[pos]);
                        //Substring 4 to skip 77E
                        string77E = string77E.Substring(3 + codeOffset);
                        ProcessMessageBodyLines(string77E, true);
                        return;
                    }

                    SwiftImportDataLine line = AddDataLine(actualCode, textArray[pos], true, hasTradeEnvirlop);
                    if (line != null)
                    {
                        MessageDataLines.Add(line);
                    }
                    pos++;
                }
            }
        }
Exemple #2
0
        private SwiftImportDataLine AddDataLine(string code, string textBlock, bool scan, bool subMessage)
        {
            IMetaSwiftLine swiftLine = metaSwiftLines.Where(a => a.Code.Equals(code)).FirstOrDefault();

            if (swiftLine != null)
            {
                string text = ExtractValue(textBlock, scan, subMessage);

                SwiftImportDataLine dataLine = new SwiftImportDataLine();
                dataLine.Code       = code;
                dataLine.MetaLineID = swiftLine.ID;
                dataLine.Ordinal    = swiftLine.Ordinal;
                dataLine.Value      = text;

                //Fetch DLC Ref is it's not yet fetched
                if (DlcRef == null && ("20".Equals(dataLine.Code) || "21".Equals(dataLine.Code)) && DlcRef == null)
                {
                    DlcRef = text;
                }

                return(dataLine);
            }
            else if ("12".Equals(code))
            {
                string text = ExtractValue(textBlock, scan, subMessage);
                //Fetch real message type if this has enverlop
                if (EnverlopType != null)
                {
                    MessageType = text;
                }
                return(null);
            }
            else
            {
                throw new Exception("Swift code '" + code + "' does not exist in META!");
            }
        }