protected void Application_PostAuthenticateRequest() { if (Request.IsAuthenticated) { IIdentity user = HttpContext.Current.User.Identity; IEmployeeRepository employeeRepository = NinjectIoC.Initialize().Get <IEmployeeRepository>(); CustomPrincipal customPrincipal = new CustomPrincipal(user, employeeRepository); HttpContext.Current.User = customPrincipal; } }
//Send XMPP message private void SendNotificationOut(NotificationViewModel notification, XMPPSettings xMPPSettings) { IXMPPClient sender = NinjectIoC.Initialize().Get <IXMPPClient>(); string[] xmppRecipients = notification.sendto.Select(s => sender.GetUserName(employeeRepository.GetEmployee(s).Login, xMPPSettings.Domain)).ToArray <string>(); if (!sender.IsConnected()) { sender.Connect(xMPPSettings.Server, xMPPSettings.Port, xMPPSettings.User, xMPPSettings.Password, xMPPSettings.AutoReconnect); Thread.Sleep(1000); } Task.Run(() => { sender.SendNotification(xmppRecipients, FullTemplate(notification, xMPPSettings.MessageTemplate)); }); }
private IEnumerable <DropDownTreeItemModel> GetPossibleRecipients() { IEmployeeRepository employees = NinjectIoC.Initialize().Get <IEmployeeRepository>(); INotificationRepository notification = NinjectIoC.Initialize().Get <INotificationRepository>(); var possiblerecipients = employees.GetEmployeesWithDepartments(""); var connections = notification.Connections.AsEnumerable(); var rk = possiblerecipients.Where(r => r.ParentId == null).FirstOrDefault(); List <DropDownTreeItemModel> treeview = possiblerecipients.Where(r => r.ParentId == null) .Select(o => new DropDownTreeItemModel { Id = o.ID.ToString(), Text = o.Name, Value = o.ID.ToString(), Items = GetChildren(possiblerecipients, o.ID, connections).ToList(), SpriteCssClass = connections.Any(e => e.EmployeeID == o.ID) ? "status-online" : "" }).ToList(); return(treeview); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); NinjectIoC.Initialize(); NinjectIoC.Container.Bind <ITesseractApi>() .ToConstructor(ctorArg => new TesseractApi(Android.App.Application.Context, AssetsDeployment.OncePerInitialization)); NinjectIoC.Container.Bind <IProcessAssert>() .ToConstructor(ctorArg => new ProcessAssert(this.Assets)); LoadApplication(new App()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //Ninject ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory()); GlobalHost.DependencyResolver = new NinjectSignalRDependencyResolver(NinjectIoC.Initialize()); //XMPP XMPPSettings xMPPSettings = XMPPConfig.ReadSettings(); if (xMPPSettings.Enable) { IXMPPClient sender = NinjectIoC.Initialize().Get <IXMPPClient>(); sender.Connect(xMPPSettings.Server, xMPPSettings.Port, xMPPSettings.User, xMPPSettings.Password, xMPPSettings.AutoReconnect); } }