コード例 #1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (fuItem.HasFile)
            {
                string           sUser      = Session["LoginName"].ToString();
                Classes.cPicture NewPicture = new Classes.cPicture();
                NewPicture.CreateNewPictureRecord(sUser);
                NewPicture.PictureType = Classes.cPicture.PictureTypes.Item;
                string sExtension = Path.GetExtension(fuItem.FileName);
                string filename   = "CI" + NewPicture.PictureID.ToString("D10") + sExtension;

                NewPicture.PictureFileName = filename;

                if (!Directory.Exists(Path.GetDirectoryName(NewPicture.PictureLocalName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(NewPicture.PictureLocalName));
                }

                string FinalFileName = NewPicture.PictureLocalName; // Path.Combine(Server.MapPath(Path.GetDirectoryName(NewPicture.PictureLocalName)), filename);
                fuItem.SaveAs(FinalFileName);

                //int iTemp;
                //if (int.TryParse(ViewState["CurrentCharacter"].ToString(), out iTemp))
                //    NewPicture.CharacterID = iTemp;

                if (oCharSelect.CharacterID.HasValue)
                {
                    NewPicture.CharacterID = oCharSelect.CharacterID.Value;
                }

                NewPicture.Save(sUser);

                List <Classes.cPicture> Items = new List <Classes.cPicture>();
                Items = Session["Items"] as List <Classes.cPicture>;
                Items.Add(NewPicture);
                Session["Items"] = Items;

                DataTable dtPictures = Classes.cUtilities.CreateDataTable(Items);

                //if ( dtPictures.Columns["PictureURL"] == null )
                //    dtPictures.Columns.Add(new DataColumn("PictureURL", typeof(string)));

                string sFilter = "RecordStatus <> '" + ((int)Classes.RecordStatuses.Delete).ToString() + "' and " +
                                 "PictureType = " + ((int)Classes.cPicture.PictureTypes.Item).ToString();
                DataView dvPictures = new DataView(dtPictures, sFilter, "", DataViewRowState.CurrentRows);
                dlItems.DataSource = dvPictures;
                dlItems.DataBind();
            }
        }
コード例 #2
0
ファイル: Profile.aspx.cs プロジェクト: larportal/uilarportal
        protected void btnSavePicture_Click(object sender, EventArgs e)
        {
            if (ulFile.HasFile)
            {
                try
                {
                    string           sUser      = Session["LoginName"].ToString();
                    Classes.cPicture NewPicture = new Classes.cPicture();
                    NewPicture.PictureType = Classes.cPicture.PictureTypes.Profile;
                    NewPicture.CreateNewPictureRecord(sUser);
                    string sExtension = Path.GetExtension(ulFile.FileName);
                    NewPicture.PictureFileName = "PL" + NewPicture.PictureID.ToString("D10") + sExtension;

                    //int iCharacterID = 0;
                    //int.TryParse(ViewState["CurrentCharacter"].ToString(), out iCharacterID);
                    //NewPicture.CharacterID = iCharacterID;

                    string LocalName = NewPicture.PictureLocalName;

                    if (!Directory.Exists(Path.GetDirectoryName(NewPicture.PictureLocalName)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(NewPicture.PictureLocalName));
                    }

                    ulFile.SaveAs(NewPicture.PictureLocalName);
                    NewPicture.Save(sUser);

                    ViewState["UserIDPicture"] = NewPicture.PictureID;
                    ViewState.Remove("PictureDeleted");

                    imgPlayerImage.ImageUrl = NewPicture.PictureURL;
                    imgPlayerImage.Visible  = true;
                    btnClearPicture.Visible = true;
                }
                catch (Exception ex)
                {
                    lblMessage.Text = ex.Message + "<br>" + ex.StackTrace;
                }
            }
        }
