Пример #1
0
    protected void UsersGridView_RowCommand(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "EditCharacter")
        {
            Response.Redirect(string.Format("{0}?CharacterId={1}&Origin={2}", PageReferrer.Page_Admin_EditUser, e.CommandArgument.ToString(), GetOrigin()));
        }
        else if (e.CommandName == "DeleteCharacter")
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
            {
                int characterId = e.CommandArgument.ToString().ToInt();

                var roles = context.PlexUserRoles.FirstOrDefault(x => x.CharacterId == characterId);

                if (roles != null && roles.Roles.Contains("Super"))
                {
                    return;
                }

                context.PlexUsers.DeleteOnSubmit(context.PlexUsers.FirstOrDefault(x => x.CharacterId == characterId));

                context.SubmitChanges();

                DoSearch(SearchTextBox.Text);
            }
        }
    }
Пример #2
0
    protected void RequestLinkButton_Click(object sender, EventArgs e)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PasswordMismatchLabel.Visible = false;
            var user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);

            if (user == null)
            {
                if (PasswordTextBox.Text != ConfirmTextBox.Text || PasswordTextBox.Text.Trim().Length < 6)
                {
                    PasswordMismatchLabel.Visible = true;
                    return;
                }
            }

            var corp = context.Corps.FirstOrDefault(x => x.CorpId == CorpId);

            if (corp != null)
            {
                CreateUser(context, false);
            }
            else
            {
                //New corp
                if (CreateCorp(context))
                {
                    CreateUser(context, true);
                }
            }
        }
    }
Пример #3
0
    protected void AddPlexLinkButton_Click(object sender, EventArgs e)
    {
        int plexInfoId = PlexInfoDropDownList.SelectedValue.ToInt();

        Plex plex;

        if (PlexCorpDropDownList.SelectedValue.ToInt() != CorpId)
        {
            plex = new Plex()
            {
                FCId = CharacterId, PlexInfoId = plexInfoId, PlexingDate = DateTime.UtcNow, PlexingPeriodId = GetPlexingPeriodId(PlexCorpDropDownList.SelectedValue.ToInt()), Participants = GetPilots(), CorpId = int.Parse(PlexCorpDropDownList.SelectedValue)
            };
        }
        else
        {
            plex = new Plex()
            {
                FCId = CharacterId, PlexInfoId = plexInfoId, PlexingDate = DateTime.UtcNow, PlexingPeriodId = PlexingPeriodId, Participants = GetPilots(), CorpId = int.Parse(PlexCorpDropDownList.SelectedValue)
            };
        }

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            context.Plexes.InsertOnSubmit(plex);
            context.SubmitChanges();
        }

        FillPlexes();
    }
Пример #4
0
    protected void ChangePasswordLinkButton_Click(object sender, EventArgs e)
    {
        ErrorLabel.Visible   = false;
        SuccessLabel.Visible = false;
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            var user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);

            if (user != null)
            {
                if (FormsAuthentication.HashPasswordForStoringInConfigFile(OldPasswordTextBox.Text, "md5") == user.Password)
                {
                    if (NewPasswordTextBox.Text != ConfirmPasswordTextBox.Text || NewPasswordTextBox.Text.Length < 6)
                    {
                        ErrorLabel.Visible = true;
                        return;
                    }

                    user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(NewPasswordTextBox.Text, "md5");

                    context.SubmitChanges();
                    SuccessLabel.Visible = true;

                    return;
                }
                else
                {
                    ErrorLabel.Visible = true;
                }
            }
        }
    }
Пример #5
0
    protected void RegisterLinkButton_Click(object sender, EventArgs e)
    {
        PasswordMismatchLabel.Visible = false;

        if (PasswordTextBox.Text != ConfirmPasswordTextBox.Text || PasswordTextBox.Text.Trim().Length < 6)
        {
            PasswordMismatchLabel.Visible = true;
            return;
        }
        else
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
            {
                PlexUser plexUser = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);

                if (plexUser != null)
                {
                    ShowRegistryInformation(false, "Your character have already been registered.");
                    //User already exists, dont register again
                    return;
                }
                else
                {
                    plexUser = new PlexUser();
                };

                plexUser.CharacterId = CharacterId;
                plexUser.CharacterName = CharacterName;
                plexUser.CorpId = CorpId;
                plexUser.CorpName = CorpName;
                plexUser.AllianceId = AllianceId;
                plexUser.AllianceName = AllianceName;
                plexUser.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordTextBox.Text, "md5");
                plexUser.Enabled = true;

                context.PlexUsers.InsertOnSubmit(plexUser);

                Corp corp = context.Corps.FirstOrDefault(x => x.CorpId == CorpId);

                //Check to see if the person registring belongs to a corp that have not previously been added
                if (corp == null)
                {
                    corp = new Corp()
                    {
                        CorpId = CorpId,
                        CorpName = CorpName,
                        AllianceId = AllianceId,
                        AllianceName = AllianceName,
                        Enabled = false
                    };

                    context.Corps.InsertOnSubmit(corp);
                }

                context.SubmitChanges();

                Response.Redirect(PageReferrer.Page_Login);
            }
        }
    }
