Exemplo n.º 1
0
        private static ResultMetadata LogWrongLocalizedAssemblyPathErrors(
            string logPath,
            Dictionary <string, LocalizedAssemblyResult> collection,
            ResultType errorType,
            string errorDescription)
        {
            var result = new ResultMetadata()
            {
                Type        = errorType,
                Description = errorDescription,
                ErrorCount  = 0
            };

            // log errors for when the assembly is not localized in expected languages and at expected paths
            var errors = collection.Keys.Where(key => !collection[key].HasExpectedLocalizedAssemblies());

            if (errors.Any())
            {
                var path = Path.Combine(logPath, errorType + ".json");
                result.ErrorCount = collection.Keys.Count;
                result.Path       = path;

                Console.WriteLine("================================================================================================================");
                Console.WriteLine($"Type: {errorType} - {errorDescription}");
                Console.WriteLine($"Count: {errors.Count()}");
                Console.WriteLine($"Path: {path}");
                Console.WriteLine("================================================================================================================");

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                using (StreamWriter file = File.AppendText(path))
                {
                    var array = new JArray();
                    foreach (var error in errors)
                    {
                        array.Add(collection[error].ToJson());
                    }

                    var json = new JObject
                    {
                        ["Type"]        = errorType.ToString(),
                        ["Description"] = errorDescription,
                        ["errors"]      = array
                    };

                    var settings = new JsonSerializerSettings()
                    {
                        Formatting = Formatting.Indented
                    };

                    var serializer = JsonSerializer.Create(settings);
                    serializer.Serialize(file, json);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private static ResultMetadata LogErrors(
            string logPath,
            IEnumerable <StringCompareResult> errors,
            ResultType errorType,
            string errorDescription)
        {
            var result = new ResultMetadata()
            {
                Type        = errorType,
                Description = errorDescription,
                ErrorCount  = 0
            };

            if (errors.Any())
            {
                var path = Path.Combine(logPath, errorType + ".json");
                result.ErrorCount = errors.Count();
                result.Path       = path;

                Console.WriteLine("================================================================================================================");
                Console.WriteLine($"Type: {errorType} - {errorDescription}");
                Console.WriteLine($"Count: {errors.Count()}");
                Console.WriteLine($"Path: {path}");
                Console.WriteLine("================================================================================================================");

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                using (StreamWriter file = File.AppendText(path))
                {
                    var array = new JArray();
                    foreach (var error in errors)
                    {
                        array.Add(error.ToJson());
                    }

                    var json = new JObject
                    {
                        ["Type"]        = errorType.ToString(),
                        ["Description"] = errorDescription,
                        ["errors"]      = array
                    };

                    var settings = new JsonSerializerSettings()
                    {
                        Formatting = Formatting.Indented
                    };

                    var serializer = JsonSerializer.Create(settings);
                    serializer.Serialize(file, json);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        private static ResultMetadata LogNonLocalizedAssemblyErrors(
            string logPath,
            Dictionary <string, LocalizedAssemblyResult> collection,
            ResultType errorType,
            string errorDescription)
        {
            var result = new ResultMetadata()
            {
                Type        = errorType,
                Description = errorDescription,
                ErrorCount  = 0
            };

            // log errors for when the assembly is not localized in enough languages
            var errors = collection.Keys.Where(key => !collection[key].HasAllLocales());

            if (errors.Any())
            {
                var path = Path.Combine(logPath, errorType + ".csv");
                result.ErrorCount = errors.Count();
                result.Path       = path;

                Console.WriteLine("================================================================================================================");
                Console.WriteLine($"Type: {errorType} - {errorDescription}");
                Console.WriteLine($"Count: {errors.Count()}");
                Console.WriteLine($"Path: {path}");
                Console.WriteLine("================================================================================================================");

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                using (StreamWriter w = File.AppendText(path))
                {
                    w.WriteLine("Dll Name, cs, de, es, fr, it, ja, ko, pl, pt-br, ru, tr, zh-hans, zh-hant");
                    foreach (var error in errors)
                    {
                        var assemblyLocales = collection[error].Locales;
                        var line            = new StringBuilder();
                        line.Append(error);
                        line.Append(",");
                        foreach (var language in LocaleUtility.LocaleStrings)
                        {
                            line.Append(!assemblyLocales.Contains(language) ? "Error" : "");
                            line.Append(",");
                        }

                        w.WriteLine(line.ToString());
                    }
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        private static ResultMetadata LogNonLocalizedStringsDedupedErrors(
            string logPath,
            Dictionary <string, Dictionary <string, List <string> > > collection,
            ResultType errorType,
            string errorDescription)
        {
            var result = new ResultMetadata()
            {
                Type        = errorType,
                Description = errorDescription,
                ErrorCount  = 0
            };

            if (collection.Keys.Any())
            {
                var path = Path.Combine(logPath, errorType + ".csv");
                result.ErrorCount = collection.Keys.Count;
                result.Path       = path;

                Console.WriteLine("================================================================================================================");
                Console.WriteLine($"Type: {errorType} - {errorDescription}");
                Console.WriteLine($"Count: {collection.Keys.Count}");
                Console.WriteLine($"Path: {path}");
                Console.WriteLine("================================================================================================================");

                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                using (StreamWriter w = File.AppendText(path))
                {
                    w.WriteLine("Dll Name, Resource Name, cs, de, es, fr, it, ja, ko, pl, pt-br, ru, tr, zh-hans, zh-hant");
                    foreach (var dll in collection.Keys)
                    {
                        foreach (var resource in collection[dll].Keys)
                        {
                            var line = new StringBuilder();
                            line.Append(dll);
                            line.Append(",");
                            line.Append(resource);
                            line.Append(",");
                            foreach (var language in LocaleUtility.LocaleStrings)
                            {
                                line.Append(collection[dll][resource].Contains(language) ? "Error" : "");
                                line.Append(",");
                            }

                            w.WriteLine(line.ToString());
                        }
                    }
                }
            }

            return(result);
        }