コード例 #1
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_3_1_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            var footnotes     = new HashSet <string>();
            var relationships = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix = document.Root.GetNamespaceOfPrefix("ix");

                document.Root.
                Descendants(ix + "footnote").
                Select(f => f.Attribute("id")?.Value).
                Where(a => !string.IsNullOrEmpty(a)).
                ToList().
                ForEach(f => footnotes.Add(f));

                document.Root.
                Descendants(ix + "relationship").
                Select(r => r.Attribute("toRefs")?.Value).
                Where(a => !string.IsNullOrEmpty(a)).
                ToList().
                ForEach(r => relationships.Add(r));
            }

            if (footnotes.Except(relationships).Any())
            {
                errors.Add("unusedFootnote");
            }

            return(errors.Join(","));
        }
コード例 #2
0
        public static void AddAltLexicon(byte[] b)
        {
            SpreadSheet xls = new SpreadSheet(b);

            while (xls.HasNextRow())
            {
                xls.NextRow();
                string key   = xls.GetNextCellString();
                string value = xls.GetNextCellString();
                if (key.IsEmpty())
                {
                    continue;
                }
                invAltMap[value] = key;
                if (!conflict.Contains(key))
                {
                    if (altMap.ContainsKey(key))
                    {
                        conflict.Add(key);
                    }
                    else
                    {
                        altMap[key] = value;
                    }
                }
            }
            if (log.IsLoggable(LogLevel.Log))
            {
                log.Debug("Duplicate Message Key: {0}", conflict.Join(","));
            }
        }
コード例 #3
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_1_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;
                if (document != null)
                {
                    var xbrli          = document.Root.GetNamespaceOfPrefix("xbrli");
                    var periodElements = document.Root.Descendants(xbrli + "period");
                    var dates          = periodElements.SelectMany(p => p.Descendants().Select(d => d.Value));

                    if (dates.Any(d => d.IndexOf('T') != -1))
                    {
                        errors.Add("periodWithTimeContent");
                    }

                    var zones = new char[] { 'Z', '+', '-' };
                    if (dates.Any(d => d.LastIndexOfAny(zones) > 9))
                    {
                        errors.Add("periodWithTimeZone");
                    }
                }
            }

            return(errors.Join(","));
        }
コード例 #4
0
        private void LoadParents()
        {
            string arg = "log " + GitCommandHelpers.FindRenamesAndCopiesOpts() + " --simplify-merges --parents --boundary --not --glob=notes --not --all --format=\"%H %P\"";

            if (AppSettings.OrderRevisionByDate)
            {
                arg += " --date-order";
            }
            else
            {
                arg += " --topo-order";
            }
            if (AppSettings.FullHistoryInFileHistory)
            {
                arg += " --full-history --simplify-by-decoration ";
            }
            if (AppSettings.MaxRevisionGraphCommits > 0)
            {
                arg += string.Format(" --max-count=\"{0}\"", (int)AppSettings.MaxRevisionGraphCommits);
            }
            arg += " -- \"" + _previousNames.Join("\" \"") + "\"";

            using (StreamReader gitResult = _gitExecFunc(arg))
            {
                string line;
                while ((line = gitResult.ReadLine()) != null)
                {
                    AddCommitToParentsGraph(line);
                }
            }
        }
コード例 #5
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_5_4_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            var parts = reportFiles.Where(f => f.Content is XDocument).ToArray();

            if (parts.Length > 1)
            {
                foreach (var part in parts)
                {
                    var document = part.Content as XDocument;
                    var html     = document.Root.GetDefaultNamespace();
                    if (document.Root.
                        Descendants(html + "style").
                        Any())
                    {
                        errors.Add("embeddedCssForMultiHtmlIXbrlDocumentSets");
                    }
                }
            }
            return(errors.Join(","));

            //Where an Inline XBRL document set contains multiple documents,
            //the CSS SHOULD be defined in a separate file.
        }
