Пример #1
0
    private void ShowTemplate(MailTemplate currentTemplate)
    {
        this.LabelCountryName.Text = Country.FromCode(currentTemplate.CountryCode).Name;
        this.LabelOrgName.Text     = "";
        if (currentTemplate.OrganizationId != 0)
        {
            this.LabelOrgName.Text = Organization.FromIdentity(currentTemplate.OrganizationId).Name;
            ButtonSave.Visible     = _authority.HasPermission(Permission.CanEditMailTemplates, currentTemplate.OrganizationId, -1, Authorization.Flag.Default);
        }
        else
        {
            ButtonSave.Visible = _authority.HasPermission(Permission.CanEditMailTemplates, Organization.RootIdentity, -1, Authorization.Flag.Default);
        }

        this.LabelTemplateName.Text  = currentTemplate.TemplateName;
        CurrentTemplateNameViewState = currentTemplate.TemplateName;
        CurrentTemplateIdViewState   = currentTemplate.TemplateId;
        currentTemplate.NormalizeHtml();

        TypedMailTemplate           typedTemplate = TypedMailTemplate.FromName(currentTemplate.TemplateName);
        Dictionary <string, string> placeholders  = new Dictionary <string, string>();

        foreach (string ph in typedTemplate.Placeholders.Keys)
        {
            placeholders.Add(ph.ToLower(), ph);
        }

        currentTemplate.MarkPlaceholderSpans(placeholders);

        RadEditor1.Content  = currentTemplate.TemplateBody;
        TextBoxSubject.Text = currentTemplate.TemplateTitle;
        SetEditorToolbar();
    }
Пример #2
0
    private void SetEditorToolbar()
    {
        EditorToolGroup foundgroup = null;

        foreach (EditorToolGroup tg in RadEditor1.Tools)
        {
            if (tg.Attributes["id"] == "placeholders")
            {
                foundgroup = tg;
            }
        }
        if (foundgroup != null)
        {
            RadEditor1.Tools.Remove(foundgroup);
        }

        EditorToolGroup main = new EditorToolGroup();

        main.Attributes["id"] = "placeholders";
        RadEditor1.Tools.Add(main);

        //add a custom dropdown and set its items and dimension attributes
        EditorDropDown ddn = new EditorDropDown("PlaceHolders");

        ddn.Text = "Place holders";

        //Set the popup width and height
        ddn.Attributes["width"]       = "110px";
        ddn.Attributes["popupwidth"]  = "240px";
        ddn.Attributes["popupheight"] = "200px";

        if (CurrentTemplateNameViewState != "")
        {
            TypedMailTemplate tmpl = TypedMailTemplate.FromName(CurrentTemplateNameViewState);

            foreach (string key in tmpl.Placeholders.Keys)
            {
                if (tmpl.Placeholders[key].TagOrId == TypedMailTemplate.PlaceholderType.Tag)
                {
                    ddn.Items.Add(tmpl.Placeholders[key].Label, " <span class='placeholder2' >%" + tmpl.Placeholders[key].Name + "%</span> ");
                }
                else if (tmpl.Placeholders[key].TagOrId == TypedMailTemplate.PlaceholderType.Id)
                {
                    ddn.Items.Add(tmpl.Placeholders[key].Label, " <div id=\"" + tmpl.Placeholders[key].Name + "\" class='placeholder1' > " + tmpl.Placeholders[key].Label + " </div> ");
                }
                else
                {
                    ddn.Items.Add(tmpl.Placeholders[key].Label, " <span id=\"" + tmpl.Placeholders[key].Name + "\" class='placeholder1' > <span class='placeholder2' >%" + tmpl.Placeholders[key].Name + "%</span> </span> ");
                }
            }
        }

        //Add tool to toolbar
        main.Tools.Add(ddn);
    }
Пример #3
0
        public void SendNotice(TypedMailTemplate mailtempl, int organizationId, bool asOfficer)
        {
            OutboundMail mail = mailtempl.CreateFunctionalOutboundMail(
                asOfficer ? MailAuthorType.PirateWeb : MailAuthorType.Service,
                OutboundMail.PriorityNormal, Organization.FromIdentity(organizationId),
                Geography.Root, DateTime.Now);

            mail.AddRecipient(this, asOfficer);
            mail.SetRecipientCount(1);
            mail.SetResolved();
            mail.SetReadyForPickup();
        }