Пример #6
0
    private void UpdateFleet()
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            if (PlexId.HasValue)
            {
                Plex plex = context.Plexes.FirstOrDefault(x => x.PlexId == PlexId);

                plex.Participants = GetPilots();
            }
            else
            {
                Fleet fleet = context.Fleets.FirstOrDefault(x => x.FcId == CharacterId);

                if (fleet == null)
                {
                    fleet = new Fleet()
                    {
                        FcId = CharacterId, Participants = GetPilots()
                    };
                    context.Fleets.InsertOnSubmit(fleet);
                }
                else
                {
                    fleet.Participants = GetPilots();
                }
            }

            context.SubmitChanges();
        }
    }
Пример #7
0
    private double GetPoints(int?plexingPeriodId)
    {
        if (plexingPeriodId.HasValue)
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
            {
                var plexinfos = from p in context.Plexes
                                join
                                pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                where p.PlexingPeriodId == plexingPeriodId
                                select new { pi.Points };

                if (plexinfos.Count() == 0)
                {
                    return(0);
                }

                int?points = plexinfos.Sum(x => x.Points);

                return(points.HasValue ? points.Value : 0);
            }
        }

        return(0);
    }
Пример #8
0
    protected void PlexGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EditPlex")
        {
            int plexId = e.CommandArgument.ToString().ToInt();

            Response.Redirect(string.Format("{0}?PlexId={1}", PageReferrer.Page_FC_SelectMembers, plexId));
        }
        else if (e.CommandName == "DeletePlex")
        {
            int plexId = e.CommandArgument.ToString().ToInt();

            using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
            {
                Plex p = context.Plexes.FirstOrDefault(x => x.PlexId == plexId);

                if (p != null)
                {
                    context.Plexes.DeleteOnSubmit(p);
                    context.SubmitChanges();
                }

                FillPlexes();
            }
        }
    }
Пример #9
0
    private void LoadPlexingPeriodPayoutData(int plexingPeriodId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (period != null)
            {
                if (period.PayoutSum.HasValue)
                {
                    PayoutTextBox.Text = (period.PayoutSum.Value / 1000000).ToString();
                }
                else
                {
                    PayoutTextBox.Text = string.Empty;
                }

                if (period.CorpTax.HasValue)
                {
                    CorpTaxTextBox.Text = (period.CorpTax.Value).ToString();
                }
                else
                {
                    CorpTaxTextBox.Text = string.Empty;
                }
            }
        }

        CalculatePayout();
    }
Пример #10
0
    private void LoadData()
    {
        RequestedByLabel.Text  = CharacterName;
        CorpNameLabel.Text     = CorpName;
        AllianceNameLabel.Text = AllianceId != -1 ? AllianceName : string.Empty;

        if (AllianceId != -1)
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
            {
                var user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);
                if (user != null)
                {
                    if (!user.Enabled)
                    {
                        InfoPanel.Visible    = true;
                        RequestPanel.Visible = false;
                    }

                    PasswordRow.Visible        = false;
                    ConfirmPasswordRow.Visible = false;
                }

                var alliance = context.Corps.First(x => x.AllianceId == AllianceId);

                if (alliance != null)
                {
                    AllianceTickerTextBox.Text = alliance.AllianceTag;
                }
            }
        }
    }
Пример #11
0
    private void LoadCorporationInfo(int corporationId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            var corps = from c in context.Corps
                        orderby c.CorpName
                        select c;

            CorporationDropDownList.Items.Clear();

            foreach (var corp in corps)
            {
                ListItem item = new ListItem(corp.CorpName, corp.CorpId.ToString());
                CorporationDropDownList.Items.Add(item);
            }


            ListItem corporation = CorporationDropDownList.Items.FindByValue(corporationId.ToString());

            if (corporation != null)
            {
                corporation.Selected = true;
            }
        }
    }