コード例 #6
0
        /// <summary>
        ///得到当前产品的keywords
        /// </summary>
        /// <param name="category"></param>
        /// <param name="product"></param>
        /// <returns></returns>
        private static string GetProductKeywords0(CategoryKeyWordsEntity category, ProductKeywordsQueue product)
        {
            //因为要不重复, 所以使用HashSet
            var distinctedKeywordsList = new HashSet <string>();

            //如果公共关键字不为空
            if (!category.CommonKeywords.IsNullOrEmpty())
            {
                distinctedKeywordsList.AddRange(category.CommonKeywords.Split(' '));
            }
            //得到属性关键字
            var propertyInfoList = BatchUpdateItemKeywordsDA.GetPropertyInfo(product.ProductSysNo.Value, product.C3SysNo.Value);

            foreach (var propertyInfo in propertyInfoList)
            {
                var keywords = propertyInfo.ManualInput.IsNullOrEmpty() ? propertyInfo.ValueDescription : propertyInfo.ManualInput;
                keywords = (keywords ?? string.Empty).Trim();

                if (!keywords.IsNullOrEmpty())
                {
                    distinctedKeywordsList.AddRange(keywords.Split(' '));
                }
            }

            return(distinctedKeywordsList.Join(" "));
        }
コード例 #7
0
        public ModuleDifference[] CompareTo(ModuleManifest other)
        {
            var modulePathComparer = new ModulePathComparer(pathComparer);
            var currentModules     = new HashSet <Module>(modules, modulePathComparer);
            var oldModules         = new HashSet <Module>(other.Modules, modulePathComparer);

            var addedModules = currentModules.Except(oldModules, modulePathComparer);
            var added        = addedModules.Select(m => new ModuleDifference(m, ModuleDifferenceType.Added));

            var deletedModules = oldModules.Except(currentModules, modulePathComparer);
            var deleted        = deletedModules.Select(m => new ModuleDifference(m, ModuleDifferenceType.Deleted));

            // Changed module means old and current have the same path, but different hash.
            // Use Join to pair up the modules by path.
            // Then use Where to filter out those with same hash.
            var changedModules = oldModules.Join(currentModules, m => m.Path, m => m.Path, (old, current) => new { old, current })
                                 .Where(c => c.current.Equals(c.old) == false);
            // So deleted the old modules and add the current modules.
            var changes = changedModules.SelectMany(c => new[]
            {
                new ModuleDifference(c.old, ModuleDifferenceType.Deleted),
                new ModuleDifference(c.current, ModuleDifferenceType.Added)
            }
                                                    );

            return(added.Concat(deleted).Concat(changes).ToArray());
        }
コード例 #8
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_3_1_3(IEnumerable <ReportFile> reportFiles)
        {
            var error = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix  = document.Root.GetNamespaceOfPrefix("ix");
                var xml = document.Root.GetNamespaceOfPrefix("xml");

                var reportLanguage = document.Root.Attribute(xml + "lang")?.Value ?? "";

                var footnotes =
                    document.Root.
                    Descendants(ix + "footnote").
                    ToList();

                if (footnotes.Any(f => f.Attribute(xml + "lang") == null))
                {
                    error.Add("undefinedLanguageForFootnote");
                }

                if (footnotes.
                    Select(f => f.Attribute(xml + "lang")).
                    Where(a => a != null).
                    Any(a => a.Value != reportLanguage)
                    )
                {
                    error.Add("footnoteOnlyInLanguagesOtherThanLanguageOfAReport");
                }
            }
            return(error.Join(","));
        }
