예제 #1
0
        public void SeriesNameTryParseCanOutNullValue()
        {
            SeriesName result;

            SeriesName.TryParse("Allsvenska/", out result);
            Assert.IsNull(result);
        }
예제 #2
0
        /// <see cref="IConcertRepository.SaveSeriesName" />
        public SeriesName SaveSeriesName(SeriesName model)
        {
            var pr = db.Series.FirstOrDefault(o => o.Name.ToLower().Equals(model.Name.ToLower()));

            if (pr != null)
            {
                return(pr);
            }
            if (model.Id == 0)
            {
                db.Entry(model).State = EntityState.Added;
            }
            else if (model.Id > 0)
            {
                pr = db.Series.FirstOrDefault(o => o.Id == model.Id);
                db.Entry(pr).CurrentValues.SetValues(model);
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(null);
            }
            return(model);
        }
예제 #3
0
        public void SeriesNameTryParseCanOutValidResult()
        {
            SeriesName result;

            SeriesName.TryParse("Allsvenskan", out result);
            Assert.IsTrue(result.Value == "Allsvenskan");
        }
        private Style PolyLineStyle(SeriesName series)
        {
            /* XAML equiv:
             *
             *  <Window.Resources>
             *      <Style x:Key="MainPolylineStyle" TargetType="Polyline">
             *          <Setter Property="StrokeThickness" Value="5"/>
             *      </Style>
             *  </Window.Resources>
             *
             */

            double thickness = 0;

            switch (series)
            {
            case SeriesName.Main:
                thickness = Properties.Settings.Default.Plot_Main_Thickness;
                break;

            case SeriesName.Secondary:
                thickness = Properties.Settings.Default.Plot_Secondary_Thickness;
                break;

            case SeriesName.Third:
                thickness = Properties.Settings.Default.Plot_Tertiary_Thickness;
                break;
            }

            var style = new Style(typeof(Polyline));

            style.Setters.Add(new Setter(Polyline.StrokeThicknessProperty, thickness));

            return(style);
        }
예제 #5
0
        // Check if series in database
        public static void CreateSeries(bool DeleteOldSeries = true)
        {
            if (DeleteOldSeries)
            {
                var oldseries = DS.db.GetAll <SeriesName>(a => true) as IEnumerable <SeriesName>;
                DS.db.DeleteMany(oldseries);
            }

            var modulesWithSeries = DS.db.GetAll <ModuleErp>(a => true) as IEnumerable <ModuleErp>;

            if (modulesWithSeries != null)
            {
                foreach (var module in modulesWithSeries)
                {
                    try
                    {
                        var serie = new SeriesName();
                        serie.Libelle = module.Name;
                        serie.Sufix   = new string(module.Libelle.Take(2).ToArray()).ToUpper() + "-########";
                        serie.Indexe  = 1;
                        serie.ForceIgniorValidatUnique = true;
                        serie.Save();
                        module.SeriesNames = new List <SeriesName>();
                        module.SeriesNames.Add(serie);
                        module.SeriesDefault = serie.Id;
                        module.Save();
                    }
                    catch (Exception s)
                    {
                        DataHelpers.Logger.LogError(s);
                        throw s;
                    }
                }
            }
        }
예제 #6
0
        public void SeriesNameIsComparableByValue()
        {
            var arenaNameOne = new SeriesName("Allsvenskan");
            var arenaNameTwo = new SeriesName("Allsvenskan");

            Assert.AreEqual(arenaNameOne, arenaNameTwo);
            Assert.IsTrue(arenaNameOne == arenaNameTwo);
        }
예제 #7
0
 public Series(MatchDuration matchDuration, NumberOfTeams numberOfTeams, SeriesName name)
 {
     this.Id            = Guid.NewGuid();
     this.SeriesName    = name;
     this.NumberOfTeams = numberOfTeams;
     this.MatchDuration = matchDuration;
     this.TeamIds       = new HashSet <Guid>();
     this.Schedule      = new List <Match>();
 }
예제 #8
0
        public void SeriesNameWorksWithHashSet()
        {
            var seriesNameOne = new SeriesName("Allsvenskan");
            var seriesNameTwo = new SeriesName("Allsvenskan");
            var nameHashSet   = new HashSet <SeriesName> {
                seriesNameOne, seriesNameTwo
            };

            Assert.IsTrue(nameHashSet.Count == 1);
        }
예제 #9
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (SeriesName.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("seriesName", SeriesName);
            }
            if (Color.HasValue)
            {
                writer.WriteAttributeString("color", Color.Value.ToHexString());
            }
            if (Alpha.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("alpha", Alpha);
            }
            if (Ratio.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("ratio", Ratio);
            }
            if (ShowValues.HasValue)
            {
                writer.WriteAttributeString("showValues", ShowValues.GetHashCode().ToString());
            }
            if (Dashed.HasValue)
            {
                writer.WriteAttributeString("dashed", Dashed.GetHashCode().ToString());
            }
            if (IncludeInLegend.HasValue)
            {
                writer.WriteAttributeString("includeInLegend", IncludeInLegend.GetHashCode().ToString());
            }

            if (RenderAs.HasValue)
            {
                writer.WriteAttributeString("renderAs", RenderAs.ToString());
            }
            if (ParentYAxis.HasValue)
            {
                writer.WriteAttributeString("parentYAxis", ParentYAxis.ToString());
            }

            if (_anchorAttr != null)
            {
                _anchorAttr.GenerateXmlAttributes(writer);
            }
            if (_lineAttr != null)
            {
                _lineAttr.GenerateXmlAttributes(writer);
            }
        }