Пример #12
0
 private int GetPlexingPeriodId(int corpId)
 {
     using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
     {
         PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.ToDate == null && x.CorpId == int.Parse(PlexCorpDropDownList.SelectedValue));
         return(period.PlexingPeriodId);
     }
 }
Пример #13
0
    private PlexUser GetUser(int characterId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            var user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == characterId);

            return(user);
        }
    }
Пример #14
0
 private void CalculateEfficiency(bool fromAdmin, bool fromAlliance, bool fromCorp)
 {
     using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
     {
         if ((IsSuperAdmin || IsAdmin) && fromAdmin)
         {
             List <EfficiencyInfo> plexInfos = (from p in context.Plexes
                                                join
                                                pu in context.PlexUsers on p.FCId equals pu.CharacterId
                                                join
                                                pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                                join
                                                co in context.Corps on p.CorpId equals co.CorpId
                                                where p.PlexingDate >= DateTime.Now.Subtract(new TimeSpan(DaysTextBox.Text.ToInt(), 0, 0, 0))
                                                orderby p.PlexingDate descending
                                                select new EfficiencyInfo()
             {
                 PlexingDate = p.PlexingDate.Value, FCName = pu.CharacterName, Participants = p.Participants, Points = pi.Points
             }).ToList();
             LoadPlexingEfficiencyInfo(plexInfos);
         }
         else if (IsAllianceAdmin && fromAlliance)
         {
             List <EfficiencyInfo> plexInfos = (from p in context.Plexes
                                                join
                                                pu in context.PlexUsers on p.FCId equals pu.CharacterId
                                                join
                                                pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                                join
                                                co in context.Corps on p.CorpId equals co.CorpId
                                                where p.PlexingDate >= DateTime.Now.Subtract(new TimeSpan(DaysTextBox.Text.ToInt(), 0, 0, 0)) && co.AllianceId == AllianceId && co.AllianceId != -1
                                                orderby p.PlexingDate descending
                                                select new EfficiencyInfo()
             {
                 PlexingDate = p.PlexingDate.Value, FCName = pu.CharacterName, Participants = p.Participants, Points = pi.Points
             }).ToList();
             LoadPlexingEfficiencyInfo(plexInfos);
         }
         else if (IsCorpAdmin && fromCorp)
         {
             List <EfficiencyInfo> plexInfos = (from p in context.Plexes
                                                join
                                                pu in context.PlexUsers on p.FCId equals pu.CharacterId
                                                join
                                                pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                                join
                                                co in context.Corps on p.CorpId equals co.CorpId
                                                where p.PlexingDate >= DateTime.Now.Subtract(new TimeSpan(DaysTextBox.Text.ToInt(), 0, 0, 0)) && co.CorpId == CorpId
                                                orderby p.PlexingDate descending
                                                select new EfficiencyInfo()
             {
                 PlexingDate = p.PlexingDate.Value, FCName = pu.CharacterName, Participants = p.Participants, Points = pi.Points
             }).ToList();
             LoadPlexingEfficiencyInfo(plexInfos);
         }
     }
 }
Пример #15
0
    private bool AuthenticateUser(string username, string password, out string roles)
    {
        ErrorLabel.Visible    = false;
        PasswordLabel.Visible = false;

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var user = context.PlexUsers.FirstOrDefault(x => x.CharacterName == username);

            if (user == null)
            {
                ErrorLabel.Visible = true;
                roles = "";
                return(false);
            }

            if (user.Password == FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5"))
            {
                if (user.Enabled)
                {
                    CharacterId     = user.CharacterId;
                    CharacterName   = user.CharacterName;
                    CorpId          = user.CorpId;
                    CorpName        = user.CorpName;
                    AllianceId      = user.AllianceId;
                    AllianceName    = user.AllianceName;
                    SolarSystemName = "Uknown";

                    var userRoles = context.PlexUserRoles.FirstOrDefault(x => x.CharacterId == CharacterId);

                    if (userRoles != null)
                    {
                        roles = userRoles.Roles;
                    }
                    else
                    {
                        roles = "";
                    }

                    return(true);
                }
                else
                {
                    ErrorLabel.Visible = true;
                    roles = "";
                    return(false);
                }
            }
        }

        PasswordLabel.Visible = true;

        roles = "";

        return(false);
    }
