Esempio n. 1
0
        private void BuildTable(CountTotal total, IWordCountBatchTaskSettings settings, XElement parent)
        {
            if (settings.UseLineCount)
            {
                if (settings.ReportLockedSeperately)
                {
                    parent.Add(CreateXElement(CountTotal.Locked, RateType.Locked, total, settings));
                }

                parent.Add(CreateXElement(CountTotal.Total, RateType.Total, total, settings));
            }
            else
            {
                if (settings.ReportLockedSeperately)
                {
                    parent.Add(CreateXElement(CountTotal.Locked, RateType.Locked, total, settings));
                }

                parent.Add(CreateXElement(CountTotal.PerfectMatch, RateType.PerfectMatch, total, settings));
                parent.Add(CreateXElement(CountTotal.ContextMatch, RateType.ContextMatch, total, settings));
                parent.Add(CreateXElement(CountTotal.Repetitions, RateType.Repetitions, total, settings));
                parent.Add(CreateXElement(CountTotal.CrossFileRepetitions, RateType.CrossFileRepetitions, total, settings));
                parent.Add(CreateXElement(CountTotal.OneHundredPercent, RateType.OneHundred, total, settings));
                parent.Add(CreateXElement(CountTotal.NinetyFivePercent, RateType.NinetyFive, total, settings));
                parent.Add(CreateXElement(CountTotal.EightyFivePercent, RateType.EightyFive, total, settings));
                parent.Add(CreateXElement(CountTotal.SeventyFivePercent, RateType.SeventyFive, total, settings));
                parent.Add(CreateXElement(CountTotal.FiftyPercent, RateType.Fifty, total, settings));
                parent.Add(CreateXElement(CountTotal.New, RateType.New, total, settings));
                parent.Add(CreateXElement(CountTotal.Total, RateType.Total, total, settings));
            }
        }
Esempio n. 2
0
        public KudosuInfo(Bindable <User> user)
        {
            this.user.BindTo(user);
            CountSection total;
            CountSection avaliable;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            Masking          = true;
            CornerRadius     = 3;
            Children         = new Drawable[]
            {
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FillDirection.Horizontal,
                    Spacing          = new Vector2(5, 0),
                    Children         = new[]
                    {
                        total     = new CountTotal(),
                        avaliable = new CountAvailable()
                    }
                }
            };
            this.user.ValueChanged += u =>
            {
                total.Count     = u.NewValue?.Kudosu.Total ?? 0;
                avaliable.Count = u.NewValue?.Kudosu.Available ?? 0;
            };
        }
Esempio n. 3
0
        private static string GetCountType(CountTotal total, IWordCountBatchTaskSettings settings)
        {
            string countType = total.CountMethod == CountUnit.Character ? "Characters" : "Words";

            if (settings.UseLineCount)
            {
                countType = "Number of Lines";
            }

            return(countType);
        }
Esempio n. 4
0
        public void BuildTotalTable(CountTotal total, IWordCountBatchTaskSettings settings)
        {
            string countType = GetCountType(total, settings);

            var parent = new XElement("GrandTotal",
                                      new XAttribute("CountType", countType));

            BuildTable(total, settings, parent);

            root.Add(parent);
        }
Esempio n. 5
0
 private void CountButton_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
 {
     BubbleEvent = true;
     try
     {
         InfoBoxes.UseMessageBox(CountTotal.Count(EditText0, Matrix0));
     }
     catch (Exception e)
     {
         InfoBoxes.UseMessageBox(e.Message);
     }
 }
Esempio n. 6
0
        public static string Generate(List <ISegmentWordCounter> counters, IWordCountBatchTaskSettings settings)
        {
            var grandTotal = new CountTotal();
            var fileData   = new List <CountTotal>();

            CollectFileData(counters, settings, grandTotal, fileData);

            grandTotal.CountMethod = fileData.First().CountMethod;
            grandTotal.FileName    = "Total";

            return(CreateReport(grandTotal, fileData, settings));
        }
Esempio n. 7
0
        public KudosuInfo(Bindable <User> user)
        {
            this.user.BindTo(user);
            CountSection total;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            Masking          = true;
            CornerRadius     = 3;
            Child            = total = new CountTotal();

            this.user.ValueChanged += u => total.Count = u.NewValue?.Kudosu.Total ?? 0;
        }