コード例 #9
0
ファイル: HtmlTag.cs プロジェクト: reharik/CCHtmlHelpers
        private void writeHtml(HtmlTextWriter html)
        {
            if (!WillBeRendered())
            {
                return;
            }

            _htmlAttributes.Each((key, val) =>
            {
                if (val != null)
                {
                    var stringValue = !(val is string) && key.StartsWith(DataPrefix) ? JsonUtil.ToJson(val) : val.ToString();
                    html.AddAttribute(key, stringValue);
                }
            });

            if (_cssClasses.Count > 0 || _validationHelpers.Count > 0)
            {
                var classAttribute = getValidationMetaData();
                classAttribute += _cssClasses.Join(" ");
                if (classAttribute.Length > 1)
                {
                    html.AddAttribute(CssClassAttribute, classAttribute);
                }
            }

            if (_metaData.Count > 0)
            {
                var metadataValue = JsonUtil.ToUnsafeJson(_metaData.Inner);
                html.AddAttribute(MetadataAttribute, metadataValue);
            }

            if (_customStyles.Count > 0)
            {
                var attValue = _customStyles
                               .Select(x => x.Key + ":" + x.Value)
                               .ToArray().Join(";");

                html.AddAttribute(CssStyleAttribute, attValue);
            }

            html.RenderBeginTag(_tag);

            writeInnerText(html);

            _children.Each(x => x.writeHtml(html));

            if (HasClosingTag())
            {
                html.RenderEndTag();
            }

            if (_next != null)
            {
                _next.writeHtml(html);
            }
        }
コード例 #10
0
ファイル: HtmlTag.cs プロジェクト: nirav72/htmltags
        protected void WriteBeginTag(TextWriter html, HtmlEncoder encoder)
        {
            if (!HasTag())
            {
                return;
            }

            html.Write("<");
            html.Write(_tag);

            if (_htmlAttributes.Count > 0)
            {
                _htmlAttributes.Each((key, attribute) =>
                {
                    if (attribute != null)
                    {
                        var value       = attribute.Value;
                        var stringValue = !(value is string) && key.StartsWith(DataPrefix)
                            ? JsonSerializer.Serialize(value)
                            : value.ToString();
                        RenderAttribute(html, encoder, key, stringValue, attribute.IsEncoded);
                    }
                    else
                    {
                        RenderAttribute(html, encoder, key, null, true);
                    }
                });
            }

            if (_cssClasses.Count > 0)
            {
                var classValue = _cssClasses.Join(" ");
                RenderAttribute(html, encoder, CssClassAttribute, classValue, true);
            }

            if (_metaData.Count > 0)
            {
                var metadataValue = JsonSerializer.Serialize(_metaData.Inner);
                RenderAttribute(html, encoder, MetadataAttribute, metadataValue, true);
            }

            if (_customStyles.Count > 0)
            {
                var attValue = _customStyles
                               .Select(x => x.Key + ":" + x.Value)
                               .ToArray().Join(";");

                RenderAttribute(html, encoder, CssStyleAttribute, attValue, true);
            }


            html.Write(">");
        }
コード例 #11
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_4_1_1(IEnumerable <ReportFile> reportFiles)
        {
            var error = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;
                var ix       = document.Root.GetNamespaceOfPrefix("ix");

                var hiddenFacts =
                    document.Root.
                    Descendants(ix + "hidden").
                    FirstOrDefault()?.
                    Descendants().
                    Where(d => d.Attribute("contextRef") != null);

                var transformableHiddenFacts =
                    hiddenFacts?.
                    Where(d => d.Attribute("format") != null);

                if (transformableHiddenFacts != null && transformableHiddenFacts.Any())
                {
                    error.Add("transformableElementIncludedInHiddenSection");
                }

                var hiddenFactIds =
                    hiddenFacts?.
                    Select(f => f.Attribute("id").Value).
                    ToHashSet() ?? new HashSet <string>();

                var reportHiddenFactIds =
                    document.Root.
                    Descendants().
                    Select(d => d.Attribute("style")).
                    Where(a => a != null).
                    Select(a => a.Value.Split(':')).
                    Where(v => v.First() == "-esef-ix-hidden").
                    Select(v => v.Last()).
                    ToHashSet() ?? new HashSet <string>();

                if (reportHiddenFactIds.Except(hiddenFactIds).Any())
                {
                    error.Add("esefIxHiddenStyleNotLinkingFactInHiddenSection");
                }

                if (hiddenFactIds.Except(reportHiddenFactIds).Any())
                {
                    error.Add("factInHiddenSectionNotInReport");
                }
            }
            return(error.Join(","));
        }