Пример #16
0
 protected void DisplayPlexingPeriod(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "DisplayPlexingPeriod")
     {
         using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
         {
             LoadPlexingPeriodPayoutData(e.CommandArgument.ToString().ToInt());
             FillPlexingPeriodData(e.CommandArgument.ToString().ToInt());
             ShowEndPeriodButton(!context.PlexingPeriods.First(x => x.PlexingPeriodId == e.CommandArgument.ToString().ToInt()).ToDate.HasValue);
             PlexingPeriodInfoUpdatePanel.Update();
         }
     }
 }
Пример #17
0
    public string GetCorpTag(int corpId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var corp = context.Corps.FirstOrDefault(x => x.CorpId == corpId);

            if (corp != null)
            {
                return(corp.CorpTag);
            }
        }

        return(string.Empty);
    }
Пример #18
0
    private int?GetCharacterIdByName(string name)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var user = context.PlexUsers.FirstOrDefault(x => x.CharacterName == name);

            if (user != null)
            {
                return(user.CharacterId);
            }
        }

        return(null);
    }
Пример #19
0
    private List <PlexingPeriodInfo> LoadPlexingPeriodData(int plexingPeriodId)
    {
        PlexingPeriodInfoGridView.Columns[3].Visible = plexingPeriodId != LastPlexingPeriodId && LastPlexingPeriodId.HasValue;

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);
            IskPerPointAfterTax = period.IskPerPointAfterTax.HasValue ? period.IskPerPointAfterTax.Value : 0;

            var plexPointinfos = from p in context.Plexes
                                 join pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                 where p.PlexingPeriodId == plexingPeriodId
                                 select new { p.PlexingPeriodId, p.PlexId, p.Participants, pi.Points };

            Dictionary <string, PlexingPeriodInfo> dict = new Dictionary <string, PlexingPeriodInfo>();

            double totalPoints = 0;

            foreach (var plexPointInfo in plexPointinfos)
            {
                totalPoints += plexPointInfo.Points;

                string[] pilots = plexPointInfo.Participants.Split(',');

                double pilotPoints = ((double)plexPointInfo.Points) / pilots.Count();

                foreach (string pilot in pilots)
                {
                    if (dict.ContainsKey(pilot.Trim()))
                    {
                        dict[pilot.Trim()].Plexes += 1;
                        dict[pilot.Trim()].Points += pilotPoints;
                        dict[pilot.Trim()].Payout  = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * dict[pilot.Trim()].Points;
                    }
                    else
                    {
                        dict.Add(pilot.Trim(), new PlexingPeriodInfo()
                        {
                            PlexingPeriodId = plexPointInfo.PlexingPeriodId, PlexId = plexPointInfo.PlexId, Name = pilot.Trim(), Plexes = 1, Points = pilotPoints, Payout = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * pilotPoints
                        });
                    }
                }
            }

            TotalPointsLabel.Text = Math.Round(totalPoints, 2).ToString();

            return(dict.Values.ToList());
        }
    }
Пример #20
0
    private void FillPlexingPeriodDateData(int plexingPeriodId, DateTime date)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod pp = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (pp != null)
            {
                PlexingPeriodDateLabel.Text = GetPlexingPeriodTitle(pp.FromDate, pp.ToDate, GetCorpTag(pp.CorpId));
            }
        }

        List <MyPlexingPeriodInfo> infos = LoadPlexingPeriodData(plexingPeriodId, date);

        PlexingPeriodInfoGridView.DataSource = infos;
        PlexingPeriodInfoGridView.DataBind();
    }
