示例#1
0
        public static List <ErrorLine> DetectErrorLines(TextDocument document)
        {
            List <ErrorLine> errorLines = new List <ErrorLine>();

            bool commandSectionCheckRequired = DocumentHelper.DocumentContainsSections(document);

            foreach (DocumentLine processedLine in document.Lines)
            {
                string processedLineText = document.GetText(processedLine.Offset, processedLine.Length);

                if (LineHelper.IsEmptyLine(processedLineText))
                {
                    continue;
                }

                ErrorLine error = FindErrorsInLine(document, processedLine, processedLineText, commandSectionCheckRequired);

                if (error != null)
                {
                    errorLines.Add(error);
                }
            }

            return(errorLines);
        }
            public void Then_Error_Detail_Is_Present_When_Defined()
            {
                // Arrange
                var error = new Error(
                    $"error-{Guid.NewGuid()}",
                    $"user-{Guid.NewGuid()}",
                    ErrorLine.FromErrorResult(new ErrorResult("sample error", ErrorAlias.ConnectionFailure)));

                // Act
                XmlDocument doc = SerializeSoapMessage(AS4Message.Create(error));

                // Assert
                XmlNode errorTag = doc.SelectEbmsNode(
                    "/s12:Envelope/s12:Header/eb:Messaging/eb:SignalMessage/eb:Error");

                const string expected =
                    "<eb:Error " +
                    "category=\"Communication\" " +
                    "errorCode=\"EBMS:0005\" " +
                    "severity=\"FAILURE\" " +
                    "shortDescription=\"ConnectionFailure\" " +
                    "xmlns:eb=\"http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/\">" +
                    "<eb:ErrorDetail>sample error</eb:ErrorDetail>" +
                    "</eb:Error>";

                Assert.Equal(expected, errorTag.OuterXml);
            }
示例#3
0
        private IEnumerable <ErrorLine> ExtractErrorLines(string infoLog, string source)
        {
            var sourceLines = source.AllLines().ToList();

            foreach (var line in infoLog.AllLines())
            {
                yield return(ErrorLine.Parse(line, sourceLines));
            }
        }
示例#4
0
        private object  ShortCopy(object row)
        {
            if (this.selectedSubRow < 0 || this.selectedSubRow >= this.errorLines.Count)
            {
                return(string.Empty);
            }

            ErrorLine error = this.errorLines[this.selectedSubRow];

            return(this.file + " " + error.line + " " + error.error + ' ' + error.message);
        }
示例#5
0
        public void RemoveError(int line)
        {
            var errorLine = new ErrorLine();

            errorLine.Line  = line;
            errorLine.Error = string.Empty;

            if (errors.Contains(errorLine))
            {
                errors.Remove(errorLine);
            }

            this.gridControl1.DataSource = null;
            this.gridControl1.DataSource = this.Errors;
        }
示例#6
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ErrorLine == null ? 0 : ErrorLine.GetHashCode());
         hash = hash * 23 + (ErrorMessage == null ? 0 : ErrorMessage.GetHashCode());
         hash = hash * 23 + (ErrorNumber == default(int) ? 0 : ErrorNumber.GetHashCode());
         hash = hash * 23 + (ErrorProcedure == null ? 0 : ErrorProcedure.GetHashCode());
         hash = hash * 23 + (ErrorSeverity == null ? 0 : ErrorSeverity.GetHashCode());
         hash = hash * 23 + (ErrorState == null ? 0 : ErrorState.GetHashCode());
         hash = hash * 23 + (ErrorTime == default(DateTime) ? 0 : ErrorTime.GetHashCode());
         hash = hash * 23 + (UserName == null ? 0 : UserName.GetHashCode());
         return(hash);
     }
 }
示例#7
0
            public static ErrorLine Parse(string s, IList <string> sourceLines)
            {
                ErrorLine e = new ErrorLine();

                foreach (Match match in ErrorMatch.Matches(s))
                {
                    if (match.Groups.Count == 4)
                    {
                        e.FileIndex  = match.Groups[1].Value.ParseIntOrDefault(0);
                        e.LineNumber = match.Groups[2].Value.ParseIntOrDefault(0);
                        e.Error      = match.Groups[3].Value;

                        if (e.LineNumber > 0 && e.LineNumber <= sourceLines.Count)
                        {
                            e.LineSource = sourceLines[e.LineNumber - 1];
                        }
                    }
                }

                return(e);
            }