예제 #10
0
        public static void CreateSeries(ModuleErp module, long currentIndex, bool createAnyway = false)
        {
            if (!module.HasSeries && createAnyway == false)
            {
                return;
            }

            var serie = new SeriesName();

            serie.Libelle = _(module.Name);

            string suffix  = "";
            string libelle = module.Libelle;

            var trim = libelle.Split(' ');

            if (trim.Length == 1)
            {
                var word = trim.FirstOrDefault();
                suffix += word.Substring(0, 2).ToUpper();
            }
            else
            {
                foreach (var item in trim)
                {
                    if (item.Length > 2)
                    {
                        var firstCharcter = new string(item.Take(1).ToArray());
                        suffix += firstCharcter.ToUpper();
                    }
                }
            }

            serie.Sufix  = suffix + "-########";
            serie.Indexe = currentIndex++;
            serie.ForceIgniorValidatUnique = true;
            serie.Save();
            // module.SeriesNames = new List<SeriesName>();
            module.SeriesNames.Add(serie);
            if (module.SeriesDefault.IsValide() == false)
            {
                module.SeriesDefault = serie.Id;
            }
            module.ForceIgniorValidatUnique = true;
            module.Save();
        }
        private Style DataPointStyle(SeriesName series, bool showDataPoints)
        {
            /* XAML equiv:
             *
             *  <Window.Resources>
             *      <Style x:Key="MainLineDataPointStyle" TargetType="DVC:LineDataPoint">
             *      <Setter Property="Background" Value="Red" />
             *      <Setter Property="BorderBrush" Value="White"/>
             *      <Setter Property="BorderThickness" Value="1"/>
             *      <Setter Property="IsTabStop" Value="False"/>
             *      </Style>
             *  </Window.Resources>
             *
             */

            var style = new Style(typeof(DataPoint));

            switch (series)
            {
            case SeriesName.Main:
                style.Setters.Add(new Setter(DataPoint.BackgroundProperty, _brushMainLine));
                style.Setters.Add(new Setter(DataPoint.BorderBrushProperty, _brushMainLine));
                break;

            case SeriesName.Secondary:
                style.Setters.Add(new Setter(DataPoint.BackgroundProperty, _brushSecondaryLine));
                style.Setters.Add(new Setter(DataPoint.BorderBrushProperty, _brushSecondaryLine));
                break;

            case SeriesName.Third:
                style.Setters.Add(new Setter(DataPoint.BackgroundProperty, _brushThirdLine));
                style.Setters.Add(new Setter(DataPoint.BorderBrushProperty, _brushThirdLine));
                break;
            }

            style.Setters.Add(new Setter(DataPoint.BorderThicknessProperty, new Thickness(1)));

            if (!showDataPoints)
            {
                style.Setters.Add(new Setter(DataPoint.TemplateProperty, null));  // Nulling DataPoint.TemplateProperty turns OFF the data points
            }
            return(style);
        }
예제 #12
0
        private void AddSeriesTeam(object obj)
        {
            var timeSpanMatchDuration = new TimeSpan(0, Convert.ToInt32(matchDuration), 0);

            var seriesSeriesName    = new SeriesName(this.seriesName);
            var seriesNumberOfTeams = new NumberOfTeams(this.selectedNumberOfTeams);
            var seriesMatchDuration = new MatchDuration(timeSpanMatchDuration);

            Series seriesToAdd = new Series(seriesMatchDuration, seriesNumberOfTeams, seriesSeriesName);

            foreach (var team in teamsToAddToSeries)
            {
                this.seriesService.AddTeamToSeries(seriesToAdd, team.Id);
                team.UpdatePlayerIds();
            }

            this.seriesService.Add(seriesToAdd);

            Messenger.Default.Send <Series>(seriesToAdd);
            ResetData();
            this.SeriesAddedConfirmText = "Series Added!";
        }
예제 #13
0
        /// <summary>
        /// 속성들을 Xml Attribute로 생성합니다.
        /// </summary>
        /// <param name="writer">Attribute를 쓸 Writer</param>
        public override void GenerateXmlAttributes(System.Xml.XmlWriter writer)
        {
            base.GenerateXmlAttributes(writer);

            if (Id.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("id", Id);
            }
            if (AllowDrag.HasValue)
            {
                writer.WriteAttributeString("allowDrag", AllowDrag.Value.GetHashCode().ToString());
            }
            if (SeriesName.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("SeriesName", SeriesName);
            }
            if (Color.HasValue)
            {
                writer.WriteAttributeString("Color", Color.Value.ToHexString());
            }
            if (Alpha.IsNotWhiteSpace())
            {
                writer.WriteAttributeString("Alpha", Alpha);
            }
            if (ShowValues.HasValue)
            {
                writer.WriteAttributeString("ShowValues", ShowValues.Value.GetHashCode().ToString());
            }
            if (IncludeInLegend.HasValue)
            {
                writer.WriteAttributeString("IncludeInLegend", IncludeInLegend.Value.GetHashCode().ToString());
            }

            if (_plotBorderAttr != null)
            {
                _plotBorderAttr.GenerateXmlAttributes(writer);
            }
        }
예제 #14
0
        public void SeriesNameTryParseCanReturnFalse()
        {
            SeriesName result;

            Assert.IsFalse(SeriesName.TryParse("Allsvens)an", out result));
        }
예제 #15
0
 public void SeriesNameLengthIsValid()
 {
     var seriesName = new SeriesName("Det långa namnet på en serie som är för långt");
 }
예제 #16
0
        public void SeriesNameIsEqualToEntry()
        {
            var seriesName = new SeriesName("Allsvenskan");

            Assert.IsTrue(seriesName.Value == "Allsvenskan");
        }
예제 #17
0
 public static SeriesNameModel GetSeriesNameModel(SeriesName model)
 {
     return(new SeriesNameModel {
         Id = model.Id, Name = model.Name
     });
 }