Example #1
0
        public static string WrapInNestedCenteringTable(string htmlString)
        {
            // ReSharper disable StringLiteralTypo
            var emailCenterTable = new TableTag();

            emailCenterTable.Attr("width", "100%");
            emailCenterTable.Attr("border", "0");
            emailCenterTable.Attr("cellspacing", "0");
            emailCenterTable.Attr("cellpadding", "0");
            var emailCenterRow = emailCenterTable.AddBodyRow();

            var emailCenterLeftCell = emailCenterRow.Cell();

            emailCenterLeftCell.Attr("max-width", "1%");
            emailCenterLeftCell.Attr("align", "center");
            emailCenterLeftCell.Attr("valign", "top");
            emailCenterLeftCell.Text(" ").Encoded(false);

            var emailCenterContentCell = emailCenterRow.Cell();

            emailCenterContentCell.Attr("width", "100%");
            emailCenterContentCell.Attr("align", "center");
            emailCenterContentCell.Attr("valign", "top");

            var emailCenterRightCell = emailCenterRow.Cell();

            emailCenterRightCell.Attr("max-width", "1%");
            emailCenterRightCell.Attr("align", "center");
            emailCenterRightCell.Attr("valign", "top");
            emailCenterRightCell.Text(" ").Encoded(false);
            // ReSharper restore StringLiteralTypo

            var outerTable = new TableTag();

            emailCenterContentCell.Children.Add(outerTable);
            outerTable.Style("width", "100%");
            outerTable.Style("max-width", "900px");

            outerTable.TBody.Text(htmlString).Encoded(false);

            return(emailCenterTable.ToString());
        }
Example #2
0
        private HtmlTag EmailImageTableTag(ImageContent dbEntry)
        {
            var tableContainer = new TableTag();

            tableContainer.Style("margin", "20px").Style("text-align", "center");
            var pictureRow  = tableContainer.AddBodyRow();
            var pictureCell = pictureRow.Cell();

            pictureCell.Children.Add(Tags.PictureEmailImgTag(Pictures, true));

            var captionRow  = tableContainer.AddBodyRow();
            var captionCell = captionRow.Cell(Tags.ImageCaptionText(dbEntry));

            captionCell.Style("opacity", ".5");

            return(tableContainer);
        }
Example #3
0
        public CommonResponse NeedsReorderEmail()
        {
            var response = new CommonResponse();

            try
            {
                var ctx = context as MROContext;

                var needsReorderList = ctx.InventoryInputs
                                       .GroupBy(e => new
                {
                    e.CatMaterial
                    //, e.CatUnitOfMeasure
                }).Select(e => new
                {
                    e.Key,
                    e.Key.CatMaterial.Value,
                    e.Key.CatMaterial.MaterialDescription,
                    BalanceSum = e.Sum(b => b.Balance),
                    id         = e.Key.CatMaterial.CatMaterialKey
                })
                                       .Where(e => e.BalanceSum < e.Key.CatMaterial.Min)
                                       .ToList();


                var htmlReport = new TableTag();
                htmlReport.Style("border", "solid 1px gray");
                var headerRow = htmlReport.AddHeaderRow();

                headerRow.Header().Text("Material");
                headerRow.Header().Text("Description");
                //headerRow.Header().Text("Unit of Measure");
                headerRow.Header().Text("Balance");
                headerRow.Header("Minimum");
                foreach (var item in needsReorderList)
                {
                    var row = htmlReport.AddBodyRow();
                    row.Cell(item.Value);
                    row.Cell(item.MaterialDescription);
                    //row.Cell(item.Key.CatUnitOfMeasure.Value);
                    row.Cell(item.BalanceSum.ToString());
                    row.Cell(item.Key.CatMaterial.Min.ToString());
                }

                EmailService emailService = new EmailService("", 25)
                {
                    //EmailAddress = "",
                    //Password = "",
                    //From = "",
                    //Subject = "Needs Reorder",

                    EmailAddress = "",
                    Password     = "",
                    From         = "",
                    Subject      = "Needs Reorder",

                    Body = needsReorderList.Count > 0 ? htmlReport.ToString() : "Inventario sin requerimientos minimos. "
                };


                emailService.To.Add("");
                emailService.To.Add("");

                try
                {
                    if (needsReorderList.Count > 0)
                    {
                        emailService.SendMail();
                    }
                }
                catch (Exception ex)
                {
                    throw new KnownError("Error. Could not send email.\n" + ex.ToString());
                }

                return(response.Success());
            }
            catch (KnownError ke)
            {
                return(response.Error(ke));
            }
            catch (Exception ex)
            {
                return(response.Error(ex.Message));
            }
        }