コード例 #12
0
        public TypeListOpinion(IEnumerable<Type> inclusions, IEnumerable<Type> exclusions)
        {
            var inclusionsSet = new HashSet<Type>(inclusions ?? new Type[] { });
            var exclusionsSet = new HashSet<Type>(exclusions ?? new Type[] { });

            var intersection = inclusionsSet.Join(exclusionsSet, outer => outer, inner => inner, (outer, inner) => true);

            if (intersection.Any())
                throw new Exception("A type can only be either included or excluded, not both.");

            Inclusions = inclusionsSet;
            Exclusions = exclusionsSet;
        }
コード例 #13
0
        protected void WriteBeginTag(HtmlTextWriter html)
        {
            if (!HasTag())
            {
                return;
            }

            _htmlAttributes.Each((key, attribute) =>
            {
                if (attribute != null)
                {
                    var value       = attribute.Value;
                    var stringValue = !(value is string) && key.StartsWith(DataPrefix)
                        ? JsonConvert.SerializeObject(value)
                        : value.ToString();
                    html.AddAttribute(key, stringValue, attribute.IsEncoded);
                }
                else
                {
                    // HtmlTextWriter treats a null value as an attribute with no value (e.g., <input required />).
                    html.AddAttribute(key, null, false);
                }
            });

            if (_cssClasses.Count > 0)
            {
                var classValue = _cssClasses.Join(" ");
                html.AddAttribute(CssClassAttribute, classValue);
            }

            if (_metaData.Count > 0)
            {
                var dictionary = new Dictionary <string, object>();
                _metaData.Each((key, value) => dictionary.Add(key, value));

                var metadataValue = JsonConvert.SerializeObject(dictionary);
                html.AddAttribute(MetadataAttribute, metadataValue);
            }

            if (_customStyles.Count > 0)
            {
                var attValue = _customStyles
                               .Select(x => x.Key + ":" + x.Value)
                               .ToArray().Join(";");

                html.AddAttribute(CssStyleAttribute, attValue);
            }

            html.RenderBeginTag(_tag);
        }