Пример #4
0
    private void BuildTemplateDropdowns()
    {
        Organizations orgs = _authority.GetOrganizations(RoleTypes.AllLocalRoleTypes);
        Dictionary <string, Organization> cntryList = new Dictionary <string, Organization>();

        foreach (Organization org in orgs)
        {
            if (!cntryList.ContainsKey(org.DefaultCountry.Code.ToUpper()))
            {
                cntryList.Add(org.DefaultCountry.Code.ToUpper(), org);
            }
        }

        List <MailTemplate> templatelist = MailTemplate.GetAll();
        Dictionary <string, MailTemplate> templateDict = new Dictionary <string, MailTemplate>();

        foreach (MailTemplate mt in templatelist)
        {
            templateDict[mt.TemplateName] = mt;
        }

        DropDownName.Items.Clear();
        foreach (string basename in TypedMailTemplate.GetTemplateNames())
        {
            DropDownName.Items.Add(new ListItem(basename));
            DropDownName.Items.Add(new ListItem(basename + "Plain"));
        }

        DropDownListTemplates.Items.Clear();
        foreach (MailTemplate mt in templatelist)
        {
            // if (cntryList.ContainsKey(mt.CountryCode.ToUpper()))
            // {
            string ItemText = mt.TemplateName + ", "
                              + mt.LanguageCode + "-" + mt.CountryCode
                              + (mt.OrganizationId != 0 ? ", " + Organization.FromIdentity(mt.OrganizationId).Name : "");

            DropDownListTemplates.Items.Add(new ListItem(ItemText, mt.TemplateId.ToString()));
            // }
        }
        Countries countries = Countries.GetInUse();

        foreach (Country cntry in countries)
        {
            if (cntryList.ContainsKey(cntry.Code.ToUpper()))
            {
                DropDownCountry.Items.Add(new ListItem(cntry.Code + " - " + cntry.Name, cntry.Code));
            }
        }
    }
Пример #5
0
 public void SendNotice(TypedMailTemplate mailtempl, int organizationId)
 {
     SendNotice(mailtempl, organizationId, false);
 }
Пример #6
0
 public void SendOfficerNotice(TypedMailTemplate mailtempl, int organizationId)
 {
     SendNotice(mailtempl, organizationId, true);
 }
Пример #7
0
    private void BuildTable()
    {
        tab.Rows.Clear();

        OutboundMails mails = OutboundMails.FromArray(PirateDb.GetDatabase().GetOutboundMailQueue(500));

        TableRow row = new TableRow();

        tab.Rows.Add(row);
        TableCell c = new TableCell(); row.Cells.Add(c);

        c.Text = "Template";

        c      = new TableCell(); row.Cells.Add(c);
        c.Text = "Title";

        c      = new TableCell(); row.Cells.Add(c);
        c.Text = "Release time";

        c      = new TableCell(); row.Cells.Add(c);
        c.Text = "Time until release";

        c      = new TableCell(); row.Cells.Add(c);
        c.Text = "Counts";

        c      = new TableCell(); row.Cells.Add(c);
        c.Text = "Started";

        foreach (OutboundMail mail in mails)
        {
            TypedMailTemplate tmpl = null;
            if (mail.MailType != 0)
            {
                tmpl = TypedMailTemplate.FromName(mail.Title);
                tmpl.Initialize("SE", mail.OrganizationId, mail, "");
                tmpl.InsertAllPlaceHoldersToTemplate();
            }
            row = new TableRow();
            tab.Rows.Add(row);

            if (mail.MailType != 0)
            {
                c      = new TableCell(); row.Cells.Add(c);
                c.Text = mail.Title;

                c      = new TableCell(); row.Cells.Add(c);
                c.Text = tmpl.Template.TemplateTitleText;
            }
            else
            {
                c      = new TableCell(); row.Cells.Add(c);
                c.Text = "none";

                c      = new TableCell(); row.Cells.Add(c);
                c.Text = mail.Title;
            }
            c      = new TableCell(); row.Cells.Add(c);
            c.Text = mail.ReleaseDateTime.ToString();
            if ((new DateTime(1970, 1, 1)) == mail.StartProcessDateTime && mail.ReleaseDateTime < DateTime.Now)
            {
                c.ForeColor = System.Drawing.Color.Red;
                c.Font.Bold = true;
            }

            c      = new TableCell(); row.Cells.Add(c);
            c.Text = Math.Round((DateTime.Now.Subtract(mail.ReleaseDateTime).TotalMinutes)).ToString();


            c       = new TableCell(); row.Cells.Add(c);
            c.Text  = mail.RecipientCount.ToString();
            c.Text += " / " + mail.RecipientsSuccess.ToString();
            c.Text += " / " + mail.RecipientsFail.ToString();

            c      = new TableCell(); row.Cells.Add(c);
            c.Text = mail.StartProcessDateTime.ToString();
        }
    }