protected void Page_Load(object sender, EventArgs e) { _webContext = ObjectFactory.GetInstance<IWebContext>(); _tagsPresenter = new TagsPresenter(); _tagsPresenter.Init(this, IsPostBack); }
public EventAckModel(IWebContext webContext, IUserContext userContext, IClientAccessor clientAccessor) { this.webContext = webContext; this.userContext = userContext; this.clientAccessor = clientAccessor; dict = Locale.GetDictionary("Scada.Web.Plugins.PlgMain.Areas.Main.Pages.EventAck"); }
protected void Page_Load(object sender, EventArgs e) { _webContext = ObjectFactory.GetInstance<IWebContext>(); this.Title = ConfigurationManager.AppSettings.Get("SiteName") + " - Kiem Tra Trac Nghiem"; string webURL = _webContext.RootUrl; string initParams = "webURL=" + webURL; if (Request.Params["levelID"] != null) { try { int id = Commons.ConvertToInt(Request.QueryString["levelID"], 0); if (id > 0) { string questionsNumber = "5"; string timeExpire = "10"; initParams += ",levelID=" + Request.QueryString["levelID"] + ",questionsNumber=" + questionsNumber + ",timeExpire=" + timeExpire; this.Silverlight1.InitParameters = initParams; } else Response.Redirect(webURL+"learning/defaults.aspx"); } catch { Response.Redirect(webURL + "learning/defaults.aspx"); } } else Response.Redirect(webURL + "learning/defaults.aspx"); }
public ConfirmFriendshipRequestPresenter() { _webContext = new SPKTCore.Core.Impl.WebContext(); _friendInvitationRepository = new SPKTCore.Core.DataAccess.Impl.FriendInvitationRepository(); _accountRepository = new SPKTCore.Core.DataAccess.Impl.AccountRepository(); _redirector = new SPKTCore.Core.Impl.Redirector(); }
public ReadMessagePresenter() { _webContext = new WebContext(); _userSession = new UserSession(); _redirector = new Redirector(); _messageRepository = new SPKTCore.Core.DataAccess.Impl.MessageRepository(); }
public LanguageInterceptor(IPersister persister, ContentActivator activator, IWebContext context, ILanguageGateway gateway) { this.persister = persister; this.activator = activator; this.context = context; this.gateway = gateway; }
public void Before (IWebContext webContext) { if( !HasExtension(webContext) && !HasRoute(webContext) || IsDefault(webContext)) webContext.RewritePath("/index.html"); }
public void Return_status_400_message_if_instance_should_be_offline_and_status_not_being_changed() { ApplicationInstance instance = new ApplicationInstance(); instance.AvailableForLoadBalancing = false; MockRepository mocks = new MockRepository(); IApplicationInstanceContext instanceContext = mocks.CreateMock <IApplicationInstanceContext>(); IWebContext context = mocks.CreateMock <IWebContext>(); using (mocks.Record()) { Expect.Call(instanceContext.GetCurrent()).Return(instance); Expect.Call(context.GetRequestItem(LoadBalanceStatusManager.ENABLED_PARAM)).Return(null); context.SetHttpResponseStatus(400, "This application has been turned off"); } using (mocks.Playback()) { ILoadBalanceStatusManager manager = new LoadBalanceStatusManager(instanceContext, context, null); string errorMessage = manager.HandleLoadBalanceRequest(); Assert.That(errorMessage, Is.Empty); } }
public void Should_disable_load_balancing_when_requested() { ApplicationInstance instance = new ApplicationInstance(); instance.AvailableForLoadBalancing = false; MockRepository mocks = new MockRepository(); IApplicationInstanceContext instanceContext = mocks.CreateMock <IApplicationInstanceContext>(); IWebContext context = mocks.CreateMock <IWebContext>(); ISecureAvailabilityStatusUpdater updater = mocks.CreateMock <ISecureAvailabilityStatusUpdater>(); using (mocks.Record()) { Expect.Call(instanceContext.GetCurrent()).Return(instance); Expect.Call(context.GetRequestItem(LoadBalanceStatusManager.ENABLED_PARAM)).Return("FALSE"); Expect.Call(updater.SetStatus(false)).Return(string.Empty); } using (mocks.Playback()) { ILoadBalanceStatusManager manager = new LoadBalanceStatusManager(instanceContext, context, updater); string errorMessage = manager.HandleLoadBalanceRequest(); Assert.That(errorMessage, Is.Empty); } }
/// <summary> /// Initializes the user menu. /// </summary> public virtual void Init(IWebContext webContext, User user, UserRights userRights) { ArgumentNullException.ThrowIfNull(webContext, nameof(webContext)); ArgumentNullException.ThrowIfNull(user, nameof(user)); ArgumentNullException.ThrowIfNull(userRights, nameof(userRights)); try { // add menu items from plugins foreach (PluginLogic pluginLogic in webContext.PluginHolder.EnumeratePlugins()) { MergeMenuItems(MenuItems, webContext.PluginHolder.GetUserMenuItems(pluginLogic, user, userRights), 0); } // add default menu items MergeMenuItems(MenuItems, new List <MenuItem> { MenuItem.FromKnownMenuItem(KnownMenuItem.Reports), MenuItem.FromKnownMenuItem(KnownMenuItem.About) }, 0); } catch (Exception ex) { webContext.Log.WriteError(ex, Locale.IsRussian ? "Ошибка при инициализации меню пользователя" : "Error initializing user menu"); } }
public virtual void Search() { target(Search); String addr = ctx.Post("webAddress"); if (strUtil.IsNullOrEmpty(addr) || addr.StartsWith("http:") == false) { set("dirAndFiles", ""); return; } IWebContext webContext = MockWebContext.New(ctx.viewer.Id, addr, new StringWriter()); AdminSecurityUtils.SetSession(webContext); try { new CoreHandler().ProcessRequest(webContext); } catch (Exception ex) { set("dirAndFiles", "<div class=\"warning\">" + lang("exSearchViews") + "</div><div style=\"border:1px #f2f2f2 solid; margin-top:10px; padding:10px;display:none;\">" + ex.ToString().Replace(Environment.NewLine, "<br/>") + "</div>"); return; } List <string> list = CurrentRequest.getItem(Template.loadedTemplates) as List <string>; bindResults(list); }
public AlertService() { _userSession = new UserSession(); _alertRepository = new AlertRepository(); _webContext = new WebContext(); alert = new Alert(); }
public XmlInstallationManager(IHost host, IPersister persister, ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, ContentActivator activator) : base(connectionContext, importer, webContext, persister, activator) { this.host = host; this.persister = persister; }
public CommentsPresenter() { _commentRepository = new CommentRepository(); _webContext = new WebContext(); _userSession = new UserSession(); _alertService = new AlertService(); }
/// <summary> /// Deconstructs the contexts request into a set of prameters for the context. /// </summary> /// <remarks> /// The deafult implementation uses the convention of `/area/concern/action.aspc/tail?querystring` /// </remarks> /// <param name="ev">The vent that was considered for this action.</param> /// <param name="context">The context to act upon.</param> public override void Action(IEvent ev, IWebContext context) { // eliminate the app directory from the path string path = _appDirectory.Length > 0 ? context.Request.UrlInfo.AppPath.Trim('/').Replace(_appDirectory, "") : context.Request.UrlInfo.AppPath; path = path.Trim('/'); if (!String.IsNullOrEmpty(context.Request.UrlInfo.File)) { context.Params["action"] = context.Request.UrlInfo.File.Split('.')[0].ToLower(); string[] parts = path.Split('/'); if (parts.Length >= 2) { context.Params["area"] = parts[parts.Length - 2].ToLower(); context.Params["concern"] = parts[parts.Length - 1].ToLower(); } else if (parts.Length == 1) { context.Params["area"] = parts[0]; } } // import query string and form values context.Params.Import(context.Request.Params.Where(kv => !kv.Key.StartsWith("_"))); // establish flags foreach (string flag in context.Request.Flags.Where(f => !f.StartsWith("_"))) { context.Flags.Add(flag); } context.Params.Import(context.Request.Headers); // note method and tail context.Params["method"] = context.Request.Method; context.Params["tail"] = context.Request.UrlInfo.Tail; string requestViews = String.Join(";", context.Request.UrlInfo.Tail.Split(new string[] {"/"}, StringSplitOptions.RemoveEmptyEntries)); if (!String.IsNullOrEmpty(requestViews)) { context.Params["views"] = requestViews; } }
/// <summary>Creates a new instance of the <see cref="ConfigurationBuilder"/>.</summary> public ConfigurationBuilder(IDefinitionProvider[] definitionProviders, ClassMappingGenerator generator, IWebContext webContext, ConfigurationBuilderParticipator[] participators, DatabaseSection config, ConnectionStringsSection connectionStrings) { this.definitionProviders = definitionProviders; this.generator = generator; this.webContext = webContext; this.participators = participators; if (config == null) { config = new DatabaseSection(); } if (!string.IsNullOrEmpty(config.HibernateMapping)) { DefaultMapping = config.HibernateMapping; } SetupProperties(config, connectionStrings); SetupMappings(config); TryLocatingHbmResources = config.TryLocatingHbmResources; tablePrefix = config.TablePrefix; batchSize = config.BatchSize; childrenLaziness = config.ChildrenLaziness; }
public TreeSorter(IPersister persister, IEditManager editManager, IWebContext webContext, IVersionManager versionMaker) { this.persister = persister; this.editManager = editManager; this.webContext = webContext; this.versionMaker = versionMaker; }
public void Before (IWebContext webContext) { if( !HasExtension(webContext) && !webContext.HasRouteForCurrentRequest || IsDefault(webContext)) webContext.RewritePath("/index.html"); }
public GroupPresenter() { _redirector = new Redirector(); _webContext = new WebContext(); _groupRepository = new GroupRepository(); _fileService = new FileService(); }
public ConfirmFriendshipRequestPresenter() { _webContext = ObjectFactory.GetInstance<IWebContext>(); _configuration = ObjectFactory.GetInstance<IConfiguration>(); _redirector = ObjectFactory.GetInstance<IRedirector>(); _friendService = ObjectFactory.GetInstance<IFriendService>(); }
protected void Page_Load(object sender, EventArgs e) { _webContext = new WebContext(); _userSession=new UserSession(); if (!_userSession.LoggedIn) { _redirector.GoToAccountLoginPage(); } else { _permissionRepository = new PermissionRepository(); Account account=_userSession.CurrentUser; List<Permission> permissions = _permissionRepository.GetPermissionsByAccountID(account.AccountID); int i=0; foreach (Permission p in permissions) { if (p.PermissionID != _permissionRepository.GetPermissionByName("Admin").PermissionID) { i++; } } if (i == permissions.Count) { linkAddcate.Visible = false; linkAddForum.Visible = false; lblMessage.Text = "Chỉ có Addmin mới có quyền xem trang này"; } } }
public SearchConfigurationBuilderParticipator(IWebContext webContext, DatabaseSection config) { this.webContext = webContext; searchEnabled = config.Search.Enabled; asyncIndexing = config.Search.AsyncIndexing; indexPath = config.Search.IndexPath; }
public override void SetUp() { base.SetUp(); config = TestSupport.SetupEngineSection(); actions = new ScheduledAction[] { new OnceAction(), new RepeatAction() }; heart = mocks.Stub <IHeart>(); heart.Beat += null; raiser = LastCall.IgnoreArguments().GetEventRaiser(); mocks.Replay(heart); errorHandler = mocks.DynamicMock <IErrorNotifier>(); mocks.Replay(errorHandler); ctx = mocks.DynamicMock <IWebContext>(); mocks.Replay(ctx); engine = new Fakes.FakeEngine(); engine.Container.AddComponentInstance("", typeof(IErrorNotifier), MockRepository.GenerateStub <IErrorNotifier>()); worker = new AsyncWorker(); worker.QueueUserWorkItem = delegate(WaitCallback function) { function(null); return(true); }; scheduler = new Scheduler(engine, heart, worker, ctx, errorHandler, actions, config); scheduler.Start(); }
protected void Page_Load(object sender, EventArgs e) { _redirector = ObjectFactory.GetInstance<IRedirector>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _presenter = new EditPhotosPresenter(); _presenter.Init(this); }
public ProfilePresenter() { _redirector = ObjectFactory.GetInstance<IRedirector>(); _userSession = ObjectFactory.GetInstance<IUserSession>(); if (!_userSession.LoggedIn || _userSession.CurrentUser == null) _redirector.GoToAccountLoginPage(); _alertService = ObjectFactory.GetInstance<IAlertService>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _accountService = ObjectFactory.GetInstance<IAccountService>(); _privacyService = ObjectFactory.GetInstance<IPrivacyService>(); _account = _userSession.CurrentUser; if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID) { _accountBeingViewed = _accountService.GetAccountByID(_webContext.AccountID); _accountBeingViewed.Profile = Profile.GetProfileByAccountID(_webContext.AccountID); } else { _accountBeingViewed = _userSession.CurrentUser; _accountBeingViewed.Profile = Profile.GetProfileByAccountID(_userSession.CurrentUser.AccountID); } if (_accountBeingViewed == null) _redirector.GoToAccountLoginPage(); if (_accountBeingViewed.Profile != null && _accountBeingViewed.Profile.ProfileID > 0) _privacyFlags = PrivacyFlag.GetPrivacyFlagsByProfileID(_accountBeingViewed.Profile.ProfileID); else _redirector.GoToHomePage(); }
public ViewPageResult(ContentItem thePage, IControllerMapper controllerMapper, IWebContext webContext, IActionInvoker actionInvoker) { _thePage = thePage; _controllerMapper = controllerMapper; _webContext = webContext; _actionInvoker = actionInvoker; }
protected void Page_Load(object sender, EventArgs e) { //_profileRepository = new ProfileRepository(); _fr = new FileRepository(); _userSession = new UserSession(); _accountRepository = new AccountRepository(); _webContext = new WebContext(); if (_userSession.LoggedIn && _userSession.CurrentUser != null) { account = _userSession.CurrentUser; file = _fr.GetFileByID(fileID); } //show the appropriate image if (file != null) { //Response.Clear(); Response.ContentType = "jpg"; Response.BinaryWrite(file.ContentFile.ToArray()); } }
public override void SetUp() { base.SetUp(); IPersister persister = mocks.Stub <IPersister>(); Expect.Call(delegate { persister.Save(null); }) .IgnoreArguments() .Do(new Action <ContentItem>(savedItems.Add)) .Repeat.Any(); IEditManager editManager = mocks.Stub <IEditManager>(); Expect.Call(editManager.GetEditorFilter(null)) .IgnoreArguments() .Return(new PageFilter()); IWebContext webContext = mocks.Stub <IWebContext>(); mocks.ReplayAll(); root = CreateOneItem <NormalPage>(1, "root", null); page1 = CreateOneItem <NormalPage>(2, "page1", root); page2 = CreateOneItem <NormalPage>(3, "page2", root); page2.SortOrder = 1; page3 = CreateOneItem <NormalPage>(4, "page3", root); page3.SortOrder = 2; sorter = new TreeSorter(persister, editManager, webContext); }
public void Apply(IWebContext context) { context.RemoveHeader(HttpConsts.HeaderServer); context.AddHeader(HttpConsts.HeaderXFrameOptions, "SAMEORIGIN"); context.AddHeader(HttpConsts.HeaderXXssProtection, "1; mode=block"); context.AddHeader(HttpConsts.HeaderXContentTypeOptions, "nosniff"); }
public StatisticsLogger(EventBroker broker, IWebContext context, Collector collector, StatisticsRepository repository) { this.broker = broker; this.context = context; this.filler = collector; this.repository = repository; }
public ContentMessageSource(IPersister persister, IIntegrityManager integrity, ISecurityManager security, IWebContext context) { this.persister = persister; this.integrity = integrity; this.security = security; this.context = context; }
public SessionProvider(IConfigurationBuilder builder, IInterceptor interceptor, IWebContext webContext) { nhSessionFactory = builder.BuildSessionFactory(); logger.Debug("Built Session Factory " + DateTime.Now); this.webContext = webContext; this.interceptor = interceptor; }
public void Correctly_assigns_current_user_to_role() { MockRepository mocks = new MockRepository(); IPrincipal principal = mocks.CreateMock <IPrincipal>(); IIdentity identity = mocks.CreateMock <IIdentity>(); IWebContext context = mocks.CreateMock <IWebContext>(); IPrincipalFactory principalFactory = mocks.CreateMock <IPrincipalFactory>(); using (mocks.Record()) { Expect.Call(context.GetUserIdentity()).Return(identity); Expect.Call(principalFactory.CreatePrincipal(identity, "Administrator", "Other Role")).Return(principal); context.SetUser(principal); } mocks.ReplayAll(); using (mocks.Playback()) { IRoleAssigner assigner = new RoleAssigner(context, principalFactory); assigner.AssignCurrentUserToRoles("Administrator", "Other Role"); } mocks.VerifyAll(); }
public SessionProvider(IConfigurationBuilder builder, IInterceptor interceptor, IWebContext webContext) { nhSessionFactory = builder.BuildSessionFactory(); Debug.WriteLine("Built Session Factory " + DateTime.Now); this.webContext = webContext; this.interceptor = interceptor; }
public ViewForumPresenter() { _postRepository = new BoardPostRepository(); _webContext = new WebContext(); _forumRepository = new BoardForumRepository(); _redirector = new Redirector(); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ObjRightHandler(IWebContext webContext, IUserContext userContext, IHttpContextAccessor httpContextAccessor) { this.webContext = webContext ?? throw new ArgumentNullException(nameof(webContext)); this.userContext = userContext ?? throw new ArgumentNullException(nameof(userContext)); this.httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor)); }
public NotifycationControlPresenter() { _webContext = new WebContext(); _userSession = new UserSession(); _redirector = new Redirector(); _notifycationService = new NotificationService(); }
public CachingUrlParserDecorator(IUrlParser inner, IPersister persister, IWebContext webContext, CacheWrapper cache) { this.inner = inner; this.persister = persister; this.webContext = webContext; this.cache = cache; }
public FileService() { _fileRepository = new FileRepository(); _folderRepository = new FolderRepository(); _webContext = new WebContext(); _accountRepository = new AccountRepository(); }
public MyBlogsPresenter() { _webContext = ObjectFactory.GetInstance<IWebContext>(); _blogRepository = ObjectFactory.GetInstance<IBlogRepository>(); _redirector = ObjectFactory.GetInstance<IRedirector>(); _userSession = ObjectFactory.GetInstance<IUserSession>(); }
public void Init(IInviteFriends view) { _view = view; //_userSession = ObjectFactory.GetInstance<IUserSession>(); //_email = ObjectFactory.GetInstance<IEmail>(); //_friendInvitationRepository = ObjectFactory.GetInstance<IFriendInvitationRepository>(); //_accountRepository = ObjectFactory.GetInstance<IAccountRepository>(); //_webContext = ObjectFactory.GetInstance<IWebContext>(); _userSession = new SPKTCore.Core.Impl.UserSession(); _friendInvitationRepository = new SPKTCore.Core.DataAccess.Impl.FriendInvitationRepository(); _email = new SPKTCore.Core.Impl.Email(); _webContext = new SPKTCore.Core.Impl.WebContext(); if (_userSession.LoggedIn) { _account = _userSession.CurrentUser; _accountRepository = new SPKTCore.Core.DataAccess.Impl.AccountRepository(); if (_account != null) { _view.DisplayToData(_account.UserName + " <" + _account.Email + ">"); if (_webContext.AccoundIdToInvite > 0) { _accountToInvite = _accountRepository.GetAccountByID(_webContext.AccoundIdToInvite); if (_accountToInvite != null) { SendInvitation(_accountToInvite.Email, _account.UserName + " " + _account.UserName + " "); _view.ShowMessage(_accountToInvite.UserName + " Đã được gửi đi!"); _view.TogglePnlInvite(false); } } } } }
public MongoInstallationManager(MongoDatabaseProvider database, IHost host, IPersister persister, ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, ContentActivator activator) : base(connectionContext, importer, webContext, persister, activator) { this.database = database; this.host = host; this.persister = persister; }
public void BasicJsonView() { IWebContext context = this.GetContext(); context.Params["action"] = "test1"; context.Params["views"] = "json"; context.Fire("test"); Assert.IsTrue(context.ViewSteps.HasSteps); Assert.IsTrue(context.ViewSteps.Count == 2); Assert.IsTrue(context.ViewSteps.Last.HasContent); Assert.IsTrue(context.ViewSteps.Last.ContentType == "text/json"); JObject result = context.ViewSteps.Last.Content.AsJObject(); Assert.IsTrue(result.SelectToken("$.params.action").Value <string>() == "test1"); Assert.IsTrue(result.SelectToken("$.params.views").Value <string>() == "json"); Assert.IsTrue(result["eventTrace"].Values <JObject>().Count() == 2); Assert.IsTrue(result.SelectTokens("$.eventTrace[?(@.message=='work-message-one')]").Count() == 1); Assert.IsTrue(result.SelectTokens("$.eventTrace[?(@.message=='work-message-two')]").Count() == 1); Assert.IsTrue(context.Response.ContentType == context.ViewSteps.Last.ContentType); string render = ((MockWebResponse)context.Response).Result; Assert.AreEqual(context.ViewSteps.Last.Content, render); JObject result1 = context.Resources.Open("Resources/Results/result-1-0.json").AsJObject(); Assert.IsTrue(JToken.DeepEquals(result1, render.AsJObject())); }
public CacheWrapper(IPersister persister, IWebContext context, DatabaseSection config) { this.persister = persister; this.context = context; this.tablePrefix = config.TablePrefix; this.sqlCacheDependency = config.SqlCacheDependency; }
/// <summary> /// Creates the web context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public void Setup(IOwinContext context) { if (_webContext == null) { _webContext = new WebContext(context); } }
public static string DumpRequestHeaders(this IWebContext context) { Contract.Requires(context != null); Contract.Ensures(Contract.Result <string>() != null); StringBuilder s = new StringBuilder(); string headerSeparator = null; foreach (string header in context.RequestHeaders) { s.AppendFormat(CultureInfo.InvariantCulture, "{1}{0}=", header, headerSeparator); headerSeparator = "; "; string valueComma = null; string[] values = context.RequestHeaders.GetValues(header); if (values != null) { foreach (string value in values) { s.AppendFormat(CultureInfo.InvariantCulture, "{0}'{1}'", valueComma, value); valueComma = ","; } } } return(s.ToString()); }
public LanguageInterceptor(IPersister persister, IDefinitionManager definitions, IWebContext context, ILanguageGateway gateway) { this.persister = persister; this.definitions = definitions; this.context = context; this.gateway = gateway; }
public XmlInstallationManager(IHost host, IPersister persister, XmlContentRepository repository, ConnectionMonitor connectionContext, Importer importer, IWebContext webContext, ContentActivator activator) : base(connectionContext, importer, webContext, persister, activator) { this.host = host; this.persister = persister; this.repository = repository; }
protected void Page_Load(object sender, EventArgs e) { _accountRepository = new AccountRepository(); _commentRepository = new CommentRepository(); _webContext = new WebContext(); _userSession = new UserSession(); }
protected override void OnInit(EventArgs e) { //_webContext = ObjectFactory.GetInstance<IWebContext>(); _presenter = new SearchPresenter(); _webContext = new SPKTCore.Core.Impl.WebContext(); _presenter.Init(this); if (string.IsNullOrEmpty(_webContext.SearchText)) { lblSearchTerm.Text = "Please use the search box to the left!"; } else { if (!IsPostBack) { lblSearchTerm.Text = "Bạn muốn tìm bạn : " + _webContext.SearchText; } if (_webContext.SearchText.Length > 3) { _presenter.PerformSearch(_webContext.SearchText); } else { lblSearchTerm.Text += " <BR><BR> Your chuoi tim kiem phai lon hon 3 ky tu!"; } } }