コード例 #14
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_4_2_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;
                var xml      = document.Root.GetNamespaceOfPrefix("xml");
                if (document.Root.DescendantsAndSelf().Any(e => e.Attribute(xml + "base") != null))
                {
                    errors.Add("htmlOrXmlBaseUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #15
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_2_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document     = reportFile.Content as XDocument;
                var factElements = InlineXbrl.FindFacts(document);

                if (factElements.Any(e => e.Attribute("precision") != null))
                {
                    errors.Add("precisionAttributeUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #16
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_1_3_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document        = reportFile.Content as XDocument;
                var xbrli           = document.Root.GetNamespaceOfPrefix("xbrli");
                var segmentElements = document.Root.Descendants(xbrli + "segment");
                if (segmentElements.Any())
                {
                    errors.Add("segmentUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #17
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_4_2_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;
                var html     = document.Root.GetDefaultNamespace();

                if (document.Root.Descendants(html + "base").Any())
                {
                    errors.Add("htmlOrXmlBaseUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #18
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_1_3_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document         = reportFile.Content as XDocument;
                var xbrli            = document.Root.GetNamespaceOfPrefix("xbrli");
                var xbrldi           = document.Root.GetNamespaceOfPrefix("xbrldi");
                var scenarioElements = document.Root.Descendants(xbrli + "scenario");
                var customElements   = scenarioElements.SelectMany(s => s.Descendants().Where(e => e.Name.Namespace != xbrldi));

                if (customElements.Any())
                {
                    errors.Add("scenarioContainsNonDimensionalContent");
                }
            }
            return(errors.Join(","));
        }
コード例 #19
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G3_5_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            var parts = reportFiles.Where(f => f.Content is XDocument).ToArray();

            foreach (var part in parts)
            {
                var document = part.Content as XDocument;
                var html     = document.Root.GetDefaultNamespace();
                if (document.Root.
                    Descendants().
                    Any(d => (d.Attribute("src")?.Value ?? "").StartsWith("http")))
                {
                    errors.Add("inlinXbrlContainsExternalReferences");                     // Typo in the conformance test data
                }
            }
            return(errors.Join(","));
        }
コード例 #20
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_5_3(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix = document.Root.GetNamespaceOfPrefix("ix");
                if (document.Root.
                    Descendants().
                    Where(e => e.Name.Namespace == ix).
                    Any(e => e.Attribute("target") != null))
                {
                    errors.Add("targetAttributeUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #21
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_5_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;
                var html     = document.Root.GetDefaultNamespace();
                if (document.Root.
                    Descendants(html + "img").
                    Select(i => i.Attribute("src").Value).
                    Where(src => !src.StartsWith("http")).                     // external reference handled elsewhere
                    Any(src => !src.StartsWith("data:") || src.IndexOf(";base64,") == -1))
                {
                    errors.Add("embeddedImageNotUsingBase64Encoding");
                }
            }
            return(errors.Join(","));
        }
コード例 #22
0
        /// <summary>
        /// 添加默认关键字
        /// </summary>
        /// <param name="item"></param>
        public virtual void AddAdvancedKeywords(AdvancedKeywordsInfo item)
        {
            if (ValidateAdvancedKeywords(item))
            {
                var keywordsLines = item.Keywords.Content.SplitByLine();
                var hashSet       = new HashSet <string>();
                for (int i = 0; i < keywordsLines.Length; i++)
                {
                    var line = keywordsLines[i].Trim();
                    if (string.IsNullOrEmpty(line.ToString()))
                    {
                        continue;
                    }

                    if (line.IndexOf(' ') != -1)  //if the line has any space
                    //throw new BizException("失败!每行关键字中不能有空格");
                    {
                        throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_HaveSpace"));
                    }

                    hashSet.Add(line);
                }
                item.Keywords.Content = hashSet.Join("\n");

                if (keywordDA.CheckSameAdvancedKeywords(item))
                {
                    //throw new BizException("Keywords 在数据库中已存在!");
                    throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_ExsistKeywords"));
                }
                else
                {
                    int sysNO = keywordDA.AddAdvancedKeywords(item);
                    AdvancedKeywordsLog log = new AdvancedKeywordsLog();
                    log.CompanyCode = item.CompanyCode;
                    log.Operation   = "Create";
                    log.AdvancedKeywordsInfoSysNo = sysNO;
                    log.Description  = "";
                    log.LanguageCode = item.Keywords.LanguageCode;
                    keywordDA.CreateAdvancedKeywordsLog(log);
                }
            }
        }
コード例 #23
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_3_1_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix            = document.Root.GetNamespaceOfPrefix("ix");
                var footnotes     = document.Root.Descendants(ix + "footnote");
                var relationships = document.Root.Descendants(ix + "relationship");

                if (footnotes.Any(f => f.Attribute("footnoteRole") != null) ||
                    relationships.Any(r => r.Attribute("arcrole") != null))
                {
                    errors.Add("nonStandardRoleForFootnote");
                }
            }
            return(errors.Join(","));
        }
コード例 #24
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_2_3(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ixt = document.Root.GetNamespaceOfPrefix("ixt");
                if (!(
                        ixt == null ||
                        ixt.NamespaceName == "http://www.xbrl.org/inlineXBRL/transformation/2015-02-26" ||                 // TR 3
                        ixt.NamespaceName == "http://www.xbrl.org/inlineXBRL/transformation/2019-04-19" ||                 // TR 4 PWD
                        ixt.NamespaceName == "http://www.xbrl.org/inlineXBRL/transformation/2020-02-12"                    // TR 4
                        ))
                {
                    errors.Add("transformRegistry");
                }
            }
            return(errors.Join(","));
        }
コード例 #25
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_5_2(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix  = document.Root.GetNamespaceOfPrefix("ix");
                var xml = document.Root.GetNamespaceOfPrefix("xml");

                var reportLanguage =
                    document.Root.
                    Attribute(xml + "lang")?.
                    Value;

                var textFactLanguages =
                    document.Root.
                    Descendants(ix + "nonNumeric").
                    Select(f =>
                           f.Attribute(xml + "lang")?.Value ?? f.Parent.Attribute(xml + "lang")?.Value).
                    ToHashSet();

                if (string.IsNullOrEmpty(reportLanguage))
                {
                    if (textFactLanguages.Any(l => string.IsNullOrEmpty(l)))
                    {
                        errors.Add("undefinedLanguageForTextFact");
                    }
                }
                else
                {
                    if (textFactLanguages.Where(l => !string.IsNullOrEmpty(l)).Any(l => l != reportLanguage))
                    {
                        errors.Add("taggedTextFactOnlyInLanguagesOtherThanLanguageOfAReport");
                    }
                }
            }
            return(errors.Join(","));
        }
コード例 #26
0
        private void Validate()
        {
            if (this.settings.CommandTree == null)
            {
                throw new ArgumentException("There is no command tree.");
            }

            var root = this.settings.CommandTree.Root;

            if (root == null)
            {
                throw new ArgumentException("The command tree does not have a root.");
            }

            var overridesHelp = false;

            if (root is BranchCommand branchCommand)
            {
                overridesHelp = branchCommand.ChildCommands
                                ?.Any(x => ExplicitHelpRequestIndicators.Contains(x.Label)) == true;
            }
            else if (root is LeafCommand leafCommand)
            {
                overridesHelp = leafCommand.Options
                                ?.Any(x => ExplicitHelpRequestIndicators.Contains(x.Label)) == true;
            }
            else
            {
                ThrowHelper.UnrecognizedType(root);
            }

            if (overridesHelp)
            {
                ThrowHelper.Exception(
                    "Providing the help command explicitly is forbidden, as it collides ",
                    "with the in-built mechanism. Please don't use the following labels ",
                    $"for the root command: [ {ExplicitHelpRequestIndicators.Join(", ")} ].");
            }
        }
コード例 #27
0
        protected void WriteBeginTag(HtmlTextWriter html)
        {
            if (!HasTag())
            {
                return;
            }

            _htmlAttributes.Each((key, attribute) =>
            {
                if (attribute != null)
                {
                    var value       = attribute.Value;
                    var stringValue = value.ToString();
                    html.AddAttribute(key, stringValue, attribute.IsEncoded);
                }
                else
                {
                    // HtmlTextWriter treats a null value as an attribute with no value (e.g., <input required />).
                    html.AddAttribute(key, null, false);
                }
            });

            if (_cssClasses.Count > 0)
            {
                var classValue = _cssClasses.Join(" ");
                html.AddAttribute(CssClassAttribute, classValue);
            }

            if (_customStyles.Count > 0)
            {
                var attValue = _customStyles
                               .Select(x => x.Key + ":" + x.Value)
                               .ToArray().Join(";");

                html.AddAttribute(CssStyleAttribute, attValue);
            }

            html.RenderBeginTag(_tag);
        }
コード例 #28
0
        public static bool HasGlobalKey(this ZoneSystem zoneSystem, string playerName, string key)
        {
            HashSet <string> globalKeys = _globalKeysField.GetValue(zoneSystem) as HashSet <string>;

#if DEBUG
            Log.LogDebug($"Checking for {key} in keys: " + globalKeys.Join());
#endif

            if (globalKeys is null)
            {
                Log.LogWarning("Unable to find/access global keys.");
                return(false);
            }

            if (Enum.TryParse(ConfigurationManager.GeneralConfig.KeyMode.Value, true, out KeyMode keyMode))
            {
                switch (keyMode)
                {
                case KeyMode.Player:
#if DEBUG
                    Log.LogDebug($"Checking key {key} for player {playerName}");
#endif
                    return(EnhancedGlobalKey.HasPlayerKey(playerName, key, globalKeys));

                case KeyMode.Tribe:
#if DEBUG
                    Log.LogDebug($"Checking key {key} for tribe of {playerName}");
#endif
                    return(EnhancedGlobalKey.HasTribeKey(playerName, key, globalKeys));

                default:
                    return(globalKeys.Contains(key));
                }
            }

            //If no key-mode is set, use default global keys.
            Log.LogWarning("Unable to find valid key-mode configuration. Will fallback to Default mode.");
            return(globalKeys.Contains(key));
        }
コード例 #29
0
        private static void Save(Account account, HashSet <int> avatars)
        {
            Dictionary <string, AbstractFieldValue> dataToUpdate = new Dictionary <string, AbstractFieldValue> {
                { TableSpec.FIELD_AVATARS, new ScalarFieldValue(avatars.Join(",")) },
            };
            Dictionary <string, AbstractFieldValue> dataToInsert = new Dictionary <string, AbstractFieldValue>(dataToUpdate)
            {
                { TableSpec.FIELD_ACCOUNTID, new ScalarFieldValue(account.id.ToString()) },
            };

            ChangeSetUtil.ApplyChanges(
                new InsertOrUpdateChange(
                    TableSpec.instance,
                    dataToInsert,
                    dataToUpdate,
                    new ComparisonCondition(
                        TableSpec.instance.getColumnSpec(TableSpec.FIELD_ACCOUNTID),
                        ComparisonType.EQUAL,
                        account.id.ToString()
                        )
                    )
                );
        }
コード例 #30
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_4_1_3(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            foreach (var reportFile in reportFiles.Where(f => f.Content is XDocument))
            {
                var document = reportFile.Content as XDocument;

                var ix        = document.Root.GetNamespaceOfPrefix("ix");
                var fractions = document.Root.Descendants(ix + "fraction");

                if (fractions.Any(t => (t.Attribute("name")?.Value ?? "").IndexOf(':') != -1))
                {
                    errors.Add("fractionDefinedInExtensionTaxonomy");
                }

                if (fractions.Any())
                {
                    errors.Add("fractionElementUsed");
                }
            }
            return(errors.Join(","));
        }
コード例 #31
0
ファイル: EsefReportingManual.cs プロジェクト: dgm9704/Xoxo
        private static string G2_5_4_1(IEnumerable <ReportFile> reportFiles)
        {
            var errors = new HashSet <string>();

            var parts = reportFiles.Where(f => f.Content is XDocument).ToArray();

            if (parts.Length == 1)
            {
                var document = parts.Single().Content as XDocument;
                var html     = document.Root.GetDefaultNamespace();
                if (
                    document.Root.
                    Descendants(html + "link").
                    Any(l => l.Attributes("rel").
                        Any(r => r.Value == "stylesheet")))
                {
                    errors.Add("externalCssFileForSingleIXbrlDocument");
                }
            }
            return(errors.Join(","));
            //Where an Inline XBRL document set contains a single document,
            //the CSS MUST be embedded within the document.
        }
コード例 #32
0
ファイル: YaqaapService.cs プロジェクト: Filimindji/YAQAAP
        public object Any(Vote request)
        {
            Guid userId = UserSession.GetUserId();

            VoteResponse response = new VoteResponse
            {
                Result = ErrorCode.OK,
            };

            TableRepository tableRepository = new TableRepository();

            UserQuestionEntry userQuestionEntry = tableRepository.Get<UserQuestionEntry>(Tables.UserQuestion, request.QuestionId, userId);

            // Création d'un nouveau vote
            if (userQuestionEntry == null)
            {
                DateTime dateTime = DateTime.UtcNow;
                userQuestionEntry = new UserQuestionEntry(request.QuestionId, userId)
                {
                    Creation = dateTime,
                    Modification = dateTime
                };
            }
            else
            {
                userQuestionEntry.Modification = DateTime.UtcNow;
            }

            Guid target = request.VoteTarget == VoteTarget.Question ? request.QuestionId : request.OwnerId;

            HashSet<string> votesUp = new HashSet<string>(userQuestionEntry.VotesUp?.Split('|') ?? new string[] { });
            HashSet<string> votesDown = new HashSet<string>(userQuestionEntry.VotesDown?.Split('|') ?? new string[] { });

            VoteKind oldValue = VoteKind.None;
            if (votesUp.Contains(target.ToString()))
                oldValue = VoteKind.Up;
            else if (votesDown.Contains(target.ToString()))
                oldValue = VoteKind.Down;

            response.VoteKind = request.VoteKind;

            votesUp.Remove(target.ToString());
            votesDown.Remove(target.ToString());

            if (response.VoteKind == oldValue) response.VoteKind = VoteKind.None;
            else
            {
                switch (response.VoteKind)
                {
                    case VoteKind.Up:
                        votesUp.Add(target.ToString());
                        break;
                    case VoteKind.Down:
                        votesDown.Add(target.ToString());
                        break;
                }
            }

            userQuestionEntry.VotesUp = votesUp.Join("|");
            userQuestionEntry.VotesDown = votesDown.Join("|");

            if (request.VoteTarget == VoteTarget.Answer)
            {
                AnswerEntry answerEntry = tableRepository.Get<AnswerEntry>(Tables.Answers, request.QuestionId, request.OwnerId);
                answerEntry.Votes -= (int)oldValue;
                answerEntry.Votes += (int)response.VoteKind;
                tableRepository.InsertOrMerge(answerEntry, Tables.Answers);
                response.VoteValue = answerEntry.Votes;

                // badges
                if (response.VoteKind == VoteKind.Up)
                {
                    switch (answerEntry.Votes)
                    {
                        case 1: AllBadges.Approved.CreateIfNotExist(tableRepository, answerEntry.GetAnswerOwnerId()); break;
                        case 10: AllBadges.NiceAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                        case 25: AllBadges.GoodAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                        case 100: AllBadges.GreatAnswer.CreateForQuestion(tableRepository, answerEntry.GetAnswerOwnerId(), request.QuestionId); break;
                    }
                }
            }
            else
            {
                QuestionEntry questionEntry = tableRepository.Get<QuestionEntry>(Tables.Questions, request.OwnerId, request.QuestionId);
                questionEntry.Votes -= (int)oldValue;
                questionEntry.Votes += (int)response.VoteKind;
                tableRepository.InsertOrMerge(questionEntry, Tables.Questions);
                response.VoteValue = questionEntry.Votes;

                // badges
                if (response.VoteKind == VoteKind.Up)
                {
                    switch (questionEntry.Votes)
                    {
                        case 1: AllBadges.Padawan.CreateIfNotExist(tableRepository, questionEntry.GetOwnerId()); break;
                        case 10: AllBadges.NiceQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                        case 25: AllBadges.GoodQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                        case 100: AllBadges.GreatQuestion.CreateForQuestion(tableRepository, questionEntry.GetOwnerId(), request.QuestionId); break;
                    }
                }
            }

            // insert le vote
            tableRepository.InsertOrReplace(userQuestionEntry, Tables.UserQuestion);

            // badges
            if (response.VoteKind == VoteKind.Up)
                AllBadges.Supporter.CreateIfNotExist(tableRepository, userId);
            else if (response.VoteKind == VoteKind.Down)
                AllBadges.Critic.CreateIfNotExist(tableRepository, userId);

            return response;
        }
コード例 #33
0
        static FileFilterProvider()
        {
			_managedFileExtensions = GetManagedFileExtensions();
			_tagFileRegex = new Regex(@".*\.(" + _managedFileExtensions.Join("|") +")", RegexOptions.IgnoreCase | RegexOptions.Compiled);
			_pruneHistoryMatcherRegex = new Regex(@"^.*\" + PruneOperation.PRUNE_INVENTORY_FILE + "$", RegexOptions.Compiled);
        }