Example #1
0
        protected void SendStaffCommentEMail(DataTable dtComments)
        {
            DateTime dtTemp;

            if (hidCharacterID.Value.Length > 0)
            {
                //string sSubject = Session["LoginName"].ToString() + " has added a comment to a character history.";
                //string sBody = Session["LoginName"].ToString() + " has added a comment to a character history for " + hidCharacterAKA.Value + "<br><br>";
                string sSubject = hidAuthorName.Value + " has added a comment to a character history.";
                string sBody    = hidAuthorName.Value + " has added a comment to a character history for " + hidCharacterAKA.Value + "<br><br>";

                string sCommentTable = "<table border='1'><tr><th>Date Added</th><th>Added By</th><th>Comment</th></tr>";

                DataView dvComments = new DataView(dtComments, "", "DateAdded desc", DataViewRowState.CurrentRows);
                foreach (DataRowView dRow in dvComments)
                {
                    sCommentTable += "<tr><td>";

                    if (DateTime.TryParse(dRow["DateAdded"].ToString(), out dtTemp))
                    {
                        sCommentTable += dtTemp.ToShortDateString();
                    }

                    sCommentTable += "</td><td>" + dRow["UserName"].ToString() + "</td><td>" + dRow["StaffComments"].ToString() + "</td></tr>";
                }

                sCommentTable += "</table>";
                sBody         += sCommentTable;

                Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                cEMS.SendMail(sSubject, sBody, hidNotificationEMail.Value, "", "", "CharacterHistory", Session["Username"].ToString());
            }
        }
Example #2
0
        private void SendSubmittedEmail(string sHistory, Classes.cCharacterHistory cHist)
        {
            try
            {
                Classes.cUser User     = new Classes.cUser(Master.UserName, "PasswordNotNeeded", Session.SessionID);
                string        sSubject = cHist.CampaignName + " character history from " + cHist.PlayerName + " - " + cHist.CharacterAKA;

                string sBody = (string.IsNullOrEmpty(User.NickName) ? User.FirstName : User.NickName) +
                               " " + User.LastName + " has submitted a character history for " + cHist.CharacterAKA + ".<br><br>" +
                               sHistory;

                if (hidNotificationEMail.Value.Length > 0)
                {
                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(sSubject, sBody, cHist.NotificationEMail, "", "", "CharacterHistory", Master.UserName);
                }
                //Classes.cSendNotifications SendNot = new Classes.cSendNotifications();
                //SendNot.SubjectText = sSubject;
                //SendNot.EMailBody = sBody;
                //SendNot.NotifyType = Classes.cNotificationTypes.HISTORYSUBMIT;
                //SendNot.SendNotification(Master.UserID, Master.UserName);
            }
            catch (Exception ex)
            {
                // Write the exception to error log and then throw it again...
                Classes.ErrorAtServer lobjError = new Classes.ErrorAtServer();
                lobjError.ProcessError(ex, "CharacterEdit.aspx.SendSubmittedEmail", "", Session.SessionID);
            }
        }
Example #3
0
        protected void GenerateEmail()
        {
            lblEmailFailed.Text = "";
            string strTo = hidEmailTo.Value;

            if (strTo == "")
            {
                string jsString = "alert('There is no To: address.  Please enter email for additional recipients.');";
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                                                    "MyApplication",
                                                    jsString,
                                                    true);
                lblEmailFailed.Text = "There is no To: address.  Please enter email for additional recipients.";
                return;
            }
            string strCC      = hidEmailCC.Value;
            string strBCC     = hidEmailBCC.Value;
            string strSubject = hidEmailSubject.Value;
            string strBody    = hidEmailBody.Value;

            Classes.cEmailMessageService NotifyStaff = new Classes.cEmailMessageService();
            try
            {
                NotifyStaff.SendMail(strSubject, strBody, strTo, strCC, strBCC, "PointsEmail", hidUserName.Value);
            }
            catch (Exception)
            {
                lblEmailFailed.Text = "There was an issue. Please contact us at [email protected] for assistance.";
            }
        }