Пример #21
0
    private List <PlexingPeriodInfo> LoadPlexingPeriodData(int plexingPeriodId, DateTime date)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            DateTime lastDate = new DateTime(date.Year, date.Month, date.Day).AddDays(1);

            var plexPointinfos = from p in context.Plexes
                                 join pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                 where p.PlexingPeriodId == plexingPeriodId && p.PlexingDate >= date && p.PlexingDate <= lastDate //&& p.CorpId == CorpId
                                 select new { p.PlexId, p.Participants, pi.Points };

            Dictionary <string, PlexingPeriodInfo> dict = new Dictionary <string, PlexingPeriodInfo>();

            double totalPoints = 0;

            foreach (var plexPointInfo in plexPointinfos)
            {
                totalPoints += plexPointInfo.Points;
                string[] pilots = plexPointInfo.Participants.Split(',');

                double pilotPoints = ((double)plexPointInfo.Points) / pilots.Count();

                foreach (string pilot in pilots)
                {
                    if (dict.ContainsKey(pilot.Trim()))
                    {
                        dict[pilot.Trim()].Plexes += 1;
                        dict[pilot.Trim()].Points += pilotPoints;
                        dict[pilot.Trim()].Payout  = (IskPerPointAfterTax / 1000000) * dict[pilot.Trim()].Points;
                    }
                    else
                    {
                        dict.Add(pilot.Trim(), new PlexingPeriodInfo()
                        {
                            PlexId = plexPointInfo.PlexId, CharacterId = GetCharacterIdByName(pilot.Trim()), Name = pilot.Trim(), Plexes = 1, Points = pilotPoints, Payout = (IskPerPointAfterTax / 1000000) * pilotPoints
                        });
                    }
                }
            }

            TotalPointsLabel.Text = totalPoints.ToString();

            return(dict.Values.ToList());
        }
    }
Пример #22
0
    protected void EndPeriodLinkButton_Click(object sender, EventArgs e)
    {
        CalculatePayout(true);

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == PlexingPeriodId);

            if (period != null)
            {
                period.ToDate = DateTime.Now;
            }

            context.SubmitChanges();

            ShowEndPeriodButton(false);
        }
    }
Пример #23
0
    private void FillFleet()
    {
        PilotListBox.Items.Clear();

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            Fleet fleet = context.Fleets.FirstOrDefault(x => x.FcId == CharacterId);

            if (fleet != null)
            {
                string[] pilots = fleet.Participants.Split(',');

                foreach (string pilot in pilots)
                {
                    PilotListBox.Items.Add(new ListItem(pilot, pilot));
                }
            }
        }
    }
Пример #24
0
    private void FillPlexes()
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var p = from plexes in context.Plexes
                    join plexUsers in context.PlexUsers on plexes.FCId equals plexUsers.CharacterId
                    join plexInfo in context.PlexInfos on plexes.PlexInfoId equals plexInfo.PlexId
                    join corps in context.Corps on plexes.CorpId equals corps.CorpId
                    where (IsAdmin && plexes.PlexingDate >= GetCurrentPlexingPeriodDate()) || (plexes.FCId == CharacterId && plexes.PlexingDate >= GetCurrentPlexingPeriodDate()) || (IsAllianceAdmin && plexes.PlexingDate >= GetCurrentPlexingPeriodDate() && corps.AllianceId == AllianceId) || (IsCorpAdmin && plexes.PlexingDate >= GetCurrentPlexingPeriodDate() && plexes.CorpId == CorpId)
                    orderby plexes.PlexingDate descending
                    select new PlexListInfo()
            {
                PlexId = plexes.PlexId, FCName = plexUsers.CharacterName, PlexName = plexInfo.Name, PlexingDate = plexes.PlexingDate.Value, Participants = plexes.Participants, Points = plexInfo.Points, CorpTag = corps.CorpTag
            };

            PlexGridView.DataSource = p;
            PlexGridView.DataBind();
        }
    }
Пример #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PasswordMismatchLabel.Visible = false;

            using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
            {
                if (EveTrusted)
                {
                    var character = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);
                    if (character != null)
                    {
                        ShowRegistryInformation(false, "Your character have already been registered.");
                        return;
                    }

                    var rules = from p in context.Rules
                                where p.Id == AllianceId || p.Id == CorpId || p.Id == CharacterId
                                select p;


                    //foreach (var rule in rules)
                    //{
                    //    if (rule.Allowed.HasValue && !rule.Allowed.Value)
                    //    {
                    //        ShowRegistryInformation(rules.Count() > 0, "You are not part of an alliance, corporation or character that are allowed to register.");
                    //        return;
                    //    }
                    //}

                    ShowRegistryInformation(rules.Count() > 0, "You are not part of an alliance, corporation or character that are allowed to register.");
                }
                else
                {
                    ShowRegistryInformation(false, "You are not using IGB trust. IGB trust is required to register. If you have trusted this site and still can't register try removing trust, close the IGB and try again. For some reason IGB trust fails sometimes for unknown reasons.");
                }
            }

            UsernameLabel.Text = CharacterName;
        }
    }