コード例 #3
0
        protected void btnSaveItem_Click(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            int iInventoryID;

            lblMessage.Text = "";
            try
            {
                if (int.TryParse(hidInventoryID.Value, out iInventoryID))
                {
                    int?   iNewPictureID = null;
                    string sPictureURL   = null;

                    if (fuItemPicture.HasFile)
                    {
                        System.Web.HttpPostedFile PostedFile = fuItemPicture.PostedFile;
                        //var postedFile = fuItemPicture.PostedFile;
                        int    dataLength = PostedFile.ContentLength;
                        byte[] myData     = new byte[dataLength];
                        PostedFile.InputStream.Read(myData, 0, dataLength);

                        Classes.cPicture NewPicture = new Classes.cPicture();
                        NewPicture.PictureType = Classes.cPicture.PictureTypes.Item;
                        string sExtension = Path.GetExtension(fuItemPicture.FileName);
                        NewPicture.CreateNewPictureRecord(cPicture.PictureTypes.Item, sExtension, Master.UserName);

                        int iTemp;
                        if (int.TryParse(hidProfileID.Value, out iTemp))
                        {
                            NewPicture.ProfileID = iTemp;
                        }

                        string LocalName = NewPicture.PictureLocalName;

                        if (!Directory.Exists(Path.GetDirectoryName(NewPicture.PictureLocalName)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(NewPicture.PictureLocalName));
                        }

                        try
                        {
                            fuItemPicture.SaveAs(NewPicture.PictureLocalName);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "While trying to save the file, got an error.<br>" + ex.Message + "<br>" +
                                              ex.StackTrace + "<br>";
                            ErrorAtServer lobjError = new ErrorAtServer();
                            lobjError.ProcessError(ex, lsRoutineName + ".PicutreSaveAs", Master.UserName);
                        }
                        NewPicture.Save(Master.UserName);
                        sPictureURL   = NewPicture.PictureURL;
                        iNewPictureID = NewPicture.PictureID;
                    }
                    else
                    {
                        // No file was sent
                    }

                    int iTypeID;
                    int.TryParse(ddlType.SelectedValue, out iTypeID);
                    Classes.cPlayerInventory cInvItem = new cPlayerInventory(iInventoryID, Master.UserName, Master.UserID);
                    cInvItem.ItemName        = tbItemName.Text;
                    cInvItem.Description     = tbDescription.Text;
                    cInvItem.InventoryTypeID = iTypeID;
                    cInvItem.Quantity        = tbQuantity.Text;
                    cInvItem.Size            = tbSize.Text;
                    cInvItem.Location        = tbLocation.Text;
                    cInvItem.PowerNeeded     = ddlPowerNeeded.SelectedValue;
                    cInvItem.WillShare       = cbxWillShare.Checked;
                    cInvItem.PlayerComments  = tbComments.Text;
                    if (iNewPictureID.HasValue)
                    {
                        cInvItem.ImageID  = iNewPictureID.Value;
                        cInvItem.ImageURL = sPictureURL;
                    }

                    int iProfileID;
                    if (int.TryParse(hidProfileID.Value, out iProfileID))
                    {
                        cInvItem.PlayerProfileID = iProfileID;
                    }

                    cInvItem.RecordStatus = RecordStatuses.Active;
                    cInvItem.Save(Master.UserName, Master.UserID);
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text += "There was a general error saving the file. The message was<br>" +
                                   ex.Message + "<br>" +
                                   ex.StackTrace + "<br>";
                ErrorAtServer lobjError = new ErrorAtServer();
                lobjError.ProcessError(ex, lsRoutineName, Master.UserName);
            }
            if (lblMessage.Text.Length > 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
            }
        }
コード例 #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int iTemp;

            oCharSelect.LoadInfo();

            if ((oCharSelect.SkillSetID.HasValue) && (oCharSelect.CharacterInfo != null))
            {
                int    i = 0;
                string sHiddenSkillList = "";

                foreach (GridViewRow row in gvHiddenSkillAccess.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox    cbxHasSkill            = (row.Cells[1].FindControl("cbxHasSkill") as CheckBox);
                        HiddenField hidHadOriginally       = (row.Cells[2].FindControl("hidHadOriginally") as HiddenField);
                        HiddenField hidCampaignSkillNodeID = (row.Cells[2].FindControl("hidCampaignSkillNodeID") as HiddenField);
                        HiddenField hidSkillName           = (row.Cells[2].FindControl("hidSkillName") as HiddenField);

                        if ((cbxHasSkill != null) &&
                            (hidHadOriginally != null) &&
                            (hidCampaignSkillNodeID != null))
                        {
                            bool bHasOriginally = false;
                            if (hidHadOriginally.Value == "1")
                            {
                                bHasOriginally = true;
                            }
                            if (bHasOriginally != cbxHasSkill.Checked)
                            {
                                if (cbxHasSkill.Checked)
                                {
                                    // Since the value has changed, and it's checked, it means we need to add the value;
                                    int iCampaignSkillNodeID;
                                    if (int.TryParse(hidCampaignSkillNodeID.Value, out iCampaignSkillNodeID))
                                    {
                                        SortedList sParams = new SortedList();
                                        sParams.Add("@UserID", Master.UserID);
                                        sParams.Add("@CampaignSkillsStandardID", iCampaignSkillNodeID);
                                        sParams.Add("@SkillSetID", oCharSelect.SkillSetID);
                                        sParams.Add("@Comments", "Skill added by " + Master.UserName);
                                        sParams.Add("@CharacterID", oCharSelect.CharacterID);
                                        Classes.cUtilities.PerformNonQuery("uspInsUpdCHCampaignSkillAccess", sParams, "LARPortal", Master.UserName);

                                        if (hidSkillName != null)
                                        {
                                            sHiddenSkillList += hidSkillName.Value + "<br>";
                                        }
                                    }
                                }
                                else
                                {
                                    // Since the value has changed, and it's not checked, it means we need to delete the value;
                                    HiddenField hidCampaignSkillAccessID = (row.Cells[2].FindControl("hidCampaignSkillAccessID") as HiddenField);
                                    if (hidCampaignSkillAccessID != null)
                                    {
                                        int iCampaignSkillAccessID;
                                        if (int.TryParse(hidCampaignSkillAccessID.Value, out iCampaignSkillAccessID))
                                        {
                                            SortedList sParams = new SortedList();
                                            sParams.Add("@CampaignSkillAccessID", iCampaignSkillAccessID);
                                            sParams.Add("@UserName", Master.UserName);
                                            sParams.Add("@UserID", Master.UserID);
                                            Classes.cUtilities.PerformNonQuery("uspDelCHCampaignSkillAccess", sParams, "LARPortal", Master.UserName);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    i++;
                }

                // If there were any hidden skills given to the character, send them an email.
                if ((sHiddenSkillList.Length > 0) &&
                    (oCharSelect.CharacterInfo.CharacterEmail.ToString().Length > 0))
                {
                    string sSubject = "LARP Portal Notification - " + Master.CampaignName + " staff has given you access to a hidden skill.";
                    string sBody    = "The staff of " + Master.CampaignName + " has given your character " + oCharSelect.CharacterInfo.AKA + " access to the following skill(s):<br>" +
                                      "<br>" +
                                      sHiddenSkillList;

                    Classes.cUser User = new Classes.cUser(Master.UserName, "PasswordNotNeeded", Session.SessionID);
                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(sSubject, sBody, oCharSelect.CharacterInfo.CharacterEmail, "", User.PrimaryEmailAddress.EmailAddress, "CharInfo - Hidden Skills", Master.UserName);
                }

                if ((tbAKA.Text.Length == 0) &&
                    (tbFirstName.Text.Length == 0))
                {
                    // JBradshaw  7/11/2016    Request #1286     Must have at least first name or last name.
                    lblmodalError.Text = "You must fill in at least the first name or the character AKA.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openError();", true);
                    return;
                }

                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacterBySkillSetID(oCharSelect.SkillSetID.Value);

                if (ulFile.HasFile)
                {
                    try
                    {
                        //                        string sUser = Session["LoginName"].ToString();
                        Classes.cPicture NewPicture = new Classes.cPicture();
                        NewPicture.PictureType = Classes.cPicture.PictureTypes.Profile;
                        NewPicture.CreateNewPictureRecord(Master.UserName);
                        string sExtension = Path.GetExtension(ulFile.FileName);
                        NewPicture.PictureFileName = "CP" + NewPicture.PictureID.ToString("D10") + sExtension;

                        NewPicture.CharacterID = oCharSelect.CharacterID.Value;

                        string LocalName = NewPicture.PictureLocalName;

                        if (!Directory.Exists(Path.GetDirectoryName(NewPicture.PictureLocalName)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(NewPicture.PictureLocalName));
                        }

                        ulFile.SaveAs(NewPicture.PictureLocalName);
                        NewPicture.Save(Master.UserName);

                        cChar.ProfilePicture = NewPicture;
                        //                        ViewState["UserIDPicture"] = NewPicture;
                        ViewState.Remove("PictureDeleted");

                        imgCharacterPicture.ImageUrl = NewPicture.PictureURL;
                        imgCharacterPicture.Visible  = true;
                        //                    btnClearPicture.Visible = true;
                    }
                    catch                     //(Exception ex)
                    {
                        //                    lblMessage.Text = ex.Message + "<br>" + ex.StackTrace;
                    }
                }

                cChar.FirstName  = tbFirstName.Text;
                cChar.MiddleName = tbMiddleName.Text;
                cChar.LastName   = tbLastName.Text;

                cChar.CurrentHome = tbBirthPlace.Text;

                cChar.AllowCharacterRebuildToDate = null;

                if (oCharSelect.WhichSelected == LarpPortal.Controls.CharacterSelect.Selected.CampaignCharacters)
                {
                    cChar.CharacterStatusID = Convert.ToInt32(ddlStatus.SelectedValue);
                    cChar.CharacterType     = Convert.ToInt32(ddlCharType.SelectedValue);

                    //if (ddlAllowRebuild.SelectedValue == "Y")
                    //{
                    //    tbRebuildToDate.Style["display"] = "inline";
                    //    lblExpiresOn.Style["display"] = "inline";
                    //    DateTime dtTemp;
                    //    if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                    //        cChar.AllowCharacterRebuildToDate = dtTemp;
                    //}
                    //else
                    //{
                    //    tbRebuildToDate.Style["display"] = "none";
                    //    lblExpiresOn.Style["display"] = "none";
                    //}
                }

                if (ddlVisible.SelectedValue == "1")
                {
                    cChar.VisibleToPCs = true;
                }
                else
                {
                    cChar.VisibleToPCs = false;
                }

                cChar.AKA         = tbAKA.Text;
                cChar.CurrentHome = tbHome.Text;
                cChar.WhereFrom   = tbBirthPlace.Text;

                // If the drop down list is visible, it means they belong to multiple teams so we need to check it.
                if (ddlTeamList.Visible)
                {
                    if (int.TryParse(ddlTeamList.SelectedValue, out iTemp))
                    {
                        cChar.TeamID = iTemp;
                    }
                }

                cChar.DateOfBirth = tbDOB.Text;
                if (ViewState["UserIDPicture"] != null)
                {
                    cChar.ProfilePicture = ViewState["UserIDPicture"] as Classes.cPicture;
                    if (ViewState["PictureDeleted"] != null)
                    {
                        cChar.ProfilePicture.RecordStatus = Classes.RecordStatuses.Delete;
                    }
                }
                else
                {
                    cChar.ProfilePicture = null;
                }

                if (ddlRace.SelectedIndex > -1)
                {
                    cChar.Race = new Classes.cRace();
                    int.TryParse(ddlRace.SelectedValue, out iTemp);
                    cChar.Race.CampaignRaceID = iTemp;
                }

                if (ddlAllowRebuild.SelectedValue == "Y")
                {
                    DateTime dtTemp;
                    if (DateTime.TryParse(tbRebuildToDate.Text, out dtTemp))
                    {
                        cChar.AllowCharacterRebuildToDate = dtTemp;
                    }
                }
                else
                {
                    cChar.AllowCharacterRebuildToDate = new DateTime(1900, 1, 1);
                }

                if (cChar.CharacterType != 1)                       // Means it's not a PC so we need to check who is the current actor.
                {
                    var LastActor = cChar.Actors.OrderByDescending(x => x.StartDate).ToList();
                    if (LastActor == null)
                    {
                        cChar.CurrentUserID = Master.UserID;
                    }
                    else
                    {
                        if (LastActor.Count > 0)
                        {
                            cChar.CurrentUserID = LastActor[0].UserID;
                        }
                    }
                }

                cChar.StaffComments = tbStaffComments.Text;

                cChar.SaveCharacter(Master.UserName, Master.UserID);
                // JBradshaw  7/11/2016    Request #1286     Changed over to bootstrap popup.
                lblmodalMessage.Text = "Character " + cChar.AKA + " has been saved.";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openMessage();", true);
            }
        }