Esempio n. 8
0
        private static void CollectFileData(List <ISegmentWordCounter> counters, IWordCountBatchTaskSettings settings, CountTotal grandTotal, List <CountTotal> fileData)
        {
            foreach (var counter in counters)
            {
                var info = new CountTotal();

                AccumulateCountData(settings, counter, info);

                fileData.Add(info);
                grandTotal.Increment(info);
                grandTotal.UnlockedSpaceCountTotal += info.UnlockedSpaceCountTotal;
                grandTotal.LockedSpaceCountTotal   += info.LockedSpaceCountTotal;
            }
        }
        public void BuildTotalTable(CountTotal total, IWordCountBatchTaskSettings settings)
        {
            Contract.Requires <ArgumentNullException>(total != null);
            Contract.Requires <ArgumentNullException>(settings != null);

            string countType = GetCountType(total, settings);

            var parent = new XElement("GrandTotal",
                                      new XAttribute("CountType", countType));

            BuildTable(total, settings, parent);

            root.Add(parent);
        }
Esempio n. 10
0
        private static string CreateReport(CountTotal grandTotal, List <CountTotal> fileData, IWordCountBatchTaskSettings settings)
        {
            var builder = new ReportBuilder();

            // Build grand total table
            builder.BuildTotalTable(grandTotal, settings);

            // Build individual file tables
            foreach (var data in fileData)
            {
                builder.BuildFileTable(data, settings);
            }

            return(builder.GetReport());
        }
        public static string Generate(List <ISegmentWordCounter> counters, IWordCountBatchTaskSettings settings)
        {
            Contract.Requires <ArgumentNullException>(counters != null);
            Contract.Requires <ArgumentNullException>(settings != null);

            CountTotal        grandTotal = new CountTotal();
            List <CountTotal> fileData   = new List <CountTotal>();

            CollectFileData(counters, settings, grandTotal, fileData);

            grandTotal.CountMethod = fileData.First().CountMethod;
            grandTotal.FileName    = "Total";

            return(CreateReport(grandTotal, fileData, settings));
        }
Esempio n. 12
0
        private static void AccumulateCountData(IWordCountBatchTaskSettings settings, ISegmentWordCounter counter, CountTotal info)
        {
            info.FileName = counter.FileName;

            SetCountMethod(settings, counter, info);

            foreach (var segInfo in counter.FileCountInfo.SegmentCounts)
            {
                var origin = segInfo.TranslationOrigin;

                if (origin == null)
                {
                    info.Increment(CountTotal.New, segInfo.CountData);
                }
                else
                {
                    if (settings.ReportLockedSeperately && segInfo.IsLocked)
                    {
                        info.Increment(CountTotal.Locked, segInfo.CountData);
                    }
                    else if (origin.OriginType == "document-match")
                    {
                        info.Increment(CountTotal.PerfectMatch, segInfo.CountData);
                    }
                    else if (origin.IsRepeated)
                    {
                        info.Increment(CountTotal.Repetitions, segInfo.CountData);
                    }
                    else if (origin.MatchPercent == 100)
                    {
                        if (origin.TextContextMatchLevel == Sdl.FileTypeSupport.Framework.NativeApi.TextContextMatchLevel.SourceAndTarget)
                        {
                            info.Increment(CountTotal.ContextMatch, segInfo.CountData);
                        }
                        else
                        {
                            info.Increment(CountTotal.OneHundredPercent, segInfo.CountData);
                        }
                    }
                    else if (origin.MatchPercent >= 95)
                    {
                        info.Increment(CountTotal.NinetyFivePercent, segInfo.CountData);
                    }
                    else if (origin.MatchPercent >= 85)
                    {
                        info.Increment(CountTotal.EightyFivePercent, segInfo.CountData);
                    }
                    else if (origin.MatchPercent >= 75)
                    {
                        info.Increment(CountTotal.SeventyFivePercent, segInfo.CountData);
                    }
                    else if (origin.MatchPercent >= 50)
                    {
                        info.Increment(CountTotal.FiftyPercent, segInfo.CountData);
                    }
                    else
                    {
                        info.Increment(CountTotal.New, segInfo.CountData);
                    }
                }

                if (!(settings.ReportLockedSeperately && segInfo.IsLocked))
                {
                    info.Increment(CountTotal.Total, segInfo.CountData);
                }

                if (segInfo.IsLocked)
                {
                    info.LockedSpaceCountTotal += segInfo.SpaceCount;
                }
                else
                {
                    info.UnlockedSpaceCountTotal += segInfo.SpaceCount;
                }
            }
        }
Esempio n. 13
0
        private static void SetCountMethod(IWordCountBatchTaskSettings settings, ISegmentWordCounter counter, CountTotal info)
        {
            Language language = null;

            if (settings.UseSource)
            {
                language = counter.FileCountInfo.SourceInfo;
            }
            else
            {
                language = counter.FileCountInfo.TargetInfo;
            }

            if (language.UsesCharacterCounts)
            {
                info.CountMethod = CountUnit.Character;
            }
            else
            {
                info.CountMethod = CountUnit.Word;
            }
        }