Пример #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PasswordMismatchLabel.Visible = false;

            using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
            {
                if (EveTrusted)
                {
                    var character = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);
                    if (character != null)
                    {
                        ShowRegistryInformation(false, "Your character have already been registered.");
                        return;
                    }

                    var rules = from p in context.Rules
                                where p.Id == AllianceId || p.Id == CorpId || p.Id == CharacterId
                                select p;

                    //foreach (var rule in rules)
                    //{
                    //    if (rule.Allowed.HasValue && !rule.Allowed.Value)
                    //    {
                    //        ShowRegistryInformation(rules.Count() > 0, "You are not part of an alliance, corporation or character that are allowed to register.");
                    //        return;
                    //    }
                    //}

                    ShowRegistryInformation(rules.Count() > 0, "You are not part of an alliance, corporation or character that are allowed to register.");
                }
                else
                {
                    ShowRegistryInformation(false, "You are not using IGB trust. IGB trust is required to register. If you have trusted this site and still can't register try removing trust, close the IGB and try again. For some reason IGB trust fails sometimes for unknown reasons.");
                }
            }

            UsernameLabel.Text = CharacterName;
        }
    }
Пример #27
0
    private void CalculatePayout(bool savePayout)
    {
        double payout  = PayoutTextBox.Text.ToDouble() * 1000000;
        double percent = CorpTaxTextBox.Text.ToDouble();

        double payoutAfterTax = payout * (1 - (percent / 100));
        double tax            = (payout - payoutAfterTax);
        double points         = GetPoints(PlexingPeriodId);

        IskPerPoint         = payout / points;
        IskPerPointAfterTax = payoutAfterTax / points;

        TotalPayoutLabel.Text = FormatMillions(Math.Round((payoutAfterTax / 1000000), 2).ToString());
        TaxLabel.Text         = FormatMillions(Math.Round(tax / 1000000, 0).ToString());

        IskPerPointLabel.Text         = FormatMillions(Math.Round(IskPerPoint / 1000000, 3).ToString());
        IskPerPointAfterTaxLabel.Text = FormatMillions(Math.Round(IskPerPointAfterTax / 1000000, 3).ToString());

        TaxUpdatePanel.Update();
        TotalPayOutUpdatePanel.Update();
        IskPerPointAfterTaxUpdatePanel.Update();

        if (savePayout)
        {
            using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
            {
                PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == PlexingPeriodId);

                if (period != null)
                {
                    period.PayoutSum           = payout;
                    period.CorpTax             = CorpTaxTextBox.Text.ToDouble();
                    period.Points              = points;
                    period.IskPerPoint         = IskPerPoint;
                    period.IskPerPointAfterTax = IskPerPointAfterTax;

                    context.SubmitChanges();
                }
            }
        }
    }
Пример #28
0
    private DateTime GetCurrentPlexingPeriodDate()
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            DateTime result         = DateTime.Now;
            var      plexingPeriods = from p in context.PlexingPeriods
                                      where p.ToDate == null
                                      orderby p.FromDate
                                      select p;

            foreach (var period in plexingPeriods)
            {
                if (period.FromDate < result)
                {
                    result = period.FromDate.Value;
                }
            }

            return(result);
        }
    }
Пример #29
0
    private void FillPlexingPeriodData(int plexingPeriodId)
    {
        PlexingPeriodId = plexingPeriodId;
        CalculatePayout();
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexingPeriod pp = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (pp != null)
            {
                PlexingPeriodDateLabel.Text = GetPlexingPeriodTitle(pp.FromDate, pp.ToDate, GetCorpTag(pp.CorpId));
            }
        }

        List <PlexingPeriodInfo> infos = LoadPlexingPeriodData(plexingPeriodId);

        infos.Sort();

        PlexingPeriodInfoGridView.DataSource = infos;
        PlexingPeriodInfoGridView.DataBind();
    }
