Example #1
0
                public SummaryOutput GetOuput()
                {
                    SummaryOutput output = new SummaryOutput
                    {
                        Ignored = Ignored,
                        Special = IsSpecial
                    };

                    if (IsSpecial)
                    {
                        output.Details = $"{episodeGotCount} / {episodeCount}";
                        if (Ignored)
                        {
                            output.Color = Color.LightSlateGray;
                        }
                        else if (episodeGotCount == episodeCount)
                        {
                            output.Color = Color.Green;
                        }
                        else if (episodeGotCount == 0)
                        {
                            output.Color = Color.Red;
                        }
                        else
                        {
                            output.Color = Color.Orange;
                        }
                    }
                    else
                    {
                        // show amount of aired eps
                        output.Details = $"{episodeGotCount} / {episodeAiredCount}";
                        // show amount of unaired eps
                        if (episodeCount > episodeAiredCount)
                        {
                            output.Details += $" ({episodeCount - episodeAiredCount})";
                        }

                        if (Ignored)
                        {
                            output.Color = Color.LightSlateGray;
                        }
                        else if (episodeGotCount == episodeAiredCount)
                        {
                            output.Color = episodeCount - episodeAiredCount == 0 ? Color.Green : Color.GreenYellow;
                        }
                        else
                        {
                            output.Color = episodeGotCount == 0 ? Color.Red : Color.Orange;
                        }
                    }
                    return(output);
                }
Example #2
0
                public SummaryOutput GetOuput()
                {
                    SummaryOutput output = new SummaryOutput();

                    if (this.SeasonNumber == 0)
                    {
                        output.Details = $"{this.episodeGotCount} / {this.episodeCount}";
                        if (this.episodeGotCount == this.episodeCount)
                        {
                            output.Color = Color.Green;
                        }
                        else if (this.episodeGotCount == 0)
                        {
                            output.Color = Color.Red;
                        }
                        else
                        {
                            output.Color = Color.Orange;
                        }
                    }
                    else
                    {
                        // show amount of aired eps
                        output.Details = $"{this.episodeGotCount} / {this.episodeAiredCount}";
                        // show amount of unaired eps
                        output.Details += this.episodeCount - this.episodeAiredCount == 0 ? string.Empty : $" ({this.episodeCount - this.episodeAiredCount})";

                        if (this.episodeGotCount == this.episodeAiredCount)
                        {
                            output.Color = (this.episodeCount - this.episodeAiredCount) == 0 ? Color.Green : Color.GreenYellow;
                        }
                        else
                        {
                            output.Color = this.episodeGotCount == 0 ? Color.Red : Color.Orange;
                        }
                    }
                    return(output);
                }
Example #3
0
                public SummaryOutput getOuput()
                {
                    SummaryOutput output = new SummaryOutput();

                    if (this.seasonNumber == 0)
                    {
                        output.details = string.Format("{0} / {1}", this.episodeGotCount, this.episodeCount);
                        if (this.episodeGotCount == this.episodeCount)
                        {
                            output.color = Color.Green;
                        }
                        else if (this.episodeGotCount == 0)
                        {
                            output.color = Color.Red;
                        }
                        else
                        {
                            output.color = Color.Orange;
                        }
                    }
                    else
                    {
                        // show amount of aired eps
                        output.details = string.Format("{0} / {1}", this.episodeGotCount, this.episodeAiredCount);
                        // show amount of unaired eps
                        output.details += this.episodeCount - this.episodeAiredCount == 0 ? string.Empty : string.Format(" ({0})", this.episodeCount - this.episodeAiredCount);

                        if (this.episodeGotCount == this.episodeAiredCount)
                        {
                            output.color = (this.episodeCount - this.episodeAiredCount) == 0 ? Color.Green : Color.GreenYellow;
                        }
                        else
                        {
                            output.color = this.episodeGotCount == 0 ? Color.Red : Color.Orange;
                        }
                    }
                    return(output);
                }
        public SummaryOutput Post(DataInput raw)
        {
            IList <string> messages = new List <string>();

            try
            {
                if (raw != null && raw.value != null)
                {
                    IList <XMLElement> ListOfXMLElements = Extract(raw.value);
                    SummaryOutput = Validate(ListOfXMLElements);
                }
                else
                {
                    if (raw == null)
                    {
                        messages.Add("The data is not in JSON format.");
                    }
                    if (raw != null && raw.value == null)
                    {
                        messages.Add("The 'value' property is missing in the JSON string.");
                    }

                    SummaryOutput.results = Constants.FAILED;
                    SummaryOutput.message = messages;
                }
            }
            catch (Exception ex)
            {
                messages.Add(ex.Message);
                SummaryOutput.results = Constants.FAILED;
                SummaryOutput.message = messages;
                return(SummaryOutput);
            }

            return(SummaryOutput);
        }
        private SummaryOutput Validate(IList <XMLElement> list)
        {
            SummaryOutput  output   = new SummaryOutput();
            DataExtracted  data     = new DataExtracted();
            IList <string> messages = new List <string>();

            foreach (XMLElement xml in list)
            {
                if (xml.Name == Constants.TOTAL && xml.Value == Constants.UNKNOWN)
                {
                    output.results = Constants.FAILED;
                    messages.Add("The whole data import is rejected because of a missing <" + xml.Name + "> element.");
                    break;
                }
                else if (xml.Value == Constants.OPENING_TAG_NOT_FOUND)
                {
                    output.results = Constants.FAILED;
                    messages.Add("The whole data import is rejected because a closing tag </" + xml.Name + "> has no corresponding opening tag.");
                    break;
                }
                else if (xml.Value == Constants.CLOSING_TAG_NOT_FOUND)
                {
                    output.results = Constants.FAILED;
                    messages.Add("The whole data import is rejected because an opening tag <" + xml.Name + "> has no corresponding closing tag.");
                    break;
                }
                else if (xml.Name == Constants.COST_CENTRE && xml.Value == Constants.UNKNOWN)
                {
                    messages.Add("The whole data import is succesful eventhough <" + xml.Name + "> is missing. the value is set to unknown.");
                }

                if (string.IsNullOrEmpty(output.results))
                {
                    data = Save(xml.Name, (xml.Value == Constants.UNKNOWN && xml.Name != Constants.COST_CENTRE) ? null : xml.Value, data);
                }
            }

            if (output.results == Constants.FAILED)
            {
                if (messages.Count == 0)
                {
                    messages.Add("The whole data import is rejected.");
                }
            }
            else
            {
                output.data = new DataOutput
                {
                    extracted  = data,
                    calculated = Calculate(data.total)
                };

                if (string.IsNullOrEmpty(output.results))
                {
                    output.results = Constants.SUCCESS;
                }

                if (messages.Count == 0)
                {
                    messages.Add("The whole data import is succesful.");
                }
            }

            output.message = messages;

            return(output);
        }