Esempio n. 14
0
        private static void SetCountMethod(IWordCountBatchTaskSettings settings, ISegmentWordCounter counter, CountTotal info)
        {
            Language language;

            language = settings.UseSource ? counter.FileCountInfo.SourceInfo : counter.FileCountInfo.TargetInfo;

            info.CountMethod = language.UsesCharacterCounts ? CountUnit.Character : CountUnit.Word;
        }
Esempio n. 15
0
        private XElement CreateXElement(string item, RateType type, CountTotal total, IWordCountBatchTaskSettings settings)
        {
            var countData = total.Totals[item];
            var count     = (total.CountMethod == CountUnit.Character) ? countData.Characters : countData.Words;
            var segments  = countData.Segments;

            var invoiceItem = settings.InvoiceRates[(int)type];

            decimal rate = 0M;

            if (!string.IsNullOrEmpty(invoiceItem.Rate))
            {
                rate = decimal.Parse(invoiceItem.Rate, System.Globalization.NumberStyles.Currency, CultureRepository.Cultures[settings.Culture]);
            }

            var amount    = count * rate;
            int output    = 0;
            int totalChar = 0;

            if (settings.UseLineCount)
            {
                count  = CalculateLineCount(type, settings, countData, total, ref output, ref totalChar);
                amount = count * rate;
            }

            totalAmount += amount;

            if (RateType.Total != type)
            {
                if (settings.UseLineCount)
                {
                    return(new XElement(item,
                                        new XAttribute("Segments", segments),
                                        new XAttribute("TotalCharacters", totalChar),
                                        new XAttribute("CharactersPerLine", output),
                                        new XAttribute("Count", count),
                                        new XAttribute("Rate", string.IsNullOrWhiteSpace(invoiceItem.Rate) ? "0" : invoiceItem.Rate),
                                        new XAttribute("Amount", amount.ToString("C2", CultureRepository.Cultures[settings.Culture]))));
                }
                else
                {
                    return(new XElement(item,
                                        new XAttribute("Segments", segments),
                                        new XAttribute("Count", count),
                                        new XAttribute("Rate", string.IsNullOrWhiteSpace(invoiceItem.Rate) ? "0" : invoiceItem.Rate),
                                        new XAttribute("Amount", amount.ToString("C2", CultureRepository.Cultures[settings.Culture]))));
                }
            }
            else
            {
                var t = totalAmount;
                totalAmount = 0M;

                if (settings.UseLineCount)
                {
                    return(new XElement(item,
                                        new XAttribute("Segments", segments),
                                        new XAttribute("TotalCharacters", totalChar),
                                        new XAttribute("CharactersPerLine", output),
                                        new XAttribute("Count", count),
                                        new XAttribute("Rate", string.IsNullOrWhiteSpace(invoiceItem.Rate) ? "0" : invoiceItem.Rate),
                                        new XAttribute("Amount", t.ToString("C2", CultureRepository.Cultures[settings.Culture]))));
                }
                else
                {
                    return(new XElement(item,
                                        new XAttribute("Segments", segments),
                                        new XAttribute("Count", count),
                                        new XAttribute("Rate", ""),
                                        new XAttribute("Amount", t.ToString("C2", CultureRepository.Cultures[settings.Culture]))));
                }
            }
        }
Esempio n. 16
0
        private static int CalculateLineCount(RateType type, IWordCountBatchTaskSettings settings, CountData countData, CountTotal total, ref int output, ref int totalChar)
        {
            if (!string.IsNullOrWhiteSpace(settings.CharactersPerLine))
            {
                if (int.TryParse(settings.CharactersPerLine, out output))
                {
                    if (type == RateType.Locked && settings.ReportLockedSeperately)
                    {
                        if (settings.IncludeSpaces)
                        {
                            totalChar = countData.Characters + total.LockedSpaceCountTotal;
                        }
                        else
                        {
                            totalChar = countData.Characters;
                        }
                    }
                    else
                    {
                        if (settings.IncludeSpaces)
                        {
                            if (settings.ReportLockedSeperately)
                            {
                                totalChar = countData.Characters + total.UnlockedSpaceCountTotal;
                            }
                            else
                            {
                                totalChar = countData.Characters + total.UnlockedSpaceCountTotal + total.LockedSpaceCountTotal;
                            }
                        }
                        else
                        {
                            totalChar = countData.Characters;
                        }
                    }

                    var num = Math.Round(Convert.ToDecimal(totalChar) / Convert.ToDecimal(output), MidpointRounding.AwayFromZero);
                    return(Convert.ToInt32(num));
                }
            }

            return(0);
        }