示例#8
0
        public void AddError(int line, string error)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new AddErrorDelegate(this.AddError), line, error);
            }
            else
            {
                var errorLine = new ErrorLine();
                errorLine.Line  = line;
                errorLine.Error = error;

                if (errors.Contains(errorLine))
                {
                    errors.Remove(errorLine);
                }
                errors.Add(errorLine);

                this.gridControl1.DataSource = null;
                this.gridControl1.DataSource = this.Errors;
            }
        }
        protected override string VerfiyLineData(CodeGen data, bool showNotification = true)
        {
            string error = "";


            if (string.IsNullOrEmpty(data.NickName))
            {
                error = string.Format("当前ID:{0} 建议NickName字段不要为空 请您补全描述信息便于查错", data.ID);
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (GetType(data.ClassType) == null && ReflectionHelper.GetCurrentAssemblyType(data.ClassType) == null)
            {
                error = string.Format("当前ID:{0} {1} 找不到 请您确认代码中有这个类", data.ID, GetFieldDisplayFromChache("ClassType"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (GetType(data.SubType) == null && ReflectionHelper.GetCurrentAssemblyType(data.SubType) == null)
            {
                error = string.Format("当前ID:{0} {1} 找不到 请您确认代码中有这个类", data.ID, GetFieldDisplayFromChache("SubType"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (string.IsNullOrEmpty(data.CodeExportPath))
            {
                error = string.Format("当前ID:{0} {1}没写 麻烦你写下", data.ID, GetFieldDisplayFromChache("CodeExportPath"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (string.IsNullOrEmpty(data.InOutPath))
            {
                error = string.Format("当前ID:{0} {1}没写 麻烦你写下", data.ID, GetFieldDisplayFromChache("InOutPath"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                                //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (string.IsNullOrEmpty(data.EditorPath))
            {
                error = string.Format("当前ID:{0} {1}没写 麻烦你写下", data.ID, GetFieldDisplayFromChache("EditorPath"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else if (string.IsNullOrEmpty(data.EditorName))
            {
                error = string.Format("当前ID:{0} {1}没写 麻烦你写下", data.ID, GetFieldDisplayFromChache("EditorName"));
                if (!ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Add(data.ID);                               //添加报错提示
                }
                if (showNotification)
                {
                    ShowNotification(new GUIContent(error));
                }
            }
            else
            {
                if (showNotification)
                {
                    ShowNotification(new GUIContent(string.Format(Language.VerfiyMessageSuccess, data.ID)));
                }

                if (ErrorLine.Contains(data.ID))
                {
                    ErrorLine.Remove(data.ID);                              //校验成功解除报错信息
                }
            }

            return(error);
        }
        /// <summary>
        /// Transform a given <see cref="ReceivedMessage"/> to a Canonical <see cref="MessagingContext"/> instance.
        /// </summary>
        /// <param name="message">Given message to transform.</param>
        /// <returns></returns>
        public async Task <MessagingContext> TransformAsync(ReceivedMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (message.UnderlyingStream == null)
            {
                throw new InvalidMessageException(
                          "The incoming stream is not an ebMS Message. " +
                          "Only ebMS messages conform with the AS4 Profile are supported.");
            }

            if (!ContentTypeSupporter.IsContentTypeSupported(message.ContentType))
            {
                throw new InvalidMessageException(
                          $"ContentType is not supported {message.ContentType}{Environment.NewLine}" +
                          $"Supported ContentTypes are {Constants.ContentTypes.Soap} and {Constants.ContentTypes.Mime}");
            }

            ReceivedMessage rm = await EnsureIncomingStreamIsSeekable(message);

            AS4Message as4Message = await DeserializeToAS4Message(rm);

            //Debug.Assert(m.UnderlyingStream.Position == 0, "The Deserializer failed to reposition the stream to its start-position");

            if (as4Message.IsSignalMessage && ReceivingPMode != null)
            {
                Logger.Error(
                    "Static Receive configuration doesn't allow receiving signal messages. " +
                    $"Please remove the static configured Receiving PMode: {ReceivingPMode} to also receive signal messages");

                throw new InvalidMessageException(
                          "Static Receive configuration doesn't allow receiving signal messages. ");
            }

            if (as4Message.PrimaryMessageUnit != null)
            {
                Logger.Info($"(Receive) Receiving AS4Message -> {as4Message.PrimaryMessageUnit.GetType().Name} {as4Message.PrimaryMessageUnit.MessageId}");
            }

            var context = new MessagingContext(as4Message, rm, MessagingContextMode.Receive);

            if (ReceivingPMode != null)
            {
                ReceivingProcessingMode pmode =
                    _config.GetReceivingPModes()
                    ?.FirstOrDefault(p => p.Id == ReceivingPMode);

                if (pmode != null)
                {
                    context.ReceivingPMode = pmode;
                }
                else
                {
                    Logger.Error(
                        $"ReceivingPMode with Id: {ReceivingPMode} was configured as default PMode, but this PMode cannot be found in the configured receiving PModes."
                        + $"{Environment.NewLine} Configured Receiving PModes are placed on the folder: '.\\config\\receive-pmodes\\'.");

                    var errorResult = new ErrorResult(
                        "Static configured ReceivingPMode cannot be found",
                        ErrorAlias.ProcessingModeMismatch);

                    var as4Error = new Error(
                        IdentifierFactory.Instance.Create(),
                        as4Message.GetPrimaryMessageId() ?? IdentifierFactory.Instance.Create(),
                        ErrorLine.FromErrorResult(errorResult));

                    return(new MessagingContext(
                               AS4Message.Create(as4Error),
                               MessagingContextMode.Receive)
                    {
                        ErrorResult = errorResult
                    });
                }
            }

            return(context);
        }
示例#11
0
    // Update is called once per frame
    void Update()
    {
        if (bGetRankings)
        {
            RankingsRequest     = new WWW(RankingURL);
            bWaitingForRankings = true;
            bGetRankings        = false;
            FetchStatus         = "Querying Shrednow.com";
        }
        else if (bWaitingForRankings && RankingsRequest.isDone)
        {
            if (RankingsRequest.error != null)
            {
                FetchStatus = RankingsText = RankingsRequest.error;
            }
            else
            {
                RankingsText = Encoding.UTF7.GetString(RankingsRequest.bytes, 0, RankingsRequest.bytes.Length);

                //int RankStartIndex = "<td align=\"center\">".Length;
                string       line    = null;
                StringReader AllText = new StringReader(RankingsText);
                AllPlayers.Clear();
                while ((line = AllText.ReadLine()) != null)
                {
                    // Old Arthur parsing
                    //if (line.StartsWith("<td align=\"center\">"))
                    //{
                    //    PlayerData NewData = new PlayerData();
                    //    int.TryParse(line.Substring(RankStartIndex, line.IndexOf('<', RankStartIndex) - RankStartIndex), out NewData.Rank);
                    //    int StartNameIndex = line.IndexOf("</td><td>") + "</td><td>".Length;
                    //    string LastName = line.Substring(StartNameIndex, line.IndexOf(',', StartNameIndex) - StartNameIndex);
                    //    string FirstName = line.Substring(line.IndexOf(',', StartNameIndex) + 2, line.IndexOf('<', StartNameIndex) - line.IndexOf(',', StartNameIndex) - 2);
                    //    int StartPointsIndex = line.IndexOf("</td><td align=\"center\">", StartNameIndex + FirstName.Length + LastName.Length + 10) +
                    //        "</td><td align=\"center\">".Length;
                    //    float.TryParse(line.Substring(StartPointsIndex, line.IndexOf('<', StartPointsIndex) - StartPointsIndex), out NewData.RankingPoints);

                    //    NameData NewName = NameDatabase.TryAddNewName(FirstName, LastName);
                    //    NewData.NameId = NewName.Id;

                    //    AllPlayers.Add(NewData);
                    //}

                    line = line.Trim();

                    string RankTd = "<td height=19 class=xl6322297 style='height:14.5pt'>";

                    string NameClass   = "xl1522297";
                    string PointsClass = "xl6322297";

                    // New Kolja parsing
                    if (line.StartsWith(RankTd))
                    {
                        PlayerData NewData = new PlayerData();
                        string     rankStr = line.Trim().Replace(RankTd, "");
                        rankStr = rankStr.Replace("</td>", "");
                        int.TryParse(rankStr, out NewData.Rank);
                        AllText.ReadLine();

                        string NameLine           = AllText.ReadLine().Trim().Replace("<td class=" + NameClass + ">", "");
                        int    NameLineCommaIndex = NameLine.IndexOf(',');
                        if (NameLineCommaIndex == -1)
                        {
                            continue;
                        }
                        string   LastName  = NameLine.Substring(0, NameLineCommaIndex);
                        string   FirstName = NameLine.Substring(NameLineCommaIndex + 2, NameLine.Length - LastName.Length - 7);
                        NameData NewName   = NameDatabase.TryAddNewName(FirstName, LastName);
                        NewData.NameId = NewName.Id;

                        AllText.ReadLine();
                        AllText.ReadLine();
                        string PointsLine = AllText.ReadLine().Trim();
                        PointsLine = PointsLine.Replace("<td class=" + PointsClass + ">", "").Replace("</td>", "").Replace(",", ".");
                        float.TryParse(PointsLine, out NewData.RankingPoints);

                        AllPlayers.Add(NewData);
                    }
                }

                RankingsText = "";
                for (int i = 0; i < AllPlayers.Count; ++i)
                {
                    PlayerData Data = AllPlayers[i];
                    RankingsText += NameDatabase.FindInDatabase(Data.NameId).DisplayName + "   " + Data.Rank + "   " + Data.RankingPoints + "\n";
                }

                FetchStatus = "Got " + AllPlayers.Count + " Players Rankings";

                InputTeamsTextChanged = true;
            }

            bWaitingForRankings = false;
        }

        if (InputTeamsTextChanged)
        {
            InputTeamsTextChanged = false;

            ParseTeamsText = "";
            StringReader TeamText = new StringReader(InputTeamsText);
            string       line     = null;
            AllTeams.Clear();
            ErrorList.Clear();
            while ((line = TeamText.ReadLine()) != null)
            {
                TeamData NewTeam = GetTeamFromString(line);
                if (NewTeam != null)
                {
                    AllTeams.Add(NewTeam);
                }
                else
                {
                    char[] BreakCharArray = new char[10];
                    BreakChars.CopyTo(BreakCharArray, 0);
                    string[]  NameArray = line.Split(BreakCharArray);
                    ErrorLine NewError  = new ErrorLine();
                    NewError.OriginalLine = line;
                    foreach (string s in NameArray)
                    {
                        string            NameStr    = s.Trim();
                        List <PlayerData> OutPlayers = new List <PlayerData>();
                        GetPlayersFromString(NameStr, ref OutPlayers);
                        NewError.ErrorList.Add(new ErrorData(NameStr, OutPlayers.Count == 0));
                    }
                    ErrorList.Add(NewError);
                }
            }

            if (bSortTeams)
            {
                AllTeams.Sort(TeamSorter);
            }

            for (int TeamIndex = 0; TeamIndex < AllTeams.Count; ++TeamIndex)
            {
                ParseTeamsText += (TeamIndex + 1) + ". " + AllTeams[TeamIndex].PlayerNames + " : " + AllTeams[TeamIndex].TotalRankPoints + "\n";
            }

            AllPools.Clear();
            if (PoolCount > 0)
            {
                char PoolName = 'A';
                for (int TeamIndex = 0; TeamIndex < AllTeams.Count; ++TeamIndex)
                {
                    if (bSortTeams)
                    {
                        int PoolIndex = TeamIndex % PoolCount;
                        if (PoolIndex >= AllPools.Count)
                        {
                            AllPools.Add(new PoolDataDisplay((PoolName++).ToString()));
                        }

                        AllPools[PoolIndex].Data.Teams.Add(new TeamDataDisplay(AllTeams[TeamIndex]));
                    }
                    else
                    {
                        int TeamsPerPool = AllTeams.Count / PoolCount;
                        int PoolIndex    = TeamIndex / TeamsPerPool;
                        if (PoolIndex >= AllPools.Count)
                        {
                            AllPools.Add(new PoolDataDisplay((PoolName++).ToString()));
                        }

                        AllPools[PoolIndex].Data.Teams.Add(new TeamDataDisplay(AllTeams[TeamIndex]));
                    }
                }
            }

            InputTeamsTextReduced = false;

            //Debug.Log("Parsing pools. Teams: " + AllTeams.Count + "  Pools: " + AllPools.Count);
        }

        if (Input.GetMouseButton(0))
        {
            if (MovingTeam != null)
            {
            }
        }
        else
        {
            if (MovingTeam != null)
            {
                for (int PoolIndex = 0; PoolIndex < AllPools.Count; ++PoolIndex)
                {
                    Vector3 NewMousePos = new Vector3(Input.mousePosition.x, Screen.height - Input.mousePosition.y + ParsedScrollPos.y, 0);
                    if (AllPools[PoolIndex].DisplayRect.Contains(NewMousePos))
                    {
                        MovedTeamBetweenPools(MovingTeam, PoolIndex);
                        break;
                    }
                }
            }

            for (int PoolIndex = 0; PoolIndex < AllPools.Count; ++PoolIndex)
            {
                PoolData PData = AllPools[PoolIndex].Data;
                for (int TeamIndex = 0; TeamIndex < PData.Teams.Count; ++TeamIndex)
                {
                    PData.Teams[TeamIndex].bClickedOn = false;
                }
            }

            MovingTeam = null;
        }
    }