Esempio n. 1
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;
                }
            }
        }
    }
Esempio n. 2
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();
            }
        }
    }
Esempio n. 3
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();
        }
    }
Esempio n. 4
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);
            }
        }
    }
Esempio n. 5
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();
    }
Esempio n. 6
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);
        }
    }
Esempio n. 7
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();
                }
            }
        }
    }
Esempio n. 8
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);
    }
Esempio n. 9
0
    protected void UpdateLinkButton_Click(object sender, EventArgs e)
    {
        using (PlexingFleetDataContext context = new PlexingFleetDataContext(ConnectionString))
        {
            PlexUser user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterIdLabel.Text.ToInt());

            user.Enabled = !BannedCheckBox.Checked;

            if (user.CorpId != CorporationDropDownList.SelectedValue.ToInt())
            {
                var corp = context.Corps.FirstOrDefault(x => x.CorpId == CorporationDropDownList.SelectedValue.ToInt());

                if (corp != null)
                {
                    user.CorpId       = corp.CorpId;
                    user.AllianceId   = corp.AllianceId;
                    user.CorpName     = corp.CorpName;
                    user.AllianceName = corp.AllianceName;
                }
            }

            if (NewPasswordTextBox.Text.Trim() != string.Empty && NewPasswordTextBox.Text == ConfirmPasswordTextBox.Text)
            {
                user.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(NewPasswordTextBox.Text, "md5");
            }

            PlexUserRole role = context.PlexUserRoles.FirstOrDefault(x => x.CharacterId == CharacterIdLabel.Text.ToInt());

            SetPermission(context, role, SuperAdminCheckBox.Checked, "Super");
            SetPermission(context, role, AdministratorCheckBox.Checked, "Admin");
            SetPermission(context, role, AllianceCheckBox.Checked, "Alliance");
            SetPermission(context, role, CorporationCheckBox.Checked, "Corporation");

            context.SubmitChanges();
        }

        Response.Redirect(string.Format("{0}?{1}=1", PageReferrer.Page_Admin_Users, Origin));
    }
    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);
                }
            }
        }
    }
Esempio n. 11
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);
            }
        }
    }
Esempio n. 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoginButton.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");

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

                    if (user != null)
                    {
                        UsernameTextBox.Text = CharacterName;

                        if (user.AllianceId != AllianceId || user.CorpId != CorpId)
                        {
                            Corp corp = context.Corps.FirstOrDefault(x => x.CorpId == CorpId);

                            if (corp == null)
                            {
                                Response.Redirect(PageReferrer.Page_Anonymous_AccessRequest);
                            }

                            //If the user have switched alliance and/or corporation update the database with the new information.
                            user.AllianceId   = AllianceId;
                            user.AllianceName = AllianceName;
                            user.CorpId       = CorpId;
                            user.CorpName     = CorpName;

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

                            //The user have switched to a new corp that have not been registered yet
                            if (corp == null)
                            {
                                corp              = new Corp();
                                corp.CorpId       = CorpId;
                                corp.CorpName     = CorpName;
                                corp.AllianceId   = AllianceId;
                                corp.AllianceName = AllianceName;
                                corp.CorpTag      = CorpName.Length > 5 ? CorpName.Substring(0, 5) : CorpName;
                                corp.AllianceTag  = AllianceName.Length > 5 ? AllianceName.Substring(0, 5) : AllianceName;

                                context.Corps.InsertOnSubmit(corp);
                            }


                            context.SubmitChanges();
                        }

                        ShowLogin(true);
                        return;
                    }
                    else
                    {
                        Response.Redirect(PageReferrer.Page_Register);
                    }
                }
            }
            else
            {
                RememberMeCheckBox.Visible = false;
                RememberMeCheckBox.Checked = false;
                //ShowLogin(false);
            }
        }
    }
    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);
                }
            }
        }
    }
Esempio n. 14
0
    private void CreateUser(PlexingFleetDataContext context, bool newCorp)
    {
        PlexUser user = context.PlexUsers.FirstOrDefault(x => x.CharacterId == CharacterId);

        if (user == null)
        {
            user = new PlexUser()
            {
                CharacterId   = this.CharacterId,
                CharacterName = this.CharacterName,
                AllianceId    = this.AllianceId,
                CorpId        = this.CorpId,
                AllianceName  = this.AllianceName,
                CorpName      = this.CorpName,
                Password      = FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordTextBox.Text.Trim(), "md5"),
                Enabled       = true
            };

            context.PlexUsers.InsertOnSubmit(user);

            if (newCorp)
            {
                PlexUserRole role = new PlexUserRole()
                {
                    CharacterId = this.CharacterId,
                    Roles       = "Corporation"
                };

                context.PlexUserRoles.InsertOnSubmit(role);
            }
        }
        else
        {
            //Only do this if the user enabled.
            if (user.Enabled)
            {
                user.AllianceId   = this.AllianceId;
                user.CorpId       = this.CorpId;
                user.AllianceName = this.AllianceName;
                user.CorpName     = this.CorpName;

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

                    //If no roles were found then add the one registring the corp admin rights for that corp.
                    if (userRoles == null)
                    {
                        PlexUserRole role = new PlexUserRole();
                        role.CharacterId = CharacterId;
                        role.Roles       = "Corporation";
                        context.PlexUserRoles.InsertOnSubmit(role);
                    }
                    else
                    {
                        //Only add the corporation role if it is missing.
                        if (!userRoles.Roles.Contains("Corporation"))
                        {
                            userRoles.Roles += ",Corporation";
                        }
                    }
                }
            }
            else
            {
                user.AllianceId   = this.AllianceId;
                user.CorpId       = this.CorpId;
                user.AllianceName = this.AllianceName;
                user.CorpName     = this.CorpName;
            }
        }

        context.SubmitChanges();
    }
Esempio n. 15
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);
            }
        }
    }