예제 #1
0
    private void FillPlexingPeriods(int?plexingPeriodId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var plexingPeriods = from p in context.PlexingPeriods
                                 orderby p.FromDate descending
                                 select new PlexingPeriodListInfo()
            {
                PlexingPeriodId = p.PlexingPeriodId, FromDate = p.FromDate, ToDate = p.ToDate, CorpId = p.CorpId, CorpTag = GetCorpTag(p.CorpId)
            };

            List <PlexingPeriodListInfo> periods = plexingPeriods.ToList <PlexingPeriodListInfo>();

            foreach (var period in periods)
            {
                var plexingDates = from p in context.Plexes
                                   where p.PlexingPeriodId == period.PlexingPeriodId && p.Participants.Contains(CharName)
                                   orderby p.PlexingDate descending
                                   select p;

                Dictionary <string, DateInfos> infos = new Dictionary <string, DateInfos>();

                foreach (var plex in plexingDates)
                {
                    string datestring = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day).ToString();
                    if (!infos.ContainsKey(datestring))
                    {
                        infos.Add(datestring, new DateInfos()
                        {
                            Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                        });
                        period.DateInfos.Add(new DateInfos()
                        {
                            Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                        });
                    }
                }

                //period.DateInfos = infos.Values.ToList();
            }

            PlexingPeriodsDataList.DataSource = periods;
            PlexingPeriodsDataList.DataBind();

            if (plexingPeriods.Count() > 0)
            {
                if (plexingPeriodId.HasValue)
                {
                    FillPlexingPeriodData(plexingPeriodId.Value);
                    PlexingPeriodId = plexingPeriodId.Value;
                }
                else
                {
                    //FillPlexingPeriodData(plexingPeriods.First().PlexingPeriodId);
                    //PlexingPeriodId = plexingPeriods.First().PlexingPeriodId;
                    if (plexingPeriods.FirstOrDefault(x => x.CorpId == CorpId) != null)
                    {
                        FillPlexingPeriodData(plexingPeriods.FirstOrDefault(x => x.CorpId == CorpId).PlexingPeriodId);
                    }
                    else
                    {
                        FillPlexingPeriodData(plexingPeriods.First().PlexingPeriodId);
                    }

                    PlexingPeriodId = plexingPeriods.First().PlexingPeriodId;
                    //LastPlexingPeriodId = PlexingPeriodId;
                }
            }
        }
    }
예제 #2
0
    private void FillPlexingPeriods(int?plexingPeriodId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var plexingPeriods = from p in context.PlexingPeriods
                                 join c in context.Corps on p.CorpId equals c.CorpId
                                 orderby p.FromDate descending
                                 select new PlexingPeriodListInfo()
            {
                PlexingPeriodId = p.PlexingPeriodId, FromDate = p.FromDate, ToDate = p.ToDate, CorpId = p.CorpId, CorpTag = c.CorpTag
            };

            List <PlexingPeriodListInfo> periods = new List <PlexingPeriodListInfo>();// = plexingPeriods.ToList<PlexingPeriodListInfo>();

            foreach (var period in plexingPeriods)
            {
                if (IsSuperAdmin)
                {
                    periods.Add(period);
                }
                else
                {
                    if (period.CorpId == CorpId)
                    {
                        periods.Add(period);
                    }
                }
            }

            foreach (var period in periods)
            {
                var plexingDates = from p in context.Plexes
                                   where p.PlexingPeriodId == period.PlexingPeriodId
                                   orderby p.PlexingDate descending
                                   select p;

                Dictionary <string, DateInfos> infos = new Dictionary <string, DateInfos>();

                foreach (var plex in plexingDates)
                {
                    string datestring = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day).ToString();
                    if (!infos.ContainsKey(datestring))
                    {
                        infos.Add(datestring, new DateInfos()
                        {
                            Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                        });
                        period.DateInfos.Add(new DateInfos()
                        {
                            Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                        });
                    }
                }

                //period.DateInfos = infos.Values.ToList();
            }

            PlexingPeriodsDataList.DataSource = periods;
            PlexingPeriodsDataList.DataBind();

            if (plexingPeriods.Count() > 0)
            {
                if (plexingPeriodId.HasValue)
                {
                    FillPlexingPeriodData(plexingPeriodId.Value);
                    PlexingPeriodId = plexingPeriodId.Value;
                }
                else
                {
                    var period = plexingPeriods.FirstOrDefault(x => x.CorpId == CorpId);
                    if (period != null)
                    {
                        LoadPlexingPeriodPayoutData(period.PlexingPeriodId);
                        FillPlexingPeriodData(period.PlexingPeriodId);
                        PlexingPeriodId = period.PlexingPeriodId;
                        LastPeriodId    = PlexingPeriodId;
                    }
                }
            }

            var plexingPeriod = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == PlexingPeriodId);

            if (plexingPeriod != null)
            {
                ShowEndPeriodButton(!plexingPeriod.ToDate.HasValue);
            }
        }
    }
예제 #3
0
    private void FillPlexingPeriods(int?plexingPeriodId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var plexingPeriods = from p in context.PlexingPeriods
                                 join c in context.Corps on p.CorpId equals c.CorpId
                                 where (c.AllianceId == AllianceId && c.AllianceId != -1) || c.CorpId == CorpId
                                 orderby p.FromDate descending
                                 select new PlexingPeriodListInfo()
            {
                PlexingPeriodId = p.PlexingPeriodId, FromDate = p.FromDate, ToDate = p.ToDate, CorpId = p.CorpId, CorpTag = c.CorpTag
            };

            List <PlexingPeriodListInfo> periods = plexingPeriods.ToList <PlexingPeriodListInfo>();

            int periodCounter = 0;
            int maxPeriods    = 2;
            foreach (var period in periods)
            {
                var plexingDates = from p in context.Plexes
                                   where p.PlexingPeriodId == period.PlexingPeriodId
                                   orderby p.PlexingDate descending
                                   select p;

                Dictionary <string, DateInfos> infos = new Dictionary <string, DateInfos>();

                foreach (var plex in plexingDates)
                {
                    string datestring = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day).ToString();
                    if (!infos.ContainsKey(datestring))
                    {
                        infos.Add(datestring, new DateInfos()
                        {
                            Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                        });

                        //Only add all plexing dates if you are an admin
                        if (periodCounter < maxPeriods || IsAdmin)
                        {
                            period.DateInfos.Add(new DateInfos()
                            {
                                Date = new DateTime(plex.PlexingDate.Value.Year, plex.PlexingDate.Value.Month, plex.PlexingDate.Value.Day), PlexingPeriodId = period.PlexingPeriodId
                            });
                        }
                    }
                }
                periodCounter += 1;
                //period.DateInfos = infos.Values.ToList();
            }

            PlexingPeriodsDataList.DataSource = periods;
            PlexingPeriodsDataList.DataBind();

            if (plexingPeriods.Count() > 0)
            {
                if (plexingPeriodId.HasValue)
                {
                    FillPlexingPeriodData(plexingPeriodId.Value);
                    PlexingPeriodId = plexingPeriodId.Value;
                }
                else
                {
                    if (plexingPeriods.FirstOrDefault(x => x.CorpId == CorpId) != null)
                    {
                        FillPlexingPeriodData(plexingPeriods.FirstOrDefault(x => x.CorpId == CorpId).PlexingPeriodId);
                    }
                    else
                    {
                        FillPlexingPeriodData(plexingPeriods.First().PlexingPeriodId);
                    }

                    PlexingPeriodId     = plexingPeriods.First().PlexingPeriodId;
                    LastPlexingPeriodId = PlexingPeriodId;
                }
            }
        }
    }