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 Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<SmtpConfigurationEntity>(); dqm.RegisterQuery(typeof(SmtpConfigurationEntity), () => from s in Database.Query<SmtpConfigurationEntity>() select new { Entity = s, s.Id, s.DeliveryMethod, s.Network.Host, s.Network.Username, s.PickupDirectoryLocation }); SmtpConfigCache = sb.GlobalLazy(() => Database.Query<SmtpConfigurationEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(SmtpConfigurationEntity))); new Graph<SmtpConfigurationEntity>.Execute(SmtpConfigurationOperation.Save) { AllowsNew = true, Lite = false, Execute = (sc, _) => { }, }.Register(); } }
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) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ResetPasswordRequestEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.RequestDate, e.Code, e.User, e.User.Email }); EmailLogic.AssertStarted(sb); SystemEmailLogic.RegisterSystemEmail <ResetPasswordRequestMail>(() => new EmailTemplateEntity { Messages = CultureInfoLogic.ForEachCulture(culture => new EmailTemplateMessageEmbedded(culture) { Text = "<p>{0}</p>".FormatWith(AuthEmailMessage.YouRecentlyRequestedANewPassword.NiceToString()) + "<p>{0} @[User.UserName]</p>".FormatWith(AuthEmailMessage.YourUsernameIs.NiceToString()) + "<p>{0}</p>".FormatWith(AuthEmailMessage.YouCanResetYourPasswordByFollowingTheLinkBelow.NiceToString()) + "<p><a href=\"@[m:Url]\">@[m:Url]</a></p>", Subject = AuthEmailMessage.ResetPasswordRequestSubject.NiceToString() }).ToMList() }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { PermissionAuthLogic.RegisterPermissions(MapPermission.ViewMap); } }
private void ResetPassword() { String lcDataBlock; String lcQueryName; String lcResult; if ((!String.IsNullOrWhiteSpace(lcQueryName = ApplicationFrame.GetParameter(ctARGParameter))) && (!String.IsNullOrWhiteSpace(lcDataBlock = ApplicationFrame.GetParameter(ctARGDataBlock)))) { try { if ((lcResult = DynamicQueryManager.GetInstance().GetStringResult(DynamicQueryManager.ExecuteMode.Scalar, lcQueryName, General.Base64Decode(lcDataBlock))) != null) { clServiceResponse.AddResponse(CobraServiceResponse.RSP_Result.ToString(), lcResult); clServiceResponse.Success = true; } } catch (Exception paException) { if (paException.InnerException != null) { TranslateException(paException.InnerException); } } } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Schema.SchemaCompleted += Schema_SchemaCompleted; } }
/// <summary> /// Obtiene una implementación de una consulta que puede cambiar según la base de datos. /// </summary> /// <remarks> /// Registro de versiones: /// /// 1.0 07/08/2015 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial. /// </remarks> /// <param name="clase">Clase mediante reflexión, que contiene el método que desea acceder a la base de datos.</param> /// <param name="nombre">Nombre de la consulta en el archivo de configuración.</param> public DynamicQuery CrearQueryDinamica(Type clase, string nombre) { QueryTag consulta = DynamicQueryManager.ObtenerConsulta(nombre, conexion.Type, clase); Query aux = null; if (consulta.Tipo == "StoreProcedure") { aux = CrearProcedimientoAlmacenado(); } else if (consulta.Tipo == "Query") { aux = CrearQuery(); } else { throw new PreparacionException(string.Format("¡El tipo de consulta {0} no es válida!", consulta.Tipo)); } DynamicQuery retorno = new DynamicQuery(this, aux.Mapeador, aux.CreadorQuery); retorno.TipoBaseDatos = conexion.Type; retorno.Nombre = nombre; retorno.Tipo = consulta.Tipo; retorno.Consulta = consulta.Consulta; return(retorno); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { SymbolLogic <TypeConditionSymbol> .Start(sb, dqm, () => infos.SelectMany(a => a.Value.Keys).ToHashSet()); } }
private DataTable RetrieveData() { DataTable lcDataTable; QueryClass lcQueryClass; GridFilterController lcGridFilterController; String lcFilterOption; String lcSortOption; lcGridFilterController = new GridFilterController(SC_FilterMetaData); lcFilterOption = lcGridFilterController.GetMultiFilterStr(clFilterInfo); lcSortOption = lcGridFilterController.GetMultiSortKeyStr(clSortInfo); lcQueryClass = DynamicQueryManager.GetInstance().GetQueryClass(ctRetrieveGridData); lcQueryClass.ReplacePlaceHolder("$FILTEROPTION", lcFilterOption, false); lcQueryClass.ReplacePlaceHolder("$SORTOPTION", lcSortOption, false); lcQueryClass.ReplacePlaceHolder("$PAGEINDEX", clPageIndex.ToString(), false); lcQueryClass.ReplacePlaceHolder("$PAGESIZE", SC_PageSize.ToString(), false); lcDataTable = lcQueryClass.RunQuery(); if (lcDataTable.Rows.Count > 0) { clTotalRows = Convert.ToInt32(lcDataTable.Rows[0][ctCOLTotalRows]); clTotalPages = Convert.ToInt32(lcDataTable.Rows[0][ctCOLTotalPages]); clFetchedRows = lcDataTable.Rows.Count; } else { clTotalRows = 0; clTotalPages = 0; clFetchedRows = 0; } return(lcDataTable); }
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(string connectionString) { DBMS dbms = DBMS.SqlServer2008; SchemaBuilder sb = new SchemaBuilder(dbms); DynamicQueryManager dqm = new DynamicQueryManager(); if (dbms == DBMS.SqlCompact) Connector.Default = new SqlCeConnector(@"Data Source=C:\BaseDatos.sdf", sb.Schema, dqm); else Connector.Default = new SqlConnector(connectionString, sb.Schema, dqm); sb.Schema.Version = typeof(Starter).Assembly.GetName().Version; sb.Schema.Settings.OverrideAttributes((OperationLogDN ol) => ol.User, new ImplementedByAttribute()); sb.Schema.Settings.OverrideAttributes((ExceptionDN e) => e.User, new ImplementedByAttribute()); Validator.PropertyValidator((OperationLogDN e) => e.User).Validators.Clear(); TypeLogic.Start(sb, dqm); OperationLogic.Start(sb, dqm); ExceptionLogic.Start(sb, dqm); MusicLogic.Start(sb, dqm); }
internal static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ChartScriptEntity>() .WithSave(ChartScriptOperation.Save) .WithQuery(dqm, () => uq => new { Entity = uq, uq.Id, uq.Name, uq.GroupBy, uq.Columns.Count, uq.Icon, }); Scripts = sb.GlobalLazy(() => { var result = Database.Query <ChartScriptEntity>().ToDictionary(a => a.Name); foreach (var e in result.Values) { if (e.Icon != null) { e.Icon.Retrieve(); } } return(result); }, new InvalidateWith(typeof(ChartScriptEntity))); RegisterOperations(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <CultureInfoEntity>() .WithSave(CultureInfoOperation.Save) .WithQuery(dqm, () => c => new { Entity = c, c.Id, c.Name, c.EnglishName, c.NativeName, }); CultureInfoToEntity = sb.GlobalLazy(() => Database.Query <CultureInfoEntity>().ToDictionary(ci => ci.Name, ci => ci), invalidateWith: new InvalidateWith(typeof(CultureInfoEntity))); EntityToCultureInfo = sb.GlobalLazy(() => Database.Query <CultureInfoEntity>().ToDictionary(ci => ci, ci => CultureInfoModifier(CultureInfo.GetCultureInfo(ci.Name))), invalidateWith: new InvalidateWith(typeof(CultureInfoEntity))); sb.Schema.Synchronizing += Schema_Synchronizing; } }
static IDisposable Current_QueryExecuted(DynamicQueryManager.ExecuteType type, object queryName, BaseQueryRequest request) { if (request == null || !LogQuery(request, type)) return null; var old = Connector.CurrentLogger; StringWriter sw = new StringWriter(); Connector.CurrentLogger = old == null ? (TextWriter)sw : new DuplicateTextWriter(sw, old); var viewLog = new ViewLogEntity { Target = QueryLogic.GetQueryEntity(queryName).ToLite(), User = UserHolder.Current?.ToLite(), ViewAction = type.ToString(), }; return new Disposable(() => { try { viewLog.EndDate = TimeZoneManager.Now; viewLog.Data = request.QueryUrl + "\r\n\r\n" + sw.ToString(); using (ExecutionMode.Global()) viewLog.Save(); } finally { Connector.CurrentLogger = old; } }); }
private static void StartSouthwindConfiguration(SchemaBuilder sb, DynamicQueryManager dqm) { sb.Include <ApplicationConfigurationEntity>(); Configuration = sb.GlobalLazy <ApplicationConfigurationEntity>( () => Database.Query <ApplicationConfigurationEntity>().Single(a => a.Environment == Settings.Default.Environment), new InvalidateWith(typeof(ApplicationConfigurationEntity))); new Graph <ApplicationConfigurationEntity> .Execute(ApplicationConfigurationOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { }, } .Register(); dqm.RegisterQuery(typeof(ApplicationConfigurationEntity), () => from s in Database.Query <ApplicationConfigurationEntity>() select new { Entity = s, s.Id, s.Environment, s.Email.SendEmails, s.Email.OverrideEmailAddress, s.Email.DefaultCulture, s.Email.UrlLeft }); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <SmtpConfigurationEntity>() .WithQuery(dqm, () => s => new { Entity = s, s.Id, s.DeliveryMethod, s.Network.Host, s.Network.Username, s.PickupDirectoryLocation }); SmtpConfigCache = sb.GlobalLazy(() => Database.Query <SmtpConfigurationEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(SmtpConfigurationEntity))); new Graph <SmtpConfigurationEntity> .Execute(SmtpConfigurationOperation.Save) { AllowsNew = true, Lite = false, Execute = (sc, _) => { }, } .Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { AuthLogic.AssertStarted(sb); sb.Include<SessionLogEntity>(); PermissionAuthLogic.RegisterPermissions(SessionLogPermission.TrackSession); dqm.RegisterQuery(typeof(SessionLogEntity), () => from sl in Database.Query<SessionLogEntity>() select new { Entity = sl, sl.Id, sl.User, sl.SessionStart, sl.SessionEnd, sl.SessionTimeOut }); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <OrderEntity>() .WithQuery(dqm, () => o => new { Entity = o, o.Id, o.State, o.Customer, o.Employee, o.OrderDate, o.RequiredDate, o.ShipAddress, o.ShipVia, }); dqm.RegisterQuery(OrderQuery.OrderLines, () => from o in Database.Query <OrderEntity>() from od in o.Details select new { Entity = o, o.Id, od.Product, od.Quantity, od.UnitPrice, od.Discount, od.SubTotalPrice, }); OrderGraph.Register(); ProcessLogic.Register(OrderProcess.CancelOrders, new CancelOrderAlgorithm()); SimpleTaskLogic.Register(OrderTask.CancelOldOrdersWithProcess, ctx => { var package = new PackageEntity().CreateLines(Database.Query <OrderEntity>().Where(a => a.OrderDate < DateTime.Now.AddDays(-7) && a.State != OrderState.Canceled)); var process = ProcessLogic.Create(OrderProcess.CancelOrders, package); process.Execute(ProcessOperation.Execute); return(process.ToLite()); }); SimpleTaskLogic.Register(OrderTask.CancelOldOrders, ctx => { Database.Query <OrderEntity>() .Where(a => a.OrderDate < DateTime.Now.AddDays(-7)) .UnsafeUpdate() .Set(o => o.CancelationDate, o => DateTime.Now) .Set(o => o.State, o => OrderState.Canceled) .Execute(); return(null); });//CancelOldOrdersProcess } }
internal static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<ChartScriptEntity>(); dqm.RegisterQuery(typeof(ChartScriptEntity), () => from uq in Database.Query<ChartScriptEntity>() select new { Entity = uq, uq.Id, uq.Name, uq.GroupBy, uq.Columns.Count, uq.Icon, }); Scripts = sb.GlobalLazy(() => { var result = Database.Query<ChartScriptEntity>().ToDictionary(a => a.Name); foreach (var e in result.Values) if (e.Icon != null) e.Icon.Retrieve(); return result; }, new InvalidateWith(typeof(ChartScriptEntity))); RegisterOperations(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<DynamicValidationEntity>() .WithSave(DynamicValidationOperation.Save) .WithQuery(dqm, e => new { Entity = e, e.Id, e.Name, e.EntityType, e.PropertyRoute, e.Eval, }); DynamicValidations = sb.GlobalLazy(() => Database.Query<DynamicValidationEntity>() .Select(dv => new DynamicValidationPair { Validation = dv, PropertyRoute = dv.PropertyRoute.ToPropertyRoute() }) .GroupToDictionary(a => a.PropertyRoute.PropertyInfo), new InvalidateWith(typeof(DynamicValidationEntity))); sb.Schema.Initializing += () => { initialized = true; }; Validator.GlobalValidation += DynamicValidation; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <TranslationReplacementEntity>() .WithSave(TranslationReplacementOperation.Save) .WithDelete(TranslationReplacementOperation.Delete) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.CultureInfo, e.WrongTranslation, e.RightTranslation, }); sb.AddUniqueIndex <TranslationReplacementEntity>(tr => new { tr.CultureInfo, tr.WrongTranslation }); ReplacementsLazy = sb.GlobalLazy(() => Database.Query <TranslationReplacementEntity>() .AgGroupToDictionary(a => a.CultureInfo.ToCultureInfo(), gr => { var dic = gr.ToDictionaryEx(a => a.WrongTranslation, a => a.RightTranslation, StringComparer.InvariantCultureIgnoreCase, "wrong translations"); var regex = new Regex(dic.Keys.ToString(Regex.Escape, "|"), RegexOptions.IgnoreCase); return(new TranslationReplacementPack { Dictionary = dic, Regex = regex }); }), new InvalidateWith(typeof(TranslationReplacementEntity))); } }
public static FluentInclude <T> WithTree <T>(this FluentInclude <T> include, DynamicQueryManager dqm, Func <T, MoveTreeModel, T> copy = null) where T : TreeEntity, new() { RegisterExpressions <T>(dqm); RegisterOperations <T>(copy); include.WithUniqueIndex(n => new { n.ParentRoute, n.Name }); return(include); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ShipperEntity>(); dqm.RegisterQuery(typeof(ShipperEntity), () => from a in Database.Query <ShipperEntity>() select new { Entity = a, a.Id, a.CompanyName, a.Phone }); new Graph <ShipperEntity> .Execute(ShipperOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { } } .Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <RestApiKeyEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.User, e.ApiKey }); new Graph <RestApiKeyEntity> .Execute(RestApiKeyOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { }, } .Register(); RestApiKeyCache = sb.GlobalLazy(() => { return(Database.Query <RestApiKeyEntity>().ToDictionaryEx(rak => rak.ApiKey)); }, new InvalidateWith(typeof(RestApiKeyEntity))); } }
public SqlConnector(string connectionString, Schema schema, DynamicQueryManager dqm, SqlServerVersion version) : base(schema, dqm) { this.connectionString = connectionString; this.ParameterBuilder = new SqlParameterBuilder(); this.Version = version; if (version >= SqlServerVersion.SqlServer2008 && schema != null) { var s = schema.Settings; if (!s.TypeValues.ContainsKey(typeof(TimeSpan))) { schema.Settings.TypeValues.Add(typeof(TimeSpan), SqlDbType.Time); } if (!s.UdtSqlName.ContainsKey(typeof(SqlHierarchyId))) { s.UdtSqlName.Add(typeof(SqlHierarchyId), "HierarchyId"); } if (!s.UdtSqlName.ContainsKey(typeof(SqlGeography))) { s.UdtSqlName.Add(typeof(SqlGeography), "Geography"); } if (!s.UdtSqlName.ContainsKey(typeof(SqlGeometry))) { s.UdtSqlName.Add(typeof(SqlGeometry), "Geometry"); } } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <IsolationEntity>() .WithSave(IsolationOperation.Save) .WithQuery(dqm, () => iso => new { Entity = iso, iso.Id, iso.Name }); sb.Schema.EntityEventsGlobal.PreSaving += EntityEventsGlobal_PreSaving; sb.Schema.SchemaCompleted += AssertIsolationStrategies; OperationLogic.SurroundOperation += OperationLogic_SurroundOperation; Isolations = sb.GlobalLazy(() => Database.RetrieveAllLite <IsolationEntity>(), new InvalidateWith(typeof(IsolationEntity))); ProcessLogic.ApplySession += ProcessLogic_ApplySession; Validator.OverridePropertyValidator((IsolationMixin m) => m.Isolation).StaticPropertyValidation += (mi, pi) => { if (strategies.GetOrThrow(mi.MainEntity.GetType()) == IsolationStrategy.Isolated && mi.Isolation == null) { return(ValidationMessage._0IsNotSet.NiceToString(pi.NiceName())); } return(null); }; IsStarted = true; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { PermissionAuthLogic.RegisterPermissions(MapPermission.ViewMap); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ExceptionEntity>(); dqm.RegisterQuery(typeof(ExceptionEntity), () => from r in Database.Query <ExceptionEntity>() select new { Entity = r, r.Id, r.CreationDate, r.ExceptionType, ExcepcionMessage = r.ExceptionMessage, r.StackTraceHash, }); dqm.RegisterQuery(typeof(ExceptionEntity), () => from r in Database.Query <ExceptionEntity>() select new { Entity = r, r.Id, r.CreationDate, r.ExceptionType, ExcepcionMessage = r.ExceptionMessage, r.StackTraceHash, }); DefaultEnvironment = "Default"; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <DynamicValidationEntity>() .WithSave(DynamicValidationOperation.Save) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.EntityType, e.PropertyRoute, e.Eval, }); DynamicValidations = sb.GlobalLazy(() => Database.Query <DynamicValidationEntity>() .Select(dv => new DynamicValidationPair { Validation = dv, PropertyRoute = dv.PropertyRoute.ToPropertyRoute() }) .GroupToDictionary(a => a.PropertyRoute.PropertyInfo), new InvalidateWith(typeof(DynamicValidationEntity))); DynamicValidationEntity.GetMainType = dve => dve.PropertyRoute?.ToPropertyRoute().Parent.Type; sb.Schema.Initializing += () => { initialized = true; }; Validator.GlobalValidation += DynamicValidation; sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += type => Administrator.UnsafeDeletePreCommand(Database.Query <DynamicValidationEntity>().Where(dv => dv.EntityType == type)); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <EmailMasterTemplateEntity>() .WithQuery(dqm, () => t => new { Entity = t, t.Id, t.Name, }); EmailMasterTemplateGraph.Register(); Validator.PropertyValidator <EmailMasterTemplateEntity>(et => et.Messages).StaticPropertyValidation += (et, pi) => { if (!et.Messages.Any(m => m.CultureInfo.Is(EmailLogic.Configuration.DefaultCulture))) { return(EmailTemplateMessage.ThereMustBeAMessageFor0.NiceToString().FormatWith(EmailLogic.Configuration.DefaultCulture.EnglishName)); } return(null); }; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { TypeLogic.AssertStarted(sb); AuthLogic.AssertStarted(sb); TypeConditionLogic.Start(sb, dqm); sb.Schema.EntityEventsGlobal.Saving += Schema_Saving; //because we need Modifications propagated sb.Schema.EntityEventsGlobal.Retrieved += EntityEventsGlobal_Retrieved; sb.Schema.IsAllowedCallback += Schema_IsAllowedCallback; sb.Schema.SchemaCompleted += () => { foreach (var type in TypeConditionLogic.Types) { miRegister.GetInvoker(type)(Schema.Current); } }; sb.Schema.Synchronizing += Schema_Synchronizing; cache = new TypeAuthCache(sb, merger: TypeAllowedMerger.Instance); AuthLogic.ExportToXml += exportAll => cache.ExportXml(exportAll ? TypeLogic.TypeToEntity.Keys.ToList() : null); AuthLogic.ImportFromXml += (x, roles, replacements) => cache.ImportXml(x, roles, replacements); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<ExceptionEntity>(); dqm.RegisterQuery(typeof(ExceptionEntity),()=> from r in Database.Query<ExceptionEntity>() select new { Entity = r, r.Id, r.CreationDate, r.ExceptionType, ExcepcionMessage = r.ExceptionMessage, r.StackTraceHash, }); dqm.RegisterQuery(typeof(ExceptionEntity), ()=> from r in Database.Query<ExceptionEntity>() select new { Entity = r, r.Id, r.CreationDate, r.ExceptionType, ExcepcionMessage = r.ExceptionMessage, r.StackTraceHash, }); DefaultEnvironment = "Default"; } }
private void RenderBrowserMode(ComponentController paComponentController) { IncludeExternalLinkFiles(paComponentController); clItemList = DynamicQueryManager.GetInstance().GetDataTableResult(ctDQYRetrieveItemList); paComponentController.AddAttribute(HtmlAttribute.Class, ctCLSSubControlPOSItemPanelComposite); paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_Type, "itempanel"); paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_Mode, clPriceMode.ToString().ToLower()); // paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_Edition, clEdition.ToString().ToLower()); paComponentController.AddElementType(ComponentController.ElementType.Composite); paComponentController.RenderBeginTag(HtmlTag.Div); paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_DisplayMode, clTransactionSetting.GetData(ctKEYItemPanelDisplayMode, "price").ToLower()); paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_Mode, "list"); paComponentController.AddElementAttribute(ComponentController.ElementAttribute.ea_Root, clLanguageManager.GetText(ctTXTRootCategory)); paComponentController.AddAttribute(HtmlAttribute.Class, ctCLSSubControlPOSItemPanel); paComponentController.AddElementType(ComponentController.ElementType.Panel); paComponentController.RenderBeginTag(HtmlTag.Div); RenderHeaderBar(paComponentController); RenderComponentContainer(paComponentController); paComponentController.RenderEndTag(); paComponentController.RenderEndTag(); }
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(string connectionString) { SchemaBuilder sb = new SchemaBuilder(); DynamicQueryManager dqm = new DynamicQueryManager(); //Connector.Default = new SqlCeConnector(@"Data Source=C:\BaseDatos.sdf", sb.Schema, dqm); Connector.Default = new SqlConnector(connectionString, sb.Schema, dqm, SqlServerVersion.SqlServer2008); sb.Schema.Version = typeof(MusicStarter).Assembly.GetName().Version; sb.Schema.Settings.FieldAttributes((OperationLogEntity ol) => ol.User).Add(new ImplementedByAttribute()); sb.Schema.Settings.FieldAttributes((ExceptionEntity e) => e.User).Add(new ImplementedByAttribute()); Validator.PropertyValidator((OperationLogEntity e) => e.User).Validators.Clear(); TypeLogic.Start(sb, dqm); OperationLogic.Start(sb, dqm); ExceptionLogic.Start(sb, dqm); MusicLogic.Start(sb, dqm); sb.Schema.OnSchemaCompleted(); }
public static void Start(string connectionString) { SchemaBuilder sb = new SchemaBuilder(true); DynamicQueryManager dqm = new DynamicQueryManager(); //Connector.Default = new SqlCeConnector(@"Data Source=C:\BaseDatos.sdf", sb.Schema, dqm); Connector.Default = new SqlConnector(connectionString, sb.Schema, dqm, SqlServerVersion.SqlServer2008); sb.Schema.Version = typeof(MusicStarter).Assembly.GetName().Version; sb.Schema.Settings.FieldAttributes((OperationLogEntity ol) => ol.User).Add(new ImplementedByAttribute()); sb.Schema.Settings.FieldAttributes((ExceptionEntity e) => e.User).Add(new ImplementedByAttribute()); Validator.PropertyValidator((OperationLogEntity e) => e.User).Validators.Clear(); TypeLogic.Start(sb, dqm); OperationLogic.Start(sb, dqm); ExceptionLogic.Start(sb, dqm); MusicLogic.Start(sb, dqm); sb.Schema.OnSchemaCompleted(); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <DynamicTypeEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.TypeName, e.BaseType, }); AvailableEmbeddedEntities = sb.GlobalLazy(() => { var namespaces = DynamicCode.GetNamespaces().ToHashSet(); return(DynamicCode.GetAssemblies() .SelectMany(a => Assembly.LoadFile(a).GetTypes()) .Where(t => typeof(EmbeddedEntity).IsAssignableFrom(t) && namespaces.Contains(t.Namespace)) .ToHashSet()); }, new InvalidateWith(typeof(TypeEntity))); DynamicTypeGraph.Register(); DynamicLogic.GetCodeFiles += GetCodeFiles; DynamicLogic.OnWriteDynamicStarter += WriteDynamicStarter; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, bool excelReport) { if (excelReport) { QueryLogic.Start(sb); sb.Include<ExcelReportEntity>(); dqm.RegisterQuery(typeof(ExcelReportEntity), () => from s in Database.Query<ExcelReportEntity>() select new { Entity = s, s.Id, s.Query, s.File.FileName, s.DisplayName, }); new Graph<ExcelReportEntity>.Execute(ExcelReportOperation.Save) { AllowsNew = true, Lite = false, Execute = (er, _) => { } }.Register(); new Graph<ExcelReportEntity>.Delete(ExcelReportOperation.Delete) { Lite = true, Delete = (er, _) => { er.Delete(); } }.Register(); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { SymbolLogic <ModelConverterSymbol> .Start(sb, dqm, () => Converters.Keys); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <SqlMigrationEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.VersionNumber, }); sb.Include <CSharpMigrationEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.UniqueName, e.ExecutionDate, }); sb.Include <LoadMethodLogEntity>() .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Start, e.Duration, e.ClassName, e.MethodName, e.Description, }); } }
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(); OperationLogic.SetProtectedSave<FilePathEntity>(false); 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) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <DynamicExpressionEntity>() .WithUniqueIndex(a => new { a.FromType, a.Name }) .WithSave(DynamicExpressionOperation.Save) .WithDelete(DynamicExpressionOperation.Delete) .WithQuery(dqm, () => e => new { Entity = e, e.Id, e.Name, e.ReturnType, e.FromType, }); new Graph <DynamicExpressionEntity> .ConstructFrom <DynamicExpressionEntity>(DynamicExpressionOperation.Clone) { Construct = (e, _) => { return(new DynamicExpressionEntity { Name = e.Name + "_2", ReturnType = e.ReturnType, FromType = e.FromType, Body = e.Body, }); } } .Register(); DynamicLogic.GetCodeFiles += GetCodeFiles; DynamicLogic.OnWriteDynamicStarter += WriteDynamicStarter; DynamicTypeLogic.GetAlreadyTranslatedExpressions = () => { CacheLogic.GloballyDisabled = true; try { if (!Administrator.ExistsTable <DynamicExpressionEntity>()) { return(new Dictionary <string, Dictionary <string, string> >()); } using (ExecutionMode.Global()) return(Database.Query <DynamicExpressionEntity>() .Where(a => a.Translation == DynamicExpressionTranslation.TranslateExpressionName) .AgGroupToDictionary(a => a.FromType, gr => gr.ToDictionary(a => a.Name, a => "CodeGenExpressionMessage." + a.Name))); } finally { CacheLogic.GloballyDisabled = false; } }; sb.Schema.Table <TypeEntity>().PreDeleteSqlSync += type => Administrator.UnsafeDeletePreCommand(Database.Query <DynamicExpressionEntity>().Where(de => de.FromType == ((TypeEntity)type).ClassName)); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<PasswordExpiresIntervalEntity>(); dqm.RegisterQuery(typeof(PasswordExpiresIntervalEntity), ()=> from e in Database.Query<PasswordExpiresIntervalEntity>() select new { Entity = e, e.Id, e.Enabled, e.Days, e.DaysWarning }); new Graph<PasswordExpiresIntervalEntity>.Execute(PasswordExpiresIntervalOperation.Save) { AllowsNew = true, Lite = false, Execute = (pei, _) => { }, }.Register(); AuthLogic.UserLogingIn += (u => { if (u.PasswordNeverExpires) return; var ivp = Database.Query<PasswordExpiresIntervalEntity>().Where(p => p.Enabled).FirstOrDefault(); if (ivp == null) return; if (TimeZoneManager.Now > u.PasswordSetDate.AddDays((double)ivp.Days)) throw new PasswordExpiredException(AuthMessage.ExpiredPassword.NiceToString()); }); AuthLogic.LoginMessage += (() => { UserEntity u = UserEntity.Current; if (u.PasswordNeverExpires) return null; PasswordExpiresIntervalEntity ivp = null; using (AuthLogic.Disable()) ivp = Database.Query<PasswordExpiresIntervalEntity>().Where(p => p.Enabled).FirstOrDefault(); if (ivp == null) return null; if (TimeZoneManager.Now > u.PasswordSetDate.AddDays((double)ivp.Days).AddDays((double)-ivp.DaysWarning)) return AuthMessage.YourPasswordIsNearExpiration.NiceToString(); return null; }); } }
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) { sb.Include<ExcelAttachmentEntity>(); dqm.RegisterQuery(typeof(ExcelAttachmentEntity), () => from s in Database.Query<ExcelAttachmentEntity>() select new { Entity = s, s.Id, s.FileName, s.UserQuery, s.Related, }); EmailTemplateLogic.FillAttachmentTokens.Register((ExcelAttachmentEntity uqe, EmailTemplateLogic.FillAttachmentTokenContext ctx) => { if (uqe.FileName != null) EmailTemplateParser.Parse(uqe.FileName, ctx.QueryDescription, ctx.ModelType).FillQueryTokens(ctx.QueryTokens); if (uqe.Title != null) EmailTemplateParser.Parse(uqe.Title, ctx.QueryDescription, ctx.ModelType).FillQueryTokens(ctx.QueryTokens); }); Validator.PropertyValidator((ExcelAttachmentEntity e) => e.FileName).StaticPropertyValidation = ExcelAttachmentFileName_StaticPropertyValidation; Validator.PropertyValidator((ExcelAttachmentEntity e) => e.Title).StaticPropertyValidation = ExcelAttachmentTitle_StaticPropertyValidation; EmailTemplateLogic.GenerateAttachment.Register((ExcelAttachmentEntity uqe, EmailTemplateLogic.GenerateAttachmentContext ctx) => { var finalEntity = uqe.Related?.Retrieve() ?? (Entity)ctx.Entity; using (finalEntity == null ? null : CurrentEntityConverter.SetCurrentEntity(finalEntity)) using (CultureInfoUtils.ChangeBothCultures(ctx.Culture)) { QueryRequest request = UserQueryLogic.ToQueryRequest(uqe.UserQuery.Retrieve()); var title = GetTemplateString(uqe.Title, ref uqe.TitleNode, ctx); var fileName = GetTemplateString(uqe.FileName, ref uqe.FileNameNode, ctx); var bytes = ExcelLogic.ExecutePlainExcel(request, title); return new List<EmailAttachmentEntity> { new EmailAttachmentEntity { File = Files.EmbeddedFilePathLogic.SaveFile(new Entities.Files.EmbeddedFilePathEntity(EmailFileType.Attachment, fileName, bytes)), Type = EmailAttachmentType.Attachment, } }; } }); }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { QueryLogic.Start(sb); PermissionAuthLogic.RegisterPermissions(UserQueryPermission.ViewUserQuery); UserAssetsImporter.RegisterName<UserQueryEntity>("UserQuery"); sb.Schema.Synchronizing += Schema_Synchronizing; sb.Include<UserQueryEntity>(); dqm.RegisterQuery(typeof(UserQueryEntity), () => from uq in Database.Query<UserQueryEntity>() select new { Entity = uq, uq.Query, uq.Id, uq.DisplayName, uq.EntityType, }); sb.Schema.EntityEvents<UserQueryEntity>().Retrieved += UserQueryLogic_Retrieved; new Graph<UserQueryEntity>.Execute(UserQueryOperation.Save) { AllowsNew = true, Lite = false, Execute = (uq, _) => { } }.Register(); new Graph<UserQueryEntity>.Delete(UserQueryOperation.Delete) { Lite = true, Delete = (uq, _) => uq.Delete() }.Register(); UserQueries = sb.GlobalLazy(() => Database.Query<UserQueryEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(UserQueryEntity))); UserQueriesByQuery = sb.GlobalLazy(() => UserQueries.Value.Values.Where(a => a.EntityType == null).GroupToDictionary(a => a.Query.ToQueryName(), a => a.ToLite()), new InvalidateWith(typeof(UserQueryEntity))); UserQueriesByType = sb.GlobalLazy(() => UserQueries.Value.Values.Where(a => a.EntityType != null).GroupToDictionary(a => TypeLogic.IdToType.GetOrThrow(a.EntityType.Id), a => a.ToLite()), new InvalidateWith(typeof(UserQueryEntity))); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { if (sb.Schema.Tables.ContainsKey(typeof(UserChartEntity))) throw new InvalidOperationException("UserChart has already been registered"); UserAssetsImporter.RegisterName<UserChartEntity>("UserChart"); sb.Schema.Synchronizing += Schema_Synchronizing; sb.Include<UserChartEntity>(); dqm.RegisterQuery(typeof(UserChartEntity), () => from uq in Database.Query<UserChartEntity>() select new { Entity = uq, uq.Query, uq.EntityType, uq.Id, uq.DisplayName, uq.ChartScript, uq.GroupResults, }); sb.Schema.EntityEvents<UserChartEntity>().Retrieved += ChartLogic_Retrieved; new Graph<UserChartEntity>.Execute(UserChartOperation.Save) { AllowsNew = true, Lite = false, Execute = (uc, _) => { } }.Register(); new Graph<UserChartEntity>.Delete(UserChartOperation.Delete) { Delete = (uc, _) => { uc.Delete(); } }.Register(); UserCharts = sb.GlobalLazy(() => Database.Query<UserChartEntity>().ToDictionary(a => a.ToLite()), new InvalidateWith(typeof(UserChartEntity))); UserChartsByQuery = sb.GlobalLazy(() => UserCharts.Value.Values.Where(a => a.EntityType == null).GroupToDictionary(a => a.Query.ToQueryName(), a => a.ToLite()), new InvalidateWith(typeof(UserChartEntity))); UserChartsByType = sb.GlobalLazy(() => UserCharts.Value.Values.Where(a => a.EntityType != null).GroupToDictionary(a => TypeLogic.IdToType.GetOrThrow(a.EntityType.Id), a => a.ToLite()), new InvalidateWith(typeof(UserChartEntity))); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm, bool timeTracker, bool heavyProfiler, bool overrideSessionTimeout) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { if (timeTracker) PermissionAuthLogic.RegisterPermissions(ProfilerPermission.ViewTimeTracker); if (heavyProfiler) PermissionAuthLogic.RegisterPermissions(ProfilerPermission.ViewHeavyProfiler); if (overrideSessionTimeout) PermissionAuthLogic.RegisterPermissions(ProfilerPermission.OverrideSessionTimeout); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<DynamicViewEntity>() .WithUniqueIndex(a => new { a.ViewName, a.EntityType }) .WithSave(DynamicViewOperation.Save) .WithDelete(DynamicViewOperation.Delete) .WithQuery(dqm, e => new { Entity = e, e.Id, e.ViewName, e.EntityType, }); new Graph<DynamicViewEntity>.Construct(DynamicViewOperation.Create) { Construct = (_) => new DynamicViewEntity(), }.Register(); new Graph<DynamicViewEntity>.ConstructFrom<DynamicViewEntity>(DynamicViewOperation.Clone) { Construct = (e, _) => new DynamicViewEntity() { ViewName = "", EntityType = e.EntityType, ViewContent = e.ViewContent, }, }.Register(); DynamicViews = sb.GlobalLazy(() => Database.Query<DynamicViewEntity>().GroupToDictionary(a => a.EntityType.ToType()), new InvalidateWith(typeof(DynamicViewEntity))); sb.Include<DynamicViewSelectorEntity>() .WithSave(DynamicViewSelectorOperation.Save) .WithDelete(DynamicViewSelectorOperation.Delete) .WithQuery(dqm, e => new { Entity = e, e.Id, e.EntityType, }); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { FileTypeLogic.Start(sb, dqm); EmbeddedFilePathEntity.OnPreSaving += efp => { if(efp.BinaryFile != null) //First time { FileTypeLogic.SaveFile(efp); } }; EmbeddedFilePathEntity.CalculatePrefixPair += CalculatePrefixPair; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<TranslationReplacementEntity>(); sb.AddUniqueIndex<TranslationReplacementEntity>(tr => new { tr.CultureInfo, tr.WrongTranslation }); dqm.RegisterQuery(typeof(TranslationReplacementEntity), () => from e in Database.Query<TranslationReplacementEntity>() select new { Entity = e, e.Id, e.CultureInfo, e.WrongTranslation, e.RightTranslation, }); new Graph<TranslationReplacementEntity>.Execute(TranslationReplacementOperation.Save) { AllowsNew = true, Lite = false, Execute = (e, _) => { }, }.Register(); new Graph<TranslationReplacementEntity>.Delete(TranslationReplacementOperation.Delete) { Delete = (e, _) => { e.Delete(); }, }.Register(); ReplacementsLazy = sb.GlobalLazy(() => Database.Query<TranslationReplacementEntity>() .AgGroupToDictionary(a => a.CultureInfo.ToCultureInfo(), gr => { var dic = gr.ToDictionary(a => a.WrongTranslation, a => a.RightTranslation, StringComparer.InvariantCultureIgnoreCase, "wrong translations"); var regex = new Regex(dic.Keys.ToString(Regex.Escape, "|"), RegexOptions.IgnoreCase); return new TranslationReplacementPack { Dictionary = dic, Regex = regex }; }), new InvalidateWith(typeof(TranslationReplacementEntity))); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { SymbolLogic<FileTypeSymbol>.Start(sb, () => FileTypes.Keys.ToHashSet()); dqm.RegisterQuery(typeof(FileTypeSymbol), () => from f in Database.Query<FileTypeSymbol>() select new { Entity = f, f.Key }); sb.Schema.SchemaCompleted += Schema_SchemaCompleted; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<ExceptionEntity>() .WithQuery(dqm, e => new { Entity = e, e.Id, e.CreationDate, e.ExceptionType, e.ExceptionMessage, e.StackTraceHash, }); DefaultEnvironment = "Default"; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include<RestLogEntity>() .WithQuery(dqm, e => new { Entity = e, e.Id, e.StartDate, e.Duration, e.Url, e.User, e.Exception, }); } ExceptionLogic.DeleteLogs += DeleteRestLogs; }
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, 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())) { sb.Include<ApplicationEventLogEntity>(); dqm.RegisterQuery(typeof(ApplicationEventLogEntity), () => from s in Database.Query<ApplicationEventLogEntity>() select new { Entity = s, s.Id, s.MachineName, s.GlobalEvent, s.Date, }); ExceptionLogic.DeleteLogs += ExceptionLogic_DeleteLogs; } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { // QueryManagers = queryManagers; sb.Schema.Initializing += () => { queryNamesLazy.Load(); queryNameToEntityLazy.Load(); }; sb.Include<QueryEntity>() .WithQuery(dqm, q => new { Entity = q, q.Key, }); sb.Schema.Synchronizing += SynchronizeQueries; sb.Schema.Generating += Schema_Generating; queryNamesLazy = sb.GlobalLazy(() => CreateQueryNames(), new InvalidateWith(typeof(QueryEntity)), Schema.Current.InvalidateMetadata); queryNameToEntityLazy = sb.GlobalLazy(() => EnumerableExtensions.JoinRelaxed( Database.Query<QueryEntity>().ToList(), QueryNames, q => q.Key, kvp => kvp.Key, (q, kvp) => KVP.Create(kvp.Value, q), "caching QueryEntity").ToDictionary(), new InvalidateWith(typeof(QueryEntity)), Schema.Current.InvalidateMetadata); } }
internal static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { SymbolLogic<SimpleTaskSymbol>.Start(sb, () => tasks.Keys.ToHashSet()); SchedulerLogic.ExecuteTask.Register((SimpleTaskSymbol st) => { Func<Lite<IEntity>> func = tasks.GetOrThrow(st); return func(); }); dqm.RegisterQuery(typeof(SimpleTaskSymbol), ()=> from ct in Database.Query<SimpleTaskSymbol>() select new { Entity = ct, ct.Id, ct.Key, }); } }