public async Task <IList <PersonRole> > GetRolesAsync(int personId) { using (var ctx = new DispatchContext()) { return(await ctx.PersonRoles.Include("Role").Where(p => p.PersonId == personId).ToListAsync()); } }
public void VisitString(DispatchContext parserRule, IFunctionCil cilTree, List <IHolderCil> Params) { var value = GetValue(Params[0], cilTree, CilAst.String); var Length = new LocalCil($"_length{cilTree.LocalCils.Count}"); cilTree.LocalCils.Add(Length); var isParam1NotInRange = new LocalCil($"_isParam1InRange{cilTree.LocalCils.Count}"); cilTree.LocalCils.Add(isParam1NotInRange); cilTree.ThreeDirInses.Add(new LenghtCil(Length, value)); //tomamos los valores de los argumentos var param1 = GetValue(Params[1], cilTree, CilAst.Int); var param2 = GetValue(Params[2], cilTree, CilAst.Int); // cilTree.ThreeDirInses.Add(new MinorCil(isParam1NotInRange, param1, Length)); Visit_Runtime_Error_whit_Cond(isParam1NotInRange, cilTree, $"\"({parserRule.id.Line},{parserRule.id.Column+1}) - Rutime Error : Substring out of range\""); var lastIndex = new LocalCil($"_lastIndex{cilTree.LocalCils.Count}"); cilTree.LocalCils.Add(lastIndex); cilTree.ThreeDirInses.Add(new SumCil(lastIndex, param1, param2)); var isParam2NotInRange = new LocalCil($"_isParam2InRange{cilTree.LocalCils.Count}"); cilTree.LocalCils.Add(isParam2NotInRange); cilTree.ThreeDirInses.Add(new Minor_EqualCil(isParam2NotInRange, lastIndex, Length)); Visit_Runtime_Error_whit_Cond(isParam2NotInRange, cilTree, $"\"({parserRule.id.Line},{parserRule.id.Column + 1}) - Rutime Error : Substring out of range\""); }
public static MvcHtmlString Menu(this HtmlHelper helper) { string area = (string)helper.ViewContext.RouteData.DataTokens["area"]; if (area != null && area == "HelpPage") area = null; string controller = (string)helper.ViewContext.RouteData.Values["controller"]; string action = (string)helper.ViewContext.RouteData.Values["action"]; string html = "<ul class='nav nav-list'>"; using (DispatchContext db = new DispatchContext()) { var items = db.MenuItems.OrderBy(i => i.Ordinal).ToList(); items.ForEach(i => { html += "<li"; if (area == i.Area && controller == i.Controller && (i.ActiveForAllActions || action == i.Action)) html += " class='active'"; html += ">"; html += "<a href='"; html += i.Area == null ? "" : "/" + i.Area; html += i.Controller == null ? "" : "/" + i.Controller; html += i.Action == null ? "" : "/" + i.Action; html += "'>"; html += i.Icon == null ? "" : "<i class='" + i.Icon + "'></i>"; html += "<span class='menu-text'> " + i.Caption + " </span>"; html += "</a>"; html += "</li>"; }); } return new MvcHtmlString(html); }
ISendContext CreateSendContext(DispatchContext executionContext, Uri sourceAddress) { var context = new SendMessageContext(executionContext.Body); context.SetSourceAddress(sourceAddress); context.SetDestinationAddress(executionContext.DestinationAddress); context.SetResponseAddress(executionContext.ResponseAddress); context.SetFaultAddress(executionContext.FaultAddress); context.SetRequestId(executionContext.RequestId); context.SetConversationId(executionContext.ConversationId); context.SetCorrelationId(executionContext.CorrelationId); if (executionContext.ExpirationTime.HasValue) context.SetExpirationTime(executionContext.ExpirationTime.Value); context.SetNetwork(executionContext.Network); context.SetRetryCount(executionContext.RetryCount); context.SetContentType(executionContext.ContentType); foreach (var header in executionContext.Headers) context.SetHeader(header.Key, header.Value); return context; }
public DispatchAcceptedEvent(DispatchContext context) { EventId = NewId.NextGuid(); Timestamp = DateTime.UtcNow; _context = context; }
public IList <DTO.Dtos.FareInformation> GetFareInformation(int countryId, int stateId, int cityId) { using (var ctx = new DispatchContext()) { var result = (from cr in ctx.CountryRegions join sp in ctx.StateProvinces on cr.ID equals sp.CountryRegionId join c in ctx.Cities on sp.ID equals c.StateProvinceId join totcf in ctx.TransportOptionToCityFarePrices on c.ID equals totcf.CityId join to in ctx.TransportOptions on totcf.TransportOptionId equals to.ID join t in ctx.TransportTypes on to.TransportTypeId equals t.ID where (cr.ID == countryId && sp.ID == stateId && c.ID == cityId) orderby sp.Name, c.Name select new DTO.Dtos.FareInformation { Country = cr.Name, State = sp.Name, City = c.Name, BaseFare = totcf.BaseFare, PerMile = totcf.PerMile, PerMinute = totcf.PerMinute, TransportType = t.Name, TransportOption = to.Name }).Distinct(); return(result.ToList()); } }
ISendContext CreateSendContext(DispatchContext executionContext, Uri sourceAddress) { var context = new SendMessageContext(executionContext.Body); context.SetSourceAddress(sourceAddress); context.SetDestinationAddress(executionContext.DestinationAddress); context.SetResponseAddress(executionContext.ResponseAddress); context.SetFaultAddress(executionContext.FaultAddress); context.SetRequestId(executionContext.RequestId); context.SetConversationId(executionContext.ConversationId); context.SetCorrelationId(executionContext.CorrelationId); if (executionContext.ExpirationTime.HasValue) { context.SetExpirationTime(executionContext.ExpirationTime.Value); } context.SetNetwork(executionContext.Network); context.SetRetryCount(executionContext.RetryCount); context.SetContentType(executionContext.ContentType); foreach (var header in executionContext.Headers) { context.SetHeader(header.Key, header.Value); } return(context); }
public IList <Entity> GetWhere(Expression <Func <Entity, bool> > predicate) { using (var ctx = new DispatchContext()) { return(ctx.Set <Entity>().Where(predicate).ToList()); } }
public Task <Person> GetByUserNameAsync(string name) { using (var ctx = new DispatchContext()) { return(Task.FromResult(ctx.People.Include("PersonRoles").Include("AspNetUserClaims").Where(p => p.UserName == name).FirstOrDefault())); } }
public EmailTemplate GetEmail(string emailKey) { using (var ctx = new DispatchContext()) { return(ctx.EmailTemplates.Where(t => t.EmailKey == emailKey).FirstOrDefault()); } }
public Entity GetById(int id) { using (var ctx = new DispatchContext()) { return(ctx.Set <Entity>().Where(x => x.ID == id).FirstOrDefault()); } }
public IList <Entity> GetAll(params Expression <Func <Entity, Object> >[] includeProperties) { using (var ctx = new DispatchContext()) { var query = ctx.Set <Entity>().AsQueryable <Entity>(); query = includeProperties.Aggregate(query, (x, y) => x.Include(y)); return(query.ToList()); } }
public Entity CreateEntity(Entity entity) { using (var ctx = new DispatchContext()) { var addedEntity = ctx.Set <Entity>().Add(entity); ctx.SaveChanges(); return(addedEntity); } }
public async Task <Role> FindRoleByNameAsync(string roleName) { using (var ctx = new DispatchContext()) { var role = await ctx.Roles.Where(r => r.Name == roleName).FirstOrDefaultAsync(); return(role); } }
public async Task <Entity> AddEntityAsync(Entity entity) { using (var ctx = new DispatchContext()) { ctx.Set <Entity>().Add(entity); await ctx.SaveChangesAsync(); return(entity); } }
public Task <Entity> GetByIdAsync(int id, params Expression <Func <Entity, Object> >[] includeProperties) { using (var ctx = new DispatchContext()) { var query = ctx.Set <Entity>().AsQueryable <Entity>(); query = includeProperties.Aggregate(query, (x, y) => x.Include(y)); return(Task.FromResult(query.FirstOrDefault(x => x.ID == id))); } }
IPipe <SendContext> CreateMessageContext(DispatchContext dispatchContext) { IPipe <SendContext> pipe = dispatchContext.CreateCopyContextPipe((consumeContext, context) => { context.SourceAddress = dispatchContext.ReceiveContext.InputAddress; context.Serializer = new BodySerializer(context.ContentType, Encoding.UTF8.GetBytes(dispatchContext.Body)); }); return(pipe); }
public DispatchResult Check(DispatchContext dispatchContext) { MessageDispatchContext <T> context; if (dispatchContext.TryGetContext(out context)) { return(_predicate(context)); } return(dispatchContext.Accept()); }
IPipe<SendContext> CreateMessageContext(DispatchContext dispatchContext) { IPipe<SendContext> pipe = dispatchContext.CreateCopyContextPipe((consumeContext, context) => { context.SourceAddress = dispatchContext.ReceiveContext.InputAddress; context.Serializer = new BodySerializer(context.ContentType, Encoding.UTF8.GetBytes(dispatchContext.Body)); }); return pipe; }
public async Task <Entity> UpdateAsync(Entity entity) { using (var ctx = new DispatchContext()) { var existing = ctx.Set <Entity>().Find(entity.ID); ctx.Entry(existing).CurrentValues.SetValues(entity); await ctx.SaveChangesAsync(); return(entity); } }
public async Task ApproveVerification(int personId) { using (var ctx = new DispatchContext()) { var person = ctx.People.Include("AspNetUserClaims").Where(p => p.ID == personId).First(); person.IsMobileVerified = true; person.TwoFactorEnabled = false; var claim = person.AspNetUserClaims.Where(c => c.ClaimType == "Verification").First(); claim.ClaimValue = "1"; await ctx.SaveChangesAsync(); } }
public async Task <IList <Role> > GetUserRolesByName(string name) { using (var ctx = new DispatchContext()) { var result = (from p in ctx.People join pr in ctx.PersonRoles on p.ID equals pr.PersonId join r in ctx.Roles on pr.RoleId equals r.ID where p.UserName == name select r).ToListAsync(); return(await result); } }
private void DispatchMessage(ReceptionContext <TMessage> receptionContext) { var timeout = Timeout.HasValue ? Timeout.Value : Constants.DefaultTimeoutMilliseconds.AsNullableTimeSpan().Value; var dispatchContext = new DispatchContext <TMessage>( receptionContext.Message, timeout, _cts, (sender, status) => { if (status == DispatchStatus.Complete) { ContinueOnSuccess(receptionContext, sender); } else if (status == DispatchStatus.Timeout) { ContinueOnTimeout(receptionContext, sender); } }); try { var options = new ParallelOptions { CancellationToken = dispatchContext.LinkedCancellation.Token }; var result = Parallel.ForEach(_messageHandlers, options, (handler) => { try { handler(dispatchContext); } catch (Exception ex) { dispatchContext.LogException(ex); } }); if (result.IsCompleted) { dispatchContext.GotoComplete(); } } catch (OperationCanceledException) { if (!_cts.Token.IsCancellationRequested) { dispatchContext.GotoTimeout(); } } }
public async Task SaveMobileGeneratedVerificationCode(int personId, int Code) { using (var ctx = new DispatchContext()) { DTO.Entities.MobileVerification mv = new MobileVerification { PersonId = personId, VerificationCode = Code }; ctx.MobileVerifications.Add(mv); await ctx.SaveChangesAsync(); } }
public Task <UserInformation> FindByEmail(string email) { using (var ctx = new DispatchContext()) { var userInfo = ctx.People.Include("Role").Where(p => p.PrimaryEmail == email) .Select(u => new UserInformation { Id = u.ID, Email = u.PrimaryEmail, MobileCountryCode = u.MobileCountryCode, PhoneNumber = u.MobilePhone, Roles = u.PersonRoles, PasswordHash = u.Password }).FirstOrDefault(); return(Task.FromResult(userInfo)); } }
private void ContinueOnTimeout(ReceptionContext <TMessage> receptionContext, DispatchContext <TMessage> dispatchContext) { if (!dispatchContext.OwnedCancellation.IsCancellationRequested) { lock (dispatchContext.Locker) { if (!dispatchContext.OwnedCancellation.IsCancellationRequested) { foreach (var timeout in _timeoutHandlers) { try { timeout(dispatchContext); } catch { } } dispatchContext.Dispose(); receptionContext.Timeout(); } } } }
private void ContinueOnSuccess(ReceptionContext <TMessage> receptionContext, DispatchContext <TMessage> dispatchContext) { if (!dispatchContext.OwnedCancellation.IsCancellationRequested) { lock (dispatchContext.Locker) { if (!dispatchContext.OwnedCancellation.IsCancellationRequested) { foreach (var complete in _completeHandlers) { try { complete(dispatchContext); } catch { } } dispatchContext.Dispose(); receptionContext.Success(); } } } }
public Task <Result <RegistrationResult> > Registor(Person person) { int roleId = person.PersonRoles.Select(r => r.RoleId).First(); var result = new Result <RegistrationResult>(); result.Value = new RegistrationResult(); using (var ctx = new DispatchContext()) { int customerId = (from p in ctx.People join pr in ctx.PersonRoles on p.ID equals pr.PersonId where p.PrimaryEmail.Trim() == person.PrimaryEmail.Trim() && pr.RoleId == roleId select p.ID).FirstOrDefault(); if (customerId != 0) { result.Value.IsExists = true; return(Task.FromResult(result)); } if (roleId == Constants.Roles.Customer) { Random random = new Random(); int randomNumber = random.Next(10000); person.MobileVerifications = new MobileVerification[] { new MobileVerification { VerificationCode = 123, Created = DateTime.UtcNow } }; result.Value.MobileConfirmationNumber = randomNumber; } ctx.People.Add(person); ctx.SaveChanges(); return(Task.FromResult(result)); } }
async Task DispatchAgent.Execute(DispatchContext context) { try { ISendEndpoint endpoint = await context.GetSendEndpoint(context.Destination); IPipe<SendContext> messageContext = CreateMessageContext(context); var dispatched = new Dispatched(); await endpoint.Send(dispatched, messageContext); PublishCommandForwardedEvent(context); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", string.Join(",", context.DispatchTypes), context.Destination); _log.Error(message, ex); throw new DispatchException(message, ex); } }
async Task DispatchAgent.Execute(DispatchContext context) { try { ISendEndpoint endpoint = await context.GetSendEndpoint(context.Destination); IPipe <SendContext> messageContext = CreateMessageContext(context); var dispatched = new Dispatched(); await endpoint.Send(dispatched, messageContext); PublishCommandForwardedEvent(context); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", string.Join(",", context.DispatchTypes), context.Destination); _log.Error(message, ex); throw new DispatchException(message, ex); } }
public void Execute(DispatchContext context) { try { Uri sourceAddress = _bus.Endpoint.Address.Uri; IEndpoint endpoint = _bus.GetEndpoint(context.Destination); ISendContext messageContext = CreateSendContext(context, sourceAddress); endpoint.OutboundTransport.Send(messageContext); PublishCommandForwardedEvent(context); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", string.Join(",", context.DispatchTypes), context.Destination); _log.Error(message, ex); throw new DispatchException(message, ex); } }
public BasicTypes(ProgramContext program, IGlobalContext globalContext) { //Tipo Int Int = new ClassContext(program, 0); Int.type = new CommonToken(42, "Int"); var value = new AttributeContext(new FeatureContext()); value.idText = "x"; value.decl = new DeclarationContext(program, 0); value.decl.idText = "x"; value.decl.typeText = "Int"; value.decl.type = new CommonToken(42, "Int"); Int._features = new FeatureContext[1] { value }; //var value = new AttributeContext(new FeatureContext()); //value.= new CommonToken(42, "value"); //Tipo Bool Bool = new ClassContext(program, 0); Bool.type = new CommonToken(42, "Bool"); Bool._features = new FeatureContext[1] { value }; //Tipo String String = new ClassContext(program, 0); String.type = new CommonToken(42, "String"); var lenght = new MethodContext(new FeatureContext()); lenght.methodName = new CommonToken(42, "lenght"); lenght.TypeReturn = new CommonToken(42, "Int"); lenght.idText = "lenght"; lenght.typeText = "String"; lenght._formals = new FormalContext[] { }; lenght.Parent = String; var concat = new MethodContext(new FeatureContext()); concat.methodName = new CommonToken(42, "concat"); concat.TypeReturn = new CommonToken(42, "String"); concat.idText = "concat"; concat.typeText = "String"; var str_x = new FormalContext(program, 0); str_x.idText = "x"; str_x.typeText = "String"; concat._formals = new FormalContext[1] { str_x }; concat.Parent = String; var substr = new MethodContext(new FeatureContext()); substr.methodName = new CommonToken(42, "substr"); substr.TypeReturn = new CommonToken(42, "String"); substr.idText = "substr"; substr.typeText = "String"; var int_i = new FormalContext(program, 0); int_i.idText = "i"; int_i.typeText = "Int"; var int_l = new FormalContext(program, 0); int_l.idText = "l"; int_l.typeText = "Int"; substr._formals = new FormalContext[2] { int_i, int_l }; substr.Parent = String; String._features = new FeatureContext[4] { value, concat, lenght, substr }; //Object Object = new ClassContext(program, 0); Object.type = new CommonToken(42, "Object"); var abort = new MethodContext(new FeatureContext()); abort.methodName = new CommonToken(42, "abort"); abort.TypeReturn = new CommonToken(42, "Object"); abort.idText = "abort"; abort.typeText = "Object"; abort._formals = new FormalContext[] { }; abort.Parent = Object; var type_name = new MethodContext(new FeatureContext()); type_name.methodName = new CommonToken(42, "type_name"); type_name.TypeReturn = new CommonToken(42, "String"); type_name.idText = "type_name"; type_name.typeText = "String"; type_name.Parent = Object; var copy = new MethodContext(new FeatureContext()); copy.methodName = new CommonToken(42, "copy"); copy.TypeReturn = new CommonToken(42, "SELF_TYPE"); copy.idText = "copy"; copy.typeText = "SELF_TYPE"; copy.Parent = Object; Object._features = new FeatureContext[3] { abort, type_name, copy }; //IO IO = new ClassContext(program, 0); IO.type = new CommonToken(42, "IO"); //out_string var out_string = new MethodContext(new FeatureContext()); out_string.methodName = new CommonToken(42, "out_string"); out_string.TypeReturn = new CommonToken(42, "SELF_TYPE"); out_string.idText = "out_string"; out_string.typeText = "SELF_TYPE"; out_string.Parent = IO; var string_x = new FormalContext(program, 0); string_x.idText = "x"; string_x.typeText = "String"; out_string._formals = new FormalContext[1] { string_x }; //out_int var out_int = new MethodContext(new FeatureContext()); out_int.methodName = new CommonToken(42, "out_int"); out_int.TypeReturn = new CommonToken(42, "SELF_TYPE"); out_int.idText = "out_int"; out_int.typeText = "SELF_TYPE"; out_int.Parent = IO; var int_x = new FormalContext(program, 0); int_x.idText = "x"; int_x.typeText = "Int"; out_int._formals = new FormalContext[1] { int_x }; //in_string var in_string = new MethodContext(new FeatureContext()); in_string.methodName = new CommonToken(42, "in_string"); in_string.TypeReturn = new CommonToken(42, "String"); in_string.idText = "in_string"; in_string.typeText = "String"; in_string.Parent = IO; //in_int var in_int = new MethodContext(new FeatureContext()); in_int.methodName = new CommonToken(42, "in_int"); in_int.TypeReturn = new CommonToken(42, "Int"); in_int.idText = "in_int"; in_int.typeText = "Int"; in_int.Parent = IO; IO._features = new FeatureContext[4] { out_string, out_int, in_string, in_int }; entry = new MethodContext(new FeatureContext()); entry.methodName = new CommonToken(42, "entry"); entry.TypeReturn = new CommonToken(42, "Int"); entry.idText = "entry"; entry.typeText = "Int"; var exprBody = new BlockExprContext(new ExprContext()); //La primera expresion var exprBody1 = new DispatchContext(new ExprContext()); exprBody1.id = new CommonToken(42, "main"); exprBody1._expresions = new List <ExprContext>(); var expr = new NewTypeExprContext(new ExprContext()); expr.type = new CommonToken(42, "Main"); exprBody1.expresion = expr; entry.exprBody = exprBody1; //La segunda expresion var exprBody2 = new IntegerExprContext(new ExprContext()); exprBody2.integer = new CommonToken(41, "0"); exprBody._expresions = new List <ExprContext>(); exprBody._expresions.Add(exprBody1); exprBody.finalExpresion = exprBody2; entry.exprBody = exprBody; //El tipo void Void = new ClassContext(program, 0); Void.type = new CommonToken(42, "void"); }
void PublishCommandForwardedEvent(DispatchContext context) { var @event = new DispatchAcceptedEvent(context); context.Publish<DispatchAccepted>(@event); }
void PublishCommandForwardedEvent(DispatchContext context) { var @event = new DispatchAcceptedEvent(context); context.Publish <DispatchAccepted>(@event); }
public DispatchResult Check(DispatchContext dispatchContext) { return dispatchContext.Accept(); }
public DispatchResult Check(DispatchContext dispatchContext) { return(dispatchContext.Accept()); }