Пример #30
0
    private bool CreateCorp(PlexingFleetDataContext context)
    {
        Rule rule = context.Rules.FirstOrDefault(x => x.Id.Value == CorpId);

        if (rule == null)
        {
            rule = new Rule()
            {
                Id       = CorpId,
                RuleName = CorpName,
                Allowed  = true,
            };

            context.Rules.InsertOnSubmit(rule);
        }
        else
        {
            if (rule.Allowed.HasValue && !rule.Allowed.Value)
            {
                return(false);
            }
        }

        Corp corp = new Corp()
        {
            CorpId       = this.CorpId,
            CorpName     = this.CorpName,
            CorpTag      = this.CorpTickerTextBox.Text,
            AllianceId   = this.AllianceId == 0 ? -1 : this.AllianceId,
            AllianceName = this.AllianceName,
            AllianceTag  = this.AllianceTickerTextBox.Text,
            Enabled      = true
        };

        context.Corps.InsertOnSubmit(corp);

        context.SubmitChanges();

        return(true);
    }
Пример #31
0
    private void FillPlexInfos()
    {
        PlexInfoDropDownList.Items.Clear();

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var plexes = from p in context.PlexInfos
                         orderby p.Name
                         select p;

            foreach (var plex in plexes)
            {
                PlexInfoDropDownList.Items.Add(new ListItem(plex.Name, plex.PlexId.ToString()));
            }

            if (IsAdmin)
            {
                //Display all active corps
                var corps = (from c in context.Corps
                             where c.Enabled
                             orderby c.CorpName
                             select c).Distinct();

                AddPlexCorps(corps.ToList());
            }
            else
            {
                //Only display active corps in the alliance
                var corps = (from c in context.Corps
                             where c.Enabled && ((c.AllianceId == AllianceId && AllianceId != -1) || c.CorpId == CorpId)
                             orderby c.CorpName
                             select c).Distinct();

                AddPlexCorps(corps.ToList());
            }

            PlexCorpDropDownList.Items.FindByValue(CorpId.ToString()).Selected = true;
        }
    }
Пример #32
0
    private void DoSearch(string searchString)
    {
        SearchResultListBox.Items.Clear();

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            if (SearchTextBox.Text.Trim() == string.Empty)
            {
                var users = from u in context.PlexUsers
                            where u.Enabled && ((AllianceId == u.AllianceId && AllianceId != -1) || (CorpId == u.CorpId))
                            orderby u.CharacterName
                            select u;

                foreach (var user in users)
                {
                    if (PilotListBox.Items.FindByValue(user.CharacterName) == null)
                    {
                        SearchResultListBox.Items.Add(new ListItem(user.CharacterName, user.CharacterName));
                    }
                }
            }
            else
            {
                var users = from u in context.PlexUsers
                            where u.CharacterName.Contains(SearchTextBox.Text) && (u.Enabled) && ((AllianceId == u.AllianceId && AllianceId != -1) || (CorpId == u.CorpId))
                            orderby u.CharacterName
                            select u;

                foreach (var user in users)
                {
                    if (PilotListBox.Items.FindByValue(user.CharacterName) == null)
                    {
                        SearchResultListBox.Items.Add(new ListItem(user.CharacterName, user.CharacterName));
                    }
                }
            }
        }
    }
Пример #33
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;
                }
            }
        }
    }
Пример #34
0
    private List<PlexingPeriodInfo> LoadPlexingPeriodData(int plexingPeriodId, DateTime date)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod period = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);
            IskPerPointAfterTax = period.IskPerPointAfterTax.HasValue ? period.IskPerPointAfterTax.Value : 0;

            DateTime lastDate = new DateTime(date.Year, date.Month, date.Day).AddDays(1);

            var plexPointinfos = from p in context.Plexes
                                 join pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                 where p.PlexingPeriodId == plexingPeriodId && p.PlexingDate >= date && p.PlexingDate <= lastDate
                                 select new { p.PlexingPeriodId, p.PlexId, p.Participants, pi.Points };

            Dictionary<string, PlexingPeriodInfo> dict = new Dictionary<string, PlexingPeriodInfo>();

            double totalPoints = 0;

            foreach (var plexPointInfo in plexPointinfos)
            {
                totalPoints += plexPointInfo.Points;
                string[] pilots = plexPointInfo.Participants.Split(',');

                double pilotPoints = ((double)plexPointInfo.Points) / pilots.Count();

                foreach (string pilot in pilots)
                {
                    if (dict.ContainsKey(pilot.Trim()))
                    {
                        dict[pilot.Trim()].Plexes += 1;
                        dict[pilot.Trim()].Points += pilotPoints;
                        dict[pilot.Trim()].Payout = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * dict[pilot.Trim()].Points;
                    }
                    else
                    {
                        dict.Add(pilot.Trim(), new PlexingPeriodInfo() { PlexId = plexPointInfo.PlexId, Name = pilot.Trim(), Plexes = 1, Points = pilotPoints, Payout = ((IskPerPointAfterTax.HasValue ? IskPerPointAfterTax.Value : 0) / 1000000) * pilotPoints });
                    }
                }
            }

            TotalPointsLabel.Text = totalPoints.ToString();

            return dict.Values.ToList();
        }
    }