Example #4
0
        //protected void CharacterHistoryEmailNotificaiton()
        //{
        //    if (hidPlayerEMail.Value.Length > 0)
        //    {
        //        string strSubject = "Character History Approved for Character " + lblCharacter.Text;
        //        string strBody = "Your character history for " + lblCharacter.Text + " has been approved.<br>";
        //        strBody += "You have been awarded " + tbCPAwarded.Text + " CP.<br><br>";
        //        strBody = strBody + "History Text:<br>" + lblHistory.Text;
        //        strBody = strBody.Replace(System.Environment.NewLine, "<br />");

        //        Classes.cEmailMessageService SubmitCharacterHistory = new Classes.cEmailMessageService();
        //        try
        //        {
        //            SubmitCharacterHistory.SendMail(strSubject, strBody, hidPlayerEMail.Value, "", "");
        //        }
        //        catch (Exception)
        //        {

        //        }
        //    }
        //}
        protected void btnApprove_Command(object sender, CommandEventArgs e)
        {
            int iCharID;

            if (int.TryParse(Request["CharID"], out iCharID))
            {
                Classes.cCharacter cChar = new Classes.cCharacter();
                cChar.LoadCharacter(iCharID);

                if (e.CommandName == "APPROVE")
                {
                    cChar.DateHistoryApproved = DateTime.Now;
                    cChar.SaveCharacter(Session["UserName"].ToString(), (int)Session["UserID"]);
                    lblCharApprovedMessage.Text = "The character history for " + cChar.AKA + " has been approved.";

                    Classes.cPoints Points      = new Classes.cPoints();
                    int             UserID      = 0;
                    int             CharacterID = 0;
                    int             CampaignCPOpportunityDefaultID = 0;
                    double          CPAwarded = 0.0;

                    int.TryParse(Session["UserID"].ToString(), out UserID);
                    int.TryParse(hidCampaignCPOpportunityDefaultID.Value, out CampaignCPOpportunityDefaultID);
                    double.TryParse(tbCPAwarded.Text, out CPAwarded);

                    Points.AssignHistoryPoints(UserID, cChar.PlayerID, CharacterID, CampaignCPOpportunityDefaultID, cChar.CampaignID, CPAwarded, DateTime.Now);

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);

                    if (hidPlayerEMail.Value.Length > 0)
                    {
                        string strSubject = "Character History Approved for Character " + lblCharacter.Text;
                        string strBody    = "Your character history for " + lblCharacter.Text + " has been approved.<br>";
                        strBody += "You have been awarded " + tbCPAwarded.Text + " CP.<br><br>";
                        strBody  = strBody + "History Text:<br>" + lblHistory.Text;
                        strBody  = strBody.Replace(System.Environment.NewLine, "<br />");

                        Classes.cEmailMessageService SubmitCharacterHistory = new Classes.cEmailMessageService();
                        try
                        {
                            SubmitCharacterHistory.SendMail(strSubject, strBody, hidPlayerEMail.Value, "", "", "CharacterHistory", Session["Username"].ToString());
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
Example #5
0
        protected void SendStaffAddendumCommentEMail(DataTable dtComments)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (hidPELNotificationEMail.Value.Length > 0)
            {
                string   sEventDate = "";
                DateTime dtTemp;
                if (DateTime.TryParse(hidEventDate.Value, out dtTemp))
                {
                    sEventDate = " that took place on " + dtTemp.ToShortDateString();
                }

                //string sSubject = Session["LoginName"].ToString() + " has added a comment to a PEL Addendum.";
                //string sBody = Session["LoginName"].ToString() + " has added a comment to a PEL Addendum for " + hidCharacterAKA.Value + " for the event " + hidEventDesc.Value + sEventDate + "<br><br>";
                string sSubject = hidAuthorName.Value + " has added a comment to a PEL Addendum.";
                string sBody    = hidAuthorName.Value + " has added a comment to a PEL Addendum for " + hidCharacterAKA.Value + " for the event " + hidEventDesc.Value + sEventDate + "<br><br>";

                string AddendumText  = "";
                string sCommentTable = "<table border='1'><tr><th>Date Added</th><th>Added By</th><th>Comment</th></tr>";

                DataView dvComments = new DataView(dtComments, "", "DateAdded desc", DataViewRowState.CurrentRows);
                foreach (DataRowView dRow in dvComments)
                {
                    AddendumText = dRow["Addendum"].ToString();

                    sCommentTable += "<tr><td>";

                    if (DateTime.TryParse(dRow["DateAdded"].ToString(), out dtTemp))
                    {
                        sCommentTable += dtTemp.ToShortDateString();
                    }

                    sCommentTable += "</td><td>" + dRow["UserName"].ToString() + "</td><td>" + dRow["StaffComments"].ToString() + "</td></tr>";
                }

                sCommentTable += "</table>";

                sBody += "The original addendum was:<br>" + AddendumText.Replace("\n", "<br>") + "<br><br>";
                sBody += "The comments for the addendum are newest first:<br><br>";

                sBody += sCommentTable;

                Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                cEMS.SendMail(sSubject, sBody, hidPELNotificationEMail.Value, "", "", "PELComments", Master.UserName);
            }
        }
Example #6
0
        protected void btnSendMessage_Click(object sender, EventArgs e)
        {
            SortedList sParams = new SortedList();

            sParams.Add("@UserID", Session["UserID"].ToString());
            sParams.Add("@CharacterID", hidCharacterID.Value);
            sParams.Add("@ClearHistorySubmitted", true);

            Classes.cUtilities.PerformNonQuery("uspInsUpdCHCharacters", sParams, "LARPortal", Session["UserName"].ToString());
            Session["UpdateHistoryMessage"] = "alert('The character history has been sent back to the user.');";

            Classes.cUser User     = new Classes.cUser(Session["UserName"].ToString(), "PasswordNotNeeded");
            string        sSubject = "Character history for " + hidCharacterAKA.Value + " needs revision";

            Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
            cEMS.SendMail(sSubject, ckHistory.Text, hidEmail.Value, "", hidNotificationEMail.Value, "CharacterHistory", Session["Username"].ToString());

            Response.Redirect("ApprovalList.aspx", true);
        }
Example #7
0
        private void SendEmailPELSubmitted(string sEmailBody)
        {
            try
            {
                if (ViewState["PELNotificationEMail"].ToString().Length > 0)
                {
                    string sPlayerName    = ViewState["PlayerName"].ToString();
                    string sCharacterName = "";
                    if (ViewState["CharacterAKA"] != null)
                    {
                        sCharacterName = ViewState["CharacterAKA"].ToString();
                    }

                    string sEventDate = "";
                    if (ViewState["EventDate"] != null)
                    {
                        DateTime dtTemp;
                        if (DateTime.TryParse(ViewState["EventDate"].ToString(), out dtTemp))
                        {
                            sEventDate = " that took place on " + ViewState["EventDate"].ToString();
                        }
                    }

                    string sEventName            = ViewState["EventName"].ToString();
                    string sPELNotificationEMail = ViewState["PELNotificationEMail"].ToString();

                    string sSubject = "PEL Submitted: " + sPlayerName + " has submitted a PEL.";
                    string sBody    = sPlayerName + " has submitted a PEL for " + sCharacterName + " for the event " + sEventName + sEventDate + "<br><br>" +
                                      sEmailBody;

                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(sSubject, sBody, sPELNotificationEMail, "", "", "PEL", Session["Username"].ToString());
                }
            }
            catch (Exception ex)
            {
                // Write the exception to error log and then throw it again...
                Classes.ErrorAtServer lobjError = new Classes.ErrorAtServer();
                lobjError.ProcessError(ex, "PELEdit.aspx.SendEmailPELSubmitted", "", Session.SessionID);
            }
        }
Example #8
0
        protected void SendStaffCommentEMail(string AddendumText)
        {
            if (hidPELNotificationEMail.Value.Length > 0)
            {
                string   sEventDate = "";
                DateTime dtTemp;
                if (DateTime.TryParse(hidEventDate.Value, out dtTemp))
                {
                    sEventDate = " that took place on " + dtTemp.ToShortDateString();
                }

                //string sSubject = Session["UserName"].ToString() + " has added an addendum to a PEL.";
                //string sBody = Session["UserName"].ToString() + " has added an addendum to a PEL for the event " + hidEventDesc.Value + sEventDate + "<br><br>" +
                //    AddendumText.Replace(Environment.NewLine, "<br>");
                string sSubject = hidAuthorName.Value + " has added an addendum to a PEL.";
                string sBody    = hidAuthorName.Value + " has added an addendum to a PEL for the event " + hidEventDesc.Value + sEventDate + "<br><br>" +
                                  AddendumText.Replace(Environment.NewLine, "<br>");

                Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                cEMS.SendMail(sSubject, sBody, hidPELNotificationEMail.Value, "", "", "PELAddendum", Session["Username"].ToString());
            }
        }
Example #9
0
        private void SendSubmittedEmail(string sHistory, Classes.cCharacterHistory cHist)
        {
            try
            {
                if (hidNotificationEMail.Value.Length > 0)
                {
                    Classes.cUser User     = new Classes.cUser(Session["UserName"].ToString(), "PasswordNotNeeded");
                    string        sSubject = cHist.CampaignName + " character history from " + cHist.PlayerName + " - " + cHist.CharacterAKA;

                    string sBody = (string.IsNullOrEmpty(User.NickName) ? User.FirstName : User.NickName) +
                                   " " + User.LastName + " has submitted a character history for " + cHist.CharacterAKA + ".<br><br>" +
                                   sHistory;
                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(sSubject, sBody, cHist.NotificationEMail, "", "", "CharacterHistory", Session["Username"].ToString());
                }
            }
            catch (Exception ex)
            {
                // Write the exception to error log and then throw it again...
                Classes.ErrorAtServer lobjError = new Classes.ErrorAtServer();
                lobjError.ProcessError(ex, "CharacterEdit.aspx.SendSubmittedEmail", "", Session.SessionID);
            }
        }
Example #10
0
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            int iCharacterID = -1;
            int iTemp;

            if (int.TryParse(hidCharacterID.Value, out iTemp))
            {
                iCharacterID = iTemp;
            }

            Classes.cCharacter cChar = new Classes.cCharacter();
            cChar.LoadCharacter(iCharacterID);

            SortedList sParams = new SortedList();

            sParams.Add("@UserID", Session["UserID"].ToString());
            sParams.Add("@CharacterID", iCharacterID);

            sParams.Add("@DateHistoryApproved", DateTime.Now);

            Classes.cUtilities.PerformNonQuery("uspInsUpdCHCharacters", sParams, "LARPortal", Session["UserName"].ToString());
            Session["UpdateHistoryMessage"] = "alert('The character history has been approved.');";

            Classes.cPoints Points           = new Classes.cPoints();
            int             UserID           = 0;
            int             CampaignPlayerID = 0;
            int             CharacterID      = 0;
            int             CampaignCPOpportunityDefaultID = 0;
            int             CampaignID = 0;
            double          CPAwarded  = 0.0;

            int.TryParse(Session["UserID"].ToString(), out UserID);
            int.TryParse(hidCampaignPlayerID.Value, out CampaignPlayerID);
            int.TryParse(hidCharacterID.Value, out CharacterID);
            int.TryParse(hidCampaignCPOpportunityDefaultID.Value, out CampaignCPOpportunityDefaultID);
            int.TryParse(hidCampaignID.Value, out CampaignID);
            double.TryParse(tbCPAwarded.Text, out CPAwarded);

            DateTime dtDateSubmitted;

            if (!DateTime.TryParse(hidSubmitDate.Value, out dtDateSubmitted))
            {
                dtDateSubmitted = DateTime.Now;
            }

            Classes.cUser User     = new Classes.cUser(Session["UserName"].ToString(), "PasswordNotNeeded");
            string        sSubject = "Character history for " + hidCharacterAKA.Value + " had been approved.";

            string sBody = hidCampaignName.Value + " staff has approved the character history for " + hidCharacterAKA.Value + "<br><br>" +
                           "You have been awarded " + CPAwarded.ToString() + " CP.";
            //"<br><br>Character History:<br><br>" + ckHistory.Text;
            string sEmailToSendTo = hidEmail.Value;

            Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
            cEMS.SendMail(sSubject, sBody, sEmailToSendTo, "", "", "CharacterHistory", Session["Username"].ToString());

            //Classes.cSendNotifications SendNot = new Classes.cSendNotifications();
            //SendNot.SubjectText = sSubject;
            //SendNot.EMailBody = sBody;
            //SendNot.NotifyType = Classes.cNotificationTypes.HISTORYAPPROVE;
            //SendNot.SendNotification(cChar.CurrentUserID, _UserName);

            Points.AssignHistoryPoints(UserID, CampaignPlayerID, CharacterID, CampaignCPOpportunityDefaultID, CampaignID, CPAwarded, dtDateSubmitted);

            Response.Redirect("ApprovalList.aspx", true);
        }
Example #11
0
        public void SendNotification(int iUserID, string sUserName)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (NotifyType == cNotificationTypes.NOTSPECIFIED)
            {
                throw new System.Exception("The NotifyType must be specified to be able to send a notification to the user.");
            }

            SortedList sParam = new SortedList();

            sParam.Add("@UserID", iUserID);
            DataTable dtPref = cUtilities.LoadDataTable("uspGetPlayerNotificationPrefs", sParam, "LARPortal", sUserName, lsRoutineName);

            dtPref.CaseSensitive = false;
            DataView dvPref = new DataView(dtPref, "NotificationCode = '" + NotifyType.ToString() + "' and isnull(DeliveryMethod,'NONE') <>  'NONE'", "", DataViewRowState.CurrentRows);

            if (dvPref.Count > 0)
            {
                string sNotifyType = dvPref[0]["DeliveryMethod"].ToString().ToUpper();
                string sAddress    = "";
                string sCallingJob = "";

                sCallingJob = dvPref[0]["CallingJob"].ToString();

                if (sNotifyType.StartsWith("T"))
                {
                    sAddress = dvPref[0]["TextAddress"].ToString();
                    if (dvPref[0]["TextAddress"].ToString().Length > 0)
                    {
                        if (SubjectText.Length == 0)
                        {
                            // If there is nothing in the current subject text and the text address on the record > '' set the subject text.
                            SubjectText = dvPref[0]["TextMessageText"].ToString();
                            //                        sAddress = dvPref[0]["TextAddress"].ToString();
                        }
                    }

                    if (SubjectText.Length == 0)
                    {
                        // If the subject is blank (wasn't specified or was blank in the record) use the Email settings.
                        sNotifyType = "Email";
                    }
                }

                if (sNotifyType.StartsWith("E"))
                {
                    // Either the user specified Email, or there's missing information from the text address.
                    sAddress = dvPref[0]["EMailAddress"].ToString();
                    if (SubjectText.Length == 0)
                    {
                        SubjectText = dvPref[0]["EMailSubjectText"].ToString();
                    }
                    if (EMailBody.Length == 0)
                    {
                        EMailBody = dvPref[0]["EMailMessageText"].ToString();
                    }

                    // If the subject is blank, use the first 100 characters from the body of the email.
                    if (SubjectText.Length == 0)
                    {
                        // Take the first 100 character from body.
                        SubjectText = (EMailBody.Length <= 100 ? EMailBody : EMailBody.Substring(0, 100));
                    }
                }

                if ((sAddress.Length > 0) &&
                    (SubjectText.Length > 0) &&
                    (sCallingJob.Length > 0))
                {
                    Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                    cEMS.SendMail(SubjectText, EMailBody, sAddress, "", "", sCallingJob, sUserName);
                }
            }
        }
Example #12
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);
            }
        }
