Exemple #1
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        lblTempError.Text = string.Empty;

        lblTempError.Text += IptechLib.Validation.ValidateDropDownList("Select Rounds", ddlRounds, roundRow.Visible, string.Empty.ToString());
        lblTempError.Text += IptechLib.Validation.ValidateDropDownList("Select Template", ddlTemplateList, templateRow.Visible, Guid.Empty.ToString());

        if (String.IsNullOrEmpty(lblTempError.Text))
        {
            SendInvitationCriteria invCriteria = new SendInvitationCriteria();

            if (roundRow.Visible)
            {
                invCriteria.isRound1 = ddlRounds.SelectedValue.Equals(RoundsType.Round1) || ddlRounds.SelectedValue.Equals(RoundsType.BothRounds);
                invCriteria.isRound2 = ddlRounds.SelectedValue.Equals(RoundsType.Round2) || ddlRounds.SelectedValue.Equals(RoundsType.BothRounds);
                invCriteria.isSend   = false;

                GenerateInvitation(invCriteria, new Guid(ddlTemplateList.SelectedValue));
            }
            else
            {
                EmailTemplate choosenTemplate = EmailTemplate.GetEmailTemplate(new Guid(ddlTemplateList.SelectedValue.ToString()));

                if (choosenTemplate != null)
                {
                    invCriteria.isRound1 = choosenTemplate.UserData1.Equals(RoundsType.Round1) || choosenTemplate.UserData1.Equals(RoundsType.BothRounds);
                    invCriteria.isRound2 = choosenTemplate.UserData1.Equals(RoundsType.Round2) || choosenTemplate.UserData1.Equals(RoundsType.BothRounds);
                    invCriteria.isSend   = true;

                    if (choosenTemplate.IsInvitation)
                    {
                        GenerateInvitation(invCriteria, new Guid(ddlTemplateList.SelectedValue));
                    }
                    else
                    {
                        GenerateEmails(new Guid(ddlTemplateList.SelectedValue));
                    }
                }
            }

            phSelectTemplate.Visible = false;

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "none", "<script>ClearDataOnLoad();</script>", false);
        }
    }
Exemple #2
0
    public void GenerateInvitation(SendInvitationCriteria invCriteria, Guid templateId)
    {
        string evetnYear = string.Empty;

        try
        {
            evetnYear = Gen_GeneralUseValueList.GetGen_GeneralUseValueList("EventCode")[0].Value;
        }
        catch { }

        lblError.Text = string.Empty;
        int counter = 0;

        foreach (GridDataItem item in radGridJury.Items)
        {
            CheckBox    chkbox = (CheckBox)item.FindControl("chkbox");
            HiddenField hdfId  = (HiddenField)item.FindControl("hdfId");

            if (chkbox.Checked)
            {
                Jury jury = Jury.GetJury(new Guid(hdfId.Value.ToString()));

                InvitationList invList = InvitationList.GetInvitationList(jury.Id, Gen_GeneralUseValueList.GetGen_GeneralUseValueList("EventCode")[0].Value);

                Invitation inv = null;

                if (invList.Count > 0)
                {
                    inv = invList[0];
                }
                else
                {
                    inv = Invitation.NewInvitation();
                }

                inv.EventCode = Gen_GeneralUseValueList.GetGen_GeneralUseValueList("EventCode")[0].Value.ToString();
                inv.JuryId    = jury.Id;

                if (invCriteria.isRound1)
                {
                    inv.IsRound1Invited           = true;
                    inv.DateRound1EmailSentString = DateTime.Now.ToString();
                }
                if (invCriteria.isRound2)
                {
                    inv.IsRound2Invited           = true;
                    inv.DateRound2EmailSentString = DateTime.Now.ToString();
                }

                if (inv.IsNew)
                {
                    inv.DateCreatedString = DateTime.Now.ToString();
                }

                inv.DateModifiedString = DateTime.Now.ToString();

                if (invCriteria.isSend)
                {
                    Email.SendInvitationTemplateEmail(inv, templateId);
                    GeneralFunction.SaveEmailSentLog(jury, templateId, evetnYear);
                }
                else
                {
                    inv.IsLocked = true;
                }

                if (inv.IsValid)
                {
                    inv.Save();
                }

                chkbox.Checked = false;
                counter++;
            }
        }

        if (counter == 0)
        {
            lblError.Text = "Please select atleat one jury to send Invitation.<br/>";
        }
        else
        {
            if (invCriteria.isSend)
            {
                lblError.Text = "Email sent to " + (counter).ToString() + " Jury(s).<br/>";
            }
            else
            {
                lblError.Text = "Invitation added for " + (counter).ToString() + " Jury(s).<br/>";
            }
        }
    }