示例#1
0
        public string GetAllSegments()
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                ITeamRepository    teamRepository = new TeamRepository(context);
                ISegmentRepository segRepository  = new SegmentRepository(context);


                // Remove current structure from the database scheme level
                IDivisionRepository repository = new DivisionRepository(context);

                AppDivisionSegmentsService service = new AppDivisionSegmentsService(teamRepository, segRepository, repository);

                var segments = service.GetAllSegments();
                // Divid all the segments into array
                int len = segments.Count / 6 == 0?segments.Count:segments.Count + 1;

                AppSegment[][] array = new AppSegment[len][];
                for (int i = 0; i < 6; i++)
                {
                    array[i] = new AppSegment[] { };
                }
                return(jss.Serialize(segments));
            }
        }
示例#2
0
        public static AppSegment ToAppSegement(this Segment seg)
        {
            var childTeam = seg.Teamsites.Select(_ => new AppSegment()
            {
                TeamGuid = _.TeamGuid, title = _.TeamName, key = _.TeamGuid.ToString(), teampic = _.TeamLogo, PrarentSegementId = _.SegmentId.GetValueOrDefault(), tooltip = "team"
            }).ToArray();
            List <AppSegment> childSegments = new List <AppSegment>();


            // If the child segment has child team we need to add it into the list
            if (seg.ChildSegements != null)
            {
                List <AppSegment> childSegmentTeamsNode = new List <AppSegment>();

                foreach (var c in seg.ChildSegements)
                {
                    AppSegment se = new AppSegment()
                    {
                        title = c.Name, PrarentSegementId = c.ParentId.GetValueOrDefault(), tooltip = "segment"
                    };


                    var ts = c.Teamsites.Select(_ => new AppSegment()
                    {
                        title             = _.TeamName, teampic = _.TeamLogo, key = _.TeamGuid.ToString(),
                        PrarentSegementId = (_.SegmentId.HasValue)? _.SegmentId.Value:-1, tooltip = "team"
                    }).ToArray();
                    foreach (var t in ts)
                    {
                        childSegmentTeamsNode.Add(t);
                    }
                    se.children = childSegmentTeamsNode;


                    childSegments.Add(se);
                }
            }

            var finalChilds = new List <AppSegment>();

            foreach (var c in childTeam)
            {
                finalChilds.Add(c);
            }
            foreach (var c in childSegments)
            {
                finalChilds.Add(c);
            }

            return(new AppSegment()
            {
                Id = seg.Id,
                SegmentGuid = seg.SegmentGuid,
                title = seg.Name,
                key = "seg" + seg.SegmentGuid,
                tooltip = "segment",
                children = finalChilds
            });
        }
示例#3
0
 public static Segment ToSegement(this AppSegment seg)
 {
     return(new Segment()
     {
         SegmentGuid = seg.SegmentGuid,
         Name = seg.title,
         DivisionId = seg.DivisionId
     });
 }