Example #13
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (Session["TeamMembers"] != null)
            {
                int Approval  = -1;
                int Member    = -1;
                int Invited   = -1;
                int Requested = -1;

                DataTable dtTeamMembers = Session["TeamMembers"] as DataTable;

                SortedList sParams  = new SortedList();
                DataTable  dtStatus = cUtilities.LoadDataTable("select RoleID, RoleDescription from MDBRoles where RoleTier='Team'", sParams, "LARPortal",
                                                               _UserName, lsRoutineName, cUtilities.LoadDataTableCommandType.Text);

                foreach (DataRow dStatus in dtStatus.Rows)
                {
                    string sRoles = dStatus["RoleDescription"].ToString().ToUpper();
                    if (sRoles.Contains("APPROVAL"))
                    {
                        int.TryParse(dStatus["RoleID"].ToString(), out Approval);
                    }
                    else if (sRoles.Contains("REQUESTED"))
                    {
                        int.TryParse(dStatus["RoleID"].ToString(), out Requested);
                    }
                    else if (sRoles.Contains("INVITED"))
                    {
                        int.TryParse(dStatus["RoleID"].ToString(), out Invited);
                    }
                    else if (sRoles == "TEAM MEMBER")
                    {
                        int.TryParse(dStatus["RoleID"].ToString(), out Member);
                    }
                }

                DataView dv = new DataView(dtTeamMembers, "UpdateRecord", "", DataViewRowState.CurrentRows);

                foreach (DataRowView dRow in dv)
                {
                    string sProcedureName = "uspInsUpdCMTeamMembers";

                    int CharID = -1;
                    int TeamID = -1;
                    int.TryParse(dRow["CharacterID"].ToString(), out CharID);
                    int.TryParse(dRow["TeamID"].ToString(), out TeamID);
                    sParams = new SortedList();
                    sParams.Add("@UserID", _iUserID);
                    sParams.Add("@TeamID", TeamID);
                    sParams.Add("@CharacterID", CharID);

                    if ((bool)dRow["Approval"])
                    {
                        sParams.Add("@RoleID", Approval);
                    }
                    else if ((bool)dRow["Member"])
                    {
                        sParams.Add("@RoleID", Member);
                    }
                    else if ((bool)dRow["Requested"])
                    {
                        sParams.Add("@RoleID", Requested);
                    }
                    else if ((bool)dRow["Invited"])
                    {
                        sParams.Add("@RoleID", Invited);
                    }
                    else
                    {
                        sProcedureName = "uspDelCMTeamMembers";
                    }

                    cUtilities.PerformNonQuery(sProcedureName, sParams, "LARPortal", _UserName);

                    if (dRow["SendEMail"].ToString().Length > 0)
                    {
                        sParams = new SortedList();
                        sParams.Add("@TeamID", TeamID);
                        // Fixed Current User filter. Using wrong field.
                        DataView dvApprover = new DataView(dtTeamMembers, "CurrentUserID = " + _iUserID.ToString(), "", DataViewRowState.CurrentRows);
                        if (dvApprover.Count == 0)
                        {
                            dvApprover = new DataView(dtTeamMembers, "Approval = 1", "", DataViewRowState.CurrentRows);
                        }
                        if (dvApprover.Count > 0)
                        {
                            DataRowView dApprover = dvApprover[0];
                            string      sBody     = dRow["CharacterAKA"].ToString() + "<br><br>" +
                                                    dApprover["CharacterAKA"].ToString() + " has invited you to join the " + dApprover["TeamName"].ToString() +
                                                    " team.  To accept visit larportal.com and Go to Character > Join Team to accept or decline." +
                                                    "<br><br>" +
                                                    "Thanks!";
                            string sSubject = dApprover["CharFullName"].ToString() + " has invited you to join " + dApprover["TeamName"].ToString() + " team.";

                            Classes.cEmailMessageService cEMS = new Classes.cEmailMessageService();
                            cEMS.SendMail(sSubject, sBody, dRow["EmailAddress"].ToString(), "", "", "Teams", _UserName);
                        }
                        dRow["SendEMail"] = "";
                    }
                }
            }
            lblmodalMessage.Text        = "Changes have been saved.";
            lblChangesNotSaved.Visible  = false;
            lblChangesNotSaved2.Visible = false;
            Session.Remove("TeamMembers");
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openMessage();", true);
        }