Exemple #1
0
        public static void Start(bool smtpConfig, bool newsletter, bool pop3Config, bool emailReport, Type[] quickLinkFrom)
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                CultureInfoClient.Start();

                Navigator.RegisterArea(typeof(MailingClient));
                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EmbeddedEntitySettings <EmailAttachmentEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAttachment")
                    },
                    new EntitySettings <EmailPackageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailPackage")
                    },

                    new EntitySettings <EmailMessageEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMessage"), AvoidValidateRequest = true
                    },

                    new EmbeddedEntitySettings <EmailAddressEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailAddress")
                    },
                    new EmbeddedEntitySettings <EmailRecipientEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailRecipient")
                    },

                    new EmbeddedEntitySettings <EmailConfigurationEmbedded> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailConfiguration")
                    },
                    new EntitySettings <SystemEmailEntity> {
                    },

                    new EntitySettings <EmailMasterTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailMasterTemplateMessageEmbedded>
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailMasterTemplateMessage"),
                        MappingDefault  = new EntityMapping <EmailMasterTemplateMessageEmbedded>(true)
                                          .SetProperty(emtm => emtm.MasterTemplate, ctx =>
                        {
                            return((EmailMasterTemplateEntity)ctx.Parent.Parent.Parent.Parent.UntypedValue);
                        })
                    },

                    new EntitySettings <EmailTemplateEntity> {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplate"), AvoidValidateRequest = true
                    },
                    new EmbeddedEntitySettings <EmailTemplateMessageEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateMessage")
                    },

                    new EmbeddedEntitySettings <EmailTemplateContactEmbedded>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateContact"),
                        MappingDefault  = new EntityMapping <EmailTemplateContactEmbedded>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);
                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        }),
                    },

                    new EmbeddedEntitySettings <EmailTemplateRecipientEntity>()
                    {
                        PartialViewName = e => ViewPrefix.FormatWith("EmailTemplateRecipient"),
                        MappingDefault  = new EntityMapping <EmailTemplateRecipientEntity>(true)
                                          .SetProperty(ec => ec.Token, ctx =>
                        {
                            string tokenStr = UserAssetsHelper.GetTokenString(ctx);

                            return(ParseQueryToken(tokenStr, ctx.Parent.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", EntityBaseKeys.RuntimeInfo)]));
                        })
                    },
                });

                OperationClient.AddSettings(new List <OperationSettings>
                {
                    new EntityOperationSettings <EmailTemplateEntity>(EmailMessageOperation.CreateEmailFromTemplate)
                    {
                        Group = EntityOperationGroup.None,
                        Click = ctx => Module["createMailFromTemplate"](ctx.Options(), JsFunction.Event,
                                                                        new FindOptions(((EmailTemplateEntity)ctx.Entity).Query.ToQueryName()).ToJS(ctx.Prefix, "New"),
                                                                        ctx.Url.Action((MailingController mc) => mc.CreateMailFromTemplateAndEntity()))
                    }
                });

                if (smtpConfig)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SmtpConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpConfiguration")
                        },
                        new EmbeddedEntitySettings <SmtpNetworkDeliveryEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("SmtpNetworkDelivery")
                        },
                        new EmbeddedEntitySettings <ClientCertificationFileEmbedded> {
                            PartialViewName = e => ViewPrefix.FormatWith("ClientCertificationFile")
                        },
                    });
                }

                if (newsletter)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <NewsletterEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Newsletter"), AvoidValidateRequest = true
                        },
                        new EntitySettings <NewsletterDeliveryEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("NewsletterDelivery")
                        },
                    });

                    OperationClient.AddSettings(new List <OperationSettings>
                    {
                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.RemoveRecipients)
                        {
                            Click = ctx => Module["removeRecipients"](ctx.Options(),
                                                                      new FindOptions(typeof(NewsletterDeliveryEntity), "Newsletter", ctx.Entity).ToJS(ctx.Prefix, "New"),
                                                                      ctx.Url.Action((MailingController mc) => mc.RemoveRecipientsExecute()))
                        },

                        new EntityOperationSettings <NewsletterEntity>(NewsletterOperation.Send)
                        {
                            Group = EntityOperationGroup.None,
                        }
                    });
                }

                if (emailReport)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <SendEmailTaskEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("SendEmailTask")
                        }
                    });
                }

                if (pop3Config)
                {
                    Navigator.AddSettings(new List <EntitySettings>
                    {
                        new EntitySettings <Pop3ConfigurationEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Configuration")
                        },
                        new EntitySettings <Pop3ReceptionEntity> {
                            PartialViewName = e => ViewPrefix.FormatWith("Pop3Reception")
                        },
                    });
                }

                if (quickLinkFrom != null)
                {
                    LinksClient.RegisterEntityLinks <Entity>((lite, ctx) =>
                    {
                        if (!quickLinkFrom.Contains(lite.EntityType))
                        {
                            return(null);
                        }

                        return(new[] { new QuickLinkExplore(typeof(EmailMessageEntity), "Target", lite) });
                    });
                }


                TasksGetWebMailBody += WebMailProcessor.ReplaceUntrusted;
                TasksGetWebMailBody += WebMailProcessor.CidToFilePath;

                TasksSetWebMailBody += WebMailProcessor.AssertNoUntrusted;
                TasksSetWebMailBody += WebMailProcessor.FilePathToCid;

                Navigator.EntitySettings <EmailMessageEntity>().MappingMain.AsEntityMapping()
                .RemoveProperty(a => a.Body)
                .SetProperty(a => a.Body, ctx =>
                {
                    if (!ctx.HasInput)
                    {
                        return(ctx.None());
                    }

                    var email = ((EmailMessageEntity)ctx.Parent.UntypedValue);

                    return(SetWebMailBody(ctx.Input, new WebMailOptions
                    {
                        Attachments = email.Attachments,
                        UntrustedImage = null,
                        Url = RouteHelper.New(),
                    }));
                });

                SpecialOmniboxProvider.Register(new SpecialOmniboxAction("AsyncEmailPanel",
                                                                         () => AsyncEmailSenderPermission.ViewAsyncEmailSenderPanel.IsAuthorized(),
                                                                         uh => uh.Action((AsyncEmailSenderController pc) => pc.View())));
            }
        }
