예제 #1
0
        /// <summary>
        /// Validade the properties.
        /// </summary>
        internal static bool Validade()
        {
            if (!(Exceptions.Any() || Warnings.Any() || Messages.Any() || Successes.Any()))
            {
                //throw new ArgumentException("At least one Exception/Warning/Message/Success expected.");
                return(false);
            }

            if (String.IsNullOrEmpty(ProjectName))
            {
                throw new ArgumentException("Project name must be declared.");
            }

            if (String.IsNullOrEmpty(Folder))
            {
                throw new ArgumentException("You must inform the Folder wich the Log will be writen.");
            }

            if (!Directory.Exists(Folder))
            {
                Directory.CreateDirectory(Folder);
            }

            if (!FileName.StartsWith("\\"))
            {
                FileName = "\\" + FileName;
            }

            if (!FileName.EndsWith(".htm"))
            {
                FileName += ".htm";
            }

            return(true);
        }
예제 #2
0
        void CheckAll()
        {
            bool clearRest = false;

            foreach (var issue in IssueList)
            {
                if (clearRest)
                {
                    issue.Severity = IssueSeverity.None;
                }
                else
                {
                    issue.Check();
                }
                // If issue is critical then...
                if (issue.Severity == IssueSeverity.Critical)
                {
                    // Skip checking other issues.
                    clearRest = true;
                }
                // Try to get issue from warnings list.
                var item = Warnings.FirstOrDefault(x => x.Name == issue.Name);
                // If issue found and not a problem then...
                if (item != null && issue.Severity == IssueSeverity.None)
                {
                    // Remove from the list.
                    Warnings.Remove(item);
                }
                // If issue not found and there is a problem then...
                else if (item != null && issue.Severity != IssueSeverity.None)
                {
                    // Add to the list.
                    Warnings.Add(issue);
                }
            }
            HasIssues = IgnoreAll
                                ? false
                                : Warnings.Any(x => x.Severity > IssueSeverity.Moderate);
            var ev = CheckCompleted;

            if (ev != null)
            {
                CheckCompleted(this, new EventArgs());
            }
        }
예제 #3
0
        private void UpdateErrors(INotifyDataErrorInfo viewModel)
        {
            ClearErrors();

            var validations = GetErrors(viewModel).ToList();

            foreach (var validation in validations.Where(x => x.Severity == Validation.IssueSeverity.Error))
            {
                Errors.Add(validation);
            }

            foreach (var validation in validations.Where(x => x.Severity == Validation.IssueSeverity.Warning))
            {
                Warnings.Add(validation);
            }

            HasIssues   = validations.Any();
            HasWarnings = Warnings.Any();
            HasErrors   = Errors.Any();
        }
예제 #4
0
파일: Treatment.cs 프로젝트: ptitim/PuffMvc
 /// <summary>
 /// Check if no warnings
 /// </summary>
 /// <returns></returns>
 public bool HasWarnings()
 {
     return(Warnings.Any());
 }
예제 #5
0
        public void AssertWarningNotLogged(string warning)
        {
            var found = Warnings.Any(s => warning.Equals(s, System.StringComparison.CurrentCulture));

            found.Should().BeFalse("Not expecting the warning to have been logged: '{0}'", warning);
        }
