Пример #1
0
    protected void ButtonTest_Click(object sender, EventArgs e)
    {
        int actingOrgId = (int)ViewState["actingOrg"];

        if (actingOrgId == 0)
        {
            ErrorMsg.Text = "No organisation!";
            return;
        }
        Geography    geography = this.GeographyTree.SelectedGeography;
        Organization actingOrg = Organization.FromIdentity(actingOrgId);

        if (this.CheckSms.Checked)
        {
            string smsText = this.TextSms.Text;
            if (!string.IsNullOrEmpty(smsText) && smsText.Trim().Length > 3) // 3 characters is too small message, should always be more
            {
                _currentUser.SendPhoneMessage("PP: " + smsText.Trim());

                ChargeBudget(SelectBudget(geography), PhoneMessageTransmitter.SMSCost, "Test SMS");
            }
        }

        if (this.CheckMail.Checked)
        {
            ActivistMail activistMail = new ActivistMail();

            activistMail.pSubject       = this.TextMailSubject.Text;
            activistMail.pBodyContent   = this.TextMailBody.Text;
            activistMail.pOrgName       = actingOrg.MailPrefixInherited;
            activistMail.pGeographyName = (geography.Identity == Geography.RootIdentity ? "" : geography.Name);

            OutboundMail mail = activistMail.CreateFunctionalOutboundMail(MailAuthorType.ActivistService, OutboundMail.PriorityNormal, actingOrg, geography);

            mail.AddRecipient(_currentUser, false);
            mail.SetRecipientCount(1);
            mail.SetResolved();
            mail.SetReadyForPickup();
        }
        PanelTestSent.Visible = true;
    }
Пример #2
0
        internal static void ProcessActivistMailsCreated (BasicPWEvent newEvent)
        {
            Geography geography = Geography.FromIdentity(newEvent.GeographyId);
            People activists = Activists.FromGeography(geography).People;
            Organization sendingOrg = Organization.FromIdentity(newEvent.OrganizationId);

            int indexOfBar = newEvent.ParameterText.IndexOf('|');

            ActivistMail activistMail = new ActivistMail();
            string body = newEvent.ParameterText.Substring(indexOfBar + 1);
            activistMail.pSubject = newEvent.ParameterText.Substring(0, indexOfBar);
            activistMail.pBodyContent = newEvent.ParameterText.Substring(indexOfBar + 1); // In the template: + "\r\n\r\n" + App_LocalResources.EventProcessor.ActivistMail_Ending + "\r\n\r\n";
            activistMail.pOrgName = sendingOrg.MailPrefixInherited;
            activistMail.pGeographyName = (geography.Identity == Geography.RootIdentity ? "" : geography.Name);

            OutboundMail mail = activistMail.CreateFunctionalOutboundMail(MailAuthorType.ActivistService, OutboundMail.PriorityNormal, sendingOrg, geography);


            int finlandCountryId = Country.FromCode("FI").CountryId;
            bool isFinlandSelected = newEvent.GeographyId == Geography.FinlandId || geography.Inherits(Geography.FinlandId);

            int recipientsCount = 0;
            foreach (Person activist in activists)
            {
                //Hack to avoid finnish activists getting swedish mails. Only send to finns if finlad is selected
                if (newEvent.OrganizationId == Organization.PPFIid)
                {
                    //For PPFI: Only send to finns 
                    if (activist.CountryId == finlandCountryId || isFinlandSelected
                       )
                    {
                        mail.AddRecipient(activist, false);
                        recipientsCount++;
                    }
                }
                else
                {
                    //For PPSE: Dont send to finns unless finland is selected
                    if (activist.CountryId != finlandCountryId || isFinlandSelected
                       )
                    {
                        mail.AddRecipient(activist, false);
                        recipientsCount++;
                    }
                }

            }
            mail.SetRecipientCount(recipientsCount);
            mail.SetResolved();
            mail.SetReadyForPickup();
        }
Пример #3
0
    protected void ButtonTest_Click (object sender, EventArgs e)
    {
        int actingOrgId = (int)ViewState["actingOrg"];

        if (actingOrgId == 0)
        {
            ErrorMsg.Text = "No organisation!";
            return;
        }
        Geography geography = this.GeographyTree.SelectedGeography;
        Organization actingOrg = Organization.FromIdentity(actingOrgId);

        if (this.CheckSms.Checked)
        {
            string smsText = this.TextSms.Text;
            if (!string.IsNullOrEmpty(smsText) && smsText.Trim().Length > 3) // 3 characters is too small message, should always be more
            {
                _currentUser.SendPhoneMessage("PP: " + smsText.Trim());

                ChargeBudget(SelectBudget(geography), PhoneMessageTransmitter.SMSCost, "Test SMS");
            }
        }

        if (this.CheckMail.Checked)
        {

            ActivistMail activistMail = new ActivistMail();

            activistMail.pSubject = this.TextMailSubject.Text;
            activistMail.pBodyContent = this.TextMailBody.Text;
            activistMail.pOrgName = actingOrg.MailPrefixInherited;
            activistMail.pGeographyName = (geography.Identity == Geography.RootIdentity ? "" : geography.Name);

            OutboundMail mail = activistMail.CreateFunctionalOutboundMail(MailAuthorType.ActivistService, OutboundMail.PriorityNormal, actingOrg, geography);

            mail.AddRecipient(_currentUser, false);
            mail.SetRecipientCount(1);
            mail.SetResolved();
            mail.SetReadyForPickup();

        }
        PanelTestSent.Visible = true;
    }