Exemple #2
0
        public static void Start()
        {
            if (Navigator.Manager.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                QueryClient.Start();

                UserAssetsClient.Start();
                UserAssetsClient.RegisterExportAssertLink <UserChartEntity>();

                LinksClient.RegisterEntityLinks <UserChartEntity>((lite, ctx) => new[]
                {
                    new QuickLinkAction(ChartMessage.Preview, RouteHelper.New().Action <ChartController>(cc => cc.ViewUserChart(lite, null)))
                    {
                        IsVisible = ChartPermission.ViewCharting.IsAuthorized()
                    }
                });

                Func <SubTokensOptions, Mapping <QueryTokenEmbedded> > qtMapping = ops => ctx =>
                {
                    string tokenStr = UserAssetsHelper.GetTokenString(ctx);

                    string queryKey  = ctx.Parent.Parent.Parent.Inputs[TypeContextUtilities.Compose("Query", "Key")];
                    object queryName = QueryLogic.ToQueryName(queryKey);

                    var chart = ((UserChartEntity)ctx.Parent.Parent.Parent.UntypedValue);

                    QueryDescription qd = DynamicQueryManager.Current.QueryDescription(queryName);
                    return(new QueryTokenEmbedded(QueryUtils.Parse(tokenStr, qd, ops | (chart.GroupResults ? SubTokensOptions.CanAggregate : 0))));
                };

                Navigator.AddSettings(new List <EntitySettings>
                {
                    new EntitySettings <UserChartEntity> {
                        PartialViewName = _ => ChartClient.ViewPrefix.FormatWith("UserChart"), IsCreable = EntityWhen.Never
                    }
                });

                Navigator.EntitySettings <UserChartEntity>().MappingMain = Navigator.EntitySettings <UserChartEntity>().MappingLine =
                    new EntityMapping <UserChartEntity>(true)
                    .SetProperty(cb => cb.Columns, new ChartClient.MListCorrelatedOrDefaultMapping <ChartColumnEmbedded>(ChartClient.MappingChartColumn))
                    .SetProperty(cr => cr.Filters, new MListMapping <QueryFilterEmbedded>
                {
                    ElementMapping = new EntityMapping <QueryFilterEmbedded>(false)
                                     .CreateProperty(a => a.Operation)
                                     .CreateProperty(a => a.ValueString)
                                     .SetProperty(a => a.Token, qtMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                })
                    .SetProperty(cr => cr.Orders, new MListMapping <QueryOrderEmbedded>
                {
                    ElementMapping = new EntityMapping <QueryOrderEmbedded>(false)
                                     .CreateProperty(a => a.OrderType)
                                     .SetProperty(a => a.Token, qtMapping(SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement))
                })
                    .SetProperty(cb => cb.Parameters, new MListDictionaryMapping <ChartParameterEmbedded, string>(p => p.Name)
                {
                    OnlyIfPossible = true
                });

                RouteTable.Routes.MapRoute(null, "UC/{webQueryName}/{lite}",
                                           new { controller = "Chart", action = "ViewUserChart" });

                UserChartEntity.SetConverters(query => QueryLogic.ToQueryName(query.Key), queryName =>
                                              QueryLogic.GetQueryEntity(queryName));

                OperationClient.AddSetting(new EntityOperationSettings <UserChartEntity>(UserChartOperation.Delete)
                {
                    Click = ctx => ChartClient.Module["deleteUserChart"](ctx.Options(), Finder.FindRoute(((UserChartEntity)ctx.Entity).Query.ToQueryName())),
                });

                LinksClient.RegisterEntityLinks <Entity>((entity, ctrl) =>
                {
                    if (!ChartPermission.ViewCharting.IsAuthorized())
                    {
                        return(null);
                    }

                    return(UserChartLogic.GetUserChartsEntity(entity.EntityType)
                           .Select(cp => new UserChartQuickLink(cp, entity)).ToArray());
                });
            }
        }