public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, HashSet <Type> registerExpression) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ViewLogEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Target, e.ViewAction, e.User, e.Duration, e.StartDate, e.EndDate, }); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; var exp = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity entity) => entity.ViewLogs()); var expLast = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity entity) => entity.ViewLogMyLast()); foreach (var t in registerExpression) { dqm.RegisterExpression(new ExtensionInfo(t, exp, exp.Body.Type, "ViewLogs", () => typeof(ViewLogEntity).NicePluralName())); dqm.RegisterExpression(new ExtensionInfo(t, expLast, expLast.Body.Type, "LastViewLog", () => ViewLogMessage.ViewLogMyLast.NiceToString())); } DynamicQueryManager.Current.QueryExecuted += Current_QueryExecuted; sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += Type_PreDeleteSqlSync; } }
public static void RegisterExpressions <T>(DynamicQueryManager dqm) where T : TreeEntity { dqm.RegisterExpression((T c) => c.Children(), () => TreeMessage.Children.NiceToString()); dqm.RegisterExpression((T c) => c.Parent(), () => TreeMessage.Parent.NiceToString()); dqm.RegisterExpression((T c) => c.Descendants(), () => TreeMessage.Descendants.NiceToString()); dqm.RegisterExpression((T c) => c.Ascendants(), () => TreeMessage.Ascendants.NiceToString()); dqm.RegisterExpression((T c) => c.Level(), () => TreeMessage.Level.NiceToString()); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, long serverSeed = 1000000000) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { ServerSeed = serverSeed; sb.Include <DisconnectedMachineEntity>() .WithQuery(dqm, () => dm => new { Entity = dm, dm.MachineName, dm.State, dm.SeedMin, dm.SeedMax, }); sb.Include <DisconnectedExportEntity>() .WithQuery(dqm, () => dm => new { Entity = dm, dm.CreationDate, dm.Machine, dm.State, dm.Total, dm.Exception, }); sb.Include <DisconnectedImportEntity>() .WithQuery(dqm, () => dm => new { Entity = dm, dm.CreationDate, dm.Machine, dm.State, dm.Total, dm.Exception, }); dqm.RegisterExpression((DisconnectedMachineEntity dm) => dm.Imports(), () => DisconnectedMessage.Imports.NiceToString()); dqm.RegisterExpression((DisconnectedMachineEntity dm) => dm.Exports(), () => DisconnectedMessage.Exports.NiceToString()); MachineGraph.Register(); sb.Schema.SchemaCompleted += AssertDisconnectedStrategies; sb.Schema.Synchronizing += Schema_Synchronizing; sb.Schema.Generating += Schema_Generating; sb.Schema.EntityEventsGlobal.Saving += new SavingEventHandler <Entity>(EntityEventsGlobal_Saving); sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(AuthCache_PreDeleteSqlSync); Validator.PropertyValidator((DisconnectedMachineEntity d) => d.SeedMin).StaticPropertyValidation += (dm, pi) => ValidateDisconnectedMachine(dm, pi, isMin: true); Validator.PropertyValidator((DisconnectedMachineEntity d) => d.SeedMax).StaticPropertyValidation += (dm, pi) => ValidateDisconnectedMachine(dm, pi, isMin: false); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<EmailPackageEntity>(); dqm.RegisterExpression((EmailPackageEntity ep) => ep.Messages(), () => EmailMessageMessage.Messages.NiceToString()); dqm.RegisterExpression((EmailPackageEntity ep) => ep.RemainingMessages(), () => EmailMessageMessage.RemainingMessages.NiceToString()); dqm.RegisterExpression((EmailPackageEntity ep) => ep.ExceptionMessages(), () => EmailMessageMessage.ExceptionMessages.NiceToString()); ProcessLogic.AssertStarted(sb); ProcessLogic.Register(EmailMessageProcess.CreateEmailsSendAsync, new CreateEmailsSendAsyncProcessAlgorithm()); ProcessLogic.Register(EmailMessageProcess.SendEmails, new SendEmailProcessAlgorithm()); new Graph<ProcessEntity>.ConstructFromMany<EmailMessageEntity>(EmailMessageOperation.ReSendEmails) { Construct = (messages, args) => { EmailPackageEntity emailPackage = new EmailPackageEntity() { Name = args.TryGetArgC<string>() }.Save(); foreach (var m in messages.Select(m => m.RetrieveAndForget())) { new EmailMessageEntity() { Package = emailPackage.ToLite(), From = m.From, Recipients = m.Recipients.ToMList(), Target = m.Target, Body = m.Body, IsBodyHtml = m.IsBodyHtml, Subject = m.Subject, Template = m.Template, EditableMessage = m.EditableMessage, State = EmailMessageState.RecruitedForSending }.Save(); } return ProcessLogic.Create(EmailMessageProcess.SendEmails, emailPackage); } }.Register(); dqm.RegisterQuery(typeof(EmailPackageEntity), () => from e in Database.Query<EmailPackageEntity>() select new { Entity = e, e.Id, e.Name, }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { FileTypeLogic.Start(sb, dqm); sb.Include <FilePathEntity>() .WithQuery(dqm, () => p => new { Entity = p, p.Id, p.FileName, p.FileType, p.Suffix }); FilePathEntity.CalculatePrefixPair = CalculatePrefixPair; sb.Schema.EntityEvents <FilePathEntity>().PreSaving += FilePath_PreSaving; sb.Schema.EntityEvents <FilePathEntity>().PreUnsafeDelete += new PreUnsafeDeleteHandler <FilePathEntity>(FilePathLogic_PreUnsafeDelete); new Graph <FilePathEntity> .Execute(FilePathOperation.Save) { AllowsNew = true, Lite = false, Execute = (fp, _) => { if (!fp.IsNew) { var ofp = fp.ToLite().Retrieve(); if (fp.FileName != ofp.FileName || fp.Suffix != ofp.Suffix) { using (Transaction tr = new Transaction()) { var preSufix = ofp.Suffix.Substring(0, ofp.Suffix.Length - ofp.FileName.Length); fp.Suffix = Path.Combine(preSufix, fp.FileName); fp.Save(); fp.FileType.GetAlgorithm().MoveFile(ofp, fp); tr.Commit(); } } } } } .Register(); sb.AddUniqueIndex <FilePathEntity>(f => new { f.Suffix, f.FileType }); //With mixins, add AttachToUniqueIndexes to field dqm.RegisterExpression((FilePathEntity fp) => fp.WebImage(), () => typeof(WebImage).NiceName(), "Image"); dqm.RegisterExpression((FilePathEntity fp) => fp.WebDownload(), () => typeof(WebDownload).NiceName(), "Download"); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <EmailPackageEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, }); dqm.RegisterExpression((EmailPackageEntity ep) => ep.Messages(), () => EmailMessageMessage.Messages.NiceToString()); dqm.RegisterExpression((EmailPackageEntity ep) => ep.RemainingMessages(), () => EmailMessageMessage.RemainingMessages.NiceToString()); dqm.RegisterExpression((EmailPackageEntity ep) => ep.ExceptionMessages(), () => EmailMessageMessage.ExceptionMessages.NiceToString()); ProcessLogic.AssertStarted(sb); ProcessLogic.Register(EmailMessageProcess.CreateEmailsSendAsync, new CreateEmailsSendAsyncProcessAlgorithm()); ProcessLogic.Register(EmailMessageProcess.SendEmails, new SendEmailProcessAlgorithm()); new Graph <ProcessEntity> .ConstructFromMany <EmailMessageEntity>(EmailMessageOperation.ReSendEmails) { Construct = (messages, args) => { EmailPackageEntity emailPackage = new EmailPackageEntity() { Name = args.TryGetArgC <string>() }.Save(); foreach (var m in messages.Select(m => m.RetrieveAndForget())) { new EmailMessageEntity() { Package = emailPackage.ToLite(), From = m.From, Recipients = m.Recipients.ToMList(), Target = m.Target, Body = m.Body, IsBodyHtml = m.IsBodyHtml, Subject = m.Subject, Template = m.Template, EditableMessage = m.EditableMessage, State = EmailMessageState.RecruitedForSending }.Save(); } return(ProcessLogic.Create(EmailMessageProcess.SendEmails, emailPackage)); } } .Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, params Type[] registerExpressionsFor) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <AlertEntity>() .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.AlertType, a.AlertDate, a.Title, Text = a.Text.Etc(100), a.Target, a.CreationDate, a.CreatedBy, a.AttendedDate, a.AttendedBy, }); AlertGraph.Register(); sb.Include <AlertTypeEntity>() .WithSave(AlertTypeOperation.Save) .WithQuery(dqm, () => t => new { Entity = t, t.Id, t.Name, t.Key, }); SemiSymbolLogic <AlertTypeEntity> .Start(sb, () => SystemAlertTypes); if (registerExpressionsFor != null) { var alerts = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.Alerts()); var myActiveAlerts = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.MyActiveAlerts()); foreach (var type in registerExpressionsFor) { dqm.RegisterExpression(new ExtensionInfo(type, alerts, alerts.Body.Type, "Alerts", () => typeof(AlertEntity).NicePluralName())); dqm.RegisterExpression(new ExtensionInfo(type, myActiveAlerts, myActiveAlerts.Body.Type, "MyActiveAlerts", () => AlertMessage.MyActiveAlerts.NiceToString())); } } Started = true; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <FileEntity>() .WithQuery(dqm, () => a => new { Entity = a, a.Id, a.FileName, }); dqm.RegisterExpression((FileEntity f) => f.WebImage(), () => typeof(WebImage).NiceName(), "Image"); dqm.RegisterExpression((FileEntity f) => f.WebDownload(), () => typeof(WebDownload).NiceName(), "Download"); } }
public static void RegisterPreviousLog <T>(DynamicQueryManager dqm) where T : Entity { dqm.RegisterExpression( (T entity) => entity.PreviousOperationLog(), () => OperationMessage.PreviousOperationLog.NiceToString()); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, HashSet<Type> registerExpression) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<ViewLogEntity>(); dqm.RegisterQuery(typeof(ViewLogEntity), () => from e in Database.Query<ViewLogEntity>() select new { Entity = e, e.Id, e.Target, e.ViewAction, e.User, e.Duration, e.StartDate, e.EndDate, }); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; var exp = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity entity) => entity.ViewLogs()); foreach (var t in registerExpression) { dqm.RegisterExpression(new ExtensionInfo(t, exp, exp.Body.Type, "ViewLogs", () => typeof(ViewLogEntity).NicePluralName())); } DynamicQueryManager.Current.QueryExecuted += Current_QueryExecuted; sb.Schema.Table<TypeEntity>().PreDeleteSqlSync += Type_PreDeleteSqlSync; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { IsStarted = true; AuthLogic.AssertStarted(sb); sb.Include<UserTicketEntity>(); dqm.RegisterQuery(typeof(UserTicketEntity), () => from ut in Database.Query<UserTicketEntity>() select new { Entity = ut, ut.Id, ut.User, ut.Ticket, ut.ConnectionDate, ut.Device, }); dqm.RegisterExpression((UserEntity u) => u.UserTickets(), () => typeof(UserTicketEntity).NicePluralName()); sb.Schema.EntityEvents<UserEntity>().Saving += UserTicketLogic_Saving; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <OperationLogEntity>(); SymbolLogic <OperationSymbol> .Start(sb, () => RegisteredOperations); dqm.RegisterQuery(typeof(OperationSymbol), () => from os in Database.Query <OperationSymbol>() select new { Entity = os, os.Id, os.Key }); dqm.RegisterQuery(typeof(OperationLogEntity), () => from lo in Database.Query <OperationLogEntity>() select new { Entity = lo, lo.Id, lo.Target, lo.Operation, lo.User, lo.Start, lo.End, lo.Exception }); dqm.RegisterExpression((OperationSymbol o) => o.Logs(), () => OperationMessage.Logs.NiceToString()); dqm.RegisterExpression((Entity o) => o.OperationLogs(), () => typeof(OperationLogEntity).NicePluralName()); sb.Schema.EntityEventsGlobal.Saving += EntityEventsGlobal_Saving; sb.Schema.Table <OperationSymbol>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(Operation_PreDeleteSqlSync); sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(Type_PreDeleteSqlSync); sb.Schema.SchemaCompleted += OperationLogic_Initializing; ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<FileEntity>(); dqm.RegisterQuery(typeof(FileEntity), () => from a in Database.Query<FileEntity>() select new { Entity = a, a.Id, a.FileName, }); dqm.RegisterExpression((FileEntity f) => f.WebImage(), () => typeof(WebImage).NiceName(), "Image"); dqm.RegisterExpression((FileEntity f) => f.WebDownload(), () => typeof(WebDownload).NiceName(), "Download"); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, params Type[] registerExpressionsFor) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <NoteEntity>() .WithSave(NoteOperation.Save) .WithQuery(dqm, () => n => new { Entity = n, n.Id, n.CreatedBy, n.CreationDate, n.Title, Text = n.Text.Etc(100), n.Target }); new Graph <NoteEntity> .ConstructFrom <Entity>(NoteOperation.CreateNoteFromEntity) { Construct = (a, _) => new NoteEntity { CreationDate = TimeZoneManager.Now, Target = a.ToLite() } } .Register(); sb.Include <NoteTypeEntity>() .WithSave(NoteTypeOperation.Save) .WithQuery(dqm, () => t => new { Entity = t, t.Id, t.Name, t.Key, }); SemiSymbolLogic <NoteTypeEntity> .Start(sb, () => SystemNoteTypes); if (registerExpressionsFor != null) { var exp = Signum.Utilities.ExpressionTrees.Linq.Expr((Entity ident) => ident.Notes()); foreach (var type in registerExpressionsFor) { dqm.RegisterExpression(new ExtensionInfo(type, exp, exp.Body.Type, "Notes", () => typeof(NoteEntity).NicePluralName())); } } started = true; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, bool countLocalizationHits) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { CultureInfoLogic.AssertStarted(sb); sb.Include<TranslatorUserEntity>(); dqm.RegisterQuery(typeof(TranslatorUserEntity), () => from e in Database.Query<TranslatorUserEntity>() select new { Entity = e, e.Id, e.User, Cultures = e.Cultures.Count, }); PermissionAuthLogic.RegisterTypes(typeof(TranslationPermission)); dqm.RegisterExpression((IUserEntity e) => e.TranslatorUser(), () => typeof(TranslatorUserEntity).NiceName()); new Graph<TranslatorUserEntity>.Execute(TranslatorUserOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.Register(); new Graph<TranslatorUserEntity>.Delete(TranslatorUserOperation.Delete) { Delete = (e, _) => { e.Delete(); } }.Register(); if (countLocalizationHits) DescriptionManager.NotLocalizedMemeber += DescriptionManager_NotLocalizedMemeber; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { IsStarted = true; AuthLogic.AssertStarted(sb); sb.Include <UserTicketEntity>() .WithQuery(dqm, () => ut => new { Entity = ut, ut.Id, ut.User, ut.Ticket, ut.ConnectionDate, ut.Device, }); dqm.RegisterExpression((UserEntity u) => u.UserTickets(), () => typeof(UserTicketEntity).NicePluralName()); sb.Schema.EntityEvents <UserEntity>().Saving += UserTicketLogic_Saving; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<EmployeeEntity>(); dqm.RegisterQuery(typeof(RegionEntity), () => from r in Database.Query<RegionEntity>() select new { Entity = r.ToLite(), r.Id, r.Description, }); dqm.RegisterExpression((RegionEntity r) => r.Territories(), () => typeof(TerritoryEntity).NiceName()); dqm.RegisterQuery(typeof(TerritoryEntity), () => from t in Database.Query<TerritoryEntity>() select new { Entity = t.ToLite(), t.Id, t.Description, Region = t.Region.ToLite() }); dqm.RegisterQuery(typeof(EmployeeEntity), () => from e in Database.Query<EmployeeEntity>() select new { Entity = e.ToLite(), e.Id, e.FirstName, e.LastName, e.BirthDate, e.Photo, //1 }); dqm.RegisterQuery(EmployeeQuery.EmployeesByTerritory, () => from e in Database.Query<EmployeeEntity>() from t in e.Territories select new { Entity = e.ToLite(), e.Id, e.FirstName, e.LastName, e.BirthDate, e.Photo, //2 Territory = t.ToLite(), }); new Graph<EmployeeEntity>.Execute(EmployeeOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } }.Register(); new Graph<TerritoryEntity>.Execute(TerritoryOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } }.Register(); new Graph<RegionEntity>.Execute(RegionOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } }.Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { AuthLogic.AssertStarted(sb); OperationLogic.AssertStarted(sb); Implementations imp = sb.Settings.GetImplementations((ScheduledTaskEntity st) => st.Task); Implementations imp2 = sb.Settings.GetImplementations((ScheduledTaskLogEntity st) => st.Task); if (!imp2.Equals(imp2)) throw new InvalidOperationException("Implementations of ScheduledTaskEntity.Task should be the same as in ScheduledTaskLogEntity.Task"); PermissionAuthLogic.RegisterPermissions(SchedulerPermission.ViewSchedulerPanel); ExecuteTask.Register((ITaskEntity t) => { throw new NotImplementedException("SchedulerLogic.ExecuteTask not registered for {0}".FormatWith(t.GetType().Name)); }); SimpleTaskLogic.Start(sb, dqm); sb.Include<ScheduledTaskEntity>(); sb.Include<ScheduledTaskLogEntity>(); dqm.RegisterQuery(typeof(HolidayCalendarEntity), () => from st in Database.Query<HolidayCalendarEntity>() select new { Entity = st, st.Id, st.Name, Holidays = st.Holidays.Count, }); dqm.RegisterQuery(typeof(ScheduledTaskEntity), () => from st in Database.Query<ScheduledTaskEntity>() select new { Entity = st, st.Id, st.Task, st.Rule, st.Suspended, st.MachineName, st.ApplicationName }); dqm.RegisterQuery(typeof(ScheduledTaskLogEntity), () => from cte in Database.Query<ScheduledTaskLogEntity>() select new { Entity = cte, cte.Id, cte.Task, cte.ScheduledTask, cte.StartTime, cte.EndTime, cte.ProductEntity, cte.MachineName, cte.User, cte.Exception, }); dqm.RegisterExpression((ITaskEntity ct) => ct.Executions(), () => TaskMessage.Executions.NiceToString()); dqm.RegisterExpression((ITaskEntity ct) => ct.LastExecution(), () => TaskMessage.LastExecution.NiceToString()); dqm.RegisterExpression((ScheduledTaskEntity ct) => ct.Executions(), () => TaskMessage.Executions.NiceToString()); new Graph<HolidayCalendarEntity>.Execute(HolidayCalendarOperation.Save) { AllowsNew = true, Lite = false, Execute = (c, _) => { }, }.Register(); new Graph<HolidayCalendarEntity>.Delete(HolidayCalendarOperation.Delete) { Delete = (c, _) => { c.Delete(); }, }.Register(); new Graph<ScheduledTaskEntity>.Execute(ScheduledTaskOperation.Save) { AllowsNew = true, Lite = false, Execute = (st, _) => { }, }.Register(); new Graph<ScheduledTaskEntity>.Delete(ScheduledTaskOperation.Delete) { Delete = (st, _) => { st.Executions().UnsafeUpdate().Set(l => l.ScheduledTask, l => null).Execute(); var rule = st.Rule; st.Delete(); rule.Delete(); }, }.Register(); new Graph<IEntity>.ConstructFrom<ITaskEntity>(TaskOperation.ExecuteSync) { Construct = (task, _) => ExecuteSync(task, null, UserHolder.Current)?.Retrieve() }.Register(); new Graph<ITaskEntity>.Execute(TaskOperation.ExecuteAsync) { Execute = (task, _) => ExecuteAsync(task, null, UserHolder.Current) }.Register(); ScheduledTasksLazy = sb.GlobalLazy(() => Database.Query<ScheduledTaskEntity>().Where(a => !a.Suspended && (a.MachineName == ScheduledTaskEntity.None || a.MachineName == Environment.MachineName && a.ApplicationName == Schema.Current.ApplicationName)).ToList(), new InvalidateWith(typeof(ScheduledTaskEntity))); ScheduledTasksLazy.OnReset += ScheduledTasksLazy_OnReset; ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<WordTemplateEntity>(); SystemWordTemplateLogic.Start(sb, dqm); SymbolLogic<WordTransformerSymbol>.Start(sb, () => Transformers.Keys.ToHashSet()); SymbolLogic<WordConverterSymbol>.Start(sb, () => Converters.Keys.ToHashSet()); dqm.RegisterQuery(typeof(WordTemplateEntity), ()=> from e in Database.Query<WordTemplateEntity>() select new { Entity = e, e.Id, e.Query, e.Template.Entity.FileName }); dqm.RegisterQuery(typeof(WordTransformerSymbol), () => from f in Database.Query<WordTransformerSymbol>() select new { Entity = f, f.Key }); dqm.RegisterQuery(typeof(WordConverterSymbol), () => from f in Database.Query<WordConverterSymbol>() select new { Entity = f, f.Key }); dqm.RegisterExpression((SystemWordTemplateEntity e) => e.WordTemplates(), () => typeof(WordTemplateEntity).NiceName()); new Graph<WordTemplateEntity>.Execute(WordTemplateOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.Register(); new Graph<WordTemplateEntity>.Execute(WordTemplateOperation.CreateWordReport) { CanExecute = et => { if (et.SystemWordTemplate != null && SystemWordTemplateLogic.RequiresExtraParameters(et.SystemWordTemplate)) return "SystemWordTemplate ({1}) requires extra parameters".FormatWith(et.SystemWordTemplate); return null; }, Execute = (et, args) => { throw new InvalidOperationException("UI-only operation"); } }.Register(); TemplatesByType = sb.GlobalLazy(() => { var list = Database.Query<WordTemplateEntity>().Select(r => KVP.Create(r.Query, r.ToLite())).ToList(); return (from kvp in list let imp = dqm.GetEntityImplementations(kvp.Key.ToQueryName()) where !imp.IsByAll from t in imp.Types group kvp.Value by t into g select KVP.Create(g.Key.ToTypeEntity(), g.ToList())).ToDictionary(); }, new InvalidateWith(typeof(WordTemplateEntity))); WordTemplatesLazy = sb.GlobalLazy(() => Database.Query<WordTemplateEntity>() .ToDictionary(et => et.ToLite()), new InvalidateWith(typeof(WordTemplateEntity))); Schema.Current.Synchronizing += Schema_Synchronize_Tokens; Validator.PropertyValidator((WordTemplateEntity e) => e.Template).StaticPropertyValidation += ValidateTemplate; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { FileTypeLogic.Start(sb, dqm); sb.Include<FilePathEntity>(); sb.Schema.EntityEvents<FilePathEntity>().Retrieved += FilePathLogic_Retrieved; sb.Schema.EntityEvents<FilePathEntity>().PreSaving += FilePath_PreSaving; sb.Schema.EntityEvents<FilePathEntity>().PreUnsafeDelete += new PreUnsafeDeleteHandler<FilePathEntity>(FilePathLogic_PreUnsafeDelete); dqm.RegisterQuery(typeof(FilePathEntity), () => from p in Database.Query<FilePathEntity>() select new { Entity = p, p.Id, p.FileName, p.FileType, p.Sufix }); new Graph<FilePathEntity>.Execute(FilePathOperation.Save) { AllowsNew = true, Lite = false, Execute = (fp, _) => { if (!fp.IsNew) { var ofp = fp.ToLite().Retrieve(); if (fp.FileName != ofp.FileName || fp.Sufix != ofp.Sufix || fp.FullPhysicalPath != ofp.FullPhysicalPath) { using (Transaction tr = new Transaction()) { var preSufix = ofp.Sufix.Substring(0, ofp.Sufix.Length - ofp.FileName.Length); fp.Sufix = Path.Combine(preSufix, fp.FileName); fp.Save(); System.IO.File.Move(ofp.FullPhysicalPath, fp.FullPhysicalPath); tr.Commit(); } } } } }.Register(); sb.AddUniqueIndex<FilePathEntity>(f => new { f.Sufix, f.FileType }); //With mixins, add AttachToUniqueIndexes to field dqm.RegisterExpression((FilePathEntity fp) => fp.WebImage(), () => typeof(WebImage).NiceName(), "Image"); dqm.RegisterExpression((FilePathEntity fp) => fp.WebDownload(), () => typeof(WebDownload).NiceName(), "Download"); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, bool packages, bool packageOperations) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { ProcessLogic.AssertStarted(sb); sb.Settings.AssertImplementedBy((ProcessExceptionLineEntity pel) => pel.Line, typeof(PackageLineEntity)); sb.Include <PackageLineEntity>(); dqm.RegisterQuery(typeof(PackageLineEntity), () => from pl in Database.Query <PackageLineEntity>() let p = pl.Package.Entity.LastProcess() select new { Entity = pl, pl.Package, pl.Id, pl.Target, pl.Result, pl.FinishTime, LastProcess = p, Exception = pl.Exception(p), }); dqm.RegisterExpression((PackageEntity p) => p.Lines(), () => ProcessMessage.Lines.NiceToString()); if (packages) { sb.Settings.AssertImplementedBy((PackageLineEntity pl) => pl.Package, typeof(PackageEntity)); sb.Settings.AssertImplementedBy((ProcessEntity pe) => pe.Data, typeof(PackageEntity)); sb.Include <PackageEntity>(); dqm.RegisterQuery(typeof(PackageEntity), () => from pk in Database.Query <PackageEntity>() let pe = pk.LastProcess() select new { Entity = pk, pk.Id, pk.Name, NumLines = pk.Lines().Count(), LastProcess = pe, NumErrors = pk.Lines().Count(l => l.Exception(pe) != null), }); } if (packageOperations) { sb.Settings.AssertImplementedBy((PackageLineEntity pl) => pl.Package, typeof(PackageOperationEntity)); sb.Settings.AssertImplementedBy((ProcessEntity pe) => pe.Data, typeof(PackageOperationEntity)); sb.Include <PackageOperationEntity>(); dqm.RegisterQuery(typeof(PackageOperationEntity), () => from p in Database.Query <PackageOperationEntity>() let pe = p.LastProcess() select new { Entity = p, p.Id, p.Name, p.Operation, NumLines = p.Lines().Count(), LastProcess = pe, NumErrors = p.Lines().Count(l => l.Exception(pe) != null), }); ProcessLogic.Register(PackageOperationProcess.PackageOperation, new PackageOperationAlgorithm()); } ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(CompanyEntity)); sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(PersonEntity)); sb.Include <PersonEntity>() .WithSave(CustomerOperation.Save) .WithQuery(dqm, () => r => new { Entity = r, r.Id, r.FirstName, r.LastName, r.DateOfBirth, r.Phone, r.Fax, r.Address, }); sb.Include <CompanyEntity>() .WithSave(CustomerOperation.Save) .WithQuery(dqm, () => r => new { Entity = r, r.Id, r.CompanyName, r.ContactName, r.ContactTitle, r.Phone, r.Fax, r.Address, }); dqm.RegisterQuery(CustomerQuery.Customer, () => DynamicQueryCore.Manual(async(request, descriptions, token) => { var persons = Database.Query <PersonEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "P " + p.Id, Name = p.FirstName + " " + p.LastName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperationsAsync(request, token); var companies = Database.Query <CompanyEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "C " + p.Id, Name = p.CompanyName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperationsAsync(request, token); return((await persons).Concat(await companies) .OrderBy(request.Orders) .TryPaginate(request.Pagination)); }) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((PersonEntity comp) => comp.Id), PropertyRoute.Construct((CompanyEntity p) => p.Id)) .ColumnProperyRoutes(a => a.Name, PropertyRoute.Construct((PersonEntity comp) => comp.FirstName), PropertyRoute.Construct((PersonEntity comp) => comp.LastName), PropertyRoute.Construct((CompanyEntity p) => p.CompanyName)) .ColumnProperyRoutes(a => a.Address, PropertyRoute.Construct((PersonEntity comp) => comp.Address), PropertyRoute.Construct((PersonEntity comp) => comp.Address)) .ColumnProperyRoutes(a => a.Phone, PropertyRoute.Construct((PersonEntity comp) => comp.Phone), PropertyRoute.Construct((CompanyEntity p) => p.Phone)) .ColumnProperyRoutes(a => a.Fax, PropertyRoute.Construct((PersonEntity comp) => comp.Fax), PropertyRoute.Construct((CompanyEntity p) => p.Fax)) , entityImplementations: Implementations.By(typeof(PersonEntity), typeof(CompanyEntity))); dqm.RegisterExpression((CustomerEntity c) => c.Address).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Phone).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Fax).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(CompanyEntity)); sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(PersonEntity)); sb.Include<PersonEntity>(); sb.Include<CompanyEntity>(); dqm.RegisterQuery(typeof(PersonEntity), () => from r in Database.Query<PersonEntity>() select new { Entity = r, r.Id, r.FirstName, r.LastName, r.DateOfBirth, r.Phone, r.Fax, r.Address, }); dqm.RegisterQuery(typeof(CompanyEntity), () => from r in Database.Query<CompanyEntity>() select new { Entity = r, r.Id, r.CompanyName, r.ContactName, r.ContactTitle, r.Phone, r.Fax, r.Address, }); new Graph<CustomerEntity>.Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.Register(); new Graph<CompanyEntity>.Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.RegisterReplace(); new Graph<PersonEntity>.Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.RegisterReplace(); dqm.RegisterQuery(CustomerQuery.Customer, () => DynamicQueryCore.Manual((QueryRequest request, QueryDescription descriptions) => { var persons = Database.Query<PersonEntity>().Select(p => new { Entity = p.ToLite<CustomerEntity>(), Id = "P " + p.Id, Name = p.FirstName + " " + p.LastName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); var companies = Database.Query<CompanyEntity>().Select(p => new { Entity = p.ToLite<CustomerEntity>(), Id = "C " + p.Id, Name = p.CompanyName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); return persons.Concat(companies) .OrderBy(request.Orders) .TryPaginate(request.Pagination); }) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((PersonEntity comp) => comp.Id), PropertyRoute.Construct((CompanyEntity p) => p.Id)) .ColumnProperyRoutes(a => a.Name, PropertyRoute.Construct((PersonEntity comp) => comp.FirstName), PropertyRoute.Construct((PersonEntity comp) => comp.LastName), PropertyRoute.Construct((CompanyEntity p) => p.CompanyName)) .ColumnProperyRoutes(a => a.Address, PropertyRoute.Construct((PersonEntity comp) => comp.Address), PropertyRoute.Construct((PersonEntity comp) => comp.Address)) .ColumnProperyRoutes(a => a.Phone, PropertyRoute.Construct((PersonEntity comp) => comp.Phone), PropertyRoute.Construct((CompanyEntity p) => p.Phone)) .ColumnProperyRoutes(a => a.Fax, PropertyRoute.Construct((PersonEntity comp) => comp.Fax), PropertyRoute.Construct((CompanyEntity p) => p.Fax)) , entityImplementations: Implementations.By(typeof(PersonEntity), typeof(CompanyEntity))); dqm.RegisterExpression((CustomerEntity c) => c.Address).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Phone).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Fax).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ProcessAlgorithmSymbol>() .WithQuery(dqm, () => pa => new { Entity = pa, pa.Id, pa.Key }); sb.Include <ProcessEntity>() .WithQuery(dqm, () => p => new { Entity = p, p.Id, p.Algorithm, p.Data, p.State, p.MachineName, p.ApplicationName, p.CreationDate, p.PlannedDate, p.CancelationDate, p.QueuedDate, p.ExecutionStart, p.ExecutionEnd, p.SuspendDate, p.ExceptionDate, }); sb.Include <ProcessExceptionLineEntity>() .WithQuery(dqm, () => p => new { Entity = p, p.Line, p.Process, p.Exception, }); PermissionAuthLogic.RegisterPermissions(ProcessPermission.ViewProcessPanel); SymbolLogic <ProcessAlgorithmSymbol> .Start(sb, dqm, () => registeredProcesses.Keys.ToHashSet()); OperationLogic.AssertStarted(sb); ProcessGraph.Register(); dqm.RegisterExpression((ProcessAlgorithmSymbol p) => p.Processes(), () => typeof(ProcessEntity).NicePluralName()); dqm.RegisterExpression((ProcessAlgorithmSymbol p) => p.LastProcess(), () => ProcessMessage.LastProcess.NiceToString()); dqm.RegisterExpression((IProcessDataEntity p) => p.Processes(), () => typeof(ProcessEntity).NicePluralName()); dqm.RegisterExpression((IProcessDataEntity p) => p.LastProcess(), () => ProcessMessage.LastProcess.NiceToString()); dqm.RegisterExpression((IProcessLineDataEntity p) => p.ExceptionLines(), () => ProcessMessage.ExceptionLines.NiceToString()); PropertyAuthLogic.AvoidAutomaticUpgradeCollection.Add(PropertyRoute.Construct((ProcessEntity p) => p.User)); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, Func<Pop3ConfigurationEntity, IPop3Client> getPop3Client, FileTypeAlgorithm attachment) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { GetPop3Client = getPop3Client; FilePathLogic.Register(EmailFileType.Attachment, attachment); MixinDeclarations.AssertDeclared(typeof(EmailMessageEntity), typeof(EmailReceptionMixin)); MimeType.CacheExtension.TryAdd("message/rfc822", ".eml"); sb.Include<Pop3ConfigurationEntity>(); sb.Include<Pop3ReceptionEntity>(); sb.Include<Pop3ReceptionExceptionEntity>(); dqm.RegisterQuery(typeof(EmailMessageEntity), () => from e in Database.Query<EmailMessageEntity>() select new { Entity = e, e.Id, e.From, e.Subject, e.Template, e.State, e.Sent, SentDate = (DateTime?)e.Mixin<EmailReceptionMixin>().ReceptionInfo.SentDate, e.Package, e.Exception, }); dqm.RegisterQuery(typeof(Pop3ConfigurationEntity), () => from s in Database.Query<Pop3ConfigurationEntity>() select new { Entity = s, s.Id, s.Host, s.Port, s.Username, s.EnableSSL }); dqm.RegisterQuery(typeof(Pop3ReceptionEntity), () => DynamicQuery.DynamicQuery.Auto( from s in Database.Query<Pop3ReceptionEntity>() select new { Entity = s, s.Id, s.Pop3Configuration, s.StartDate, s.EndDate, s.NewEmails, EmailMessages = s.EmailMessages().Count(), Exceptions = s.Exceptions().Count(), s.Exception, }) .ColumnDisplayName(a => a.EmailMessages, () => typeof(EmailMessageEntity).NicePluralName()) .ColumnDisplayName(a => a.Exceptions, () => typeof(ExceptionEntity).NicePluralName())); dqm.RegisterQuery(typeof(Pop3ConfigurationEntity), () => from s in Database.Query<Pop3ConfigurationEntity>() select new { Entity = s, s.Id, s.Host, s.Port, s.Username, s.EnableSSL }); dqm.RegisterExpression((Pop3ConfigurationEntity c) => c.Receptions(), () => typeof(Pop3ReceptionEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.EmailMessages(), () => typeof(EmailMessageEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.Exceptions(), () => typeof(ExceptionEntity).NicePluralName()); dqm.RegisterExpression((ExceptionEntity r) => r.Pop3Reception(), () => typeof(Pop3ReceptionEntity).NiceName()); new Graph<Pop3ConfigurationEntity>.Execute(Pop3ConfigurationOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } }.Register(); new Graph<Pop3ReceptionEntity>.ConstructFrom<Pop3ConfigurationEntity>(Pop3ConfigurationOperation.ReceiveEmails) { AllowsNew = true, Lite = false, Construct = (e, _) => { using (Transaction tr = Transaction.None()) { var result = e.ReceiveEmails(); return tr.Commit(result); } } }.Register(); SchedulerLogic.ExecuteTask.Register((Pop3ConfigurationEntity smtp) => smtp.ReceiveEmails().ToLite()); SimpleTaskLogic.Register(Pop3ConfigurationAction.ReceiveAllActivePop3Configurations, () => { if (!EmailLogic.Configuration.ReciveEmails) throw new InvalidOperationException("EmailLogic.Configuration.ReciveEmails is set to false"); foreach (var item in Database.Query<Pop3ConfigurationEntity>().Where(a => a.Active).ToList()) { item.ReceiveEmails(); } return null; }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <EmployeeEntity>(); dqm.RegisterQuery(typeof(RegionEntity), () => from r in Database.Query <RegionEntity>() select new { Entity = r, r.Id, r.Description, }); dqm.RegisterExpression((RegionEntity r) => r.Territories(), () => typeof(TerritoryEntity).NiceName()); dqm.RegisterQuery(typeof(TerritoryEntity), () => from t in Database.Query <TerritoryEntity>() select new { Entity = t, t.Id, t.Description, t.Region }); dqm.RegisterQuery(typeof(EmployeeEntity), () => from e in Database.Query <EmployeeEntity>() select new { Entity = e, e.Id, e.FirstName, e.LastName, e.BirthDate, e.Photo, //1 }); dqm.RegisterQuery(EmployeeQuery.EmployeesByTerritory, () => from e in Database.Query <EmployeeEntity>() from t in e.Territories select new { Entity = e, e.Id, e.FirstName, e.LastName, e.BirthDate, e.Photo, //2 Territory = t, }); new Graph <EmployeeEntity> .Execute(EmployeeOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } } .Register(); new Graph <TerritoryEntity> .Execute(TerritoryOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } } .Register(); new Graph <RegionEntity> .Execute(RegionOperation.Save) { Lite = false, AllowsNew = true, Execute = (e, _) => { } } .Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(CompanyEntity)); sb.Settings.AssertImplementedBy((OrderEntity o) => o.Customer, typeof(PersonEntity)); sb.Include <PersonEntity>(); sb.Include <CompanyEntity>(); dqm.RegisterQuery(typeof(PersonEntity), () => from r in Database.Query <PersonEntity>() select new { Entity = r, r.Id, r.FirstName, r.LastName, r.DateOfBirth, r.Phone, r.Fax, r.Address, }); dqm.RegisterQuery(typeof(CompanyEntity), () => from r in Database.Query <CompanyEntity>() select new { Entity = r, r.Id, r.CompanyName, r.ContactName, r.ContactTitle, r.Phone, r.Fax, r.Address, }); new Graph <CustomerEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .Register(); new Graph <CompanyEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .RegisterReplace(); new Graph <PersonEntity> .Execute(CustomerOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .RegisterReplace(); dqm.RegisterQuery(typeof(CustomerEntity), () => DynamicQuery.Manual((QueryRequest request, QueryDescription descriptions) => { var persons = Database.Query <PersonEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "P " + p.Id, Name = p.FirstName + " " + p.LastName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); var companies = Database.Query <CompanyEntity>().Select(p => new { Entity = p.ToLite <CustomerEntity>(), Id = "C " + p.Id, Name = p.CompanyName, p.Address, p.Phone, p.Fax }).ToDQueryable(descriptions).AllQueryOperations(request); return(persons.Concat(companies) .OrderBy(request.Orders) .TryPaginate(request.Pagination)); }) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((PersonEntity comp) => comp.Id), PropertyRoute.Construct((CompanyEntity p) => p.Id)) .ColumnProperyRoutes(a => a.Name, PropertyRoute.Construct((PersonEntity comp) => comp.FirstName), PropertyRoute.Construct((PersonEntity comp) => comp.LastName), PropertyRoute.Construct((CompanyEntity p) => p.CompanyName)) .ColumnProperyRoutes(a => a.Address, PropertyRoute.Construct((PersonEntity comp) => comp.Address), PropertyRoute.Construct((PersonEntity comp) => comp.Address)) .ColumnProperyRoutes(a => a.Phone, PropertyRoute.Construct((PersonEntity comp) => comp.Phone), PropertyRoute.Construct((CompanyEntity p) => p.Phone)) .ColumnProperyRoutes(a => a.Fax, PropertyRoute.Construct((PersonEntity comp) => comp.Fax), PropertyRoute.Construct((CompanyEntity p) => p.Fax)) , entityImplementations: Implementations.By(typeof(PersonEntity), typeof(CompanyEntity))); dqm.RegisterExpression((CustomerEntity c) => c.Address).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Phone).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); dqm.RegisterExpression((CustomerEntity c) => c.Fax).ForcePropertyRoute = PropertyRoute.Construct((PersonEntity p) => p.Address); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <WordTemplateEntity>() .WithSave(WordTemplateOperation.Save) .WithDelete(WordTemplateOperation.Delete) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.Query, e.Culture, e.Template.Entity.FileName }); PermissionAuthLogic.RegisterPermissions(WordTemplatePermission.GenerateReport); SystemWordTemplateLogic.Start(sb, dqm); SymbolLogic <WordTransformerSymbol> .Start(sb, dqm, () => Transformers.Keys.ToHashSet()); SymbolLogic <WordConverterSymbol> .Start(sb, dqm, () => Converters.Keys.ToHashSet()); sb.Include <WordTransformerSymbol>() .WithQuery(dqm, () => f => new { Entity = f, f.Key }); sb.Include <WordConverterSymbol>() .WithQuery(dqm, () => f => new { Entity = f, f.Key }); ToDataTableProviders.Add("Model", new ModelDataTableProvider()); ToDataTableProviders.Add("UserQuery", new UserQueryDataTableProvider()); ToDataTableProviders.Add("UserChart", new UserChartDataTableProvider()); dqm.RegisterExpression((SystemWordTemplateEntity e) => e.WordTemplates(), () => typeof(WordTemplateEntity).NiceName()); new Graph <WordTemplateEntity> .Execute(WordTemplateOperation.CreateWordReport) { CanExecute = et => { if (et.SystemWordTemplate != null && SystemWordTemplateLogic.RequiresExtraParameters(et.SystemWordTemplate)) { return(WordTemplateMessage._01RequiresExtraParameters.NiceToString(typeof(SystemWordTemplateEntity).NiceName(), et.SystemWordTemplate)); } return(null); }, Execute = (et, args) => { throw new InvalidOperationException("UI-only operation"); } } .Register(); WordTemplatesLazy = sb.GlobalLazy(() => Database.Query <WordTemplateEntity>() .ToDictionary(et => et.ToLite()), new InvalidateWith(typeof(WordTemplateEntity))); TemplatesByQueryName = sb.GlobalLazy(() => { return(WordTemplatesLazy.Value.Values.GroupToDictionary(a => a.Query.ToQueryName())); }, new InvalidateWith(typeof(WordTemplateEntity))); TemplatesByEntityType = sb.GlobalLazy(() => { return((from wr in WordTemplatesLazy.Value.Values let imp = DynamicQueryManager.Current.GetEntityImplementations(wr.Query.ToQueryName()) where !imp.IsByAll from t in imp.Types select KVP.Create(t, wr)) .GroupToDictionary(a => a.Key, a => a.Value)); }, new InvalidateWith(typeof(WordTemplateEntity))); Schema.Current.Synchronizing += Schema_Synchronize_Tokens; Validator.PropertyValidator((WordTemplateEntity e) => e.Template).StaticPropertyValidation += ValidateTemplate; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, Func <WorkflowConfigurationEmbedded> getConfiguration) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { PermissionAuthLogic.RegisterPermissions(WorkflowScriptRunnerPanelPermission.ViewWorkflowScriptRunnerPanel); WorkflowLogic.getConfiguration = getConfiguration; sb.Include <WorkflowEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.MainEntityStrategy, }); WorkflowGraph.Register(); dqm.RegisterExpression((WorkflowEntity wf) => wf.WorkflowStartEvent()); DynamicCode.GetCustomErrors += GetCustomErrors; sb.Include <WorkflowPoolEntity>() .WithUniqueIndex(wp => new { wp.Workflow, wp.Name }) .WithSave(WorkflowPoolOperation.Save) .WithDelete(WorkflowPoolOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowPools()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Workflow, }); sb.Include <WorkflowLaneEntity>() .WithUniqueIndex(wp => new { wp.Pool, wp.Name }) .WithSave(WorkflowLaneOperation.Save) .WithDelete(WorkflowLaneOperation.Delete) .WithExpressionFrom(dqm, (WorkflowPoolEntity p) => p.WorkflowLanes()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Pool, e.Pool.Workflow, }); sb.Include <WorkflowActivityEntity>() .WithUniqueIndex(w => new { w.Lane, w.Name }) .WithSave(WorkflowActivityOperation.Save) .WithDelete(WorkflowActivityOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowActivities()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowActivities()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.Comments, e.Lane, e.Lane.Pool.Workflow, }); sb.AddUniqueIndexMList((WorkflowActivityEntity a) => a.Jumps, mle => new { mle.Parent, mle.Element.To }); sb.Include <WorkflowEventEntity>() .WithSave(WorkflowEventOperation.Save) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowEvents()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowEvents()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Type, e.Name, e.BpmnElementId, e.Lane, e.Lane.Pool.Workflow, }); new Graph <WorkflowEventEntity> .Delete(WorkflowEventOperation.Delete) { Delete = (e, _) => { if (e.Type.IsTimerStart()) { var scheduled = e.ScheduledTask(); if (scheduled != null) { WorkflowEventTaskLogic.DeleteWorkflowEventScheduledTask(scheduled); } } e.Delete(); }, } .Register(); sb.Include <WorkflowGatewayEntity>() .WithSave(WorkflowGatewayOperation.Save) .WithDelete(WorkflowGatewayOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowGateways()) .WithExpressionFrom(dqm, (WorkflowLaneEntity p) => p.WorkflowGateways()) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Type, e.Name, e.BpmnElementId, e.Lane, e.Lane.Pool.Workflow, }); sb.Include <WorkflowConnectionEntity>() .WithSave(WorkflowConnectionOperation.Save) .WithDelete(WorkflowConnectionOperation.Delete) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowConnections()) .WithExpressionFrom(dqm, (WorkflowEntity p) => p.WorkflowMessageConnections(), null) .WithExpressionFrom(dqm, (WorkflowPoolEntity p) => p.WorkflowConnections()) .WithExpressionFrom(dqm, (IWorkflowNodeEntity p) => p.NextConnections(), null) .WithExpressionFrom(dqm, (IWorkflowNodeEntity p) => p.PreviousConnections(), null) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.BpmnElementId, e.From, e.To, }); WorkflowGraphLazy = sb.GlobalLazy(() => { using (new EntityCache()) { var events = Database.RetrieveAll <WorkflowEventEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var gateways = Database.RetrieveAll <WorkflowGatewayEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var activities = Database.RetrieveAll <WorkflowActivityEntity>().GroupToDictionary(a => a.Lane.Pool.Workflow.ToLite()); var connections = Database.RetrieveAll <WorkflowConnectionEntity>().GroupToDictionary(a => a.From.Lane.Pool.Workflow.ToLite()); var result = Database.RetrieveAll <WorkflowEntity>().ToDictionary(workflow => workflow.ToLite(), workflow => { var w = workflow.ToLite(); var nodeGraph = new WorkflowNodeGraph { Workflow = workflow, Events = events.TryGetC(w).EmptyIfNull().ToDictionary(e => e.ToLite()), Gateways = gateways.TryGetC(w).EmptyIfNull().ToDictionary(g => g.ToLite()), Activities = activities.TryGetC(w).EmptyIfNull().ToDictionary(a => a.ToLite()), Connections = connections.TryGetC(w).EmptyIfNull().ToDictionary(c => c.ToLite()), }; nodeGraph.FillGraphs(); return(nodeGraph); }); return(result); } }, new InvalidateWith(typeof(WorkflowConnectionEntity))); Validator.PropertyValidator((WorkflowConnectionEntity c) => c.Condition).StaticPropertyValidation = (e, pi) => { if (e.Condition != null && e.From != null) { var conditionType = Conditions.Value.GetOrThrow(e.Condition).MainEntityType; var workflowType = e.From.Lane.Pool.Workflow.MainEntityType; if (!conditionType.Is(workflowType)) { return(WorkflowMessage.Condition0IsDefinedFor1Not2.NiceToString(conditionType, workflowType)); } } return(null); }; sb.Include <WorkflowConditionEntity>() .WithSave(WorkflowConditionOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.Eval.Script }); new Graph <WorkflowConditionEntity> .Delete(WorkflowConditionOperation.Delete) { Delete = (e, _) => { ThrowConnectionError(Database.Query <WorkflowConnectionEntity>().Where(a => a.Condition == e.ToLite()), e); e.Delete(); }, } .Register(); new Graph <WorkflowConditionEntity> .ConstructFrom <WorkflowConditionEntity>(WorkflowConditionOperation.Clone) { Construct = (e, args) => { return(new WorkflowConditionEntity { MainEntityType = e.MainEntityType, Eval = new WorkflowConditionEval { Script = e.Eval.Script } }); }, } .Register(); WorkflowEventTaskEntity.GetWorkflowEntity = lite => WorkflowGraphLazy.Value.GetOrThrow(lite).Workflow; Conditions = sb.GlobalLazy(() => Database.Query <WorkflowConditionEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowConditionEntity))); sb.Include <WorkflowActionEntity>() .WithSave(WorkflowActionOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.MainEntityType, e.Eval.Script }); new Graph <WorkflowActionEntity> .Delete(WorkflowActionOperation.Delete) { Delete = (e, _) => { ThrowConnectionError(Database.Query <WorkflowConnectionEntity>().Where(a => a.Action == e.ToLite()), e); e.Delete(); }, } .Register(); new Graph <WorkflowActionEntity> .ConstructFrom <WorkflowActionEntity>(WorkflowActionOperation.Clone) { Construct = (e, args) => { return(new WorkflowActionEntity { MainEntityType = e.MainEntityType, Eval = new WorkflowActionEval { Script = e.Eval.Script } }); }, } .Register(); Actions = sb.GlobalLazy(() => Database.Query <WorkflowActionEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowActionEntity))); sb.Include <WorkflowScriptEntity>() .WithSave(WorkflowScriptOperation.Save) .WithQuery(dqm, () => s => new { Entity = s, s.Id, s.Name, s.MainEntityType, }); new Graph <WorkflowScriptEntity> .Delete(WorkflowScriptOperation.Delete) { Delete = (s, _) => { ThrowConnectionError(Database.Query <WorkflowActivityEntity>().Where(a => a.Script.Script == s.ToLite()), s); s.Delete(); }, } .Register(); Scripts = sb.GlobalLazy(() => Database.Query <WorkflowScriptEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(WorkflowScriptEntity))); sb.Include <WorkflowScriptRetryStrategyEntity>() .WithSave(WorkflowScriptRetryStrategyOperation.Save) .WithDelete(WorkflowScriptRetryStrategyOperation.Delete) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Rule }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { if (!Schema.Current.Settings.TypeValues.ContainsKey(typeof(TimeSpan))) { sb.Settings.FieldAttributes((AlbumEntity a) => a.Songs[0].Duration).Add(new Signum.Entities.IgnoreAttribute()); sb.Settings.FieldAttributes((AlbumEntity a) => a.BonusTrack.Duration).Add(new Signum.Entities.IgnoreAttribute()); } sb.Include <AlbumEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.Author, a.Label, a.Year }); sb.Include <NoteWithDateEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Text, a.Target, a.CreationTime, }); sb.Include <PersonalAwardEntity>(); sb.Include <AwardNominationEntity>(); sb.Include <ConfigEntity>(); MinimumExtensions.IncludeFunction(sb.Schema.Assets); sb.Include <ArtistEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.IsMale, a.Sex, a.Dead, a.LastAward, }); dqm.RegisterExpression((IAuthorEntity au) => Database.Query <AlbumEntity>().Where(a => a.Author == au), () => typeof(AlbumEntity).NicePluralName(), "Albums"); sb.Include <BandEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, a.LastAward, }); sb.Include <LabelEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Name, }); sb.Include <AmericanMusicAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result, }); sb.Include <GrammyAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result }); sb.Include <PersonalAwardEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Year, a.Category, a.Result }); sb.Include <AwardNominationEntity>() .WithQuery(dqm, a => new { Entity = a, a.Id, a.Award, a.Author }); dqm.RegisterQuery(typeof(IAuthorEntity), () => DynamicQueryCore.Manual((request, descriptions) => { var one = (from a in Database.Query <ArtistEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Artist", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }).ToDQueryable(descriptions).AllQueryOperations(request); var two = (from a in Database.Query <BandEntity>() select new { Entity = (IAuthorEntity)a, a.Id, Type = "Band", a.Name, Lonely = a.Lonely(), LastAward = a.LastAward }).ToDQueryable(descriptions).AllQueryOperations(request); return(one.Concat(two).OrderBy(request.Orders).TryPaginate(request.Pagination)); }) .Column(a => a.LastAward, cl => cl.Implementations = Implementations.ByAll) .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((ArtistEntity a) => a.Id), PropertyRoute.Construct((BandEntity a) => a.Id)), entityImplementations: Implementations.By(typeof(ArtistEntity), typeof(BandEntity))); Validator.PropertyValidator((NoteWithDateEntity n) => n.Text) .IsApplicableValidator <StringLengthValidatorAttribute>(n => Corruption.Strict); AlbumGraph.Register(); RegisterOperations(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, Func <Pop3ConfigurationEntity, IPop3Client> getPop3Client) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { GetPop3Client = getPop3Client; MixinDeclarations.AssertDeclared(typeof(EmailMessageEntity), typeof(EmailReceptionMixin)); sb.Include <Pop3ConfigurationEntity>() .WithSave(Pop3ConfigurationOperation.Save) .WithQuery(dqm, () => s => new { Entity = s, s.Id, s.Host, s.Port, s.Username, s.EnableSSL }); sb.Include <Pop3ReceptionEntity>(); sb.Include <Pop3ReceptionExceptionEntity>(); sb.Include <EmailMessageEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.From, e.Subject, e.Template, e.State, e.Sent, SentDate = (DateTime?)e.Mixin <EmailReceptionMixin>().ReceptionInfo.SentDate, e.Package, e.Exception, }); dqm.RegisterQuery(typeof(Pop3ReceptionEntity), () => DynamicQueryCore.Auto( from s in Database.Query <Pop3ReceptionEntity>() select new { Entity = s, s.Id, s.Pop3Configuration, s.StartDate, s.EndDate, s.NewEmails, EmailMessages = s.EmailMessages().Count(), Exceptions = s.Exceptions().Count(), s.Exception, }) .ColumnDisplayName(a => a.EmailMessages, () => typeof(EmailMessageEntity).NicePluralName()) .ColumnDisplayName(a => a.Exceptions, () => typeof(ExceptionEntity).NicePluralName())); dqm.RegisterExpression((Pop3ConfigurationEntity c) => c.Receptions(), () => typeof(Pop3ReceptionEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.EmailMessages(), () => typeof(EmailMessageEntity).NicePluralName()); dqm.RegisterExpression((Pop3ReceptionEntity r) => r.Exceptions(), () => typeof(ExceptionEntity).NicePluralName()); dqm.RegisterExpression((ExceptionEntity r) => r.Pop3Reception(), () => typeof(Pop3ReceptionEntity).NiceName()); new Graph <Pop3ReceptionEntity> .ConstructFrom <Pop3ConfigurationEntity>(Pop3ConfigurationOperation.ReceiveEmails) { AllowsNew = true, Lite = false, Construct = (e, _) => { using (Transaction tr = Transaction.None()) { var result = e.ReceiveEmails(); return(tr.Commit(result)); } } } .Register(); SchedulerLogic.ExecuteTask.Register((Pop3ConfigurationEntity smtp, ScheduledTaskContext ctx) => smtp.ReceiveEmails().ToLite()); SimpleTaskLogic.Register(Pop3ConfigurationAction.ReceiveAllActivePop3Configurations, (ScheduledTaskContext ctx) => { if (!EmailLogic.Configuration.ReciveEmails) { throw new InvalidOperationException("EmailLogic.Configuration.ReciveEmails is set to false"); } foreach (var item in Database.Query <Pop3ConfigurationEntity>().Where(a => a.Active).ToList()) { item.ReceiveEmails(); } return(null); }); } }