Example #1
0
        public Accessibility(string src, ContnetTypeEnum contentType, ContentEncodingEnum ContentEncoding, ckdegreeEnum checklevel)
        {
            string requestUriString = src;
            StreamReader reader = null;
            string s = null;
            string str3 = string.Empty;
            int num = 1;
            this.m_ContentEncoding = System.Enum.Format(typeof(ContentEncodingEnum), ContentEncoding, "G");
            if ((this.m_ContentEncoding == null) | this.m_ContentEncoding.Equals("UTF8"))
            {
                this.m_ContentEncoding = "UTF-8";
            }
            Encoding encoding = Encoding.GetEncoding(this.m_ContentEncoding);
            switch (contentType)
            {
                case ContnetTypeEnum.web:
                    try
                    {
                        HttpWebRequest request = (HttpWebRequest) WebRequest.Create(requestUriString);
                        request.Timeout = 0xea60;
                        reader = new StreamReader(request.GetResponse().GetResponseStream(), encoding);
                    }
                    catch (WebException exception)
                    {
                        this.m_ErrorMessage = exception.Message;
                    }
                    catch (IOException exception5)
                    {
                        IOException exception2 = exception5;
                        this.m_ErrorMessage = exception2.Message;
                    }
                    catch (Exception exception6)
                    {
                        Exception exception3 = exception6;
                        this.m_ErrorMessage = exception3.Message;
                    }
                    break;

                case ContnetTypeEnum.cont:
                    try
                    {
                        reader = new StreamReader(new MemoryStream(Encoding.GetEncoding(this.m_ContentEncoding).GetBytes(requestUriString)));
                    }
                    catch (IOException exception4)
                    {
                        this.m_ErrorMessage = exception4.ToString();
                    }
                    break;

                case ContnetTypeEnum.file:
                    try
                    {
                        reader = new StreamReader(requestUriString, encoding);
                    }
                    catch (IOException exception8)
                    {
                        this.m_ErrorMessage = exception8.ToString();
                    }
                    catch (Exception exception9)
                    {
                        this.m_ErrorMessage = exception9.ToString();
                    }
                    break;
            }
            this.m_objHtmlDocument.Load(reader.BaseStream, encoding);
            StringReader reader2 = new StringReader(this.m_objHtmlDocument.DocumentNode.OuterHtml);
            while (reader2.Peek() >= 0)
            {
                s = reader2.ReadLine();
                str3 = str3 + string.Format("<a name='#{0}'>第{0}行</a>{1}", num, HttpUtility.HtmlEncode(s) + "<br />");
                num++;
            }
            this.m_strNewContents = str3;
            this.m_Checklevel = System.Enum.Format(typeof(ckdegreeEnum), checklevel, "G");
            this.m_XDoc = this.WriteXML();
            string nodeAttributeValue = string.Empty;
            string str5 = this.m_Checklevel;
            if (str5 != null)
            {
                if (!(str5 == "A"))
                {
                    if (str5 == "APlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到A+等級無障礙檢測標準,一個網頁必須通過A+等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                        nodeAttributeValue = "第一優先等級";
                        this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                        this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                        nodeAttributeValue = "A+等級檢測項目";
                        this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                        this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                        this.CreateXmlNode(this.m_XDoc, "/RESULT", "REPORT_DESC", this.m_Report_Desc, "", "");
                        this.MachineTesting(this.m_objHtmlDocument);
                        this.MachineAndHumanTesting(this.m_objHtmlDocument);
                        this.HumanTesting(this.m_objHtmlDocument);
                        this.AplusMachineTesting(this.m_objHtmlDocument);
                        this.AplusHumanTesting(this.m_objHtmlDocument);
                    }
                    else if (str5 == "AAPlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到第二優先等級無障礙檢測標準,一個網頁必須通過第二優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    }
                    else if (str5 == "AAAPlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到第三優先等級無障礙檢測標準,一個網頁必須通過第三優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    }
                }
                else
                {
                    this.m_Report_Desc = "受測網頁尚未達到第一優先等級無障礙檢測標準,一個網頁必須通過第一優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    nodeAttributeValue = "第一優先等級";
                    this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                    this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                    this.CreateXmlNode(this.m_XDoc, "/RESULT", "REPORT_DESC", this.m_Report_Desc, "", "");
                    this.MachineTesting(this.m_objHtmlDocument);
                    this.MachineAndHumanTesting(this.m_objHtmlDocument);
                    this.HumanTesting(this.m_objHtmlDocument);
                }
            }
            this.CreateXmlNode(this.m_XDoc, "/RESULT", "IS_PASS", this.m_isVerified.ToString(), "", "");
            this.m_Result = this.m_XDoc.OuterXml;
        }
Example #2
0
        public Accessibility(string src, ContnetTypeEnum contentType, ContentEncodingEnum ContentEncoding, ckdegreeEnum checklevel)
        {
            string       requestUriString = src;
            StreamReader reader           = null;
            string       s    = null;
            string       str3 = string.Empty;
            int          num  = 1;

            this.m_ContentEncoding = System.Enum.Format(typeof(ContentEncodingEnum), ContentEncoding, "G");
            if ((this.m_ContentEncoding == null) | this.m_ContentEncoding.Equals("UTF8"))
            {
                this.m_ContentEncoding = "UTF-8";
            }
            Encoding encoding = Encoding.GetEncoding(this.m_ContentEncoding);

            switch (contentType)
            {
            case ContnetTypeEnum.web:
                try
                {
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUriString);
                    request.Timeout = 0xea60;
                    reader          = new StreamReader(request.GetResponse().GetResponseStream(), encoding);
                }
                catch (WebException exception)
                {
                    this.m_ErrorMessage = exception.Message;
                }
                catch (IOException exception5)
                {
                    IOException exception2 = exception5;
                    this.m_ErrorMessage = exception2.Message;
                }
                catch (Exception exception6)
                {
                    Exception exception3 = exception6;
                    this.m_ErrorMessage = exception3.Message;
                }
                break;

            case ContnetTypeEnum.cont:
                try
                {
                    reader = new StreamReader(new MemoryStream(Encoding.GetEncoding(this.m_ContentEncoding).GetBytes(requestUriString)));
                }
                catch (IOException exception4)
                {
                    this.m_ErrorMessage = exception4.ToString();
                }
                break;

            case ContnetTypeEnum.file:
                try
                {
                    reader = new StreamReader(requestUriString, encoding);
                }
                catch (IOException exception8)
                {
                    this.m_ErrorMessage = exception8.ToString();
                }
                catch (Exception exception9)
                {
                    this.m_ErrorMessage = exception9.ToString();
                }
                break;
            }
            this.m_objHtmlDocument.Load(reader.BaseStream, encoding);
            StringReader reader2 = new StringReader(this.m_objHtmlDocument.DocumentNode.OuterHtml);

            while (reader2.Peek() >= 0)
            {
                s    = reader2.ReadLine();
                str3 = str3 + string.Format("<a name='#{0}'>第{0}行</a>{1}", num, HttpUtility.HtmlEncode(s) + "<br />");
                num++;
            }
            this.m_strNewContents = str3;
            this.m_Checklevel     = System.Enum.Format(typeof(ckdegreeEnum), checklevel, "G");
            this.m_XDoc           = this.WriteXML();
            string nodeAttributeValue = string.Empty;
            string str5 = this.m_Checklevel;

            if (str5 != null)
            {
                if (!(str5 == "A"))
                {
                    if (str5 == "APlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到A+等級無障礙檢測標準,一個網頁必須通過A+等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                        nodeAttributeValue = "第一優先等級";
                        this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                        this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                        nodeAttributeValue = "A+等級檢測項目";
                        this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                        this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                        this.CreateXmlNode(this.m_XDoc, "/RESULT", "REPORT_DESC", this.m_Report_Desc, "", "");
                        this.MachineTesting(this.m_objHtmlDocument);
                        this.MachineAndHumanTesting(this.m_objHtmlDocument);
                        this.HumanTesting(this.m_objHtmlDocument);
                        this.AplusMachineTesting(this.m_objHtmlDocument);
                        this.AplusHumanTesting(this.m_objHtmlDocument);
                    }
                    else if (str5 == "AAPlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到第二優先等級無障礙檢測標準,一個網頁必須通過第二優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    }
                    else if (str5 == "AAAPlus")
                    {
                        this.m_Report_Desc = "受測網頁尚未達到第三優先等級無障礙檢測標準,一個網頁必須通過第三優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    }
                }
                else
                {
                    this.m_Report_Desc = "受測網頁尚未達到第一優先等級無障礙檢測標準,一個網頁必須通過第一優先等級的全部檢測要點才能達到這個等級的無障礙網頁標準。";
                    nodeAttributeValue = "第一優先等級";
                    this.CreateXmlNode(this.m_XDoc, "//RESULT/DETAIL", "TITLE_DEGREE", "", "name", nodeAttributeValue);
                    this.CreateXmlNode(this.m_XDoc, string.Format("//RESULT/DETAIL/TITLE_DEGREE[@name='{0}']", nodeAttributeValue), "DESCRIPTION", "受測網頁未達此等級無障礙標準,以下是檢測時發現的錯誤:", "", "");
                    this.CreateXmlNode(this.m_XDoc, "/RESULT", "REPORT_DESC", this.m_Report_Desc, "", "");
                    this.MachineTesting(this.m_objHtmlDocument);
                    this.MachineAndHumanTesting(this.m_objHtmlDocument);
                    this.HumanTesting(this.m_objHtmlDocument);
                }
            }
            this.CreateXmlNode(this.m_XDoc, "/RESULT", "IS_PASS", this.m_isVerified.ToString(), "", "");
            this.m_Result = this.m_XDoc.OuterXml;
        }