Пример #35
0
    protected void PlexingPeriodInfoGridView_RowCommand(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "EditPlex")
        {
            Response.Redirect(string.Format("{0}?PlexId={1}&ReturnUrl={2}&PlexingPeriodId={3}&CharacterName={4}", PageReferrer.Page_FC_SelectMembers, e.CommandArgument.ToString(), PageReferrer.Page_User_PlexingPeriod, PlexingPeriodId, CharName));
        }
        else if (e.CommandName == "DeletePlex")
        {
            int plexId = e.CommandArgument.ToString().ToInt();

            using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
            {
                Plex p = context.Plexes.FirstOrDefault(x => x.PlexId == plexId);

                if (p != null)
                {
                    p.Participants = p.Participants.Replace(string.Format("{0}, ", CharName), "").Replace(string.Format(", {0}", CharName), "");
                    p.Participants = p.Participants.Replace(CharName, "");

                    if (string.IsNullOrEmpty(p.Participants.Trim()))
                        context.Plexes.DeleteOnSubmit(p);
                    context.SubmitChanges();
                }

                if (SelectedDate.HasValue)
                {
                    FillPlexingPeriodDateData(PlexingPeriodId, SelectedDate.Value);
                }
                else
                {
                    FillPlexingPeriodData(PlexingPeriodId);
                }
            }
        }
    }
Пример #36
0
    private void FillPlexingPeriodDateData(int plexingPeriodId, DateTime date)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            PlexingPeriod pp = context.PlexingPeriods.FirstOrDefault(x => x.PlexingPeriodId == plexingPeriodId);

            if (pp != null)
            {
                PlexingPeriodDateLabel.Text = GetPlexingPeriodTitle(pp.FromDate, pp.ToDate, GetCorpTag(pp.CorpId));
            }
        }

        List<MyPlexingPeriodInfo> infos = LoadPlexingPeriodData(plexingPeriodId, date);

        PlexingPeriodInfoGridView.DataSource = infos;
        PlexingPeriodInfoGridView.DataBind();
    }
Пример #37
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;
                }
            }
        }
    }
Пример #38
0
    private List<MyPlexingPeriodInfo> LoadPlexingPeriodData(int plexingPeriodId, DateTime date)
    {
        List<MyPlexingPeriodInfo> result = new List<MyPlexingPeriodInfo>();

        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            DateTime lastDate = new DateTime(date.Year, date.Month, date.Day).AddDays(1);

            var plexPointinfos = from p in context.Plexes
                                 join pi in context.PlexInfos on p.PlexInfoId equals pi.PlexId
                                 join u in context.PlexUsers on p.FCId equals u.CharacterId
                                 where p.PlexingPeriodId == plexingPeriodId && p.Participants.Contains(CharName) && p.PlexingDate >= date && p.PlexingDate <= lastDate
                                 select new { p.PlexId, pi.Name, u.CharacterName, p.PlexingDate, p.Participants, pi.Points };

            double totalpoints = 0;

            foreach (var plexPointInfo in plexPointinfos)
            {
                string[] pilots = plexPointInfo.Participants.Split(',');

                double pilotPoints = ((double)plexPointInfo.Points) / pilots.Count();

                totalpoints += pilotPoints;

                result.Add(new MyPlexingPeriodInfo() { PlexId = plexPointInfo.PlexId, PlexName = plexPointInfo.Name, PlexingDate = plexPointInfo.PlexingDate.Value, FC = plexPointInfo.CharacterName, Points = pilotPoints, Participants = pilots.Count() });
            }

            TotalPointsLabel.Text = Math.Round(totalpoints, 2).ToString();

            result.Sort();

            return result;
        }
    }
Пример #39
0
    public string GetCorpTag(int corpId)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(WebConfigurationManager.ConnectionStrings["PlexManagerConnectionString"].ConnectionString))
        {
            var corp = context.Corps.FirstOrDefault(x => x.CorpId == corpId);

            if (corp != null)
                return corp.CorpTag;
        }

        return string.Empty;
    }