예제 #6
0
        /// <summary>
        /// Creates the page and writes to disk using properties set before.
        /// </summary>
        public static void Me()
        {
            if (!Validade())
            {
                return;
            }

            var html = new Html();

            #region Head

            html.Head      = new Head();
            html.Head.Meta = new List <Meta>();
            html.Head.Meta.Add(new Meta()
            {
                Content = "en-us", HttpEquiv = "Content-Language"
            });
            html.Head.Meta.Add(new Meta()
            {
                Content = "text/html; charset=utf-16", HttpEquiv = "Content-Type"
            });
            html.Head.Title = Title;

            html.Head.Style  = Style;
            html.Head.Script = Script;

            #endregion

            #region Body

            html.Body        = new Body();
            html.Body.H1     = Header;
            html.Body.Div    = new Div();
            html.Body.Div.Id = "content";

            #region Summary Table (Overview)

            html.Body.Div.Div1               = new Div1();
            html.Body.Div.Div1.H2            = "Overview";
            html.Body.Div.Div1.Div2          = new Div2();
            html.Body.Div.Div1.Div2.Id       = "overview";
            html.Body.Div.Div1.Div2.Table    = new Table();
            html.Body.Div.Div1.Div2.Table.Tr = new List <Tr>();

            #region Header

            var tableRow = new Tr();
            tableRow.Th = new List <Th>();
            tableRow.Th.Add(new Th());
            tableRow.Th.Add(new Th("ProjectTableHeader", "Project"));
            tableRow.Th.Add(new Th("PathTableHeader", "Path"));
            tableRow.Th.Add(new Th("ErrorsTableHeader", "Errors"));
            tableRow.Th.Add(new Th("WarningsTableHeader", "Warnings"));
            tableRow.Th.Add(new Th("MessagesTableHeader", "Messages"));
            tableRow.Th.Add(new Th("SuccessesTableHeader", "Successes"));
            html.Body.Div.Div1.Div2.Table.Tr.Add(tableRow);

            #endregion

            #region Project Summary

            var tableRowItem = new Tr();
            tableRowItem.Td = new List <Td>();

            #region Project Status Icon

            if (Exceptions.Any())
            {
                tableRowItem.Td.Add(new Td("IconErrorEncoded", ""));
            }
            else if (Warnings.Any())
            {
                tableRowItem.Td.Add(new Td("IconWarningEncoded", ""));
            }
            else if (Messages.Any())
            {
                tableRowItem.Td.Add(new Td("IconInfoEncoded", ""));
            }
            else
            {
                tableRowItem.Td.Add(new Td("IconSuccessEncoded", ""));
            }

            #endregion

            tableRowItem.Td.Add(new Td("", "<strong><a href=\"#" + ProjectName + "\">" + ProjectName + "</a></strong>"));
            tableRowItem.Td.Add(new Td("", ProjectPath));

            #region Counters

            #region Exceptions

            if (Exceptions.Any())
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a href=\"#\" onclick=\"ScrollToFirstVisibleRow('" + ProjectName + "', 'Error'); return false;\">" + Exceptions.Count + "</a>"));
            }
            else
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a>0</a>")); //If zero, no href
            }

            #endregion

            #region Warnings

            if (Warnings.Any())
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a href=\"#\" onclick=\"ScrollToFirstVisibleRow('" + ProjectName + "', 'Warning'); return false;\">" + Warnings.Count + "</a>"));
            }
            else
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a>0</a>")); //If zero, no href
            }

            #endregion

            #region Messages

            if (Messages.Any())
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a href=\"#\" onclick=\"ScrollToFirstVisibleRow('" + ProjectName + "', 'Message'); return false;\">" + Messages.Count + "</a>"));
            }
            else
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a>0</a>")); //If zero, no href
            }

            #endregion

            #region Successes

            if (Successes.Any())
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a href=\"#\" onclick=\"ScrollToFirstVisibleRow('" + ProjectName + "', 'Success'); return false;\">" + Successes.Count + "</a>"));
            }
            else
            {
                tableRowItem.Td.Add(new Td("textCentered", "<a>0</a>")); //If zero, no href
            }

            #endregion

            #endregion

            html.Body.Div.Div1.Div2.Table.Tr.Add(tableRowItem);

            #endregion

            #endregion

            #region Projects

            html.Body.Div.H2        = "Details";
            html.Body.Div.Div3      = new Div3();
            html.Body.Div.Div3.Div4 = new List <Div4>();

            #region For Each Project

            var div4 = new Div4();
            div4.A        = new A();
            div4.A.Name   = ProjectName;
            div4.H3       = ProjectName;
            div4.Table    = new Table();
            div4.Table.Tr = new List <Tr>();

            #region Header Row

            var tr = new Tr();
            tr.Id = div4.H3 + "HeaderRow";
            tr.Th = new List <Th>();
            tr.Th.Add(new Th("", "", ""));
            tr.Th.Add(new Th("MessageTableHeader", "Messages", "messageCell"));

            //First cell is empty.
            //second cell is "Messages".
            div4.Table.Tr.Add(tr);

            #endregion

            #region For each Error/Warning/Message/Success

            #region Errors

            foreach (Exception exce in Exceptions)
            {
                var trException = new Tr();

                if (!ExpandErrors)
                {
                    trException.Style = "display: none";
                }

                trException.Name = "ErrorRowClass" + ProjectName;
                trException.Td   = new List <Td>();
                trException.Td.Add(new Td("IconErrorEncoded", "<a name=\"" + ProjectName + "Error\" />"));
                trException.Td.Add(new Td("messageCell", "<span>" + exce.Message + "<br><code>" + exce.StackTrace + "</code>" + "</span>"));

                div4.Table.Tr.Add(trException);
            }

            #region Show/Hide

            if (Exceptions.Count > 0 && !ExpandErrors)
            {
                #region Singular/Plural

                string singularPlural = "error";
                if (Exceptions.Count > 1)
                {
                    singularPlural += "s";
                }

                #endregion

                var trShow = new Tr();
                trShow.Name = "ErrorRowHeaderShow" + ProjectName;
                trShow.Td   = new List <Td>();
                trShow.Td.Add(new Td("IconErrorEncoded", "<a name=\" " + div4.H3 + "Error\" />", "rgb(242,255,255)"));
                trShow.Td.Add(new Td("messageCell", "<a _locid=\"ShowAdditionalErrors\" href=\"#\" name=\"" + ProjectName + "Error\" onclick=\"ToggleErrorVisibility('" + ProjectName + "'); return false;\">Show " + Exceptions.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trShow);

                var trHide = new Tr();
                trHide.Name  = "ErrorRowHeaderHide" + ProjectName;
                trHide.Style = "display: none";
                trHide.Td    = new List <Td>();
                trHide.Td.Add(new Td("IconErrorEncoded", "<a name=\" " + div4.H3 + "Error\" />", "rgb(242,255,255)"));
                trHide.Td.Add(new Td("messageCell", "<a _locid=\"HideAdditionalErrors\" href=\"#\" name=\"" + ProjectName + "Error\" onclick=\"ToggleErrorVisibility('" + ProjectName + "'); return false;\">Hide " + Exceptions.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trHide);
            }

            #endregion

            #endregion

            #region Warnings

            foreach (string warning in Warnings)
            {
                var trWarnings = new Tr();

                if (!ExpandWarnings)
                {
                    trWarnings.Style = "display: none";
                }

                trWarnings.Name = "WarningRowClass" + ProjectName;
                trWarnings.Td   = new List <Td>();
                trWarnings.Td.Add(new Td("IconWarningEncoded", "<a name=\"" + ProjectName + "Warning\" />"));
                trWarnings.Td.Add(new Td("messageCell", "<span>" + warning + "</span>"));

                div4.Table.Tr.Add(trWarnings);
            }

            #region Show/Hide

            if (Warnings.Count > 0 && !ExpandWarnings)
            {
                #region Singular/Plural

                string singularPlural = "warning";
                if (Warnings.Count > 1)
                {
                    singularPlural += "s";
                }

                #endregion

                var trShow = new Tr();
                trShow.Name = "WarningRowHeaderShow" + ProjectName;
                trShow.Td   = new List <Td>();
                trShow.Td.Add(new Td("IconWarningEncoded", "<a name=\" " + div4.H3 + "Warning\" />", "rgb(242,255,255)"));
                trShow.Td.Add(new Td("messageCell", "<a _locid=\"ShowAdditionalWarnings\" href=\"#\" name=\"" + ProjectName + "Error\" onclick=\"ToggleWarningVisibility('" + ProjectName + "'); return false;\">Show " + Warnings.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trShow);

                var trHide = new Tr();
                trHide.Name  = "WarningRowHeaderHide" + ProjectName;
                trHide.Style = "display: none";
                trHide.Td    = new List <Td>();
                trHide.Td.Add(new Td("IconWarningEncoded", "<a name=\" " + div4.H3 + "Warning\" />", "rgb(242,255,255)"));
                trHide.Td.Add(new Td("messageCell", "<a _locid=\"HideAdditionalWarnings\" href=\"#\" name=\"" + ProjectName + "Error\" onclick=\"ToggleWarningVisibility('" + ProjectName + "'); return false;\">Hide " + Warnings.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trHide);
            }

            #endregion

            #endregion

            #region Messages

            foreach (string message in Messages)
            {
                var trMessages = new Tr();

                if (!ExpandMessages)
                {
                    trMessages.Style = "display: none";
                }

                trMessages.Name = "MessageRowClass" + ProjectName;
                trMessages.Td   = new List <Td>();
                trMessages.Td.Add(new Td("IconInfoEncoded", "<a name=\"" + ProjectName + "Message\" />"));
                trMessages.Td.Add(new Td("messageCell", "<span>" + message + "</span>"));

                div4.Table.Tr.Add(trMessages);
            }

            #region Show/Hide

            if (Messages.Count > 0 && !ExpandMessages)
            {
                #region Singular/Plural

                string singularPlural = "message";
                if (Messages.Count > 1)
                {
                    singularPlural += "s";
                }

                #endregion

                var trShow = new Tr();
                trShow.Name = "MessageRowHeaderShow" + ProjectName;
                trShow.Td   = new List <Td>();
                trShow.Td.Add(new Td("IconInfoEncoded", "<a name=\" " + div4.H3 + "Message\" />", "rgb(242,255,255)"));
                trShow.Td.Add(new Td("messageCell", "<a _locid=\"ShowAdditionalMessages\" href=\"#\" name=\"" + ProjectName + "Message\" onclick=\"ToggleMessageVisibility('" + ProjectName + "'); return false;\">Show " + Messages.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trShow);

                var trHide = new Tr();
                trHide.Name  = "MessageRowHeaderHide" + ProjectName;
                trHide.Style = "display: none";
                trHide.Td    = new List <Td>();
                trHide.Td.Add(new Td("IconInfoEncoded", "<a name=\" " + div4.H3 + "Message\" />", "rgb(242,255,255)"));
                trHide.Td.Add(new Td("messageCell", "<a _locid=\"HideAdditionalMessages\" href=\"#\" name=\"" + ProjectName + "Message\" onclick=\"ToggleMessageVisibility('" + ProjectName + "'); return false;\">Hide " + Messages.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trHide);
            }

            #endregion

            #endregion

            #region Successes

            foreach (string success in Successes)
            {
                var trSuccesses = new Tr();

                if (!ExpandSuccesses)
                {
                    trSuccesses.Style = "display: none";
                }

                trSuccesses.Name = "SuccessRowClass" + ProjectName;
                trSuccesses.Td   = new List <Td>();
                trSuccesses.Td.Add(new Td("IconSuccessEncoded", "<a name=\"" + ProjectName + "Success\" />"));
                trSuccesses.Td.Add(new Td("messageCell", "<span>" + success + "</span>"));

                div4.Table.Tr.Add(trSuccesses);
            }

            #region Show/Hide

            if (Successes.Count > 0 && !ExpandSuccesses)
            {
                #region Singular/Plural

                string singularPlural = "success";
                if (Successes.Count > 1)
                {
                    singularPlural += "es";
                }

                #endregion

                var trShow = new Tr();
                trShow.Name = "SuccessRowHeaderShow" + ProjectName;
                trShow.Td   = new List <Td>();
                trShow.Td.Add(new Td("IconSuccessEncoded", "<a name=\" " + div4.H3 + "Success\" />", "rgb(242,255,255)"));
                trShow.Td.Add(new Td("messageCell", "<a _locid=\"ShowAdditionalSuccesses\" href=\"#\" name=\"" + ProjectName + "Success\" onclick=\"ToggleSuccessVisibility('" + ProjectName + "'); return false;\">Show " + Successes.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trShow);

                var trHide = new Tr();
                trHide.Name  = "SuccessRowHeaderHide" + ProjectName;
                trHide.Style = "display: none";
                trHide.Td    = new List <Td>();
                trHide.Td.Add(new Td("IconSuccessEncoded", "<a name=\" " + div4.H3 + "Success\" />", "rgb(242,255,255)"));
                trHide.Td.Add(new Td("messageCell", "<a _locid=\"HideAdditionalSuccesses\" href=\"#\" name=\"" + ProjectName + "Success\" onclick=\"ToggleSuccessVisibility('" + ProjectName + "'); return false;\">Hide " + Successes.Count + " " + singularPlural + "</a>", "background-color: rgb(239,245,249);"));

                div4.Table.Tr.Add(trHide);
            }

            #endregion

            #endregion

            #endregion

            html.Body.Div.Div3.Div4.Add(div4);

            #endregion

            #endregion

            #endregion

            #region Serialize

            XmlDocument doc     = XmlUtils.Serializar <Html>(html);
            string      xmltext = XmlUtils.GetXmlTexto(doc);

            #endregion

            #region Replace's

            xmltext = "<!DOCTYPE html>\r\n" +
                      "<!-- saved from url=(0014)about:internet -->\r\n" + xmltext;
            xmltext = xmltext.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
            xmltext = xmltext.Replace("<html>", "<html xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\">\r\n").Replace("<script>", "<script type=\"text/javascript\" language=\"javascript\">").Replace("<value>", "").Replace("</value>", "");

            #endregion

            File.WriteAllText(Folder + FileName, xmltext);
        }
예제 #7
0
        public SnpEffAnnotation(string annotation)
        {
            bool isSnpEffAnnotation = annotation.StartsWith("ANN=") || annotation.StartsWith("EFF=");

            Annotation = isSnpEffAnnotation ? annotation.Substring(4) : annotation;
            if (!isSnpEffAnnotation)
            {
                return;
            }
            string[] a = Annotation.Split('|');
            Allele            = a[0];
            Effects           = a[1].Split('&');
            PutativeImpact    = a[2];
            GeneName          = a[3];
            GeneID            = a[4];
            FeatureType       = a[5];
            FeatureID         = a[6];
            TranscriptBiotype = a[7];
            if (a[8].Split('/').Length > 0 && int.TryParse(a[8].Split('/')[0], out int x))
            {
                ExonIntronRank = x;
            }
            if (a[8].Split('/').Length > 1 && int.TryParse(a[8].Split('/')[1], out int y))
            {
                ExonIntronTotal = y;
            }
            HGVSNotationDnaLevel     = a[9];
            HGVSNotationProteinLevel = a[10];
            if (a[11].Split('/').Length > 0 && int.TryParse(a[11].Split('/')[0], out x))
            {
                OneBasedTranscriptCDNAPosition = x;
            }
            if (a[11].Split('/').Length > 1 && int.TryParse(a[11].Split('/')[1], out y))
            {
                TranscriptCDNALength = y;
            }
            if (a[12].Split('/').Length > 0 && int.TryParse(a[12].Split('/')[0], out x))
            {
                OneBasedCodingDomainSequencePosition = x;
            }
            if (a[12].Split('/').Length > 1 && int.TryParse(a[12].Split('/')[1], out y))
            {
                CodingDomainSequenceLengthIncludingStopCodon = y;
            }
            if (a[13].Split('/').Length > 0 && int.TryParse(a[13].Split('/')[0], out x))
            {
                OneBasedProteinPosition = x;
            }
            if (a[13].Split('/').Length > 1 && int.TryParse(a[13].Split('/')[1], out y))
            {
                ProteinLength = y;
            }
            if (int.TryParse(a[14], out y))
            {
                DistanceToFeature = y;
            }
            Warnings = a[15].Split('&');

            Missense          = Effects.Any(eff => eff == "missense_variant");
            Synonymous        = !Effects.Any(eff => NonSynonymousVariations.Contains(eff));
            FrameshiftVariant = Effects.Contains("frameshift_variant");
            BadTranscript     = Warnings.Any(w => BadTranscriptWarnings.Contains(w));
        }
        public SnpEffAnnotation(Variant variant, string annotation)
        {
            Variant    = variant;
            Annotation = annotation;
            string[] a = annotation.Split('|');
            Allele            = a[0];
            Effects           = a[1].Split('&');
            PutativeImpact    = a[2];
            GeneName          = a[3];
            GeneID            = a[4];
            FeatureType       = a[5];
            FeatureID         = a[6];
            TranscriptBiotype = a[7];
            if (a[8].Split('/').Length > 0 && int.TryParse(a[8].Split('/')[0], out int x))
            {
                ExonIntronRank = x;
            }
            if (a[8].Split('/').Length > 1 && int.TryParse(a[8].Split('/')[1], out int y))
            {
                ExonIntronTotal = y;
            }
            HGVSNotationDnaLevel     = a[9];
            HGVSNotationProteinLevel = a[10];
            if (a[11].Split('/').Length > 0 && int.TryParse(a[11].Split('/')[0], out x))
            {
                OneBasedTranscriptCDNAPosition = x;
            }
            if (a[11].Split('/').Length > 1 && int.TryParse(a[11].Split('/')[1], out y))
            {
                TranscriptCDNALength = y;
            }
            if (a[12].Split('/').Length > 0 && int.TryParse(a[12].Split('/')[0], out x))
            {
                OneBasedCodingDomainSequencePosition = x;
            }
            if (a[12].Split('/').Length > 1 && int.TryParse(a[12].Split('/')[1], out y))
            {
                CodingDomainSequenceLengthIncludingStopCodon = y;
            }
            if (a[13].Split('/').Length > 0 && int.TryParse(a[13].Split('/')[0], out x))
            {
                OneBasedProteinPosition = x;
            }
            if (a[13].Split('/').Length > 1 && int.TryParse(a[13].Split('/')[1], out y))
            {
                ProteinLength = y;
            }
            if (int.TryParse(a[14], out y))
            {
                DistanceToFeature = y;
            }
            Warnings = a[15].Split('&');

            if (HGVSNotationProteinLevel != null)
            {
                GroupCollection hgvsProteinMatch = HGVSProteinRegex.Match(HGVSNotationProteinLevel).Groups;
                if (hgvsProteinMatch.Count > 2)
                {
                    ReferenceAminoAcid = ProteogenomicsUtility.amino_acids_3to1[hgvsProteinMatch[2].Value];
                }
                if (hgvsProteinMatch.Count > 3 && int.TryParse(hgvsProteinMatch[3].Value, out int location))
                {
                    AminoAcidLocation = location;
                }
                if (hgvsProteinMatch.Count > 4)
                {
                    AlternateAminoAcid = ProteogenomicsUtility.amino_acids_3to1[hgvsProteinMatch[4].Value];
                }
            }

            Missense          = Effects.Any(eff => eff == "missense_variant");
            Synonymous        = !Effects.Any(eff => NonSynonymousVariations.Contains(eff));
            FrameshiftVariant = Effects.Contains("frameshift_variant");
            BadTranscript     = Warnings.Any(w => BadTranscriptWarnings.Contains(w));
        }
예제 #9
0
파일: Messages.cs 프로젝트: GFlisch/Arc4u
 public bool WouldThrow()
 {
     return(Errors.Any() || (Warnings.Any() && !_ignoreWarnings));
 }
예제 #10
0
 public bool Any() => Warnings.Any() || SafetyConcerns.Any() || SanityChecks.Any();